Bare metal VGA: allow for 64-bit video frame buffer address

This commit is contained in:
tkchia 2022-09-25 13:17:33 +00:00
parent 388c4f6060
commit 0d594ecd85
3 changed files with 9 additions and 5 deletions

View file

@ -26,8 +26,9 @@ struct mman {
or pixels (graphics) */
unsigned short pc_video_height; /* 0x1d2e — height in chars. (text)
or pixels (graphics) */
uint32_t pc_video_framebuffer; /* 0x1d30 */
uint32_t pc_video_framebuffer_size; /* 0x1d34 */
uint64_t pc_video_framebuffer; /* 0x1d30 — physical address of
video frame buffer */
uint64_t pc_video_framebuffer_size; /* 0x1d38 */
};
COSMOPOLITAN_C_END_

View file

@ -66,6 +66,9 @@
movw $25,mm+"struct mman::pc_video_height"
movl $0xb8000,mm+"struct mman::pc_video_framebuffer"
movl $0x8000,mm+"struct mman::pc_video_framebuffer_size"
xor %eax,%eax
mov %eax,mm+"struct mman::pc_video_framebuffer"+4
mov %eax,mm+"struct mman::pc_video_framebuffer_size"+4
mov $0x1003,%ax # enable/disable VGA text blinking
#ifdef VGA_USE_BLINK
mov $1,%bx

View file

@ -62,7 +62,8 @@ __attribute__((__constructor__)) static textstartup void _vga_init(void) {
if (IsMetal()) {
struct mman *mm = (struct mman *)(BANE + 0x0500);
unsigned short height = mm->pc_video_height, width = mm->pc_video_width;
void * vid_buf = (void *)(BANE + mm->pc_video_framebuffer);
uint64_t vid_buf_phy = mm->pc_video_framebuffer;
void *vid_buf = (void *)(BANE + vid_buf_phy);
size_t vid_buf_sz = mm->pc_video_framebuffer_size;
/*
* Get the initial cursor position from the BIOS data area. Also get
@ -78,8 +79,7 @@ __attribute__((__constructor__)) static textstartup void _vga_init(void) {
if (chr_ht_hi != 0 || chr_ht > 32)
chr_ht = 32;
/* Make sure the video buffer is mapped into virtual memory. */
__invert_memory_area(mm, __get_pml4t(), (uint64_t)vid_buf, vid_buf_sz,
PAGE_RW);
__invert_memory_area(mm, __get_pml4t(), vid_buf_phy, vid_buf_sz, PAGE_RW);
/*
* Initialize our tty structure from the current screen contents,
* current cursor position, & character height.