Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


moved guest files to kernel image
Jack Lange [Mon, 21 Jul 2008 05:29:10 +0000 (05:29 +0000)]
palacios/build/Makefile
palacios/include/geekos/bootinfo.h
palacios/include/geekos/defs.h
palacios/src/geekos/defs.asm
palacios/src/geekos/fd_boot.asm
palacios/src/geekos/main.c
palacios/src/geekos/mem.c
palacios/src/geekos/setup.asm
palacios/src/geekos/vm.c

index e3b6269..99965c6 100644 (file)
@@ -1,6 +1,6 @@
 # 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".
@@ -30,7 +30,7 @@
 #
 # 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
@@ -211,6 +211,9 @@ ZEROFILE := $(PERL) $(PROJECT_ROOT)/scripts/zerofile
 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.
@@ -298,10 +301,10 @@ all : $(ALL_TARGETS)
 #      $(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
@@ -332,12 +335,11 @@ run: 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 $@
 
@@ -347,7 +349,6 @@ geekos/setup.bin : geekos/kernel.bin $(PROJECT_ROOT)/src/geekos/setup.asm
                -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
@@ -358,18 +359,18 @@ geekos/kernel.bin : geekos/kernel.exe
        $(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"
 
 
 
index 5087f6f..c171095 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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".
@@ -13,8 +13,6 @@
 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 */
 };
 
index f76f013..c34de1a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * 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".
@@ -24,7 +24,7 @@
 /*
  * Address where kernel is loaded
  */
-#define KERNEL_START_ADDR 0x10000
+#define KERNEL_START_ADDR 0x100000
 
 /*
  * Kernel and user privilege levels
index a3de829..25dc811 100644 (file)
@@ -1,6 +1,6 @@
 ; 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".
@@ -37,7 +37,7 @@ KERNSEG equ 0x1000
 ;; 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>.
index 46f920f..2fbfd35 100644 (file)
@@ -1,7 +1,7 @@
 ; 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".
@@ -89,6 +89,8 @@ load_setup:
        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
@@ -102,54 +104,8 @@ load_kernel:
        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
@@ -456,13 +412,7 @@ kernelStart:
 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
index a81a85c..ba1b4d6 100644 (file)
@@ -3,7 +3,7 @@
  * 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".
@@ -183,13 +183,25 @@ void Main(struct Boot_Info* bootInfo)
 {
 
 
-  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();
@@ -201,7 +213,7 @@ void Main(struct Boot_Info* bootInfo)
   Init_VM(bootInfo);
   Init_Paging();
   
-  Init_PCI();
+  //Init_PCI();
 
   Init_Stubs();
 
index 6b3263d..b705425 100644 (file)
@@ -2,7 +2,7 @@
  * 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".
@@ -79,7 +79,7 @@ static void Add_Page_Range(ulong_t start, ulong_t end, int flags)
 {
     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));
@@ -131,7 +131,6 @@ void Init_Mem(struct Boot_Info* bootInfo)
     ulong_t pageListAddr;
     ulong_t pageListEnd;
     ulong_t kernEnd;
-    ulong_t guestEnd;
     ulong_t heapAddr;
     ulong_t heapEnd;
     ulong_t vmmMemEnd;
@@ -148,7 +147,7 @@ void Init_Mem(struct Boot_Info* bootInfo)
 
 
     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:
@@ -156,10 +155,10 @@ void Init_Mem(struct Boot_Info* bootInfo)
      * 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)
@@ -167,7 +166,9 @@ void Init_Mem(struct Boot_Info* bootInfo)
      *        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);
 
 
@@ -175,8 +176,8 @@ void Init_Mem(struct Boot_Info* bootInfo)
     /* 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);
@@ -193,16 +194,13 @@ void Init_Mem(struct Boot_Info* bootInfo)
      */
     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
@@ -221,11 +219,10 @@ void Init_Mem(struct Boot_Info* bootInfo)
     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);
index 9ddfcb3..f4d0ae7 100644 (file)
@@ -1,7 +1,7 @@
 ; -*- 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".
@@ -88,16 +88,9 @@ setup_32:
        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
 
index 5fd8965..7170ecc 100644 (file)
@@ -286,13 +286,17 @@ int RunVMM(struct Boot_Info * bootInfo) {
       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);
@@ -417,7 +421,8 @@ IGNORE},   // DMA 2 channels 4,5,6,7 (address, counter)
 
         };
 
-       struct vm_device * generic = create_generic(range,NULL,NULL);
+
+       struct vm_device * generic = create_generic(range, NULL, NULL);
 
 #endif