- Timestamp:
- 2010-05-08T07:53:23Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 051bc69a
- Parents:
- 6c39a907 (diff), 1317380 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- kernel
- Files:
-
- 49 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/_link.ld.in
r6c39a907 r25a76ab8 7 7 */ 8 8 9 #define KERNEL_LOAD_ADDRESS 0x80 8000009 #define KERNEL_LOAD_ADDRESS 0x80a00000 10 10 11 11 OUTPUT_ARCH(arm) -
kernel/arch/arm32/include/arch.h
r6c39a907 r25a76ab8 45 45 46 46 typedef struct { 47 uintptr_taddr;48 uint32_t size;47 void *addr; 48 size_t size; 49 49 char name[BOOTINFO_TASK_NAME_BUFLEN]; 50 50 } utask_t; 51 51 52 52 typedef struct { 53 uint32_t cnt;53 size_t cnt; 54 54 utask_t tasks[TASKMAP_MAX_RECORDS]; 55 55 } bootinfo_t; -
kernel/arch/arm32/include/mm/frame.h
r6c39a907 r25a76ab8 46 46 47 47 #define BOOT_PAGE_TABLE_SIZE 0x4000 48 #define BOOT_PAGE_TABLE_ADDRESS 0x 400048 #define BOOT_PAGE_TABLE_ADDRESS 0x8000 49 49 50 50 #define BOOT_PAGE_TABLE_START_FRAME (BOOT_PAGE_TABLE_ADDRESS >> FRAME_WIDTH) -
kernel/arch/arm32/src/arm32.c
r6c39a907 r25a76ab8 62 62 void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) 63 63 { 64 unsigned int i;64 init.cnt = min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 65 65 66 init.cnt = bootinfo->cnt; 67 68 for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); ++i) { 69 init.tasks[i].addr = bootinfo->tasks[i].addr; 66 size_t i; 67 for (i = 0; i < init.cnt; i++) { 68 init.tasks[i].addr = (uintptr_t) bootinfo->tasks[i].addr; 70 69 init.tasks[i].size = bootinfo->tasks[i].size; 71 70 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/ia64/include/bootinfo.h
r6c39a907 r25a76ab8 32 32 #define BOOTINFO_ADDRESS 0x4401000 33 33 34 #define CONFIG_INIT_TASKS3234 #define TASKMAP_MAX_RECORDS 32 35 35 36 36 #define MEMMAP_ITEMS 128 … … 44 44 45 45 typedef struct { 46 void *addr; 47 unsigned longsize;46 void *addr; 47 size_t size; 48 48 char name[BOOTINFO_TASK_NAME_BUFLEN]; 49 49 } binit_task_t; 50 50 51 51 typedef struct { 52 unsigned long count;53 binit_task_t tasks[ CONFIG_INIT_TASKS];52 size_t cnt; 53 binit_task_t tasks[TASKMAP_MAX_RECORDS]; 54 54 } binit_t; 55 55 … … 58 58 unsigned long base; 59 59 unsigned long size; 60 }efi_memmap_item_t; 61 60 } efi_memmap_item_t; 62 61 63 62 typedef struct { 64 63 binit_t taskmap; 65 64 66 65 efi_memmap_item_t memmap[MEMMAP_ITEMS]; 67 66 unsigned int memmap_items; 68 67 69 68 unative_t *sapic; 70 69 unsigned long sys_freq; -
kernel/arch/ia64/src/ia64.c
r6c39a907 r25a76ab8 47 47 #include <mm/as.h> 48 48 #include <config.h> 49 #include <macros.h> 49 50 #include <userspace.h> 50 51 #include <console/console.h> … … 78 79 void arch_pre_main(void) 79 80 { 80 /* Setup usermode init tasks. */ 81 82 unsigned int i; 83 84 init.cnt = bootinfo->taskmap.count; 85 81 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 82 size_t i; 86 83 for (i = 0; i < init.cnt; i++) { 87 84 init.tasks[i].addr = -
kernel/arch/mips32/include/arch.h
r6c39a907 r25a76ab8 45 45 46 46 typedef struct { 47 uintptr_taddr;47 void *addr; 48 48 size_t size; 49 49 char name[BOOTINFO_TASK_NAME_BUFLEN]; -
kernel/arch/mips32/src/debugger.c
r6c39a907 r25a76ab8 164 164 printf("Duplicate breakpoint %d.\n", i); 165 165 spinlock_unlock(&bkpoint_lock); 166 interrupts_restore(ipl); 166 167 return 0; 167 168 } else if (breakpoints[i].address == (uintptr_t)argv->intval + … … 171 172 "with %d.\n", i); 172 173 spinlock_unlock(&bkpoint_lock); 174 interrupts_restore(ipl); 173 175 return 0; 174 176 } -
kernel/arch/mips32/src/mips32.c
r6c39a907 r25a76ab8 83 83 void arch_pre_main(void *entry __attribute__((unused)), bootinfo_t *bootinfo) 84 84 { 85 /* Setup usermode */ 86 init.cnt = bootinfo->cnt; 85 init.cnt = min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 87 86 88 87 size_t i; 89 for (i = 0; i < min3(bootinfo->cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) {90 init.tasks[i].addr = bootinfo->tasks[i].addr;88 for (i = 0; i < init.cnt; i++) { 89 init.tasks[i].addr = (uintptr_t) bootinfo->tasks[i].addr; 91 90 init.tasks[i].size = bootinfo->tasks[i].size; 92 91 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/ppc32/include/arch.h
r6c39a907 r25a76ab8 36 36 #define KERN_ppc32_ARCH_H_ 37 37 38 extern void arch_pre_main(void); 38 #include <arch/boot/boot.h> 39 40 extern void arch_pre_main(bootinfo_t *); 39 41 40 42 #endif -
kernel/arch/ppc32/include/boot/boot.h
r6c39a907 r25a76ab8 52 52 53 53 typedef struct { 54 uintptr_taddr;55 uint32_t size;54 void *addr; 55 size_t size; 56 56 char name[BOOTINFO_TASK_NAME_BUFLEN]; 57 57 } utask_t; 58 58 59 59 typedef struct { 60 uint32_t count;60 size_t cnt; 61 61 utask_t tasks[TASKMAP_MAX_RECORDS]; 62 62 } taskmap_t; 63 63 64 64 typedef struct { 65 uintptr_tstart;66 uint32_t size;65 void *start; 66 size_t size; 67 67 } memzone_t; 68 68 69 69 typedef struct { 70 uint 32_t total;71 uint32_t count;70 uint64_t total; 71 size_t cnt; 72 72 memzone_t zones[MEMMAP_MAX_RECORDS]; 73 73 } memmap_t; … … 80 80 } bootinfo_t; 81 81 82 extern bootinfo_t bootinfo;82 extern memmap_t memmap; 83 83 84 84 #endif -
kernel/arch/ppc32/src/boot/boot.S
r6c39a907 r25a76ab8 47 47 48 48 # r3 contains physical address of bootinfo_t 49 # r4 contains size of bootinfo_t50 51 cmpwi r4, 052 beq bootinfo_end53 49 54 50 addis r3, r3, 0x8000 55 56 lis r31, bootinfo@ha57 addi r31, r31, bootinfo@l # r31 = bootinfo58 59 bootinfo_loop:60 61 lwz r30, 0(r3)62 stw r30, 0(r31)63 64 addi r3, r3, 465 addi r31, r31, 466 subi r4, r4, 467 68 cmpwi r4, 069 bgt bootinfo_loop70 71 bootinfo_end:72 73 51 bl arch_pre_main 74 52 b main_bsp -
kernel/arch/ppc32/src/mm/frame.c
r6c39a907 r25a76ab8 27 27 */ 28 28 29 /** @addtogroup ppc32mm 29 /** @addtogroup ppc32mm 30 30 * @{ 31 31 */ … … 41 41 42 42 uintptr_t last_frame = 0; 43 memmap_t memmap; 43 44 44 45 void physmem_print(void) … … 49 50 printf("---------- ----------\n"); 50 51 51 for (i = 0; i < bootinfo.memmap.count; i++) {52 printf("%#10x %#10x\n", bootinfo.memmap.zones[i].start,53 bootinfo.memmap.zones[i].size);52 for (i = 0; i < memmap.cnt; i++) { 53 printf("%#10x %#10x\n", memmap.zones[i].start, 54 memmap.zones[i].size); 54 55 } 55 56 } … … 62 63 size_t size; 63 64 64 for (i = 0; i < bootinfo.memmap.count; i++) {65 start = ADDR2PFN(ALIGN_UP( bootinfo.memmap.zones[i].start, FRAME_SIZE));66 size = SIZE2FRAMES(ALIGN_DOWN( bootinfo.memmap.zones[i].size, FRAME_SIZE));65 for (i = 0; i < memmap.cnt; i++) { 66 start = ADDR2PFN(ALIGN_UP((uintptr_t) memmap.zones[i].start, FRAME_SIZE)); 67 size = SIZE2FRAMES(ALIGN_DOWN(memmap.zones[i].size, FRAME_SIZE)); 67 68 68 69 if ((minconf < start) || (minconf >= start + size)) … … 72 73 73 74 zone_create(start, size, conf, 0); 74 if (last_frame < ALIGN_UP( bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE))75 last_frame = ALIGN_UP( bootinfo.memmap.zones[i].start + bootinfo.memmap.zones[i].size, FRAME_SIZE);75 if (last_frame < ALIGN_UP((uintptr_t) memmap.zones[i].start + memmap.zones[i].size, FRAME_SIZE)) 76 last_frame = ALIGN_UP((uintptr_t) memmap.zones[i].start + memmap.zones[i].size, FRAME_SIZE); 76 77 } 77 78 -
kernel/arch/ppc32/src/mm/page.c
r6c39a907 r25a76ab8 45 45 } 46 46 47 48 47 uintptr_t hw_map(uintptr_t physaddr, size_t size) 49 48 { -
kernel/arch/ppc32/src/ppc32.c
r6c39a907 r25a76ab8 65 65 66 66 /** Performs ppc32-specific initialization before main_bsp() is called. */ 67 void arch_pre_main(void) 68 { 69 init.cnt = bootinfo.taskmap.count; 70 71 uint32_t i; 72 73 for (i = 0; i < min3(bootinfo.taskmap.count, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); i++) { 74 init.tasks[i].addr = bootinfo.taskmap.tasks[i].addr; 75 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 67 void arch_pre_main(bootinfo_t *bootinfo) 68 { 69 /* Copy tasks map. */ 70 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 71 size_t i; 72 for (i = 0; i < init.cnt; i++) { 73 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr; 74 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 76 75 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 77 bootinfo.taskmap.tasks[i].name); 76 bootinfo->taskmap.tasks[i].name); 77 } 78 79 /* Copy physical memory map. */ 80 memmap.total = bootinfo->memmap.total; 81 memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS); 82 for (i = 0; i < memmap.cnt; i++) { 83 memmap.zones[i].start = bootinfo->memmap.zones[i].start; 84 memmap.zones[i].size = bootinfo->memmap.zones[i].size; 78 85 } 79 86 80 87 /* Copy boot allocations info. */ 81 ballocs.base = bootinfo.ballocs.base; 82 ballocs.size = bootinfo.ballocs.size; 83 84 ofw_tree_init(bootinfo.ofw_root); 88 ballocs.base = bootinfo->ballocs.base; 89 ballocs.size = bootinfo->ballocs.size; 90 91 /* Copy OFW tree. */ 92 ofw_tree_init(bootinfo->ofw_root); 85 93 } 86 94 -
kernel/arch/sparc64/include/arch.h
r6c39a907 r25a76ab8 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief 34 * @brief Various sparc64-specific macros. 35 35 */ 36 36 37 37 #ifndef KERN_sparc64_ARCH_H_ 38 38 #define KERN_sparc64_ARCH_H_ 39 40 #include <arch/boot/boot.h> 39 41 40 42 #if defined (SUN4U) … … 44 46 #endif 45 47 46 #define ASI_AIUP 0x10/** Access to primary context with user privileges. */47 #define ASI_AIUS 0x11/** Access to secondary context with user privileges. */48 #define ASI_AIUP 0x10 /** Access to primary context with user privileges. */ 49 #define ASI_AIUS 0x11 /** Access to secondary context with user privileges. */ 48 50 49 #define NWINDOWS 8/** Number of register window sets. */51 #define NWINDOWS 8 /** Number of register window sets. */ 50 52 51 53 #ifndef __ASM__ 52 54 53 extern void arch_pre_main( void);55 extern void arch_pre_main(bootinfo_t *); 54 56 55 57 #endif /* __ASM__ */ 56 57 58 58 59 #endif -
kernel/arch/sparc64/include/boot/boot.h
r6c39a907 r25a76ab8 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 36 36 #define KERN_sparc64_BOOT_H_ 37 37 38 #define VMA 39 #define LMA 38 #define VMA 0x400000 39 #define LMA VMA 40 40 41 41 #ifndef __ASM__ … … 46 46 #include <genarch/ofw/ofw_tree.h> 47 47 48 #define TASKMAP_MAX_RECORDS 49 #define MEMMAP_MAX_RECORDS 48 #define TASKMAP_MAX_RECORDS 32 49 #define MEMMAP_MAX_RECORDS 32 50 50 51 #define BOOTINFO_TASK_NAME_BUFLEN 3251 #define BOOTINFO_TASK_NAME_BUFLEN 32 52 52 53 53 typedef struct { 54 void * 55 uint32_t size;54 void *addr; 55 size_t size; 56 56 char name[BOOTINFO_TASK_NAME_BUFLEN]; 57 57 } utask_t; 58 58 59 59 typedef struct { 60 uint32_t count;60 size_t cnt; 61 61 utask_t tasks[TASKMAP_MAX_RECORDS]; 62 62 } taskmap_t; 63 63 64 64 typedef struct { 65 uintptr_tstart;66 uint32_t size;65 void *start; 66 size_t size; 67 67 } memzone_t; 68 68 69 69 typedef struct { 70 uint 32_t total;71 uint32_t count;70 uint64_t total; 71 size_t cnt; 72 72 memzone_t zones[MEMMAP_MAX_RECORDS]; 73 73 } memmap_t; … … 76 76 * 77 77 * Must be in sync with bootinfo structure used by the boot loader. 78 * 78 79 */ 79 80 typedef struct { … … 85 86 } bootinfo_t; 86 87 87 extern bootinfo_t bootinfo; 88 extern memmap_t memmap; 89 extern uintptr_t physmem_start; 88 90 89 91 #endif -
kernel/arch/sparc64/src/mm/sun4u/frame.c
r6c39a907 r25a76ab8 43 43 uintptr_t last_frame = NULL; 44 44 45 /** Create memory zones according to information stored in bootinfo.45 /** Create memory zones according to information stored in memmap. 46 46 * 47 * Walk the bootinfomemory map and create frame zones according to it.47 * Walk the memory map and create frame zones according to it. 48 48 */ 49 49 void frame_arch_init(void) … … 53 53 54 54 if (config.cpu_active == 1) { 55 for (i = 0; i < bootinfo.memmap.count; i++) {56 uintptr_t start = bootinfo.memmap.zones[i].start;57 size_t size = bootinfo.memmap.zones[i].size;55 for (i = 0; i < memmap.cnt; i++) { 56 uintptr_t start = (uintptr_t) memmap.zones[i].start; 57 size_t size = memmap.zones[i].size; 58 58 59 59 /* -
kernel/arch/sparc64/src/mm/sun4v/frame.c
r6c39a907 r25a76ab8 41 41 #include <macros.h> 42 42 43 /** Create memory zones according to information stored in bootinfo.43 /** Create memory zones according to information stored in memmap. 44 44 * 45 * Walk the bootinfomemory map and create frame zones according to it.45 * Walk the memory map and create frame zones according to it. 46 46 */ 47 47 void frame_arch_init(void) … … 51 51 52 52 if (config.cpu_active == 1) { 53 for (i = 0; i < bootinfo.memmap.count; i++) {54 uintptr_t start = bootinfo.memmap.zones[i].start;55 size_t size = bootinfo.memmap.zones[i].size;53 for (i = 0; i < memmap.cnt; i++) { 54 uintptr_t start = (uintptr_t) memmap.zones[i].start; 55 size_t size = memmap.zones[i].size; 56 56 57 57 /* -
kernel/arch/sparc64/src/smp/sun4v/smp.c
r6c39a907 r25a76ab8 417 417 static bool wake_cpu(uint64_t cpuid) 418 418 { 419 420 419 #ifdef CONFIG_SIMICS_SMP_HACK 421 420 ipi_unicast_to((void (*)(void)) 1234, cpuid); … … 424 423 if (__hypercall_fast1(CPU_STOP, cpuid) != EOK) 425 424 return false; 426 425 427 426 /* wait for the CPU to stop */ 428 427 uint64_t state; 429 __hypercall_fast_ret1(cpuid, 0, 0, 0, 0, 430 CPU_STATE, &state); 431 while (state == CPU_STATE_RUNNING) { 432 __hypercall_fast_ret1(cpuid, 0, 0, 0, 0, 433 CPU_STATE, &state); 434 } 435 428 __hypercall_fast_ret1(cpuid, 0, 0, 0, 0, CPU_STATE, &state); 429 while (state == CPU_STATE_RUNNING) 430 __hypercall_fast_ret1(cpuid, 0, 0, 0, 0, CPU_STATE, &state); 431 436 432 /* make the CPU run again and execute HelenOS code */ 437 if (__hypercall_fast4( 438 CPU_START, cpuid, 439 (uint64_t) KA2PA(kernel_image_start), 440 KA2PA(trap_table), bootinfo.physmem_start 441 ) != EOK) 442 return false; 433 if (__hypercall_fast4(CPU_START, cpuid, 434 (uint64_t) KA2PA(kernel_image_start), KA2PA(trap_table), 435 physmem_start) != EOK) 436 return false; 443 437 #endif 444 438 445 439 if (waitq_sleep_timeout(&ap_completion_wq, 10000000, SYNCH_FLAGS_NONE) == 446 447 printf("%s: waiting for processor (cpuid = %" PRIu32 448 ") timed out\n",__func__, cpuid);449 440 ESYNCH_TIMEOUT) 441 printf("%s: waiting for processor (cpuid = %" PRIu32 ") timed out\n", 442 __func__, cpuid); 443 450 444 return true; 451 445 } -
kernel/arch/sparc64/src/sun4u/sparc64.c
r6c39a907 r25a76ab8 36 36 #include <debug.h> 37 37 #include <config.h> 38 #include <macros.h> 38 39 #include <arch/trap/trap.h> 39 40 #include <arch/console.h> … … 50 51 #include <str.h> 51 52 52 bootinfo_t bootinfo;53 memmap_t memmap; 53 54 54 55 /** Perform sparc64-specific initialization before main_bsp() is called. */ 55 void arch_pre_main( void)56 void arch_pre_main(bootinfo_t *bootinfo) 56 57 { 57 58 /* Copy init task info. */ 58 init.cnt = bootinfo.taskmap.count;59 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 59 60 60 uint32_t i; 61 62 for (i = 0; i < bootinfo.taskmap.count; i++) { 63 init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr; 64 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 61 size_t i; 62 for (i = 0; i < init.cnt; i++) { 63 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr; 64 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 65 65 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 66 bootinfo.taskmap.tasks[i].name); 66 bootinfo->taskmap.tasks[i].name); 67 } 68 69 /* Copy physical memory map. */ 70 memmap.total = bootinfo->memmap.total; 71 memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS); 72 for (i = 0; i < memmap.cnt; i++) { 73 memmap.zones[i].start = bootinfo->memmap.zones[i].start; 74 memmap.zones[i].size = bootinfo->memmap.zones[i].size; 67 75 } 68 76 69 77 /* Copy boot allocations info. */ 70 ballocs.base = bootinfo .ballocs.base;71 ballocs.size = bootinfo .ballocs.size;78 ballocs.base = bootinfo->ballocs.base; 79 ballocs.size = bootinfo->ballocs.size; 72 80 73 ofw_tree_init(bootinfo .ofw_root);81 ofw_tree_init(bootinfo->ofw_root); 74 82 } 75 83 -
kernel/arch/sparc64/src/sun4u/start.S
r6c39a907 r25a76ab8 60 60 /* 61 61 * Here is where the kernel is passed control from the boot loader. 62 * 62 * 63 63 * The registers are expected to be in this state: 64 * - %o0 starting address of physical memory + bootstrap processor flag65 * bits 63...1: physical memory starting address / 266 * bit 0: non-zero on BSP processor, zero on AP processors67 * - %o1 bootinfo structure address (BSP only)68 * - %o2 bootinfo structure size (BSP only)64 * - %o0 bootinfo structure address (BSP only) 65 * - %o1 starting address of physical memory 66 * + bootstrap processor flag 67 * bits 63...1: physical memory starting address / 2 68 * bit 0: non-zero on BSP processor, zero on AP processors 69 69 * 70 70 * Moreover, we depend on boot having established the following environment: 71 * - TLBs are on 72 * - identity mapping for the kernel image 71 * - TLBs are on 72 * - identity mapping for the kernel image 73 * 73 74 */ 74 75 … … 76 77 kernel_image_start: 77 78 mov BSP_FLAG, %l0 78 and %o 0, %l0, %l7 ! l7 <= bootstrap processor?79 andn %o 0, %l0, %l6 ! l6 <= start of physical memory79 and %o1, %l0, %l7 ! l7 <= bootstrap processor? 80 andn %o1, %l0, %l6 ! l6 <= start of physical memory 80 81 81 82 ! Get bits (PHYSMEM_ADDR_SIZE - 1):13 of physmem_base. … … 282 283 sub %sp, STACK_BIAS, %sp 283 284 284 sethi %hi(bootinfo), %o0285 call memcpy ! copy bootinfo286 or %o0, %lo(bootinfo), %o0287 288 285 call arch_pre_main 289 286 nop -
kernel/arch/sparc64/src/sun4v/sparc64.c
r6c39a907 r25a76ab8 36 36 #include <debug.h> 37 37 #include <config.h> 38 #include <macros.h> 38 39 #include <arch/trap/trap.h> 39 40 #include <arch/console.h> … … 52 53 #include <arch/drivers/niagara.h> 53 54 54 bootinfo_t bootinfo;55 memmap_t memmap; 55 56 56 57 /** Perform sparc64-specific initialization before main_bsp() is called. */ 57 void arch_pre_main( void)58 void arch_pre_main(bootinfo_t *bootinfo) 58 59 { 59 60 /* Copy init task info. */ 60 init.cnt = bootinfo.taskmap.count;61 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 61 62 62 uint32_t i; 63 64 for (i = 0; i < bootinfo.taskmap.count; i++) { 65 init.tasks[i].addr = (uintptr_t) bootinfo.taskmap.tasks[i].addr; 66 init.tasks[i].size = bootinfo.taskmap.tasks[i].size; 63 size_t i; 64 for (i = 0; i < init.cnt; i++) { 65 init.tasks[i].addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr; 66 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 67 67 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, 68 bootinfo .taskmap.tasks[i].name);68 bootinfo->taskmap.tasks[i].name); 69 69 } 70 70 71 /* Copy physical memory map. */ 72 memmap.total = bootinfo->memmap.total; 73 memmap.cnt = min(bootinfo->memmap.cnt, MEMMAP_MAX_RECORDS); 74 for (i = 0; i < memmap.cnt; i++) { 75 memmap.zones[i].start = bootinfo->memmap.zones[i].start; 76 memmap.zones[i].size = bootinfo->memmap.zones[i].size; 77 } 78 71 79 md_init(); 72 80 } -
kernel/arch/sparc64/src/sun4v/start.S
r6c39a907 r25a76ab8 75 75 * 76 76 * parameters: 77 * addr: virtual address to be mapped 78 * rphysmem_start: register containing the starting address of the 79 * physical memory 80 * rtmp1: a register to be used as temporary 81 * rtmp2: a register to be used as temporary 82 * rd: register where the result will be saved 77 * addr: virtual address to be mapped 78 * rphysmem_start: register containing the starting address 79 * of the physical memory 80 * rtmp1: a register to be used as temporary 81 * rtmp2: a register to be used as temporary 82 * rd: register where the result will be saved 83 * 83 84 */ 84 85 #define TTE_DATA(addr, rphysmem_start, rtmp1, rtmp2, rd) \ … … 90 91 /* 91 92 * Here is where the kernel is passed control from the boot loader. 92 * 93 * 93 94 * The registers are expected to be in this state: 94 * - %o0 starting address of physical memory + bootstrap processor flag95 * bits 63...1: physical memory starting address / 296 * bit 0: non-zero on BSP processor, zero on AP processors97 * - %o1 bootinfo structure address (BSP only)98 * - %o2 bootinfo structure size (BSP only)95 * - %o0 bootinfo structure address (BSP only) 96 * - %o1 starting address of physical memory 97 * + bootstrap processor flag 98 * bits 63...1: physical memory starting address / 2 99 * bit 0: non-zero on BSP processor, zero on AP processors 99 100 * 100 101 * Moreover, we depend on boot having established the following environment: 101 * - TLBs are on 102 * - identity mapping for the kernel image 102 * - TLBs are on 103 * - identity mapping for the kernel image 104 * 103 105 */ 104 106 .global kernel_image_start 105 107 kernel_image_start: 106 108 mov BSP_FLAG, %l0 107 and %o0, %l0, %l7 ! l7 <= bootstrap processor? 108 andn %o0, %l0, %l6 ! l6 <= start of physical memory 109 or %o1, %g0, %l1 110 or %o2, %g0, %l2 109 and %o1, %l0, %l7 ! l7 <= bootstrap processor? 110 andn %o1, %l0, %l6 ! l6 <= start of physical memory 111 or %o0, %g0, %l0 111 112 112 113 ! Get bits (PHYSMEM_ADDR_SIZE - 1):13 of physmem_base. … … 245 246 sub %sp, STACK_BIAS, %sp 246 247 247 or %l1, %g0, %o1 248 or %l2, %g0, %o2 249 sethi %hi(bootinfo), %o0 250 call memcpy ! copy bootinfo 251 or %o0, %lo(bootinfo), %o0 252 248 or %l0, %g0, %o0 253 249 call arch_pre_main 254 250 nop -
kernel/doc/arch/ppc32
r6c39a907 r25a76ab8 4 4 ppc32 port is the fourth port of SPARTAN, originally written by Martin Decky. 5 5 The goal is to support 32-bit PowerPC architecture. 6 So far, it runs only in emulator.7 6 8 7 HARDWARE REQUIREMENTS 9 o no real hardware supported8 o Apple iMac G4 10 9 11 10 EMULATORS AND VIRTUALIZERS 12 o PearPC11 o QEMU 13 12 14 13 TOOLCHAIN REQUIREMENTS 15 14 o binutils 2.16 16 15 o gcc 4.0.1, 4.1.0, 4.1.1 -
kernel/genarch/include/ofw/ofw_tree.h
r6c39a907 r25a76ab8 34 34 #define OFW_TREE_PROPERTY_MAX_NAMELEN 32 35 35 36 typedef uint32_t phandle; 37 36 38 /** Memory representation of OpenFirmware device tree node property. */ 37 39 typedef struct { … … 47 49 struct ofw_tree_node *child; 48 50 49 uint32_t node_handle;/**< Old OpenFirmware node handle. */51 phandle node_handle; /**< Old OpenFirmware node handle. */ 50 52 51 53 char *da_name; /**< Disambigued name. */ 52 54 53 unsigned int properties;/**< Number of properties. */55 size_t properties; /**< Number of properties. */ 54 56 ofw_tree_property_t *property; 55 57 … … 83 85 const char *); 84 86 extern ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *, 85 uint32_t);87 phandle); 86 88 87 89 #endif -
kernel/genarch/src/ofw/ofw_tree.c
r6c39a907 r25a76ab8 65 65 const char *name) 66 66 { 67 unsigned int i;67 size_t i; 68 68 69 69 for (i = 0; i < node->properties; i++) { … … 170 170 */ 171 171 ofw_tree_node_t *ofw_tree_find_node_by_handle(ofw_tree_node_t *root, 172 uint32_thandle)172 phandle handle) 173 173 { 174 174 ofw_tree_node_t *cur; -
kernel/generic/include/func.h
r6c39a907 r25a76ab8 42 42 43 43 extern void halt(void) __attribute__((noreturn)); 44 extern unative_t atoi(const char *text);45 44 46 45 #endif -
kernel/generic/include/mm/as.h
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 227 227 extern void as_init(void); 228 228 229 extern as_t *as_create(int flags);230 extern void as_destroy(as_t * as);231 extern void as_ switch(as_t *old_as, as_t *new_as);232 extern int as_page_fault(uintptr_t page, pf_access_t access, istate_t *istate);233 234 extern as_area_t *as_area_create(as_t *as, int flags, size_t size,235 uintptr_t base, int attrs, mem_backend_t *backend, 236 mem_backend_data_t *backend_data); 237 extern int as_area_destroy(as_t *as, uintptr_t address); 238 extern int as_area_ resize(as_t *as, uintptr_t address, size_t size, int flags);239 int as_area_share(as_t *src_as, uintptr_t src_base, size_t acc_size, 240 as_t *dst_as, uintptr_t dst_base, int dst_flags_mask);241 extern int as_area_change_flags(as_t * as, int flags, uintptr_t address);242 243 extern int as_area_get_flags(as_area_t * area);244 extern bool as_area_check_access(as_area_t * area, pf_access_t access);245 extern size_t as_area_get_size(uintptr_t base);246 extern int used_space_insert(as_area_t * a, uintptr_t page, size_t count);247 extern int used_space_remove(as_area_t * a, uintptr_t page, size_t count);229 extern as_t *as_create(int); 230 extern void as_destroy(as_t *); 231 extern void as_hold(as_t *); 232 extern void as_release(as_t *); 233 extern void as_switch(as_t *, as_t *); 234 extern int as_page_fault(uintptr_t, pf_access_t, istate_t *); 235 236 extern as_area_t *as_area_create(as_t *, int, size_t, uintptr_t, int, 237 mem_backend_t *, mem_backend_data_t *); 238 extern int as_area_destroy(as_t *, uintptr_t); 239 extern int as_area_resize(as_t *, uintptr_t, size_t, int); 240 extern int as_area_share(as_t *, uintptr_t, size_t, as_t *, uintptr_t, int); 241 extern int as_area_change_flags(as_t *, int, uintptr_t); 242 243 extern int as_area_get_flags(as_area_t *); 244 extern bool as_area_check_access(as_area_t *, pf_access_t); 245 extern size_t as_area_get_size(uintptr_t); 246 extern int used_space_insert(as_area_t *, uintptr_t, size_t); 247 extern int used_space_remove(as_area_t *, uintptr_t, size_t); 248 248 249 249 250 250 /* Interface to be implemented by architectures. */ 251 251 #ifndef as_constructor_arch 252 extern int as_constructor_arch(as_t * as, int flags);252 extern int as_constructor_arch(as_t *, int); 253 253 #endif /* !def as_constructor_arch */ 254 254 #ifndef as_destructor_arch 255 extern int as_destructor_arch(as_t * as);255 extern int as_destructor_arch(as_t *); 256 256 #endif /* !def as_destructor_arch */ 257 257 #ifndef as_create_arch 258 extern int as_create_arch(as_t * as, int flags);258 extern int as_create_arch(as_t *, int); 259 259 #endif /* !def as_create_arch */ 260 260 #ifndef as_install_arch 261 extern void as_install_arch(as_t * as);261 extern void as_install_arch(as_t *); 262 262 #endif /* !def as_install_arch */ 263 263 #ifndef as_deinstall_arch 264 extern void as_deinstall_arch(as_t * as);264 extern void as_deinstall_arch(as_t *); 265 265 #endif /* !def as_deinstall_arch */ 266 266 … … 277 277 #define ELD_F_LOADER 1 278 278 279 extern unsigned int elf_load(elf_header_t * header, as_t *as, int flags);279 extern unsigned int elf_load(elf_header_t *, as_t *, int); 280 280 281 281 /* Address space area related syscalls. */ 282 extern unative_t sys_as_area_create(uintptr_t address, size_t size, int flags);283 extern unative_t sys_as_area_resize(uintptr_t address, size_t size, int flags);284 extern unative_t sys_as_area_change_flags(uintptr_t address, int flags);285 extern unative_t sys_as_area_destroy(uintptr_t address);282 extern unative_t sys_as_area_create(uintptr_t, size_t, int); 283 extern unative_t sys_as_area_resize(uintptr_t, size_t, int); 284 extern unative_t sys_as_area_change_flags(uintptr_t, int); 285 extern unative_t sys_as_area_destroy(uintptr_t); 286 286 287 287 /* Introspection functions. */ 288 extern void as_get_area_info(as_t * as, as_area_info_t **obuf, size_t *osize);289 extern void as_print(as_t * as);288 extern void as_get_area_info(as_t *, as_area_info_t **, size_t *); 289 extern void as_print(as_t *); 290 290 291 291 #endif /* KERNEL */ -
kernel/generic/include/proc/task.h
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 131 131 extern void task_init(void); 132 132 extern void task_done(void); 133 extern task_t *task_create(as_t *as, const char *name); 134 extern void task_destroy(task_t *t); 135 extern task_t *task_find_by_id(task_id_t id); 136 extern int task_kill(task_id_t id); 137 extern void task_get_accounting(task_t *t, uint64_t *ucycles, uint64_t *kcycles); 133 extern task_t *task_create(as_t *, const char *); 134 extern void task_destroy(task_t *); 135 extern void task_hold(task_t *); 136 extern void task_release(task_t *); 137 extern task_t *task_find_by_id(task_id_t); 138 extern int task_kill(task_id_t); 139 extern void task_get_accounting(task_t *, uint64_t *, uint64_t *); 138 140 extern void task_print_list(void); 139 141 140 extern void cap_set(task_t * t, cap_t caps);141 extern cap_t cap_get(task_t * t);142 extern void cap_set(task_t *, cap_t); 143 extern cap_t cap_get(task_t *); 142 144 143 145 #ifndef task_create_arch 144 extern void task_create_arch(task_t * t);146 extern void task_create_arch(task_t *); 145 147 #endif 146 148 147 149 #ifndef task_destroy_arch 148 extern void task_destroy_arch(task_t * t);150 extern void task_destroy_arch(task_t *); 149 151 #endif 150 152 151 extern unative_t sys_task_get_id(task_id_t * uspace_task_id);152 extern unative_t sys_task_set_name(const char * uspace_name, size_t name_len);153 extern unative_t sys_task_get_id(task_id_t *); 154 extern unative_t sys_task_set_name(const char *, size_t); 153 155 154 156 #endif -
kernel/generic/include/synch/spinlock.h
r6c39a907 r25a76ab8 77 77 } 78 78 79 #define spinlock_lock(lock) spinlock_lock_debug(lock) 79 #define spinlock_lock(lock) spinlock_lock_debug((lock)) 80 #define spinlock_unlock(lock) spinlock_unlock_debug((lock)) 80 81 81 82 #else … … 91 92 } 92 93 93 #define spinlock_lock(lock) atomic_lock_arch(&(lock)->val) 94 #define spinlock_lock(lock) atomic_lock_arch(&(lock)->val) 95 #define spinlock_unlock(lock) spinlock_unlock_nondebug((lock)) 94 96 95 97 #endif … … 104 106 extern int spinlock_trylock(spinlock_t *lock); 105 107 extern void spinlock_lock_debug(spinlock_t *lock); 108 extern void spinlock_unlock_debug(spinlock_t *lock); 106 109 107 110 /** Unlock spinlock 108 111 * 109 * Unlock spinlock .112 * Unlock spinlock for non-debug kernels. 110 113 * 111 114 * @param sl Pointer to spinlock_t structure. 112 115 */ 113 static inline void spinlock_unlock (spinlock_t *lock)116 static inline void spinlock_unlock_nondebug(spinlock_t *lock) 114 117 { 115 ASSERT(atomic_get(&lock->val) != 0);116 117 118 /* 118 119 * Prevent critical section code from bleeding out this way down. -
kernel/generic/src/console/cmd.c
r6c39a907 r25a76ab8 837 837 bool pointer = false; 838 838 int rc; 839 840 if (((char *) argv->buffer)[0] == '*') {839 840 if (((char *) argv->buffer)[0] == '*') { 841 841 rc = symtab_addr_lookup((char *) argv->buffer + 1, &addr); 842 842 pointer = true; 843 } else if (((char *) argv->buffer)[0] >= '0' && 844 ((char *)argv->buffer)[0] <= '9') { 845 rc = EOK; 846 addr = atoi((char *)argv->buffer); 847 } else { 843 } else if (((char *) argv->buffer)[0] >= '0' && 844 ((char *) argv->buffer)[0] <= '9') { 845 uint64_t value; 846 rc = str_uint64((char *) argv->buffer, NULL, 0, true, &value); 847 if (rc == EOK) 848 addr = (uintptr_t) value; 849 } else 848 850 rc = symtab_addr_lookup((char *) argv->buffer, &addr); 849 } 850 851 851 852 if (rc == ENOENT) 852 853 printf("Symbol %s not found.\n", argv->buffer); 854 else if (rc == EINVAL) 855 printf("Invalid address.\n"); 853 856 else if (rc == EOVERFLOW) { 854 857 symtab_print_search((char *) argv->buffer); 855 printf("Duplicate symbol , be more specific.\n");858 printf("Duplicate symbol (be more specific) or address overflow.\n"); 856 859 } else if (rc == EOK) { 857 860 if (pointer) … … 859 862 printf("Writing %#" PRIx64 " -> %p\n", arg1, addr); 860 863 *(uint32_t *) addr = arg1; 861 } else {864 } else 862 865 printf("No symbol information available.\n"); 863 }864 866 865 867 return 1; -
kernel/generic/src/console/kconsole.c
r6c39a907 r25a76ab8 455 455 printf("No symbol information available.\n"); 456 456 return false; 457 } 458 459 if (isaddr) 460 *result = (unative_t) symaddr; 461 else if (isptr) 462 *result = **((unative_t **) symaddr); 463 else 464 *result = *((unative_t *) symaddr); 457 case EOK: 458 if (isaddr) 459 *result = (unative_t) symaddr; 460 else if (isptr) 461 *result = **((unative_t **) symaddr); 462 else 463 *result = *((unative_t *) symaddr); 464 break; 465 default: 466 printf("Unknown error.\n"); 467 return false; 468 } 465 469 } else { 466 470 /* It's a number - convert it */ 467 *result = atoi(text); 468 if (isptr) 469 *result = *((unative_t *) *result); 471 uint64_t value; 472 int rc = str_uint64(text, NULL, 0, true, &value); 473 switch (rc) { 474 case EINVAL: 475 printf("Invalid number.\n"); 476 return false; 477 case EOVERFLOW: 478 printf("Integer overflow.\n"); 479 return false; 480 case EOK: 481 *result = (unative_t) value; 482 if (isptr) 483 *result = *((unative_t *) *result); 484 break; 485 default: 486 printf("Unknown error.\n"); 487 return false; 488 } 470 489 } 471 490 -
kernel/generic/src/ddi/ddi.c
r6c39a907 r25a76ab8 46 46 #include <mm/frame.h> 47 47 #include <mm/as.h> 48 #include <synch/ spinlock.h>48 #include <synch/mutex.h> 49 49 #include <syscall/copy.h> 50 50 #include <adt/btree.h> … … 54 54 55 55 /** This lock protects the parea_btree. */ 56 SPINLOCK_INITIALIZE(parea_lock);56 static mutex_t parea_lock; 57 57 58 58 /** B+tree with enabled physical memory areas. */ … … 63 63 { 64 64 btree_create(&parea_btree); 65 mutex_initialize(&parea_lock, MUTEX_PASSIVE); 65 66 } 66 67 … … 72 73 void ddi_parea_register(parea_t *parea) 73 74 { 74 ipl_t ipl = interrupts_disable(); 75 spinlock_lock(&parea_lock); 75 mutex_lock(&parea_lock); 76 76 77 77 /* … … 80 80 btree_insert(&parea_btree, (btree_key_t) parea->pbase, parea, NULL); 81 81 82 spinlock_unlock(&parea_lock); 83 interrupts_restore(ipl); 82 mutex_unlock(&parea_lock); 84 83 } 85 84 … … 141 140 spinlock_unlock(&zones.lock); 142 141 143 spinlock_lock(&parea_lock);142 mutex_lock(&parea_lock); 144 143 btree_node_t *nodep; 145 144 parea_t *parea = (parea_t *) btree_search(&parea_btree, … … 147 146 148 147 if ((!parea) || (parea->frames < pages)) { 149 spinlock_unlock(&parea_lock);148 mutex_unlock(&parea_lock); 150 149 goto err; 151 150 } 152 151 153 spinlock_unlock(&parea_lock);152 mutex_unlock(&parea_lock); 154 153 goto map; 155 154 } … … 161 160 162 161 map: 163 spinlock_lock(&TASK->lock);164 162 interrupts_restore(ipl); 163 165 164 if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp, 166 165 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { … … 169 168 * We report it using ENOMEM. 170 169 */ 171 spinlock_unlock(&TASK->lock);172 interrupts_restore(ipl);173 170 return ENOMEM; 174 171 } … … 177 174 * Mapping is created on-demand during page fault. 178 175 */ 179 180 spinlock_unlock(&TASK->lock);181 interrupts_restore(ipl);182 176 return 0; 183 177 } -
kernel/generic/src/ipc/ipc.c
r6c39a907 r25a76ab8 218 218 answerbox_t *callerbox = call->callerbox; 219 219 bool do_lock = ((!selflocked) || callerbox != (&TASK->answerbox)); 220 ipl_t ipl; 220 221 221 222 /* Count sent answer */ 223 ipl = interrupts_disable(); 222 224 spinlock_lock(&TASK->lock); 223 225 TASK->ipc_info.answer_sent++; 224 226 spinlock_unlock(&TASK->lock); 227 interrupts_restore(ipl); 225 228 226 229 call->flags |= IPC_CALL_ANSWERED; … … 281 284 static void _ipc_call(phone_t *phone, answerbox_t *box, call_t *call) 282 285 { 286 ipl_t ipl; 287 283 288 /* Count sent ipc call */ 289 ipl = interrupts_disable(); 284 290 spinlock_lock(&TASK->lock); 285 291 TASK->ipc_info.call_sent++; 286 292 spinlock_unlock(&TASK->lock); 293 interrupts_restore(ipl); 287 294 288 295 if (!(call->flags & IPC_CALL_FORWARDED)) { … … 386 393 int ipc_forward(call_t *call, phone_t *newphone, answerbox_t *oldbox, int mode) 387 394 { 395 ipl_t ipl; 396 388 397 /* Count forwarded calls */ 398 ipl = interrupts_disable(); 389 399 spinlock_lock(&TASK->lock); 390 400 TASK->ipc_info.forwarded++; 391 401 spinlock_unlock(&TASK->lock); 402 interrupts_restore(ipl); 392 403 393 404 spinlock_lock(&oldbox->lock); … … 422 433 call_t *request; 423 434 ipl_t ipl; 435 uint64_t irq_cnt = 0; 436 uint64_t answer_cnt = 0; 437 uint64_t call_cnt = 0; 424 438 int rc; 425 439 … … 431 445 spinlock_lock(&box->lock); 432 446 if (!list_empty(&box->irq_notifs)) { 433 434 447 /* Count recieved IRQ notification */ 435 spinlock_lock(&TASK->lock); 436 TASK->ipc_info.irq_notif_recieved++; 437 spinlock_unlock(&TASK->lock); 448 irq_cnt++; 438 449 439 450 ipl = interrupts_disable(); … … 447 458 } else if (!list_empty(&box->answers)) { 448 459 /* Count recieved answer */ 449 spinlock_lock(&TASK->lock); 450 TASK->ipc_info.answer_recieved++; 451 spinlock_unlock(&TASK->lock); 460 answer_cnt++; 452 461 453 462 /* Handle asynchronous answers */ … … 457 466 } else if (!list_empty(&box->calls)) { 458 467 /* Count recieved call */ 459 spinlock_lock(&TASK->lock); 460 TASK->ipc_info.call_recieved++; 461 spinlock_unlock(&TASK->lock); 468 call_cnt++; 462 469 463 470 /* Handle requests */ … … 472 479 } 473 480 spinlock_unlock(&box->lock); 481 482 ipl = interrupts_disable(); 483 spinlock_lock(&TASK->lock); 484 TASK->ipc_info.irq_notif_recieved += irq_cnt; 485 TASK->ipc_info.answer_recieved += answer_cnt; 486 TASK->ipc_info.call_recieved += call_cnt; 487 spinlock_unlock(&TASK->lock); 488 interrupts_restore(ipl); 489 474 490 return request; 475 491 } … … 675 691 call_t *call; 676 692 link_t *tmp; 693 ipl_t ipl; 677 694 695 ipl = interrupts_disable(); 678 696 spinlock_lock(&tasks_lock); 679 697 task = task_find_by_id(taskid); … … 681 699 spinlock_lock(&task->lock); 682 700 spinlock_unlock(&tasks_lock); 683 if (!task) 701 if (!task) { 702 interrupts_restore(ipl); 684 703 return; 704 } 685 705 686 706 /* Print opened phones & details */ … … 765 785 spinlock_unlock(&task->answerbox.lock); 766 786 spinlock_unlock(&task->lock); 787 interrupts_restore(ipl); 767 788 } 768 789 -
kernel/generic/src/lib/func.c
r6c39a907 r25a76ab8 27 27 */ 28 28 29 /** @addtogroup generic 29 /** @addtogroup generic 30 30 * @{ 31 31 */ … … 33 33 /** 34 34 * @file 35 * @brief 35 * @brief Miscellaneous functions. 36 36 */ 37 37 … … 79 79 } 80 80 81 /** Convert ascii representation to unative_t82 *83 * Supports 0x for hexa & 0 for octal notation.84 * Does not check for overflows, does not support negative numbers85 *86 * @param text Textual representation of number87 * @return Converted number or 0 if no valid number ofund88 */89 unative_t atoi(const char *text)90 {91 int base = 10;92 unative_t result = 0;93 94 if (text[0] == '0' && text[1] == 'x') {95 base = 16;96 text += 2;97 } else if (text[0] == '0')98 base = 8;99 100 while (*text) {101 if (base != 16 && \102 ((*text >= 'A' && *text <= 'F' )103 || (*text >='a' && *text <='f')))104 break;105 if (base == 8 && *text >='8')106 break;107 108 if (*text >= '0' && *text <= '9') {109 result *= base;110 result += *text - '0';111 } else if (*text >= 'A' && *text <= 'F') {112 result *= base;113 result += *text - 'A' + 10;114 } else if (*text >= 'a' && *text <= 'f') {115 result *= base;116 result += *text - 'a' + 10;117 } else118 break;119 text++;120 }121 122 return result;123 }124 125 81 /** @} 126 82 */ -
kernel/generic/src/lib/str.c
r6c39a907 r25a76ab8 823 823 str++; 824 824 break; 825 default: 826 str--; 825 827 } 826 828 } … … 886 888 * @param base Zero or number between 2 and 36 inclusive. 887 889 * @param strict Do not allow any trailing characters. 888 * @ apram result Result of the conversion.890 * @param result Result of the conversion. 889 891 * 890 892 * @return EOK if conversion was successful. -
kernel/generic/src/mm/as.c
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2006Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 152 152 * reference count never drops to zero. 153 153 */ 154 a tomic_set(&AS_KERNEL->refcount, 1);154 as_hold(AS_KERNEL); 155 155 } 156 156 … … 200 200 DEADLOCK_PROBE_INIT(p_asidlock); 201 201 202 ASSERT(as != AS); 202 203 ASSERT(atomic_get(&as->refcount) == 0); 203 204 204 205 /* 205 * Since there is no reference to this a rea,206 * it is safe not tolock its mutex.206 * Since there is no reference to this address space, it is safe not to 207 * lock its mutex. 207 208 */ 208 209 … … 225 226 preemption_enable(); /* Interrupts disabled, enable preemption */ 226 227 if (as->asid != ASID_INVALID && as != AS_KERNEL) { 227 if (as != AS && as->cpu_refcount == 0)228 if (as->cpu_refcount == 0) 228 229 list_remove(&as->inactive_as_with_asid_link); 229 230 asid_put(as->asid); … … 258 259 259 260 slab_free(as_slab, as); 261 } 262 263 /** Hold a reference to an address space. 264 * 265 * Holding a reference to an address space prevents destruction of that address 266 * space. 267 * 268 * @param a Address space to be held. 269 */ 270 void as_hold(as_t *as) 271 { 272 atomic_inc(&as->refcount); 273 } 274 275 /** Release a reference to an address space. 276 * 277 * The last one to release a reference to an address space destroys the address 278 * space. 279 * 280 * @param a Address space to be released. 281 */ 282 void as_release(as_t *as) 283 { 284 if (atomic_predec(&as->refcount) == 0) 285 as_destroy(as); 260 286 } 261 287 -
kernel/generic/src/mm/frame.c
r6c39a907 r25a76ab8 1033 1033 spinlock_unlock(&zones.lock); 1034 1034 interrupts_restore(ipl); 1035 1036 if (!THREAD) 1037 panic("Cannot wait for memory to become available."); 1035 1038 1036 1039 /* -
kernel/generic/src/mm/slab.c
r6c39a907 r25a76ab8 555 555 * Initialize mag_cache structure in slab cache 556 556 */ 557 static voidmake_magcache(slab_cache_t *cache)557 static bool make_magcache(slab_cache_t *cache) 558 558 { 559 559 unsigned int i; … … 562 562 563 563 cache->mag_cache = malloc(sizeof(slab_mag_cache_t) * config.cpu_count, 564 0); 564 FRAME_ATOMIC); 565 if (!cache->mag_cache) 566 return false; 567 565 568 for (i = 0; i < config.cpu_count; i++) { 566 569 memsetb(&cache->mag_cache[i], sizeof(cache->mag_cache[i]), 0); … … 568 571 "slab_maglock_cpu"); 569 572 } 573 return true; 570 574 } 571 575 … … 597 601 spinlock_initialize(&cache->maglock, "slab_maglock"); 598 602 if (!(cache->flags & SLAB_CACHE_NOMAGAZINE)) 599 make_magcache(cache);603 (void) make_magcache(cache); 600 604 601 605 /* Compute slab sizes, object counts in slabs etc. */ … … 923 927 SLAB_CACHE_MAGDEFERRED) 924 928 continue; 925 make_magcache(s);929 (void) make_magcache(s); 926 930 s->flags &= ~SLAB_CACHE_MAGDEFERRED; 927 931 } -
kernel/generic/src/printf/printf_core.c
r6c39a907 r25a76ab8 261 261 if (str == NULL) 262 262 return printf_putstr(nullstr, ps); 263 263 264 264 /* Print leading spaces. */ 265 265 size_t strw = str_length(str); 266 266 if (precision == 0) 267 267 precision = strw; 268 268 269 269 /* Left padding */ 270 270 size_t counter = 0; … … 276 276 } 277 277 } 278 278 279 279 /* Part of @a str fitting into the alloted space. */ 280 280 int retval; … … 391 391 */ 392 392 if (flags & __PRINTF_FLAG_PREFIX) { 393 switch (base) {393 switch (base) { 394 394 case 2: 395 395 /* Binary formating is not standard, but usefull */ … … 455 455 /* Print prefix */ 456 456 if (flags & __PRINTF_FLAG_PREFIX) { 457 switch (base) {457 switch (base) { 458 458 case 2: 459 459 /* Binary formating is not standard, but usefull */ … … 570 570 * 571 571 * - P, p Print value of a pointer. Void * value is expected and it is 572 * printed in hexadecimal notation with prefix (as with \%#X / \%#x 573 * for 32-bit or \%#X / \%#x for 64-bit long pointers). 572 * printed in hexadecimal notation with prefix (as with 573 * \%#0.8X / \%#0.8x for 32-bit or \%#0.16lX / \%#0.16lx for 64-bit 574 * long pointers). 574 575 * 575 576 * - b Print value as unsigned binary number. Prefix is not printed by … … 784 785 case 'p': 785 786 flags |= __PRINTF_FLAG_PREFIX; 787 flags |= __PRINTF_FLAG_ZEROPADDED; 786 788 base = 16; 787 789 qualifier = PrintfQualifierPointer; … … 846 848 case PrintfQualifierPointer: 847 849 size = sizeof(void *); 848 number = (uint64_t) (unsigned long) va_arg(ap, void *); 850 precision = size << 1; 851 number = (uint64_t) (uintptr_t) va_arg(ap, void *); 849 852 break; 850 853 default: -
kernel/generic/src/proc/scheduler.c
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2007Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 187 187 188 188 loop: 189 interrupts_enable();190 189 191 190 if (atomic_get(&CPU->nrdy) == 0) { … … 196 195 */ 197 196 198 /* 197 /* Mark CPU as it was idle this clock tick */ 198 spinlock_lock(&CPU->lock); 199 CPU->idle = true; 200 spinlock_unlock(&CPU->lock); 201 202 interrupts_enable(); 203 /* 199 204 * An interrupt might occur right now and wake up a thread. 200 205 * In such case, the CPU will continue to go to sleep 201 206 * even though there is a runnable thread. 202 207 */ 203 204 spinlock_lock(&CPU->lock);205 CPU->idle = true;206 spinlock_unlock(&CPU->lock);207 208 cpu_sleep(); 209 interrupts_disable(); 208 210 goto loop; 209 211 } 210 211 interrupts_disable();212 212 213 213 for (i = 0; i < RQ_COUNT; i++) { … … 382 382 int priority; 383 383 DEADLOCK_PROBE_INIT(p_joinwq); 384 task_t *old_task = TASK; 385 as_t *old_as = AS; 384 386 385 387 ASSERT(CPU != NULL); 386 388 389 /* 390 * Hold the current task and the address space to prevent their 391 * possible destruction should thread_destroy() be called on this or any 392 * other processor while the scheduler is still using them. 393 */ 394 if (old_task) 395 task_hold(old_task); 396 if (old_as) 397 as_hold(old_as); 398 387 399 if (THREAD) { 388 400 /* must be run after the switch to scheduler stack */ … … 476 488 */ 477 489 if (TASK != THREAD->task) { 478 as_t *as1 = NULL; 479 as_t *as2; 480 481 if (TASK) { 482 spinlock_lock(&TASK->lock); 483 as1 = TASK->as; 484 spinlock_unlock(&TASK->lock); 485 } 486 487 spinlock_lock(&THREAD->task->lock); 488 as2 = THREAD->task->as; 489 spinlock_unlock(&THREAD->task->lock); 490 as_t *new_as = THREAD->task->as; 490 491 491 492 /* … … 493 494 * space. 494 495 */ 495 if ( as1 != as2) {496 if (old_as != new_as) { 496 497 /* 497 498 * Both tasks and address spaces are different. 498 499 * Replace the old one with the new one. 499 500 */ 500 as_switch( as1, as2);501 as_switch(old_as, new_as); 501 502 } 503 502 504 TASK = THREAD->task; 503 505 before_task_runs(); 504 506 } 505 507 508 if (old_task) 509 task_release(old_task); 510 if (old_as) 511 as_release(old_as); 512 506 513 spinlock_lock(&THREAD->lock); 507 514 THREAD->state = Running; -
kernel/generic/src/proc/task.c
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 210 210 btree_create(&ta->futexes); 211 211 212 /* 213 * Get a reference to the address space. 214 */ 215 as_hold(ta->as); 216 212 217 ipl = interrupts_disable(); 213 atomic_inc(&as->refcount);214 218 spinlock_lock(&tasks_lock); 215 219 ta->taskid = ++task_counter; … … 250 254 * Drop our reference to the address space. 251 255 */ 252 if (atomic_predec(&t->as->refcount) == 0) 253 as_destroy(t->as); 256 as_release(t->as); 254 257 255 258 slab_free(task_slab, t); 256 TASK = NULL; 259 } 260 261 /** Hold a reference to a task. 262 * 263 * Holding a reference to a task prevents destruction of that task. 264 * 265 * @param t Task to be held. 266 */ 267 void task_hold(task_t *t) 268 { 269 atomic_inc(&t->refcount); 270 } 271 272 /** Release a reference to a task. 273 * 274 * The last one to release a reference to a task destroys the task. 275 * 276 * @param t Task to be released. 277 */ 278 void task_release(task_t *t) 279 { 280 if ((atomic_predec(&t->refcount)) == 0) 281 task_destroy(t); 257 282 } 258 283 -
kernel/generic/src/proc/thread.c
r6c39a907 r25a76ab8 1 1 /* 2 * Copyright (c) 20 01-2004Jakub Jermar2 * Copyright (c) 2010 Jakub Jermar 3 3 * All rights reserved. 4 4 * … … 409 409 410 410 /* 411 * t is guaranteed to be the very last thread of its task. 412 * It is safe to destroy the task. 411 * Drop the reference to the containing task. 413 412 */ 414 if (atomic_predec(&t->task->refcount) == 0) 415 task_destroy(t->task); 413 task_release(t->task); 416 414 417 415 slab_free(thread_slab, t); … … 436 434 spinlock_lock(&task->lock); 437 435 438 atomic_inc(&task->refcount); 436 /* Hold a reference to the task. */ 437 task_hold(task); 439 438 440 439 /* Must not count kbox thread into lifecount */ -
kernel/generic/src/synch/mutex.c
r6c39a907 r25a76ab8 40 40 #include <synch/synch.h> 41 41 #include <debug.h> 42 #include <arch.h> 42 43 43 44 /** Initialize mutex. … … 69 70 int rc; 70 71 71 if (mtx->type == MUTEX_PASSIVE ) {72 if (mtx->type == MUTEX_PASSIVE && THREAD) { 72 73 rc = _semaphore_down_timeout(&mtx->sem, usec, flags); 73 74 } else { 74 ASSERT(mtx->type == MUTEX_ACTIVE );75 ASSERT(mtx->type == MUTEX_ACTIVE || !THREAD); 75 76 ASSERT(usec == SYNCH_NO_TIMEOUT); 76 77 ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE)); -
kernel/generic/src/synch/spinlock.c
r6c39a907 r25a76ab8 120 120 } 121 121 122 /** Unlock spinlock 123 * 124 * Unlock spinlock. 125 * 126 * @param sl Pointer to spinlock_t structure. 127 */ 128 void spinlock_unlock_debug(spinlock_t *lock) 129 { 130 ASSERT(atomic_get(&lock->val) != 0); 131 132 /* 133 * Prevent critical section code from bleeding out this way down. 134 */ 135 CS_LEAVE_BARRIER(); 136 137 atomic_set(&lock->val, 0); 138 preemption_enable(); 139 } 140 122 141 #endif 123 142 -
kernel/generic/src/sysinfo/stats.c
r6c39a907 r25a76ab8 38 38 #include <sysinfo/stats.h> 39 39 #include <sysinfo/sysinfo.h> 40 #include <synch/spinlock.h> 41 #include <synch/mutex.h> 40 42 #include <time/clock.h> 41 43 #include <mm/frame.h> … … 68 70 static load_t avenrdy[LOAD_STEPS] = {0, 0, 0}; 69 71 70 /** Load calculation spinlock */71 SPINLOCK_STATIC_INITIALIZE_NAME(load_lock, "load_lock");72 /** Load calculation lock */ 73 static mutex_t load_lock; 72 74 73 75 /** Get system uptime … … 156 158 static size_t get_task_virtmem(as_t *as) 157 159 { 158 mutex_lock(&as->lock);159 160 160 size_t result = 0; 161 162 /* 163 * We are holding some spinlocks here and therefore are not allowed to 164 * block. Only attempt to lock the address space and address space area 165 * mutexes conditionally. If it is not possible to lock either object, 166 * allow the statistics to be inexact by skipping the respective object. 167 * 168 * Note that it may be infinitely better to let the address space 169 * management code compute these statistics as it proceeds instead of 170 * having them calculated here over and over again here. 171 */ 172 173 if (SYNCH_FAILED(mutex_trylock(&as->lock))) 174 return result * PAGE_SIZE; 161 175 162 176 /* Walk the B+ tree and count pages */ … … 171 185 as_area_t *area = node->value[i]; 172 186 173 mutex_lock(&area->lock); 187 if (SYNCH_FAILED(mutex_trylock(&area->lock))) 188 continue; 174 189 result += area->pages; 175 190 mutex_unlock(&area->lock); … … 331 346 332 347 /* Interrupts are already disabled */ 333 spinlock_lock(& (thread->lock));348 spinlock_lock(&thread->lock); 334 349 335 350 /* Record the statistics and increment the iterator */ … … 337 352 (*iterator)++; 338 353 339 spinlock_unlock(& (thread->lock));354 spinlock_unlock(&thread->lock); 340 355 341 356 return true; … … 602 617 } 603 618 604 /* To always get consistent values acquire the spinlock */ 605 ipl_t ipl = interrupts_disable(); 606 spinlock_lock(&load_lock); 619 /* To always get consistent values acquire the mutex */ 620 mutex_lock(&load_lock); 607 621 608 622 unsigned int i; … … 610 624 stats_load[i] = avenrdy[i] << LOAD_FIXED_SHIFT; 611 625 612 spinlock_unlock(&load_lock); 613 interrupts_restore(ipl); 626 mutex_unlock(&load_lock); 614 627 615 628 return ((void *) stats_load); … … 642 655 643 656 /* Mutually exclude with get_stats_load() */ 644 ipl_t ipl = interrupts_disable(); 645 spinlock_lock(&load_lock); 657 mutex_lock(&load_lock); 646 658 647 659 unsigned int i; … … 649 661 avenrdy[i] = load_calc(avenrdy[i], load_exp[i], ready); 650 662 651 spinlock_unlock(&load_lock); 652 interrupts_restore(ipl); 663 mutex_unlock(&load_lock); 653 664 654 665 thread_sleep(LOAD_INTERVAL); … … 661 672 void stats_init(void) 662 673 { 674 mutex_initialize(&load_lock, MUTEX_PASSIVE); 675 663 676 sysinfo_set_item_fn_val("system.uptime", NULL, get_stats_uptime); 664 677 sysinfo_set_item_fn_data("system.cpus", NULL, get_stats_cpus); -
kernel/generic/src/sysinfo/sysinfo.c
r6c39a907 r25a76ab8 37 37 #include <print.h> 38 38 #include <syscall/copy.h> 39 #include <synch/ spinlock.h>39 #include <synch/mutex.h> 40 40 #include <arch/asm.h> 41 41 #include <errno.h> … … 52 52 static slab_cache_t *sysinfo_item_slab; 53 53 54 /** Sysinfo spinlock */55 SPINLOCK_STATIC_INITIALIZE_NAME(sysinfo_lock, "sysinfo_lock");54 /** Sysinfo lock */ 55 static mutex_t sysinfo_lock; 56 56 57 57 /** Sysinfo item constructor … … 98 98 sizeof(sysinfo_item_t), 0, sysinfo_item_constructor, 99 99 sysinfo_item_destructor, SLAB_CACHE_MAGDEFERRED); 100 101 mutex_initialize(&sysinfo_lock, MUTEX_ACTIVE); 100 102 } 101 103 102 104 /** Recursively find an item in sysinfo tree 103 105 * 104 * Should be called with interrupts disabled 105 * and sysinfo_lock held. 106 * Should be called with sysinfo_lock held. 106 107 * 107 108 * @param name Current sysinfo path suffix. … … 168 169 /** Recursively create items in sysinfo tree 169 170 * 170 * Should be called with interrupts disabled 171 * and sysinfo_lock held. 171 * Should be called with sysinfo_lock held. 172 172 * 173 173 * @param name Current sysinfo path suffix. … … 299 299 { 300 300 /* Protect sysinfo tree consistency */ 301 ipl_t ipl = interrupts_disable(); 302 spinlock_lock(&sysinfo_lock); 301 mutex_lock(&sysinfo_lock); 303 302 304 303 if (root == NULL) … … 311 310 } 312 311 313 spinlock_unlock(&sysinfo_lock); 314 interrupts_restore(ipl); 312 mutex_unlock(&sysinfo_lock); 315 313 } 316 314 … … 332 330 { 333 331 /* Protect sysinfo tree consistency */ 334 ipl_t ipl = interrupts_disable(); 335 spinlock_lock(&sysinfo_lock); 332 mutex_lock(&sysinfo_lock); 336 333 337 334 if (root == NULL) … … 345 342 } 346 343 347 spinlock_unlock(&sysinfo_lock); 348 interrupts_restore(ipl); 344 mutex_unlock(&sysinfo_lock); 349 345 } 350 346 … … 361 357 { 362 358 /* Protect sysinfo tree consistency */ 363 ipl_t ipl = interrupts_disable(); 364 spinlock_lock(&sysinfo_lock); 359 mutex_lock(&sysinfo_lock); 365 360 366 361 if (root == NULL) … … 373 368 } 374 369 375 spinlock_unlock(&sysinfo_lock); 376 interrupts_restore(ipl); 370 mutex_unlock(&sysinfo_lock); 377 371 } 378 372 … … 394 388 { 395 389 /* Protect sysinfo tree consistency */ 396 ipl_t ipl = interrupts_disable(); 397 spinlock_lock(&sysinfo_lock); 390 mutex_lock(&sysinfo_lock); 398 391 399 392 if (root == NULL) … … 406 399 } 407 400 408 spinlock_unlock(&sysinfo_lock); 409 interrupts_restore(ipl); 401 mutex_unlock(&sysinfo_lock); 410 402 } 411 403 … … 420 412 { 421 413 /* Protect sysinfo tree consistency */ 422 ipl_t ipl = interrupts_disable(); 423 spinlock_lock(&sysinfo_lock); 414 mutex_lock(&sysinfo_lock); 424 415 425 416 if (root == NULL) … … 430 421 item->val_type = SYSINFO_VAL_UNDEFINED; 431 422 432 spinlock_unlock(&sysinfo_lock); 433 interrupts_restore(ipl); 423 mutex_unlock(&sysinfo_lock); 434 424 } 435 425 … … 446 436 { 447 437 /* Protect sysinfo tree consistency */ 448 ipl_t ipl = interrupts_disable(); 449 spinlock_lock(&sysinfo_lock); 438 mutex_lock(&sysinfo_lock); 450 439 451 440 if (root == NULL) … … 461 450 } 462 451 463 spinlock_unlock(&sysinfo_lock); 464 interrupts_restore(ipl); 452 mutex_unlock(&sysinfo_lock); 465 453 } 466 454 … … 479 467 /** Dump the structure of sysinfo tree 480 468 * 481 * Should be called with interrupts disabled 482 * and sysinfo_lock held. Because this routine 483 * might take a reasonable long time to proceed, 484 * having the spinlock held is not optimal, but 485 * there is no better simple solution. 469 * Should be called with sysinfo_lock held. 486 470 * 487 471 * @param root Root item of the current (sub)tree. … … 559 543 /* Avoid other functions to mess with sysinfo 560 544 while we are dumping it */ 561 ipl_t ipl = interrupts_disable(); 562 spinlock_lock(&sysinfo_lock); 545 mutex_lock(&sysinfo_lock); 563 546 564 547 if (root == NULL) … … 567 550 sysinfo_dump_internal(root, 0); 568 551 569 spinlock_unlock(&sysinfo_lock); 570 interrupts_restore(ipl); 552 mutex_unlock(&sysinfo_lock); 571 553 } 572 554 573 555 /** Return sysinfo item value determined by name 574 556 * 575 * Should be called with interrupts disabled 576 * and sysinfo_lock held. 557 * Should be called with sysinfo_lock held. 577 558 * 578 559 * @param name Sysinfo path. … … 632 613 /** Return sysinfo item determined by name from user space 633 614 * 634 * Should be called with interrupts disabled 635 * and sysinfo_lock held. The path string passed from 636 * the user space has to be properly null-terminated 615 * The path string passed from the user space has to be properly null-terminated 637 616 * (the last passed character must be null). 638 617 * … … 656 635 657 636 if ((copy_from_uspace(path, ptr, size + 1) == 0) 658 && (path[size] == 0)) 637 && (path[size] == 0)) { 638 /* 639 * Prevent other functions from messing with sysinfo while we 640 * are reading it. 641 */ 642 mutex_lock(&sysinfo_lock); 659 643 ret = sysinfo_get_item(path, NULL, dry_run); 660 644 mutex_unlock(&sysinfo_lock); 645 } 661 646 free(path); 662 647 return ret; … … 677 662 unative_t sys_sysinfo_get_tag(void *path_ptr, size_t path_size) 678 663 { 679 /* Avoid other functions to mess with sysinfo 680 while we are reading it */ 681 ipl_t ipl = interrupts_disable(); 682 spinlock_lock(&sysinfo_lock); 683 684 /* Get the item. 685 686 N.B.: There is no need to free any potential generated 687 binary data since we request a dry run */ 664 /* 665 * Get the item. 666 * 667 * N.B.: There is no need to free any potential generated 668 * binary data since we request a dry run. 669 */ 688 670 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true); 689 671 690 /* Map generated value types to constant types 691 (user space does not care whether the 692 value is constant or generated) */ 672 /* 673 * Map generated value types to constant types (user space does not care 674 * whether the value is constant or generated). 675 */ 693 676 if (ret.tag == SYSINFO_VAL_FUNCTION_VAL) 694 677 ret.tag = SYSINFO_VAL_VAL; … … 696 679 ret.tag = SYSINFO_VAL_DATA; 697 680 698 spinlock_unlock(&sysinfo_lock);699 interrupts_restore(ipl);700 701 681 return (unative_t) ret.tag; 702 682 } … … 719 699 void *value_ptr) 720 700 { 721 /* Avoid other functions to mess with sysinfo 722 while we are reading it */ 723 ipl_t ipl = interrupts_disable(); 724 spinlock_lock(&sysinfo_lock); 725 726 /* Get the item. 727 728 N.B.: There is no need to free any potential generated 729 binary data since we request a dry run */ 701 int rc; 702 703 /* 704 * Get the item. 705 * 706 * N.B.: There is no need to free any potential generated binary data 707 * since we request a dry run. 708 */ 730 709 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true); 731 int rc;732 710 733 711 /* Only constant or generated numerical value is returned */ … … 737 715 rc = EINVAL; 738 716 739 spinlock_unlock(&sysinfo_lock);740 interrupts_restore(ipl);741 742 717 return (unative_t) rc; 743 718 } … … 760 735 void *size_ptr) 761 736 { 762 /* Avoid other functions to mess with sysinfo 763 while we are reading it */ 764 ipl_t ipl = interrupts_disable(); 765 spinlock_lock(&sysinfo_lock); 766 767 /* Get the item. 768 769 N.B.: There is no need to free any potential generated 770 binary data since we request a dry run */ 737 int rc; 738 739 /* 740 * Get the item. 741 * 742 * N.B.: There is no need to free any potential generated binary data 743 * since we request a dry run. 744 */ 771 745 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, true); 772 int rc;773 746 774 747 /* Only the size of constant or generated binary data is considered */ … … 779 752 rc = EINVAL; 780 753 781 spinlock_unlock(&sysinfo_lock);782 interrupts_restore(ipl);783 784 754 return (unative_t) rc; 785 755 } … … 807 777 void *buffer_ptr, size_t buffer_size) 808 778 { 809 /* Avoid other functions to mess with sysinfo 810 while we are reading it */ 811 ipl_t ipl = interrupts_disable(); 812 spinlock_lock(&sysinfo_lock); 779 int rc; 813 780 814 781 /* Get the item */ 815 782 sysinfo_return_t ret = sysinfo_get_item_uspace(path_ptr, path_size, false); 816 int rc; 817 783 818 784 /* Only constant or generated binary data is considered */ 819 785 if ((ret.tag == SYSINFO_VAL_DATA) || (ret.tag == SYSINFO_VAL_FUNCTION_DATA)) { … … 831 797 free(ret.data.data); 832 798 833 spinlock_unlock(&sysinfo_lock);834 interrupts_restore(ipl);835 836 799 return (unative_t) rc; 837 800 } -
kernel/generic/src/time/clock.c
r6c39a907 r25a76ab8 140 140 /* Account lost ticks to CPU usage */ 141 141 if (CPU->idle) { 142 ASSERT(missed_clock_ticks == 0); 143 CPU->idle_ticks++; 142 CPU->idle_ticks += missed_clock_ticks + 1; 144 143 } else { 145 144 CPU->busy_ticks += missed_clock_ticks + 1;
Note:
See TracChangeset
for help on using the changeset viewer.