From 162e52b12140e1acdd5966c761fe7585032a0a68 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 17 Aug 2003 22:02:00 -0400 Subject: [PATCH] Import backup from 2003-08-17_3 --- bootdef.inc | 1 + kernel.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++ stage2.asm | 41 ++++++++++++++++++++++++++++--------- 3 files changed, 90 insertions(+), 10 deletions(-) diff --git a/bootdef.inc b/bootdef.inc index 47e4e1e..6d6ef9a 100644 --- a/bootdef.inc +++ b/bootdef.inc @@ -16,6 +16,7 @@ %define BOOT_VESA_OEM 0x0004 ;258 - null-terminated OEM identification string %define BOOT_VESA_VBE 0x0106 ;512 - copy of VESA VBEInfoBlock %define BOOT_VESA_INFO 0x0306 ;256 - copy of VESA ModeInfoBlock for selected mode +%define BOOT_MEGS 0x040A ;4 - dword - # of megabytes of RAM detected diff --git a/kernel.c b/kernel.c index c7b1ba5..53b5251 100644 --- a/kernel.c +++ b/kernel.c @@ -10,6 +10,49 @@ void k_init(); #include "functions.c" +//9000:306 + +typedef struct{ + USHORT ModeAttributes; + UCHAR WinAAttributes; + UCHAR WinBAttributes; + USHORT WinGranularity; + USHORT WinSize; + USHORT WinASegment; + USHORT WinBSegment; + UINT WinFuncPtr; + USHORT BytesPerScanLine; + + USHORT XResolution; + USHORT YResolution; + UCHAR XCharSize; + UCHAR YCharSize; + UCHAR NumberOfPlanes; + UCHAR BitsPerPixel; + UCHAR NumberOfBanks; + UCHAR MemoryModel; + UCHAR BankSize; + UCHAR NumberOfImagePages; + UCHAR Reserved1; + + UCHAR RedMaskSize; + UCHAR RedFieldPosition; + UCHAR GreenMaskSize; + UCHAR GreenFieldPosition; + UCHAR BlueMaskSize; + UCHAR BlueFieldPosition; + UCHAR RsvdMaskSize; + UCHAR RsvdFieldPosition; + UCHAR DirectColorModeInfo; + + void *PhysBasePtr; + UINT OffScreenMemOffset; + USHORT OffScreenMemSize; + UCHAR Reserved[206]; +} ModeInfoBlock; + + + void k_init() { @@ -19,6 +62,21 @@ void k_init() outportb(0x40, 0x9c); //lsb outportb(0x40, 0x2e); //msb enable_ints(); + ModeInfoBlock *mib = (ModeInfoBlock *) 0x90306; + UINT *vid = (UINT *) (mib->PhysBasePtr); + UINT a; + UINT tot = ((mib->XResolution) * (mib->YResolution)); + for (a = 0; a < tot; a++) + { + if (a < (tot / 4)) + vid[a] = 0x00FF0000; + else if (a < (tot / 2)) + vid[a] = 0x0000FF00; + else if (a < ((tot * 3) / 4)) + vid[a] = 0x000000FF; + else + vid[a] = 0x00FFFFFF; + } } void isr(int num) diff --git a/stage2.asm b/stage2.asm index 5e2b356..7d9a5f2 100644 --- a/stage2.asm +++ b/stage2.asm @@ -198,11 +198,32 @@ copydisk_loop: no_rd: xor ax, ax mov ds, ax - mov dx, 4 ;we'll assume the system has 4 megabytes of RAM... + mov edx, 4 ;we'll assume the system has 4 megabytes of RAM... mov esi, 0x3FFFFC ;4 bytes under 4 MB +ram_loop: + mov ebx, [ds:esi] + mov dword [ds:esi], "KRIS" + mov eax, [ds:esi] + mov [ds:esi], ebx + cmp eax, "KRIS" + jnz got_mem + inc edx + add esi, 0x100000 + jmp ram_loop +got_mem: + mov ax, BOOT_DATA_SEG + mov ds, ax + mov [ds:BOOT_MEGS], edx - - +; mov ax, 0xb800 +; mov es, ax +; xor di, di +; mov al, dh +; call puthex2 +; mov al, dl +; call puthex2 +; xor ax, ax +; int 0x16 ;on to vesa info... xor ax, ax @@ -421,13 +442,13 @@ vesa_copymodeinfo_loop: mov [es:BOOT_VESA], dx ;store mode# for kernel - mov ax, 0xb800 - mov es, ax - xor di, di - mov al, dh - call puthex2 - mov al, dl - call puthex2 +; mov ax, 0xb800 +; mov es, ax +; xor di, di +; mov al, dh +; call puthex2 +; mov al, dl +; call puthex2 mov bx, dx or bx, 0x4000 ;set "use LFB" bit of mode#