Closed TaiseiIto closed 2 years ago
https://wiki.osdev.org/VESA_Video_Modes この構造体を0x00000600に配置
struct vbe_mode_info_structure {
uint16 attributes; // deprecated, only bit 7 should be of interest to you, and it indicates the mode supports a linear frame buffer.
uint8 window_a; // deprecated
uint8 window_b; // deprecated
uint16 granularity; // deprecated; used while calculating bank numbers
uint16 window_size;
uint16 segment_a;
uint16 segment_b;
uint32 win_func_ptr; // deprecated; used to switch banks from protected mode without returning to real mode
uint16 pitch; // number of bytes per horizontal line
uint16 width; // width in pixels
uint16 height; // height in pixels
uint8 w_char; // unused...
uint8 y_char; // ...
uint8 planes;
uint8 bpp; // bits per pixel in this mode
uint8 banks; // deprecated; total number of banks in this mode
uint8 memory_model;
uint8 bank_size; // deprecated; size of a bank, almost always 64 KB but may be 16 KB...
uint8 image_pages;
uint8 reserved0;
uint8 red_mask;
uint8 red_position;
uint8 green_mask;
uint8 green_position;
uint8 blue_mask;
uint8 blue_position;
uint8 reserved_mask;
uint8 reserved_position;
uint8 direct_color_attributes;
uint32 framebuffer; // physical address of the linear frame buffer; write here to draw to the screen
uint32 off_screen_mem_off;
uint16 off_screen_mem_size; // size of memory in the framebuffer but not being displayed on the screen
uint8 reserved1[206];
} __attribute__ ((packed));
virtual boxで画面が表示されなくなってるのはmainブランチでも同様のようだ
virtual boxで画面が表示されない問題 issue26では画面が表示される issue27では画面が表示されない
1a2400520d7b889c9b5a3626ffeea91bff3aae86表示される
2a56343b663a6068433ae24e05fb44789d98f40d表示される
b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86表示されない
fb4443893c2ee598acff3b45d2f39779bf6c8b26表示された
virtual boxで画面が表示されなくなったのは、b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86以降ということになる。
以下のコミットでvirtual boxで画面が表示されなくなった https://github.com/TaiseiIto/hariboslinux/commit/b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86
そしてマウス割り込みも拾えていない
画面表示されない問題とマウス割り込み拾えない問題は解決
次に各画面モードが使えるかどうかを調べる
keyboard stateまではシリアル出力されている これはinitscrn.sの最後で出力されていて、その後mv2prtmd.sに移行してる Hello, mv2prtmd.binは表示されていない
ソースコード中に0xce00が残ってないかどうか確認しよう
cのファイルを検索
find . | grep \\.c$
.c,.sファイルを列挙
find . | grep -e \\.c$ -e \\.s$
結果なにもなし
cat $(find . | grep -e \\.c$ -e \\.s$) | grep ce00
initscrn.binのサイズは0x0800ではなく0x0a00になっている
使用する画面モードの条件
これらすべての条件を満たすものの中から、画面が最も大きいものを選択
画面モード探索中にスタックに保存する必要があるもの
BootInformation構造体に残しておくべきもの
以下を0x00000700-0x00000705に配置
typedef struct
{
unsigned short memory_size; // MiB
unsigned char keyboard_state;
unsigned char last_loaded_cylinder;
unsigned char last_loaded_head;
unsigned char last_loaded_sector;
} __attribute__((packed)) BootInformation;
実機で乱れた画像が表示されている
実機での実験結果 The best video mode = 0x8918
実機での実験結果その2
VBE available
VBE signature = VESA
VBE version = 0x0300
VBE OEM string pointer = 0xc0008ffc
VBE capabilities = 0x00000001
VBE video mode pointer = 0xc00090b9
VBE total memory = 0x03ff
video mode pointerがすごいところに配置されてる
0xc00090b9番地にアクセスできないっぽいので、protected modeに入ってから画面を切り替えたほうがいいかも
https://github.com/knusbaum/kernel/blob/master/vesa.c
これによると、video mode pointerは上位4ビットがセグメント、下位4ビットがオフセットを示しているらしく、1MiB協会は超えていないので普通にリアルモードでアクセスできるっぽい
実機での実験結果 The best video mode = 0x017f
衝撃的実験結果
The best video mode = 0x017f
attributes = 0x0000
pitch = 0x0000
width = 0x0000
height = 0x0000
bits per pixel = 0x00
memory model = 0x00
red mask = 0x00
red position = 0x00
green mask = 0x00
green position = 0x00
blue mask = 0x00
blue position = 0x00
frame buffer = 0x00000000
off screen mem off = 0x00000000
off screen mem size = 0x0000
実験結果
The best video mode = 0x017f
attributes = 0x009b
pitch = 0x1e00
width = 0x0780
height = 0x0438
bits per pixel = 0x20
memory model = 0x06
red mask = 0x08
red position = 0x10
green mask = 0x08
green position = 0x08
blue mask = 0x08
blue position = 0x00
frame buffer = 0xe0000000
off screen mem off = 0x00000000
off screen mem size = 0x0000
まだ実機で画面を映し出せていない。 ピクセル当たり0x20ビットなので、1バイトがアルファ値になっている可能性もある
実機でVRAMに直接書き込みしてどうなるか
実機でVRAM直接書き込みでも駄目だった。 おそらく https://wiki.osdev.org/VESA_Video_Modes の Don't Assume The Monitor Supports A Video Mode の項目が当てはまっていると思われる。
https://wiki.osdev.org/EDID これも参考になりそう
実機でCPU例外が起きている可能性も考えられる 実機のシリアルポート出力を見る手段はあるだろうか
whole_memory_segment_selectorとかに入っている値が間違っていることが判明
実機で0xe0000000番地に直接値を書き込んで白色を表示できることは確認できた。
init_mouse関数の実行によって画面表示がされなくなるということが分かった
p275 高解像度化