# Makefile for GeekOS kernel, userspace, and tools
# Copyright (c) 2004,2005 David H. Hovemeyer <daveho@cs.umd.edu>
-# $Revision: 1.44 $
+# $Revision: 1.45 $
# This is free software. You are permitted to use,
# redistribute, and modify it as specified in the file "COPYING".
#
# The setup code needs to copy it up to this address and jump there
#
-KERNEL_BASE_ADDR := 0x00010000
+KERNEL_BASE_ADDR := 0x00100000
# Kernel entry point function
KERNEL_ENTRY = $(SYM_PFX)Main
NUMSECS := $(PERL) $(PROJECT_ROOT)/scripts/numsecs
+#Round a value up to a certain factor (hex values)
+ROUND_UP_HEX := $(PERL) $(PROJECT_ROOT)/scripts/round_up_hex.pl
+
# ----------------------------------------------------------------------
# Definitions -
# Options passed to the tools.
# $(CC) geekos/test.o geekos/vmcs.o geekos/vmx_lowlevel.o -o geekos/test
# Standard floppy image - just boots the kernel
-fd.img : geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin vm_kernel
+fd.img : geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin
cat geekos/fd_boot.bin geekos/setup.bin geekos/kernel.bin > _temp
$(PAD) _temp 512
- cat _temp vm_kernel > $@
+ cp _temp fd.img
vmm.img : fd.img
cp fd.img vmm.img
# Floppy boot sector (first stage boot loader).
-geekos/fd_boot.bin : geekos/setup.bin geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/fd_boot.asm vm_kernel
+geekos/fd_boot.bin : geekos/setup.bin geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/fd_boot.asm
$(NASM) -f bin \
-I$(PROJECT_ROOT)/src/geekos/ \
-DNUM_SETUP_SECTORS=`$(NUMSECS) geekos/setup.bin` \
-DNUM_KERN_SECTORS=`$(NUMSECS) geekos/kernel.bin` \
- -DNUM_VM_KERNEL_SECTORS=`$(NUMSECS) vm_kernel` \
$(PROJECT_ROOT)/src/geekos/fd_boot.asm \
-o $@
-I$(PROJECT_ROOT)/src/geekos/ \
-DENTRY_POINT=0x`egrep 'Main$$' geekos/kernel.syms |awk '{print $$1}'` \
-DVMM_SIZE=`$(NUMSECS) geekos/kernel.bin` \
- -DGUEST_SIZE=`$(NUMSECS) vm_kernel` \
$(PROJECT_ROOT)/src/geekos/setup.asm \
-o $@
$(PAD) $@ 512
$(PAD) $@ 512
# The kernel executable and symbol map.
-geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS)
+geekos/kernel.exe : $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) vm_kernel
$(TARGET_LD) -o geekos/kernel.exe -Ttext $(KERNEL_BASE_ADDR) -e $(KERNEL_ENTRY) \
- $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS)
+ $(KERNEL_OBJS) $(COMMON_C_OBJS) $(VMM_OBJS) $(DEVICE_OBJS) -b binary vm_kernel
$(TARGET_NM) geekos/kernel.exe > geekos/kernel.syms
force:
-vm_kernel: force
- $(PAD) vm_kernel 512
- @echo "VM kernel lives at 0x100000 and is" `$(NUMSECS) vm_kernel` "sectors long"
+#vm_kernel: force
+# $(PAD) vm_kernel 512
+# @echo "VM kernel lives at 0x100000 and is" `$(NUMSECS) vm_kernel` "sectors long"
/*
* Boot information structure, passed to kernel Main() routine
* Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "COPYING".
struct Boot_Info {
int bootInfoSize; /* size of this struct; for versioning */
int vmm_size;
- int guest_load_addr;
- int guest_size;
int memSizeKB; /* number of KB, as reported by int 15h */
};
/*
* Misc. kernel definitions
* Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "COPYING".
/*
* Address where kernel is loaded
*/
-#define KERNEL_START_ADDR 0x10000
+#define KERNEL_START_ADDR 0x100000
/*
* Kernel and user privilege levels
; Definitions for use in GeekOS boot code
; Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu>
-; $Revision: 1.6 $
+; $Revision: 1.7 $
; This is free software. You are permitted to use,
; redistribute, and modify it as specified in the file "COPYING".
;; Note that this segment must not colide with where the VMM kernel
;; is initially loaded. At this point, we just place it in the last
;; 64K of RAM available before the ISA hole and hope for the best
-VMSEG equ 0x8000 ;
+ VMSEG equ 0x8000
; Size of PFAT boot record.
; Keep up to date with <geekos/pfat.h>.
; Boot sector for GeekOS
; Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
; Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
-; $Revision: 1.5 $
+; $Revision: 1.6 $
; This is free software. You are permitted to use,
; redistribute, and modify it as specified in the file "COPYING".
cmp word [sec_count], bx
jl .again
+
+
load_kernel:
; Load the kernel image from sectors KERN_START_SEC..n of the
; floppy into memory at KERNSEG. Note that there are 128 sectors
mov word [sec_count], ax
add ax, word [kernelSize]
mov word [max_sector], ax
-.again:
- mov ax, [sec_count] ; logical sector on the floppy
-; mov dx, ax
-; call PrintHex
-; call PrintNL
- push ax ; 1st param to ReadSector (log sec num)
- sub ax, [kernelStart] ; convert to 0-indexed
- mov cx, ax ; save in cx
- shr ax, 7 ; divide by 128
- shl ax, 12 ; ...and multiply by 0x1000
- add ax, KERNSEG ; ...to get base relative to KERNSEG
-; mov dx, ax
-; call PrintHex
-; call PrintNL
- push ax ; 2nd param to ReadSector (seg base)
- and cx, 0x7f ; mod sector by 128
- shl cx, 9 ; ...and multiply by 512
- push cx ; to get offset in segment (3rd parm)
-; mov dx, cx
-; call PrintHex
-; call PrintNL
-
-
- ; read the sector from the floppy
- call ReadSector
- add sp, 6 ; clear 3 word params
-
-
- ; on to next sector
- inc word [sec_count]
-
- ; have we loaded all of the sectors?
- mov bx, word [max_sector]
- cmp word [sec_count], bx
- jl .again
-
-load_vm:
- ; Load the guest image starting at 1MB
- ; floppy into memory at KERNSEG. Note that there are 128 sectors
- ; per 64K segment. So, when figuring out which segment to
- ; load the sector into, we shift right by 7 bits (which is
- ; equivalent to dividing by 128).
- ; Figure out start sector and max sector
- mov ax, word [vmStart]
- mov word [sec_count], ax
- add ax, word [vmSize]
- mov word [max_sector], ax
+
.again2:
mov ax, [sec_count] ; logical sector on the floppy
kernelSize:
dw NUM_KERN_SECTORS
- ;; part of pfat boot record
-vmStart:
- dw 1+NUM_SETUP_SECTORS+NUM_KERN_SECTORS
- ;; part of pfat boot record
-vmSize:
- dw NUM_VM_KERNEL_SECTORS
; Finish by writing the BIOS signature to mark this as
* Copyright (c) 2001,2003,2004 David H. Hovemeyer <daveho@cs.umd.edu>
* Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
* Copyright (c) 2004, Iulian Neamtiu <neamtiu@cs.umd.edu>
- * $Revision: 1.39 $
+ * $Revision: 1.40 $
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "COPYING".
{
- Out_Byte(0x1234,5);
- Out_Byte(0x1234,5);
+ //Out_Byte(0x1234,5);
+ //Out_Byte(0x1234,5);
Init_BSS();
Init_Screen();
Init_Serial();
+
+ /* {
+ extern char BSS_START, BSS_END;
+
+ SerialPrint("BSS 0x%x->0x%x\n", &BSS_START, &BSS_END);
+
+ }*/
+
+
+ // SerialPrint("Guest Mem Dump at 0x%x\n", 0x100000);
+ //SerialMemDump((unsigned char *)(0x100000), 261 * 1024);
+
Init_Mem(bootInfo);
Init_CRC32();
Init_TSS();
Init_VM(bootInfo);
Init_Paging();
- Init_PCI();
+ //Init_PCI();
Init_Stubs();
* Physical memory allocation
* Copyright (c) 2001,2003,2004 David H. Hovemeyer <daveho@cs.umd.edu>
* Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu>
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
* This is free software. You are permitted to use,
* redistribute, and modify it as specified in the file "COPYING".
{
ulong_t addr;
- PrintBoth("Start: %u, End: %u (Type=0x%.4x)\n", (unsigned int)start, (unsigned int)end, flags);
+ PrintBoth("Start: %u (0x%x), End: %u(0x%x) (Type=0x%.4x)\n", (unsigned int)start, start, (unsigned int)end, end, flags);
KASSERT(Is_Page_Multiple(start));
KASSERT(Is_Page_Multiple(end));
ulong_t pageListAddr;
ulong_t pageListEnd;
ulong_t kernEnd;
- ulong_t guestEnd;
ulong_t heapAddr;
ulong_t heapEnd;
ulong_t vmmMemEnd;
PrintBoth("Total Memory Size: %u MBytes\n", bootInfo->memSizeKB/1024);
- PrintBoth("Page List Size: %u bytes\n", numPageListBytes);
+ PrintBoth("Page List (at 0x%x) Size: %u bytes\n", &s_freeList, numPageListBytes);
/* Memory Layout:
* kernel_thread_obj (1 page)
* kernel_stack (1 page)
* available space
- * start - end: kernel
* available space
* ISA_HOLE_START - ISA_HOLE_END: hardware
* EXTENDED_MEMORY:
+ * start - end: kernel
* VM Guest (variable pages)
* Heap (512 Pages)
* Page List (variable pages)
* VM Memory (everything else)
*/
- kernEnd = Round_Up_To_Page((ulong_t)&end);
+ //kernEnd = Round_Up_To_Page((ulong_t)&end);
+ kernEnd = (ulong_t)&end;
+
PrintBoth("Kernel End=%lx\n", kernEnd);
/* If we have dynamic loading of the guest kernel, we should put the relocation code here */
/* ************************************************************************************** */
- guestEnd = Round_Up_To_Page(ISA_HOLE_END + bootInfo->guest_size);
- heapAddr = guestEnd;
+ kernEnd = Round_Up_To_Page(kernEnd);
+ heapAddr = kernEnd;
heapEnd = Round_Up_To_Page(heapAddr + KERNEL_HEAP_SIZE);
pageListAddr = heapEnd;
pageListEnd = Round_Up_To_Page(pageListAddr + numPageListBytes);
*/
vm_range_start = vmmMemEnd;
vm_range_end = endOfMem;
- guest_kernel_start = ISA_HOLE_END;
- guest_kernel_end = guestEnd;
Add_Page_Range(0, PAGE_SIZE, PAGE_UNUSED); // BIOS area
Add_Page_Range(PAGE_SIZE, PAGE_SIZE * 3, PAGE_ALLOCATED); // Intial kernel thread obj + stack
- Add_Page_Range(PAGE_SIZE * 3, KERNEL_START_ADDR, PAGE_AVAIL); // Available space
- Add_Page_Range(KERNEL_START_ADDR, kernEnd, PAGE_KERN); // VMM Kernel
- Add_Page_Range(kernEnd, ISA_HOLE_START, PAGE_AVAIL); // Available Space
+ Add_Page_Range(PAGE_SIZE * 3, ISA_HOLE_START, PAGE_AVAIL); // Available space
Add_Page_Range(ISA_HOLE_START, ISA_HOLE_END, PAGE_HW); // Hardware ROMs
- Add_Page_Range(ISA_HOLE_END, guestEnd, PAGE_VM); // Guest kernel location
+ Add_Page_Range(KERNEL_START_ADDR, kernEnd, PAGE_KERN); // VMM Kernel
+ // Add_Page_Range(guest_kernel_start, guestEnd, PAGE_VM); // Guest kernel location
Add_Page_Range(heapAddr, heapEnd, PAGE_HEAP); // Heap
Add_Page_Range(pageListAddr, pageListEnd, PAGE_KERN); // Page List
Add_Page_Range(pageListEnd, vmmMemEnd, PAGE_AVAIL); // Available VMM memory
PrintBoth("%x to %x - BIOS AREA\n", 0, PAGE_SIZE - 1);
PrintBoth("%x to %x - KERNEL_THREAD_OBJ\n", PAGE_SIZE, PAGE_SIZE * 2 - 1);
PrintBoth("%x to %x - KERNEL_STACK\n", PAGE_SIZE * 2, PAGE_SIZE * 3 - 1);
- PrintBoth("%lx to %x - FREE\n", PAGE_SIZE * 3, KERNEL_START_ADDR - 1);
- PrintBoth("%x to %x - KERNEL CODE\n", KERNEL_START_ADDR, kernEnd - 1);
- PrintBoth("%lx to %x - FREE\n", kernEnd, ISA_HOLE_START - 1);
+ PrintBoth("%lx to %x - FREE\n", PAGE_SIZE * 3, ISA_HOLE_START - 1);
PrintBoth("%x to %x - ISA_HOLE\n", ISA_HOLE_START, ISA_HOLE_END - 1);
- PrintBoth("%x to %x - VM_KERNEL\n", ISA_HOLE_END, guestEnd - 1);
+ PrintBoth("%x to %x - KERNEL CODE + VM_KERNEL\n", KERNEL_START_ADDR, kernEnd - 1);
+ // PrintBoth("%x to %x - VM_KERNEL\n", kernEnd, guestEnd - 1);
PrintBoth("%x to %x - KERNEL HEAP\n", heapAddr, heapEnd - 1);
PrintBoth("%lx to %lx - PAGE LIST\n", pageListAddr, pageListEnd - 1);
PrintBoth("%lx to %x - FREE\n", pageListEnd, vmmMemEnd - 1);
; -*- fundamental -*-
; GeekOS setup code
; Copyright (c) 2001,2004 David H. Hovemeyer <daveho@cs.umd.edu>
-; $Revision: 1.3 $
+; $Revision: 1.4 $
; This is free software. You are permitted to use,
; redistribute, and modify it as specified in the file "COPYING".
add eax, ebx
push eax ; memSizeKB
- mov eax, GUEST_SIZE
- shl eax, 9 ; Multiply the guest size by 512 to get byte size
- push eax ; Size of the guest kernel
-
- mov eax, 0x100000
- push eax ; Load address of the guest
-
mov eax, VMM_SIZE
shl eax, 9 ; Multiply the vmm size by 512 to get byte size
- push eax ; size of the VMM
+ push ebx ; size of the VMM
push dword 8 ; bootInfoSize
int i;
void * region_start;
-
- PrintBoth("Guest Size: %lu\n", bootInfo->guest_size);
+ extern char _binary_vm_kernel_start;
+ PrintBoth(" Guest Load Addr: 0x%x\n", &_binary_vm_kernel_start);
- struct guest_mem_layout * layout = (struct guest_mem_layout *)0x100000;
+ struct guest_mem_layout * layout = (struct guest_mem_layout *)&_binary_vm_kernel_start;
+ // SerialPrint("Guest Mem Dump at 0x%x\n", 0x100000);
+ //SerialMemDump((unsigned char *)(0x100000), 261 * 1024);
if (layout->magic != MAGIC_CODE) {
+
PrintBoth("Layout Magic Mismatch (0x%x)\n", layout->magic);
+ return -1;
}
PrintBoth("%d layout regions\n", layout->num_regions);
};
- struct vm_device * generic = create_generic(range,NULL,NULL);
+
+ struct vm_device * generic = create_generic(range, NULL, NULL);
#endif