資源簡介
重大軟院操作系統實驗四:虛擬內存,操作系統原理,linux

代碼片段和文件信息
/**
?*?vim:?filetype=c:fenc=utf-8:ts=4:et:sw=4:sts=4
?*
?*?Copyright?(C)?2005?2008?2013?Hong?MingJian
?*?All?rights?reserved.
?*
?*?This?file?is?part?of?the?EPOS.
?*
?*?Redistribution?and?use?in?source?and?binary?forms?are?freely
?*?permitted?provided?that?the?above?copyright?notice?and?this
?*?paragraph?and?the?following?disclaimer?are?duplicated?in?all
?*?such?forms.
?*
?*?This?software?is?provided?“AS?IS“?and?without?any?express?or
?*?implied?warranties?including?without?limitation?the?implied
?*?warranties?of?merchantability?and?fitness?for?a?particular
?*?purpose.
?*
?*/
#include?“kernel.h“
#include?“syscall-nr.h“
#include?“multiboot.h“
#include?“sem.h“??//第三次實驗第一個小實驗
#define?IO_ICU1??0x20??/*?8259A?Interrupt?Controller?#1?*/
#define?IO_ICU2??0xA0??/*?8259A?Interrupt?Controller?#2?*/
#define?IRQ_SLAVE?0x04
#define?ICU_SLAVEID?2
#define?ICU_IMR_OFFSET??1?/*?IO_ICU{12}?+?1?*/
/**
?*?初始化i8259中斷控制器
?*/
static?void?init_i8259(uint8_t?idt_offset)
{
????outportb(IO_ICU1?0x11);//ICW1
????outportb(IO_ICU1+ICU_IMR_OFFSET?idt_offset);?//ICW2
????outportb(IO_ICU1+ICU_IMR_OFFSET?IRQ_SLAVE);?//ICW3
????outportb(IO_ICU1+ICU_IMR_OFFSET?1);?//ICW4
????outportb(IO_ICU1+ICU_IMR_OFFSET?0xff);?//OCW1
????outportb(IO_ICU1?0x0a);?//OCW3
????outportb(IO_ICU2?0x11);?//ICW1
????outportb(IO_ICU2+ICU_IMR_OFFSET?idt_offset+8);?//ICW2
????outportb(IO_ICU2+ICU_IMR_OFFSET?ICU_SLAVEID);?//ICW3
????outportb(IO_ICU2+ICU_IMR_OFFSET1);?//ICW4
????outportb(IO_ICU2+ICU_IMR_OFFSET?0xff);?//OCW1
????outportb(IO_ICU2?0x0a);?//OCW3
}
/**
?*?初始化i8253定時器
?*/
static?void?init_i8253(uint32_t?freq)
{
????uint16_t?latch?=?1193182/freq;
????outportb(0x43?0x36);
????outportb(0x40?latch&0xff);
????outportb(0x40?(latch&0xff00)>>16);
}
/**
?*?讓中斷控制器打開某個中斷
?*/
void?enable_irq(uint32_t?irq)
{
????uint8_t?val;
????if(irq?8){
????????val?=?inportb(IO_ICU1+ICU_IMR_OFFSET);
????????outportb(IO_ICU1+ICU_IMR_OFFSET?val?&?(~(1< ????}?else?if(irq?????????irq?-=?8;
????????val?=?inportb(IO_ICU2+ICU_IMR_OFFSET);
????????outportb(IO_ICU2+ICU_IMR_OFFSET?val?&?(~(1< ????}
}
/**
?*?讓中斷控制器關閉某個中斷
?*/
void?disable_irq(uint32_t?irq)
{
????uint8_t?val;
????if(irq?8)?{
????????val?=?inportb(IO_ICU1+ICU_IMR_OFFSET);
????????outportb(IO_ICU1+ICU_IMR_OFFSET?val?|?(1< ????}?else?if(irq?????????irq?-=?8;
????????val?=?inportb(IO_ICU2+ICU_IMR_OFFSET);
????????outportb(IO_ICU2+ICU_IMR_OFFSET?val?|?(1< ????}
}
/**
?*?把CPU從當前線程切換去運行線程new,即上下文切換(Context?switch)
?*/
void?switch_to(struct?tcb?*new)
{
????__asm__?__volatile__?(
????????????“pushal\n\t“
????????????“pushl?$1f\n\t“
????????????“movl?%0?%%eax\n\t“
????????????“movl?%%esp?(%%eax)\n\t“
????????????“addl?$36?%%esp\n\t“
????????????:
????????????:“m“(g_task_running)
????????????:“%eax“
????????????);
????g_task_running?=?new;
????__asm__?__volat
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-12-18?21:47??操作系統實驗四\
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\
?????文件???????????3??2015-12-10?20:51??操作系統實驗四\epos\.svn\entries
?????文件???????????3??2015-12-10?20:51??操作系統實驗四\epos\.svn\format
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\01\
?????文件???????14952??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\01\0133bbeec07642e1ed0e38e0a078ee3a3d98fd57.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\02\
?????文件????????8291??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\02\02b0b9520f366c7c15371b07d890ebb5d0e21630.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\17\
?????文件????????1681??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\17\17f230794300383a59af8bae05af6784b4c574db.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\25\
?????文件????????9978??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\25\25472e8d3d2d167b88052ef819efadb3f8e5f80b.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\2a\
?????文件????????1440??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\2a\2a6d7a3d08da647a64cbfba8395d554f9bcba8e2.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\2b\
?????文件???????19393??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\2b\2b73b7375502d4e255039c92d0bd3c88bc49a40c.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\33\
?????文件????????1623??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\33\33584bc8892e89b501e8074affdc42b96d99bda8.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\42\
?????文件????????1466??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\42\42909b6fd8431fbb602ee250f2de562717e97b06.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\43\
?????文件?????????181??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\43\432d8e098dda89b4b9caa96a8d2ccf7d30f58bcc.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\5c\
?????文件????????7265??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\5c\5c3a40940b6cdc9bc91eecadec883c53b3a5c729.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\5f\
?????文件????????2777??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\5f\5fab13ea12f18c47a915f375016e3be95dbb236b.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\63\
?????文件?????????450??2015-12-10?20:51??操作系統實驗四\epos\.svn\pristine\63\6347bbb9f7252ab8038b9a0735717a569fbcf242.svn-ba
?????目錄???????????0??2015-12-18?21:45??操作系統實驗四\epos\.svn\pristine\6c\
............此處省略119個文件信息
評論
共有 條評論