30æ¥OSèªä½å ¥é7æ¥ç®ï¼Win10ï¼
åãã«
ã¤ãã«1é±éï¼ãã¦ã¹ã«åãã¦é å¼µã£ã¦ãããã¼
ä»åããåçµããã³ã¼ãã®ã³ã¡ã³ããå¢ããã¦ãããããªã¨ãèãã¦ãã¾ãã
ç®æ¬¡
æ¬æ
ãã¼ã³ã¼ããåå¾ããã(harib04a)
ãã¦ã¹ã®åé¡ãè¨å®ããåã«ãã¼ãã¼ãã®è¨å®ãããã£ã¦ç·´ç¿ãã¦ãããã£ã¦æµãã¿ããã§ãã
ããã§ãã¼ãæ¼ããããç»é¢ãå¤ããã ãã§çµããã«ããªãã§ãã¼ãæ¼ãã¦è¡¨ç¤ºãã¦ããããããå²ãè¾¼ã¿å¦çã§çµäºããå¦çãè¡ãã¿ããã§ãã
ã¡ãªã¿ã«ãæ¸ç±ã«ã®ã£ã¦ãããªã³ã¯ã¯æ¬¡ã®ãªã³ã¯ã«ç§»åãã¦ãã¾ãã
ä»åã¯inthandler21(int *esp)
ãç·¨éãã¦ãã以ä¸ã®ãããªã³ã¼ãã«å¤æ´ããããã§ãã
void inthandler21(int *esp) /* PS/2ãã¼ãã¼ãããã®å²ã込㿠*/ { struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO; unsigned char data, s[4]; io_out8(PIC0_OCW2, 0x61); /* IRQ-01åä»å®äºãPICã«éç¥ */ data = io_in8(PORT_KEYDAT); sprinf(s, "%02X", data); boxfill8(binfo->vram, binfo->scrnx, COL8_000000, 0, 16, 15, 31); putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s); /* sã®æåã0Ã16ã«æå */ return; }
ããã§è¡ã£ã¦ããã®ã¯ãã¾ããio_out8(PIC0_OCW2, 0x61);
ã§PICã«å²ãè¾¼ã¿ããããã¨ãç解ããããæã¡å ´ã«æ»ã£ã¦å¤§ä¸å¤«ã ãï¼ã£ã¦ä¼ãã¦ããããã§ããã¾ããdataã«0x060ãè£
ç½®çªå·ã¨ãã¦å
¥åãããã¨ã§ãã¼ã³ã¼ããèªã¿åããã¨ãã§ãã¾ããkeydatã£ã¦keydataã®ãã¨ããªâ¦ï¼
ããã«è¼ã£ã¦ãããã¼ã¸ã¯ãã¡ãã«åã£ã¦ããããã§ãã
ãã¼ãæ¼ãã¦ã¿ãã¨â¦
ããâ¦ããããæ¼ããã³ã«å¤åãã¦ãï¼
ã¡ãªã¿ã«ãã®ãã¼ã³ã¼ãã¯ã¨ããã¨ãã£ã¿ããã使ç¨ãããã¿ã³ãé¢ããã¨ãã®ãã¼ã³ã¼ãã§ãã
å²ãè¾¼ã¿å¦çã¯ææ©ã(harib04b)
harib04b
ã«ã¯åé¡ããã£ãã¿ããã§æåãæåããã®ãã¾ãããããã§ããï¼å²ãè¾¼ã¿å¦çãé·å¼ãã¨ã¾ããâ¦ï¼ã§ãå¦çã®é·ãæåæåãã©ã解決ãããã¨ããã¨ããããã¡ãç¨æãã¦ãã¼ã³ã¼ããHarimainå´ã§è¦ãã¦ããã¦ãããããã§ãã
int.c
ã
#define PORT_KEYDAT 0x0060 struct KEYBUF keybuf; void inthandler21(int *esp) /* PS/2ãã¼ãã¼ãããã®å²ã込㿠*/ { /* æå表示表示ã¯Harimainã§ããã®ã§sã¨BOOTINFOã¯åé¤ */ unsigned char data; io_out8(PIC0_OCW2, 0x61); /* IRQ-01åä»å®äºãPICã«éç¥ */ data = io_in8(PORT_KEYDAT); if (keybuf.flag == 0) { /* ãããã¡ã空ãç¢ºèª */ keybuf.data = data; /* ãããã¡ã¼ã«dataãæ ¼ç´ */ keybuf.flag = 1; /* ãããã¡ã«ãã¼ã¿ãå ¥ã£ãã¨æãã¦ãã */ } return; }
ã«æ¹é ããæ§é ä½ã§ãããã¡ãä½ããããã¡ãæ´»ç¨ãHarimainã«ãã¼ã³ã¼ããæãã¦ãã¾ãã
ã§ã¯æåã表示ããHarimainå´ã¯ã©ããªã£ã¦ãããã¨ããã¨ãæ¹é ããbootpack.c
ããã®ããã«ãªãã¾ã
for (;;) { io_cli(); /* å¤é¨å²ãè¾¼ã¿ç¦æ¢ï¼å²ãè¾¼ã¿å¦çä¸ã®å²ãè¾¼ã¿å¯¾çï¼ */ if (keybuf.flag == 0) { /* ãããã¡ã空ãã®ç¢ºèª */ io_stihlt(); /* å¤é¨å²ãè¾¼ã¿ã®è¨±å¯sã¨ãCPUåæ¢å½ä»¤ */ } else { i = keybuf.data; /* ãã¼ã³ã¼ãã®ã¢ãã¬ã¹ãå¤æ°iã«æ ¼ç´ */ keybuf.flag = 0; /* flagã«0ãã»ãã(ãããã¡ã空ã«ãªã£ããã¨ãæãã¦ãã) */ io_sti(); /* IFã«1ãã»ããï¼å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ï¼ */ sprintf(s, "%02X", i); /* ã¡ã¢ãªã®ãã¼ã¿ã®åç § */ boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31); /* ããã¯ã¹ã®æå */ putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s); /* æåã®è¡¨ç¤º */ } }
ï¼å¤æ°ã®å®ç¾©ãbootpack.hã«å¤åããã£ã¦ããã®ã§æ³¨æï¼
ãã®ããã«ãã¦ãif
ãå©ç¨ãããã¼ã¿ãããå ´åã¨ãªãå ´åãããã¦ãç»é¢è¡¨ç¤ºãããã¦ãã¾ãã
ããã§èµ·åããã¨â¦
æ¬ã§æ示ããã¦ããããã«å³ä¸ã®Ctrl
ãæ¼ãã¨E0ãæ¼ããã¨ããé¢ããã¨ãã表示ããã¦ãã¾ãã¾ããããã®åå ã¯Ctrlã§åºã¦ãããã¼ã³ã¼ãã2ãã¤ãã ãã©ãããã°ã©ã å´ã§2ãã¤ãåãåãæºåãã§ãã¦ããªãã£ãããã§ãã
ãã¨ãããã¤ã¬è¡ãããã¦ãææ
¢ãã¦ããç¶æ
ãã¨ããä¾ããé¢ç½ãã£ãâ¦
FIFOãããã¡ãä½ã(harib04c)
FILOåã¯ã¢ã»ã³ããªã³ã¼ãã¨ãã§è¦ããã¦ãããã©ãFILOåã¯è©³ããç¥ãã®ã¯åãã¦ãªã®ã§æ¥½ãã¿!
ä½ææ¹æ³ã¯ãdata[32]
ãå©ç¨ããããã§ãã
ã¾ãããã¼ã¿ã渡ãå´ã®int.c
ã¯æ¬¡ã®ããã«æ¹é ããã¾ã
#define PORT_KEYDAT 0x0060 struct KEYBUF keybuf; void inthandler21(int *esp) /* PS/2ãã¼ãã¼ãããã®å²ã込㿠*/ { /* æå表示表示ã¯Harimainã§ããã®ã§sã¨BOOTINFOã¯åé¤ */ unsigned char data; io_out8(PIC0_OCW2, 0x61); /* IRQ-01åä»å®äºãPICã«éç¥ */ data = io_in8(PORT_KEYDAT); if (keybuf.next < 32) { /* ãªã¼ãã¼ããã¼å¯¾ç */ keybuf.data[keybuf.next] = data; /* keybuf.nexçªç®ã«ãã¼ã¿ãæ ¼ç´ */ keybuf.next++; /* ã¤ã³ã¯ãªã¡ã³ã */ } return; }
ããã§nextãå©ç¨ããnextã0ããå§ã¾ã32åã®1ãã¤ãã®ç®±ã«ãã¼ã³ã¼ããä¿ç®¡ã§ããããã«ãªãã¾ããï¼
次ã¯ãåãåãå´ã®è¨å®!
for (;;) { io_cli(); /* å¤é¨å²ãè¾¼ã¿ç¦æ¢ï¼å²ãè¾¼ã¿å¦çä¸ã®å²ãè¾¼ã¿å¯¾çï¼ */ if (keybuf.next == 0) { /* ãããã¡ã空ãã®ç¢ºèª */ io_stihlt(); /* å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ã¨ãCPUåæ¢å½ä»¤ */ } else { i = keybuf.data[0]; /* ãã¼ã³ã¼ãã®ã¢ãã¬ã¹ãå¤æ°iã«æ ¼ç´ */ keybuf.next--; /* nextããã¯ãªã¡ã³ã */ for (j = 0; j < keybuf.next; j++) { /* FIFOåã«å¾ãç¹°ãè¿ãå¦çã§æ ¼ç´å ´æãããã */ keybuf.data[j] = keybuf.data[j + 1]; /* 1ã¤ããã */ } io_sti(); /* IFã«1ãã»ããï¼å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ï¼ */ sprintf(s, "%02X", i); /* ã¡ã¢ãªã®ãã¼ã¿ã®åç § */ boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31); /* ããã¯ã¹ã®æå */ putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s); /* æåã®è¡¨ç¤º */ } } }
ãã¡ãã®æ¹ã§ãFIFOåã®ãã¼ã¿ã®æ ¼ç´å ´æããããé¨åã®å¦çã¨å¤æ°iã¸ã®æ ¼ç´ãè¡ã£ã¦ãã¾ããã
å®è¡ãã¦ã¿ãã¨
ã¡ããã¨ã§ãã¦ã¾ããªï¼ããããã¾ã ã¾ããé¨åãããããã§ããããã¯ã3åç¨åº¦ã®ãããæä½ã§ããã°åé¡ãªãã®ã§ããã32åã¨ãã®ãã¼ã¿ãæ¥ãéã«ãããã¨ãªãã¨ãæå表示ç¨ã§ã¯ãªãã§ããå¦çæéãããã£ã¦ãã¾ãã¨ãããã¨ã§ããè¦ã¯ããå²ãè¾¼ã¿å¦çã«æéããããããï¼ã ãã©å¤ã«åºããªãâ¦ãã¨ãããã¨ã§ãã
FIFOãããã¡ãæ¹é ãã(harib04d)
harib04e
ã§ããããå¦çä¸ã«ããã®ã¯ã¾ãããã©ãã©ããããâ¦ã¨ããç¶æ³ãæ¹åããããã®ä½æ¥ã§ãã
ããã§ããæ¹æ³ã¨ããã®ããèªã¿nextã¨æ¸ãnextãç¨æããããããã®ãããã¡ã31ãè¶
ããã0ã«æ»ãã¨ãã£ãã循ç°ããªããèªã¿æ¸ããè¡ã£ã¦ããä»çµã¿ã§ããããã§ãã¾ããããããã§ãããªã¼ãã¼ããã¼ããªããã°â¦
ã§ã¯ãæ¹è¯ãããint.c
ã¯
void inthandler21(int *esp) /* PS/2ãã¼ãã¼ãããã®å²ã込㿠*/ { /* æå表示表示ã¯Harimainã§ããã®ã§sã¨BOOTINFOã¯åé¤ */ unsigned char data; io_out8(PIC0_OCW2, 0x61); /* IRQ-01åä»å®äºãPICã«éç¥ */ data = io_in8(PORT_KEYDAT); if (keybuf.len < 32) { /* ãªã¼ãã¼ããã¼å¯¾ç */ keybuf.data[keybuf.next_w] = data; /* keybuf.nexçªç®ã«ãã¼ã¿ãæ ¼ç´ */ keybuf.len++; /* ãããã¡ã®å®¹éã®ã¤ã³ã¯ãªã¡ã³ã */ keybuf.next_w++; /* èªã¿ãã¿ãããã¡ãé²ãã */ if (keybuf.next_w == 32) { keybuf.next_w = 0; /* ãããã¡ã32ã«å°éããã0ã«ç§»å */ } } return; }
ãããªæãã§æ¸ãè¾¼ã¿ã®keybuf.next_w
ããã¼ã¿ãåãåãã¨ããã£ãã¨keybuf.len
ã«ãã¼ã¿ãå
¥ãããã¨ãè¨é²ãã次ã®ãã¼ã¿ãä¿ç®¡ããç®±ã«ç§»ã£ã¦ãã¾ãã
ã§ã¯ãèªã¿è¾¼ã¿å´ã¯ã©ããªã£ã¦ãããã¨ããã¨
for (;;) { io_cli(); /* å¤é¨å²ãè¾¼ã¿ç¦æ¢ï¼å²ãè¾¼ã¿å¦çä¸ã®å²ãè¾¼ã¿å¯¾çï¼ */ if (keybuf.len == 0) { /* ãããã¡ã空ãã®ç¢ºèª */ io_stihlt(); /* å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ã¨ãCPUåæ¢å½ä»¤(å²ãè¾¼ã¿ã®çµäº) */ } else { i = keybuf.data[keybuf.next_r]; /* ãã¼ã³ã¼ãã®ã¢ãã¬ã¹ãå¤æ°iã«æ ¼ç´ */ keybuf.len--; /* ãããã¡ã®ãã¼ã¿ã1ã¤å¼ãã ãã¨ãè¨é² */ keybuf.next_r++; if (keybuf.next_r == 32) { /* FIFOåã«å¾ãç¹°ãè¿ãå¦çã§æ ¼ç´å ´æãããã */ keybuf.next_r = 0; /* èªã¿è¾¼ã¿nextã31ãè¶ ããæ0ã«æ»ã */ } io_sti(); /* IFã«1ãã»ããï¼å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ï¼ */ sprintf(s, "%02X", i); /* ã¡ã¢ãªã®ãã¼ã¿ã®åç § */ boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31); /* ç»é¢ã®ãªã»ãã */ putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s); /* æåã®è¡¨ç¤º */ } }
ãã®ããã«èªã¿è¾¼ã¿å´ã¨åãããã«keybuf.len
ã§ã©ã®ãããã®ãã¼ã¿ããããã確èªãã¦keybuf.next_r
ãå©ç¨ãã¦ãå
¥ããåæ°ã ãèªã¿ã ãã¦ãã¾ããã¾ãã31ã«éããã0ã«ç§»åããå¦çãè¡ã£ã¦ãã¾ãã
å®è¡ããã¨
å¤ãããªããã©ä¸èº«ã¯ãã£ããããæãããããé«éãããã¦æé«ãããâ¦ï¼ã¯ãã¼ã¦OSèªä½ãé«éããã¦å®æã§ããªãã£ãï¼
FIFOãããã¡ãæ´çãã(harib04e)
次ã«ãã¼ãã¼ãããéããã¦ãããã¼ã¿ã¯ããã¾ã§ã®FIFOãããã¡ã§å¦çã§ãããããã®ã§ããããã¦ã¹ããã®ãã¼ã¿ãèããã¨ãªãã¨è©±ã¯éã£ã¦ããããã§ããã¾ãããã¦ã¹ãå°ãåãã ãã§3ãã¤ããã®ãã¼ã¿ãé£ç¶ã§éããã¦ããããã¿ããã§ããããã対çããããã«ã以ä¸ã®FIFO8
ã®*buf
ã®ããã«æ§é ä½ãä½æããã¨ãã«ãããã¡ã®å¤§ãããä½ãã¤ãã§ãããããã«ãã¦ããã¿ããã§ãã
/* fifo.c */ struct FIFO8 { unsigned char *buf; /* ãããã¡ã®ä½ç½®ãç¹å®ããããã®ã¢ãã¬ã¹ */ int p, q, size, free, flags; /* pï¼æ¸ãè¾¼ã¿ä½ç½®,q:èªã¿è¾¼ã¿ä½ç½®,size:ãããã¡ã®å¤§ãã,free:ãããã¡ã®ç©ºã容é,flags:ããµãã®ç¢ºèªãã©ã°, */ };
ãã®fifo.cã§ã¯ãFIFOåãããã¡ãå¶å¾¡ããããã®4ã¤ã®é¢æ°ãããã¾ãã
ä¸ã¤ç®ã
void fifo8_init(struct FIFO8 *fifo, int size, unsigned char *buf) /* FIFOãããã¡ã®åæå */ { fifo->size = size; fifo->buf = buf; fifo->free = size; /* 空ã */ fifo->p = 0; /* æ¸ãè¾¼ã¿ä½ç½® */ fifo->q = 0; /* èªã¿è¾¼ã¿ä½ç½® */ return; }
ã§ãæ§é ä½ã®çªå°ã¨ãããã¡ã«é¢æ°ãã©ã¡ã¼ã¿ãæå®ããæ¸ãè¾¼ã¿ä½ç½®ã¨èªã¿è¾¼ã¿ä½ç½®ã0ã«åæåãã¦ãã¾ãã
äºã¤ç®ã
int fifo8_put(struct FIFO8 *fifo, unsigned char data) /* FIFOã¸ãã¼ã¿ãéãè¾¼ãã§èãã */ { if (fifo->free == 0) { /* ãã空ãããªããã° */ /* 空ãããªãã¦ããµãã */ fifo->flags |= FLAGS_OVERRUN; return -1; /* -1ãè¿ã */ } fifo->buf[fifo->p] = data; fifo->p++; /* æ¸ãè¾¼ã¿ä½ç½®ãé²ãã */ if (fifo->p == fifo->size) { /* æ¸ãè¾¼ã¿ä½ç½®ãæå¾ã«æ¥ãã */ fifo->p = 0; /* 0ã«ç§»å */ } fifo->free--; /* ãããã¡ã®ç©ºããæ¸ã£ã */ return 0; /* 0ãè¿ã */ }
ã§ãFIFOåãããã¡ã¸ãã¼ã¿ãåç´ããã®ãå½¹å²ã®é¢æ°ã§ãã
å¼æ°ã¨ãã¦ãæ§é ä½ã®ãã¤ã³ã¿ã¨1ãã¤ãã®ãã¼ã¿ãåãåããããµããå ´åã®å¦çã¨ç¡äºãã¼ã¿ãåãåã£ãå¾ã«æ¸ãè¾¼ã¿ä½ç½®ãé²ããå¦çãè¡ã£ã¦ããã
3ã¤ç®ã¯
int fifo8_get(struct FIFO8 *fifo) /* FIFOãããã¼ã¿ã1ã¤ã¨ã£ã¦æ¥ã */ { int data; if (fifo->free == fifo->size) { /* ãããã¡ã空ã£ã½ã®æã¯ãã¨ãããã-1ãè¿ããã */ return -1; } data = fifo->buf[fifo->q]; /* ãããã¡ä¸ã®èªã¿è¾¼ã¿ä½ç½®ã®ãã¼ã¿ãdataã«æ ¼ç´ */ fifo->q++; /* èªã¿è¾¼ã¿ä½ç½®ã1ã¤é²ãã */ if (fifo->q == fifo->size) { /* ãããã¡ã®æå¾ã«ãã©ãçããã */ fifo->q = 0; /* ãããã¡ã®å§ãã«ç§»åãã */ } fifo->free++; /* ãããã¡ã®ãã¼ã¿ãä¸ã¤æ¸¡ãããã¨ãfreeã«ç©ºãã1ã¤å¢ããã¨ãã¦è¨é² */ return data; /* intåã§dataãè¿ã */ }
ã§ãFIFOãããã¡ãã1ãã¤ãã®ãã¼ã¿ãåãåºãåä½ãè¡ãé¢æ°ã§ãå¼æ°ã¨ãã¦æ§é ä½ã®ãã¤ã³ã¿ã渡ããã¨ã§ããããã¡ããdataã¸ãã¼ã¿ã移ãã¦ããã
4ã¤ç®ã
int fifo8_status(struct FIFO8 *fifo) /* ã©ã®ããããã¼ã¿ããã¾ã£ã¦ããããå ±åãã */ { return fifo->size - fifo->free; /* ãããã¡ã®å¤§ãããã空ãã®å¤§ãããå¼ã */ }
ãããã¡ã®ã¢ãã¬ã¹ãåãåããæå®ããããããã¡ã«ã©ãã ãã®ãã¼ã¿ããã¾ã£ã¦ãããã®ç¢ºèªãè¡ã£ã¦ãã
ã§å®è¡ãããã¨
ãã¤éãã®è¡¨ç¤ºâ¦ã§ãããããã¡é¢ä¿ãé¢æ°ã§ã¾ã¨ãã¦ããã®ã§ããããã£ãããã¦ãï¼
ãããã¦ã¹ã (harib04f)
ã¾ãããã¦ã¹ã¨ããã®ã¯å¾ã®æ¹ã§éçºããããã®ã§ãããããã®IRQ12ã¨ãã大ãããªå²ãè¾¼ã¿çªå·ã«ãªã£ã¦ãã¾ããã¾ããå½æã¯ãã¦ã¹ã«å¯¾å¿ãã¦ããOSãå°ãªããããããã¦ã¹ã¯å°ãåããã ãã§å²ãè¾¼ã¿ãããã¦ãã¾ãã®ã§ãã¾ãâ¦CPUãç¥ããããªãå²ãè¾¼ã¿ã大éã«æ¥ã¦æ··ä¹±ããããã§â¦
ãããé²ãããã«ããã¦ã¹ã®å²ãè¾¼ã¿ãããããã«ã¯æå¹åå½ä»¤ãå¶å¾¡åè·¯ã¨ãã¦ã¹æ¬ä½ã«éãå¿
è¦ããããã¨ã«ãããã¨ã§è§£æ±ºãã¦ãã¾ãã
ã¨ãããã¨ã§ä»åã¯ãã¦ã¹ã®å²ãè¾¼ã¿ãæå¹åãã¦ããããã¨ããããã§ãã
ãã®ããã«ãbootpack.cã§ã®keyboadã®åæåãæ¹é ãããã¦ã¹ã«æå¹åå½ä»¤ãéã£ã¦ãããé¢æ°ãä½ã£ã¦ãããã¿ããã§ãã
ä¸ã¤ç®ãããã¼ãã¼ãã®å¦çã¹ãã¼ããCPUããé
ãããã«ããã¼ãã¼ããæ··ä¹±ããªãããã«ããé¢æ°ã§
void wait_KBC_sendready(void) { /* ãã¼ãã¼ãã³ã³ããã¼ã©ã¼ããã¼ã¿ãéä¿¡å¯è½ã«ãªãã®ãå¾ ã¤ */ for (;;) { if ((io_in8(PORT_KEYSTA) & KEYSTA_SEND_NOTREADY) == 0) { /* ANDã§ãã¼ã¿éä¿¡å¯è½ç¶æ ãã®ç¢ºèª */ break; } } return; }
ã¨ãªã£ã¦ãããè£ ç½®çªå·0x0064ããéããã¦ãããã¼ã¿ã®ä¸ä½2ãããã0ã«ãªãã¨ãã³ãã³ããåãä»ããããã¨ãããµã¤ã³ãªã®ã§ããã®å¾ç¡éã«ã¼ãããbreakããé¢æ°ã§ãã
2ã¤ç®ããã¼ãã¼ãã³ã³ããã¼ã©ã®åæåé¢æ°ã®æ¹é ã§ã
void init_keyboard(void) { /* ãã¼ãã¼ãã³ã³ããã¼ã©ã¼ã®åæå */ wait_KBC_sendready(); /* éä¿¡å¯è½ãã®ç¢ºèª */ io_out8(PORT_KEYCMD, KEYCMD_WRITE_MODE); /* ã¢ã¼ãè¨å®ã³ãã³ã */ wait_KBC_sendready(); /* éä¿¡å¯è½ãã®ç¢ºèª */ io_out8(PORT_KEYDAT, KBC_MODE); /* ãã¦ã¹ã¢ã¼ããæå® */ return; }
ãããã®è¨å®æ å ±ã¯æå®ããããã¤ãã®å ´æã«ä¹ã£ã¦ããããã§
ã®ã£ã¦ãããããã®ã§ããããã¼ãã¼ãã®ã¢ã¼ãå¤æã®0x0060ã¯8042ã¢ã¼ãã¬ã¸ã¹ã¿ç´æ¥æ¸ãè¾¼ã¿
ã«æ¸ãã¦ããã¨ãããã®ã§ããããã¦ã¹ã®0x47ã¯ã¹ãã¼ã¿ã¹ã¬ã¸ã¹ã¿ã®å
容ãbitãã¨ã§ã®æå®ãã¦ãããã®ãªã®ã§ããã01000111
ã§ãIRQ-1ãçºçãããã»ãã¦ã¹ãããã¼ã¿ãæ¥ãã¨ãã«IRQ-12ãçºçãããã»ã·ã¹ãã ãã©ã°ãONã»ã¹ãã£ã³ã³ã¼ã01ã使ãã¨ããè¨å®ã£ã½ãã§ãã
ã¹ãã£ã³ã³ã¼ãâ¦ãã¼ãã¼ãã®ãã¼ãæ¼ããã¨ãã«ãã¼ãã¼ããã帰ã£ã¦ããã³ã¼ãã®ãã¨ããªã01ã«ãããã¯ããããªãã£ãâ¦
3ã¤ç®ã¯ãæ··ä¹±ããªãããã«æå¾ã«åãã¦ããããã¦ã¹ã«æå¹åå½ä»¤ãéãé¢æ°ã§ã
void enable_mouse(void) { /* ãã¦ã¹æå¹å */ wait_KBC_sendready(); /* éä¿¡å¯è½ãã®ç¢ºèª */ io_out8(PORT_KEYCMD, KEYCMD_SENDTO_MOUSE); /* KBCã¸ãã¦ã¹ã¸ã®ãã¼ã¿éä¿¡ä¾é ¼ */ wait_KBC_sendready(); /* éä¿¡å¯è½ãã®ç¢ºèª */ io_out8(PORT_KEYDAT, MOUSECMD_ENABLE); /* ãã¦ã¹ã¸æå¹åå½ä»¤ãä¼é */ return; /* ãã¾ãããã¨ACKï¼0xfaï¼ãéä¿¡ããã¦ãã */ }
ãã®ããã«ããã¼ãã¼ãå¶å¾¡åè·¯ãä»ãã¦ãã¦ã¹ã«ãã¼ã¿ãéã£ã¦ããå¦çã£ã½ãã§ãã
å¾ã¯ãHarimainããããã°ã
èªèã¨â¦
ãã¦ã¹ããã®ãã¼ã¿åä¿¡(harib04g)
å²ãè¾¼ã¿ã®æ¬¡ã¯ãã¼ã¿ã®åä¿¡è¨å®ã®ããã§ã
1ã¤ç®ã¯ãPICã«åä»éç¥ãè¡ãããã¼ã¿ãåãåããFIFOãããã¡ã«æ ¼ç´ããã¨ããå¦çã以ä¸ã®int.cã®é¢æ°ã§è¡ã
void inthandler2c(int *esp) /* PS/2ãã¦ã¹ããã®å²ã込㿠*/ { unsigned char data; io_out8(PIC1_OCW2, 0x64); /* IRQ-12åä»å®äºãPIC1ã«ä¼éï¼ã¹ã¬ã¼ãã¸ï¼ */ io_out8(PIC0_OCW2, 0x62); /* IRQ-02åä»å®äºãPIC0ã«ä¼é ï¼ãã¹ã¿ã¸ï¼*/ data = io_in8(PORT_KEYDAT); /* ãã¼ãã¼ãã¨åã */ fifo8_put(&mousefifo, data); /* ãã¼ãã¼ãã¨åã */ return; }
ãã®éã¯ããã¦ã¹ã¯ã¹ã¬ã¼ãã®IRQ-12ã«ãããã®ã§ãã¹ã¬ã¼ãã¨ãã¹ã¿ãé£æºãããããã«ä¸¡æ¹ã«åä»å®äºãéã£ã¦ãã¾ãããã¨ã¯ããã¼ãã¼ãã¨åãã
2ã¤ç®ã¯ãbootpack.cå´ã®ãã¼ã¿ãåãåãæ¹ã®å¦çã«ãªãã¾ãã
enable_mouse(); /* ãã¦ã¹ã®æå¹å */ for (;;) { io_cli(); /* å¤é¨å²ãè¾¼ã¿ç¦æ¢ï¼å²ãè¾¼ã¿å¦çä¸ã®å²ãè¾¼ã¿å¯¾çï¼ */ if (fifo8_status(&keyfifo) + fifo8_status(&mousefifo) == 0) { /* ã©ã¡ãããããã¼ã¿ãæ¥ã¦ãªããã¨ã®ç¢ºèª */ io_stihlt(); /* å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ã¨ãCPUåæ¢å½ä»¤(å²ãè¾¼ã¿ã®çµäº) */ } else { if (fifo8_status(&keyfifo) != 0) { /* ãããã¼ãã¼ãã®æ¹ã®ãã¼ã¿ãæ¥ã¦ããã */ i = fifo8_get(&keyfifo); /* ãã¼ã³ã¼ãã®ã¢ãã¬ã¹ãå¤æ°iã«æ ¼ç´ */ io_sti(); /* IFã«1ãã»ããï¼å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ï¼ */ sprintf(s, "%02X", i); /* ã¡ã¢ãªã®ãã¼ã¿ã®åç § */ boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31); /* ç»é¢ã®ãªã»ãã */ putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s); /* æåã®è¡¨ç¤º */ } else if (fifo8_status(&mousefifo) != 0) { /* ããããã¦ã¹ã®ãã¼ã¿ãæ¥ã¦ããã */ i = fifo8_get(&mousefifo); /* ãã¦ã¹ã®ãã¼ã¿ããããã¡ããåå¾ã */ io_sti(); /* IFã«1ãã»ããï¼å¤é¨å²ãè¾¼ã¿ã®è¨±å¯ï¼ */ sprintf(s, "%02X", i); /* æå®ã¢ãã¬ã¹ã®å¤ã®åå¾ */ boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 32, 16, 47, 31); /* ããã¯ã¹ã®æå */ putfonts8_asc(binfo->vram, binfo->scrnx, 32, 16, COL8_FFFFFF, s); /* æåã®æå */ } }
ãã®ããã«ãã¾ãããã¦ã¹ã®æå¹åãè¡ãã¾ãã次ã«ããã¼ã¿ãæ¥ã¦ãããã¨ã確èªãã¦ãããã¼ãã¼ãã¨ãã¦ã¹ã®ãã¼ã¿ãé¸ãåãããããã¡ãããã¼ã¿ãåãåºããç»é¢è¡¨ç¤ºããã¨ããå¦çãè¡ã£ã¦ãã¾ãã
ããã¨
ãã¼ã¿ãåä¿¡ãããã¨ãã§ããï¼ãã¦ã¹ãããããåããã¨ãããããæ°å¤ãåãã¦ããã¦æåã§ãã
ææ³
7æ¥ç®ã¯ããã¦ã¹ãã©ã®ããã«ãã¼ã¿ãé£ã°ãã¦ããããç¥ããã¨ãã§ãé¢ç½ãã£ãã§ããç¹ã«ãæ§é ä½ã®åºç¤çãªä½¿ãæ¹ã身ã«ã¤ãã¦ããæ°ããã¾ãã