From 48f4046e79f458a4d1223be9b105f3efcc28eb0c Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 13 Feb 2004 22:00:00 -0500 Subject: [PATCH] Import backup from 2004-02-13 --- asmfuncs.asm | 21 +++++++++++++++++++++ k_defines.h | 6 +++++- mm.c | 8 ++++---- video.c | 4 ++-- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/asmfuncs.asm b/asmfuncs.asm index 6aacc23..9a5f5e8 100644 --- a/asmfuncs.asm +++ b/asmfuncs.asm @@ -137,6 +137,27 @@ _memcpy: pop ebp ret +;copies memory of n dwords (n*4 bytes) from src to destination +;extern void memcpyd(dword dest, dword src, dword n); +[global _memcpyd] +_memcpyd: + push ebp + mov ebp, esp + push esi + push edi + push ecx + mov edi, [ebp+8] + mov esi, [ebp+12] + mov ecx, [ebp+16] + + rep movsd + + pop ecx + pop edi + pop esi + pop ebp + ret + ;returns the number of characters in a string ;extern dword strlen(char *str); [global _strlen] diff --git a/k_defines.h b/k_defines.h index 486a652..4781b59 100644 --- a/k_defines.h +++ b/k_defines.h @@ -46,6 +46,10 @@ typedef struct { } __attribute__((packed)) qword; - +//these defines are the memory locations of values saved by the stage 2 bootloader +#define BOOT_MEMMAP_ENTRIES 0xC009040A +#define BOOT_FIRST_MEMMAP 0xC0092000 +#define BOOT_VIDEO_MODE 0xC0090002 +#define BOOT_VIDEO_MODE_INFO_BLOCK 0xC0090306 diff --git a/mm.c b/mm.c index ecdcbb8..679a990 100644 --- a/mm.c +++ b/mm.c @@ -3,19 +3,19 @@ // Created: 09/01/03 // Modified: 12/28/03 -//The total amount of physical memory available (bytes) +//The total amount of physical memory available (bytes, 1 bit per page) #define BITMAP_SIZE 0x20000 dword mm_totalmem = 0; dword mm_megabytes; -byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used, 0 if available +byte page_bitmap[BITMAP_SIZE]; //used to store a bit for each page that is used, 0 if available //0x20000*(8 bits/byte)=0x100000 pages in 4gb total //This function initializes the memory manager's linked list, filling it with the // memory areas returned by bios interrupt 0x8E20 void mm_init() { - dword memmap_entries = *(dword *)0xC009040A; - memmap_entry *maps = (memmap_entry *) 0xC0092000; + dword memmap_entries = *(dword *)BOOT_MEMMAP_ENTRIES; + memmap_entry *maps = (memmap_entry *) BOOT_FIRST_MEMMAP; dword a; for (a = 0; a < BITMAP_SIZE; a++) { diff --git a/video.c b/video.c index 514410e..dcd2c62 100644 --- a/video.c +++ b/video.c @@ -6,12 +6,12 @@ //Initialized the video mode information block video_mode and allocated double-buffer memory for graphics display void video_init() { - videoMode = *(word *)0xC0090002; + videoMode = *(word *)BOOT_VIDEO_MODE; if (!videoMode) //we are in console mode return; - video_mode = *(ModeInfoBlock *) 0xC0090306; + video_mode = *(ModeInfoBlock *) BOOT_VIDEO_MODE_INFO_BLOCK; switch(video_mode.BitsPerPixel) {