kernel and userspace now working, removed some debug printfs, general code cleanup
authorSamuel Hitz <samuel.hitz@gmail.com>
Tue, 22 May 2012 09:59:02 +0000 (11:59 +0200)
committerSamuel Hitz <samuel.hitz@gmail.com>
Tue, 22 May 2012 09:59:02 +0000 (11:59 +0200)
14 files changed:
include/mm/slot_alloc.h
include/spawndomain/spawndomain.h
kernel/arch/arm/syscall.c
kernel/arch/gem5/exceptions.S
kernel/arch/gem5/init.c
kernel/arch/gem5/paging.c
kernel/arch/gem5/startup_arch.c
kernel/capabilities.c
lib/barrelfish/capabilities.c
lib/barrelfish/vspace/memobj_anon.c
lib/barrelfish/vspace/pinned.c
lib/barrelfish/vspace/vregion.c
tools/gem5/debug.gem5.gdb
usr/init/init.c

index d2345fa..5ae3647 100644 (file)
@@ -30,7 +30,7 @@ struct slot_prealloc {
     uint8_t maxslotbits;            ///< Maximum number of slots per allocation
     uint8_t cnode_size_bits;        ///< Size of created cnodes
 
-    struct cnoderef top_cnode;    ///< Top-level cnode
+    struct cnoderef top_cnode __attribute__ ((aligned(4)));    ///< Top-level cnode
     struct capref top_cnode_slot; ///< Location to place top-level cnode
     uint64_t top_used;              ///< Slots used in top-level cnode
 
index 6d4c7e1..b731e53 100644 (file)
  */
 struct spawninfo {
     domainid_t domain_id;
-    struct cnoderef rootcn, taskcn, segcn, pagecn;
+    struct cnoderef rootcn __attribute__ ((aligned(4)));
+    struct cnoderef taskcn __attribute__ ((aligned(4)));
+    struct cnoderef segcn  __attribute__ ((aligned(4)));
+    struct cnoderef pagecn __attribute__ ((aligned(4)));
     struct capref   rootcn_cap, taskcn_cap, pagecn_cap;
     struct capref   dispframe, dcb, argspg, vtree;
     struct capref   fdcap;
index 7cc9efd..b16d1bb 100644 (file)
@@ -332,7 +332,7 @@ handle_invoke(arch_registers_state_t *context, int argc)
     uint16_t invoke_bits = (sa->arg0 >> 16) & 0xffff;
     capaddr_t  invoke_cptr = sa->arg1;
 
-    debug(SUBSYS_SYSCALL, "sys_invoke(0x%"PRIxCADDR"(%d))\n", invoke_cptr, invoke_bits);
+    //debug(SUBSYS_SYSCALL, "sys_invoke(0x%"PRIxCADDR"(%d))\n", invoke_cptr, invoke_bits);
 
     struct sysret r = { .error = SYS_ERR_OK, .value = 0 };
 
index 73b6965..644612c 100644 (file)
@@ -134,10 +134,6 @@ $exceptions_install_handlers:
 $exceptions_save_got:
         ldr     r0, = got_for_sys_mode
         str     PIC_REGISTER, [r0]
-//$exceptions_unmask_irq:
-//         mrs     r1, cpsr
-//        bic     r1, r1, #0x80
-//        msr     cpsr_c, r1
 $exceptions_init_done:
         ldmfd   sp!, {pc}
 
@@ -256,11 +252,11 @@ null_handler:
 .endm
 
         //
-        // Macro to enter SVC mode with interrupts disabled.
+        // Macro to enter SYS mode with interrupts disabled.
         // Set up stack and GOT pointer.
         //
 .macro enter_sys scratch
-        mov \scratch, #(CPSR_IF_MASK | ARM_MODE_SVC)
+        mov \scratch, #(CPSR_IF_MASK | ARM_MODE_SYS)
         msr cpsr_c, \scratch
         init_sys_pic_register
         init_sys_stack
index 509b17a..89d6302 100644 (file)
@@ -151,6 +151,7 @@ static struct atag * atag_find(struct atag *a, uint32_t tag)
 // Kernel command line variables and binding options
 //
 
+//TODO: timeslice instead of tick_hz
 static int tick_hz                   = 100;
 static int serial_console_port       = 0;
 static int serial_debug_port         = 1;
@@ -212,22 +213,16 @@ void arch_init(uint32_t     board_id,
         serial_console_init(serial_console_port);
 
         // do not remove/change this printf: needed by regression harness
-       // printf("Barrelfish CPU driver starting on ARMv5 Board id 0x%08"PRIx32"\n",
-     //          board_id);
-    //    printf("The address of paging_map_kernel_section is %p\n",
-     //          paging_map_kernel_section);
+        printf("Barrelfish CPU driver starting on ARMv7 Board id 0x%08"PRIx32"\n", board_id);
+        printf("The address of paging_map_kernel_section is %p\n", paging_map_kernel_section);
+
         errval = serial_debug_init(serial_debug_port);
         if (err_is_fail(errval))
         {
             printf("Failed to initialize debug port: %d", serial_debug_port);
         }
 
-        //lvaddr_t *foo = 0x0;
-        //elf_file = *foo;
 
-       // debug(SUBSYS_STARTUP, "alloc_top %08"PRIxLVADDR" %08"PRIxLVADDR"\n",
-      //         alloc_top, alloc_top - KERNEL_OFFSET);
-        //debug(SUBSYS_STARTUP, "elf_file %08"PRIxLVADDR"\n", elf_file);
 
         my_core_id = hal_get_cpu_id();
         
@@ -236,10 +231,6 @@ void arch_init(uint32_t     board_id,
         pit_init(tick_hz, 1);
         tsc_init();
 
-
-        //pit_start(0);
-        //while(1) {}
-
         ae = atag_find(atag_base, ATAG_MEM);
                 
         // Add unused physical memory to memory map
@@ -252,10 +243,6 @@ void arch_init(uint32_t     board_id,
                                  ARM_L1_SECTION_BYTES,
                       ae->u.mem.start + ae->u.mem.bytes);
 
-       // phys_mmap_add(&phys_mmap,
-       //               ETABLE_ADDR - KERNEL_OFFSET + BASE_PAGE_SIZE,
-       //               ae->u.mem.start + ae->u.mem.bytes);
-
         ae = atag_find(atag_base, ATAG_VIDEOLFB);
         if (NULL != ae)
         {
index 6f62710..523b9e0 100644 (file)
@@ -159,14 +159,6 @@ paging_write_l1_entry(uintptr_t ttbase, lvaddr_t va, union l1_entry l1)
     l1_table = (union l1_entry *) ttbase;
     l1_table[ARM_L1_OFFSET(va)] = l1;
 }
-/*
-inline static void
-paging_write_l2_entry(union l2_entry *l2_table, lvaddr_t va, union l2_entry l2)
-{
-       l2_table[ARM_L2_OFFSET(va)] = l2;
-}
-*/
-
 // ------------------------------------------------------------------------
 // Exported functions
 
@@ -225,34 +217,6 @@ lvaddr_t paging_map_device(lpaddr_t device_base, size_t device_bytes)
     return dev_alloc;
 }
 
-/*
-
-void
-paging_map_device_page(uintptr_t l1_table,
-                                          lvaddr_t device_vbase,
-                                          lpaddr_t device_pbase,
-                                          size_t device_bytes)
-{
-       assert(device_bytes <= BYTES_PER_PAGE);
-       union l2_entry l2;
-
-       l2.raw = 0;
-       l2.small_page.type = L2_TYPE_SMALL_PAGE;
-       l2.small_page.bufferable = 0;
-       l2.small_page.cacheable = 0;
-       l2.small_page.ap10 = 1;                 // RW/NA
-       l2.small_page.ap2 = 0;
-       l2.small_page.base_address = device_pbase >> BASE_PAGE_BITS;
-
-       //get address to l2 table
-        if (l1_table == 0) {
-               l1_table = cp15_read_ttbr() + KERNEL_OFFSET;
-           }
-
-
-       paging_write_l2_entry((union l2_entry *) l2_table, device_vbase, l2);
-}
-*/
 
 void paging_make_good(lvaddr_t new_table_base, size_t new_table_bytes)
 {
@@ -281,8 +245,6 @@ void paging_map_user_pages_l1(lvaddr_t table_base, lvaddr_t va, lpaddr_t pa)
     e.page_table.domain       = 0;
     e.page_table.base_address = (pa >> 10);
 
-    //uintptr_t* l1table = (uintptr_t*)table_base;
-    //l1table[va / BYTES_PER_SECTION] = e.raw;
     paging_write_l1_entry(table_base, va, e);
 }
 
@@ -311,6 +273,8 @@ void paging_context_switch(lpaddr_t ttbr)
     {
         cp15_write_ttbr(ttbr);
         cp15_invalidate_tlb();
+        //this isn't necessary on gem5, since gem5 doesn't implement the cache
+        //maintenance instructions, but ensures coherency by itself
         //cp15_invalidate_i_and_d_caches();
     }
 }
index c2dd6fe..6024341 100644 (file)
@@ -460,7 +460,7 @@ spawn_init(const char*      name,
 
     STARTUP_PROGRESS();
 
-    printf("XXX: Debug print to make Bram's code work\n");
+    //printf("XXX: Debug print to make Bram's code work\n");
 
     paging_context_switch(mem_to_local_phys((lvaddr_t)init_l1));
 
@@ -546,10 +546,10 @@ void arm_kernel_startup(phys_mmap_t* mmap,
 
     const uint8_t* initrd_cpio_base = (uint8_t*)local_phys_to_mem(initrd_base);
 
-   // if (!cpio_archive_valid(initrd_cpio_base, initrd_bytes))
-   // {
-   //             panic("Invalid initrd filesystem\n");
-   // }
+    if (!cpio_archive_valid(initrd_cpio_base, initrd_bytes))
+    {
+         panic("Invalid initrd filesystem\n");
+    }
 
     spawn_init(BSP_INIT_MODULE_NAME, 0, initrd_cpio_base, initrd_bytes);
 }
index a8ae44e..3fdfe63 100644 (file)
@@ -766,7 +766,7 @@ errval_t caps_retype(enum objtype type, size_t objbits,
         debug(SUBSYS_CAPS, "caps_retype: numobjs == 0\n");
         return SYS_ERR_INVALID_SIZE_BITS;
     }
-    debug(SUBSYS_CAPS, "caps_retype: numobjs == %d\n", (int)numobjs);
+   // debug(SUBSYS_CAPS, "caps_retype: numobjs == %d\n", (int)numobjs);
 
     /* check that destination slots all fit within target cnode */
     if (dest_slot + numobjs > (1UL << dest_cnode->u.cnode.bits)) {
index db49c00..8f66ff5 100644 (file)
@@ -286,8 +286,6 @@ errval_t cap_delete(struct capref cap)
     if (err == SYS_ERR_RETRY_THROUGH_MONITOR) {
         return cap_delete_remote(caddr, vbits);
     } else {
-       if(err)
-               printf("invoke_cnode_delete in capabilities.c failed\n");
         return err;
     }
 }
@@ -326,7 +324,6 @@ errval_t cap_destroy(struct capref cap)
     errval_t err;
     err = cap_delete(cap);
     if (err_is_fail(err)) {
-       printf("cap_delete in capabilities.c failed!\n");
         return err;
     }
 
@@ -579,7 +576,6 @@ errval_t frame_create(struct capref dest, size_t bytes, size_t *retbytes)
 
     err = cap_destroy(ram);
     if (err_is_fail(err)) {
-       printf("cap_destroy in capabilities.c failed!\n");
         return err;
     }
 
index 5e6921b..b6d70c0 100644 (file)
@@ -42,14 +42,12 @@ static errval_t map_region(struct memobj *memobj, struct vregion *vregion)
         void *buf;
         err = vspace_pinned_alloc(&buf, VREGION_LIST);
         if (err_is_fail(err)) {
-               printf("vspace pinned alloc fail!\n");
             return err_push(err, LIB_ERR_VSPACE_PINNED_ALLOC);
         }
         slab_grow(&anon->vregion_slab, buf,
                   VSPACE_PINNED_UNIT * sizeof(struct vregion_list));
         data = slab_alloc(&anon->vregion_slab);
         if (!data) {
-               printf("slab alloc fail!\n");
             return LIB_ERR_SLAB_ALLOC_FAIL;
         }
     }
index e06d07a..af78e6d 100644 (file)
@@ -104,7 +104,6 @@ errval_t vspace_pinned_alloc(void **retbuf, enum slab_type slab_type)
         err = frame_alloc(&frame, BASE_PAGE_SIZE, NULL);
         if (err_is_fail(err)) {
             thread_mutex_unlock(&state->mutex);
-               printf("frame alloc fail!\n");
             return err_push(err, LIB_ERR_FRAME_ALLOC);
         }
         err = state->memobj.m.f.fill((struct memobj*)&state->memobj,
@@ -112,7 +111,6 @@ errval_t vspace_pinned_alloc(void **retbuf, enum slab_type slab_type)
                                      BASE_PAGE_SIZE);
         if (err_is_fail(err)) {
             thread_mutex_unlock(&state->mutex);
-               printf("memobj fill fail!\n");
             return err_push(err, LIB_ERR_MEMOBJ_FILL);
         }
 
@@ -129,7 +127,6 @@ errval_t vspace_pinned_alloc(void **retbuf, enum slab_type slab_type)
     thread_mutex_unlock(&state->mutex);
 
     if (buf == NULL) {
-       printf("slab alloc fail!\n");
         return LIB_ERR_SLAB_ALLOC_FAIL;
     } else {
         *retbuf = buf;
index 8b2af59..66a0e92 100644 (file)
@@ -41,7 +41,6 @@ errval_t vregion_map_aligned(struct vregion *vregion, struct vspace* vspace,
     genvaddr_t address;
     err = pmap->f.determine_addr(pmap, memobj, alignment, &address);
     if (err_is_fail(err)) {
-       printf("pmap fail!\n");
         return err_push(err, LIB_ERR_PMAP_DETERMINE_ADDR);
     }
 
@@ -56,14 +55,12 @@ errval_t vregion_map_aligned(struct vregion *vregion, struct vspace* vspace,
     // Add to the vspace
     err = vspace_add_vregion(vspace, vregion);
     if (err_is_fail(err)) {
-       printf("vspace add vregion fail!\n");
         return err_push(err, LIB_ERR_VSPACE_ADD_REGION);
     }
 
     // Add to memobj
     err = memobj->f.map_region(memobj, vregion);
     if (err_is_fail(err)) {
-       printf("map region fail!\n");
         return err_push(err, LIB_ERR_MEMOBJ_MAP_REGION);
     }
 
index 7fae24b..d69b8bb 100644 (file)
@@ -30,7 +30,7 @@ end
 
 # -- Misc 
 
-#add-symbol-file arm/sbin/init 0x400000
+#add-symbol-file gem5/sbin/init 0x400000
 #set kernel_log_subsystem_mask = 0x7fffffff
 
 #break panic
index df490db..923063c 100644 (file)
@@ -30,6 +30,9 @@ static coreid_t my_core_id;
 #elif defined(__i386__)
 #       define MONITOR_NAME  "x86_32/sbin/monitor"
 #       define MEM_SERV_NAME "x86_32/sbin/mem_serv"
+#elif defined(__GEM5__)
+#       define MONITOR_NAME  "gem5/sbin/monitor"
+#       define MEM_SERV_NAME "gem5/sbin/mem_serv"
 #elif defined(__arm__)
 #       define MONITOR_NAME  "arm/sbin/monitor"
 #       define MEM_SERV_NAME "arm/sbin/mem_serv"