linux-0.01 読み (15)

このままでは寝つきが悪そうなので、と言いつつハマってみたりなど。

sys_setup 手続き

mount_root() という非常に分かり易い名前の手続きを呼び出しているんですが、その前にヤッてるナニがどうやら。
とりあえず、NR_HD の定義から掘削。

/*
 *  This struct defines the HD's and their types.
 *  Currently defined for CP3044's, ie a modified
 *  type 17.
 */
static struct hd_i_struct{
	int head,sect,cyl,wpcom,lzone,ctl;
	} hd_info[]= { HD_TYPE };

#define NR_HD ((sizeof (hd_info))/(sizeof (struct hd_i_struct)))

ええと、HD_TYPE は include/linux/config.h で以下な定義。

/*
 * HD type. If 2, put 2 structures with a comma. If just 1, put
 * only 1 struct. The structs are { HEAD, SECTOR, TRACKS, WPCOM, LZONE, CTL }
 *
 * NOTE. CTL is supposed to be 0 for drives with less than 8 heads, and
 * 8 if heads >= 8. Don't know why, and I haven't tested it on a drive with
 * more than 8 heads, but that is what the bios-listings seem to imply. I
 * just love not having a manual.
 */

#define HD_TYPE { 4,20,1024,0,4,0 }

コメントはスルーって事にしとくとして、とりあえず NR_HD は 1 になるんかな。

rw_abs_hd 手続き

add_request して buffer_head 構造体の b_lock 属性が偽になるまでビジーループというナニ。add_request では Linked List に何かを追加して do_request してます。
ここでは HardDisk Controller に対して何らかの命令を実行している模様。てか、do_hd とか read_intr とか b_lock がいつクリアされるのかとか、もう右も左も真っ暗闇だな。
とりあえず hd_out 手続きの中で do_hd に read_intr が代入されてます。do_hd の定義な箇所で以下なコメントがあります。

/*
 * This is the pointer to a routine to be executed at every hd-interrupt.
 * Interesting way of doing things, but should be rather practical.
 */
void (*do_hd)(void) = NULL;

hd-interrupt か。でも割り込み入る度に呼び出される根拠が不明。hd.c をなんとなく眺めてたら hd_interrupt という手続きを extern 宣言しているのを発見。しかも hd_init にて

	set_trap_gate(0x2E,&hd_interrupt);

してますな。そーゆー意味だとこのあたりは hd_init 手続きから掘削を開始しないと駄目だな。ちなみに hd_interrupt は kernel/system_call.s で定義されてますが、do_hd を call してますな。という事は hd_out 手続きは do_hd を呼び出すトラップ (0x2E) なナニのリクエストを云々なのだろうか。

タイムアップ

明日は健康診断なので止めて寝ます。