TaiseiIto / hariboslinux

Haribote OSをLinux環境で開発しよう
MIT License
3 stars 0 forks source link

harib11d #29

Closed TaiseiIto closed 2 years ago

TaiseiIto commented 2 years ago

p275 高解像度化

TaiseiIto commented 2 years ago

画面モード一覧 https://www.fountainware.com/EXPL/video_modes.htm

TaiseiIto commented 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));
TaiseiIto commented 2 years ago

virtual boxで画面が表示されなくなってるのはmainブランチでも同様のようだ

TaiseiIto commented 2 years ago

virtual boxで画面が表示されない問題 issue26では画面が表示される issue27では画面が表示されない

TaiseiIto commented 2 years ago

1a2400520d7b889c9b5a3626ffeea91bff3aae86表示される

TaiseiIto commented 2 years ago

2a56343b663a6068433ae24e05fb44789d98f40d表示される

TaiseiIto commented 2 years ago

b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86表示されない

TaiseiIto commented 2 years ago

fb4443893c2ee598acff3b45d2f39779bf6c8b26表示された

TaiseiIto commented 2 years ago

virtual boxで画面が表示されなくなったのは、b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86以降ということになる。

TaiseiIto commented 2 years ago

以下のコミットでvirtual boxで画面が表示されなくなった https://github.com/TaiseiIto/hariboslinux/commit/b6b63ffcd9bce77a14b77c05097f5d49a8dc6c86

TaiseiIto commented 2 years ago

そしてマウス割り込みも拾えていない

TaiseiIto commented 2 years ago

画面表示されない問題とマウス割り込み拾えない問題は解決

TaiseiIto commented 2 years ago

次に各画面モードが使えるかどうかを調べる

TaiseiIto commented 2 years ago

keyboard stateまではシリアル出力されている これはinitscrn.sの最後で出力されていて、その後mv2prtmd.sに移行してる Hello, mv2prtmd.binは表示されていない

TaiseiIto commented 2 years ago

ソースコード中に0xce00が残ってないかどうか確認しよう

TaiseiIto commented 2 years ago

cのファイルを検索

find . | grep \\.c$
TaiseiIto commented 2 years ago

.c,.sファイルを列挙

find . | grep -e \\.c$ -e \\.s$
TaiseiIto commented 2 years ago

結果なにもなし

cat $(find . | grep -e \\.c$ -e \\.s$) | grep ce00
TaiseiIto commented 2 years ago

initscrn.binのサイズは0x0800ではなく0x0a00になっている

TaiseiIto commented 2 years ago

使用する画面モードの条件

これらすべての条件を満たすものの中から、画面が最も大きいものを選択

TaiseiIto commented 2 years ago

画面モード探索中にスタックに保存する必要があるもの

TaiseiIto commented 2 years ago

BootInformation構造体に残しておくべきもの

TaiseiIto commented 2 years ago

以下を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;
TaiseiIto commented 2 years ago

実機で乱れた画像が表示されている

TaiseiIto commented 2 years ago

実機での実験結果 The best video mode = 0x8918

TaiseiIto commented 2 years ago

実機での実験結果その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がすごいところに配置されてる

TaiseiIto commented 2 years ago

0xc00090b9番地にアクセスできないっぽいので、protected modeに入ってから画面を切り替えたほうがいいかも

TaiseiIto commented 2 years ago

https://github.com/knusbaum/kernel/blob/master/vesa.c

これによると、video mode pointerは上位4ビットがセグメント、下位4ビットがオフセットを示しているらしく、1MiB協会は超えていないので普通にリアルモードでアクセスできるっぽい

TaiseiIto commented 2 years ago

実機での実験結果 The best video mode = 0x017f

TaiseiIto commented 2 years ago

衝撃的実験結果

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
TaiseiIto commented 2 years ago

実験結果

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
TaiseiIto commented 2 years ago

まだ実機で画面を映し出せていない。 ピクセル当たり0x20ビットなので、1バイトがアルファ値になっている可能性もある

TaiseiIto commented 2 years ago

実機でVRAMに直接書き込みしてどうなるか

TaiseiIto commented 2 years ago

実機でVRAM直接書き込みでも駄目だった。 おそらく https://wiki.osdev.org/VESA_Video_Modes の Don't Assume The Monitor Supports A Video Mode の項目が当てはまっていると思われる。

TaiseiIto commented 2 years ago

https://wiki.osdev.org/EDID これも参考になりそう

TaiseiIto commented 2 years ago

実機でCPU例外が起きている可能性も考えられる 実機のシリアルポート出力を見る手段はあるだろうか

TaiseiIto commented 2 years ago

whole_memory_segment_selectorとかに入っている値が間違っていることが判明

TaiseiIto commented 2 years ago

実機で0xe0000000番地に直接値を書き込んで白色を表示できることは確認できた。

TaiseiIto commented 2 years ago

init_mouse関数の実行によって画面表示がされなくなるということが分かった