雑記帳
ここはhideyosiの雑記帳です。テケトーに書き散らしてるだけなので間違っていたりとは普通にしてます。信用度は相当低いことをあらかじめご了承を。またご覧のようにWikiを使ってますが、hideyosi意外は書き込めません。
2: 2007-01-21 (日) 14:28:34 ソース バックアップ No.2 を復元して編集 現: 2024-01-06 (土) 22:39:09 ソース 編集
Line 30: Line 30:
    load_idtr(LIMIT_IDT, ADR_IDT);     load_idtr(LIMIT_IDT, ADR_IDT);
 + 
    /* IDTの設定 */     /* IDTの設定 */
    set_gatedesc(idt + 0x0c, (int) asm_inthandler0c, 2 * 8, AR_INTGATE32);     set_gatedesc(idt + 0x0c, (int) asm_inthandler0c, 2 * 8, AR_INTGATE32);
Line 68: Line 68:
    load_idtr(LIMIT_IDT, ADR_IDT);     load_idtr(LIMIT_IDT, ADR_IDT);
 + 
    /* IDTの設定 */     /* IDTの設定 */
    set_gatedesc(idt + 0x0c, (int) asm_inthandler0c, 2 * 8, AR_INTGATE32);     set_gatedesc(idt + 0x0c, (int) asm_inthandler0c, 2 * 8, AR_INTGATE32);
Line 116: Line 116:
    io_out8(PIC0_OCW2, 0x61); /* IRQ-01受付完了をPICに通知 */     io_out8(PIC0_OCW2, 0x61); /* IRQ-01受付完了をPICに通知 */
    data = io_in8(PORT_KEYDAT);     data = io_in8(PORT_KEYDAT);
 + 
    sprintf(s, "%02X", data);     sprintf(s, "%02X", data);
    boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);     boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
    putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);     putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
 + 
    return;     return;
Line 133: Line 133:
  data = io_in8(PORT_KEYDAT);   data = io_in8(PORT_KEYDAT);
  fifo32_put(keyfifo, data + keydata0);   fifo32_put(keyfifo, data + keydata0);
 + 
  /*実験部分*/   /*実験部分*/
  struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;   struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
  unsigned char s[4];   unsigned char s[4];
 + 
  sprintf(s, "%02X", data);   sprintf(s, "%02X", data);
  boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);   boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
  putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);   putfonts8_asc(binfo->vram, binfo->scrnx, 0, 16, COL8_FFFFFF, s);
  /*-------------------*/   /*-------------------*/
 + 
  return;   return;
 }  }
Line 154: Line 154:
 #include <stdio.h>  #include <stdio.h>
 #include "bootpack.h"  #include "bootpack.h"
 + 
 void inthandler26(int *esp)  void inthandler26(int *esp)
 /* FDコントローラからの割り込み */  /* FDコントローラからの割り込み */
 {  {
 + 
  /*実験部分*/   /*実験部分*/
  io_out8(PIC0_OCW2, 0x66); /* IRQ-06受付完了をPICに通知 */   io_out8(PIC0_OCW2, 0x66); /* IRQ-06受付完了をPICに通知 */
 + 
  struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;   struct BOOTINFO *binfo = (struct BOOTINFO *) ADR_BOOTINFO;
  unsigned char s[4];   unsigned char s[4];
 + 
  sprintf(s, "%02X", data);   sprintf(s, "%02X", data);
  boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);   boxfill8(binfo->vram, binfo->scrnx, COL8_008484, 0, 16, 15, 31);
  putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FF00FF, s);   putfonts8_asc(binfo->vram, binfo->scrnx, 0, 0, COL8_FF00FF, s);
  /*-------------------*/   /*-------------------*/
- +  
 + 
  return;   return;
 }  }
Line 186: Line 186:
[[OS-Wiki:http://community.osdev.info/index.php?(FDC)765A]]にも資料があるな。 [[OS-Wiki:http://community.osdev.info/index.php?(FDC)765A]]にも資料があるな。
ん????。読み出したデータのおのおののビットに意味があるの??。つーことは、0X11って 10001でしょ?。 「&」って、読み出したデータをand演算しろってこと? ん????。読み出したデータのおのおののビットに意味があるの??。つーことは、0X11って 10001でしょ?。 「&」って、読み出したデータをand演算しろってこと?
 +
 +うーん。あってるかどうかわからんが、とにもかくにもコマンドラインにこんなコマンドを実装。
 +
 + /*FDの実験*/
 + void cmd_fdtest(struct CONSOLE *cons)
 + {
 +   char a;
 +   a = io_in8(0x03f4);
 + 
 +     int s[70];
 +     sprintf(s, "0x03f4 = %d, 0x11 & = %d",a,a & 0x11);
 +  cons_putstr0(cons, s);
 +  cons_newline(cons);
 +  return;
 + }
 + /*---------------------*/
 +
 +結果、ほぼいつでも0であることがわかった。
 +
 +はりぼてWikiでは、この確認が終わったら
 + 次に以下を送信したいバイト数だけ繰り返します。
 + 
 +   * io_in8(0x03f4) & 0xc0 が 0x80 になるのを待つ
 +   * io_out8(0x03f5, データ);
 +
 +とある。ええと。これはどういうことかな? たとえば、''シリンダ0へのシーク''を行いたい場合は、[07] [00] (INT) って書いてあるけど、これは
 +
 +-- io_in8(0x03f4) & 0xc0 が 0x80 になるのを待つ(まだかな〜?)
 +-- よし! 0x80になったぞ!!
 +-- io_out8(0x03f5, 0x07); でコマンドを送信!
 +-- 再びio_in8(0x03f4) & 0xc0 が 0x80 になるのを待つ(まだかな〜?)
 +-- よし! 0x80になったぞ!!
 +-- こんどはio_out8(0x03f5, 0x00); でコマンドを送信!
 +-- コマンドは送ったぞ。あとは、IRC6からお返事が来るまで待とう
 +-- よし!割り込みが来た! ステータスレジスタを見て、成功したか失敗かを確認しなくちゃ!
 +
 +・・・っとまあ、こういうことでいいのかなぁ????
 +
 +・・・ところで、このFDの制御はどうも1秒とか3秒とかそういう時間の制御が必要ではないかと感じ始めた。なんかだんだん大げさになってくるけど、APIもあるし、タイマー制御してみることにしよう!!
 +
 +ええと。このへんのことはP507あたりに書いてあるのでと。
 +
 +そんなわけで、こんな内臓コマンドを試作して実行してみたが、割り込みもなにも発生しないようだ。コマンドの解釈が間違っているのだろうなぁ・・・
 +
 +
 + /*FDの実験*/
 + void cmd_fdtest(struct CONSOLE *cons)
 + {
 +  char s[30];
 +  char counter = 3;
 +  int p;
 + 
 +   struct FIFO32 timerfifox;
 +   struct TIMER *timerx;
 +   int timerbuf[128];
 + 
 +   fifo32_init(&timerfifox,128,timerbuf,0);
 + 
 +   timerx = timer_alloc();
 +   timer_init(timerx,&timerfifox,128);
 +   timer_settime(timerx,100);
 + 
 +  //3秒待ち
 +     for(;;){
 +       io_cli();
 +     p = fifo32_get(&timerfifox);
 +     if (counter == 0){break;}
 + 
 +     if( p == 128 ){
 +     sprintf(s, "Wait %dSec...\n",counter);
 +     cons_putstr0(cons, s);
 +    counter--;
 +    timer_settime(timerx,100);
 +   }
 +         io_sti();
 +  }
 +       io_sti();
 + 
 + 
 + 
 + 
 +  //0x03f4のチェック
 +     sprintf(s, "Check 0x03f4");
 +     cons_putstr0(cons, s);
 +     cons_newline(cons);
 + 
 +  char a;
 +  a = io_in8(0x03f4);a = a & 0x11;
 +  if ( a == 0 ) {
 +     sprintf(s, "OK! 0x03f4 & 0x11 is 0!");
 +     cons_putstr0(cons, s);
 +     cons_newline(cons);
 +  }
 + 
 +  //コマンドの送信
 +       sprintf(s, "Start command send...");
 +     cons_putstr0(cons, s);
 +     cons_newline(cons);
 + 
 + 
 +     io_out8(0x03f5, 0x07);
 +     sprintf(s, "Send 0x03f5 [0x07]");
 +     cons_putstr0(cons, s);
 +     cons_newline(cons);
 + 
 +     while(io_in8(0x03f4) & 0xC0 == 0x80 )
 + 
 +     io_out8(0x03f5, 0x00);
 +     sprintf(s, "Send 0x03f5 [0x00]");
 +     cons_putstr0(cons, s);
 +     cons_newline(cons);
 + 
 + 
 +       timer_free(&timerx);
 + 
 +    return;
 + }
 + /*---------------------*/