Changes in / [1720cf9:571addd] in mainline
- Files:
-
- 1 added
- 35 edited
Legend:
- Unmodified
- Added
- Removed
-
HelenOS.config
r1720cf9 r571addd 498 498 @ "1152x720" 499 499 @ "1152x864" 500 @ "1280x720" 501 @ "1280x800" 500 502 @ "1280x960" 501 503 @ "1280x1024" … … 544 546 ! CONFIG_BAREBONE (n/y) 545 547 548 % Line debugging information 549 ! [CONFIG_STRIP_BINARIES!=y] CONFIG_LINE_DEBUG (n/y) -
boot/Makefile.build
r1720cf9 r571addd 61 61 GCC_CFLAGS += -Werror 62 62 ICC_CFLAGS += -Werror 63 endif 64 65 ifeq ($(CONFIG_LINE_DEBUG),y) 66 GCC_CFLAGS += -g 67 ICC_CFLAGS += -g 68 SUNCC_CFLAGS += -g 69 CLANG_CFLAGS += -g 63 70 endif 64 71 -
boot/arch/arm32/Makefile.inc
r1720cf9 r571addd 54 54 $(COMPS_C) \ 55 55 genarch/src/division.c \ 56 generic/src/memstr.c \ 56 57 generic/src/printf_core.c \ 57 58 generic/src/vprintf.c \ -
boot/arch/arm32/src/asm.S
r1720cf9 r571addd 35 35 .global boot_stack 36 36 .global halt 37 .global memcpy38 37 .global jump_to_kernel 39 38 … … 55 54 b halt 56 55 57 memcpy:58 add r3, r1, #359 bic r3, r3, #360 cmp r1, r361 stmdb sp!, {r4, r5, lr}62 mov r5, r063 beq 4f64 65 1:66 cmp r2, #067 movne ip, #068 beq 3f69 70 2:71 ldrb r3, [ip, r1]72 strb r3, [ip, r0]73 add ip, ip, #174 cmp ip, r275 bne 2b76 77 3:78 mov r0, r579 ldmia sp!, {r4, r5, pc}80 81 4:82 add r3, r0, #383 bic r3, r3, #384 cmp r0, r385 bne 1b86 movs r4, r2, lsr #287 moveq lr, r488 beq 6f89 mov lr, #090 mov ip, lr91 92 5:93 ldr r3, [ip, r1]94 add lr, lr, #195 cmp lr, r496 str r3, [ip, r0]97 add ip, ip, #498 bne 5b99 100 6:101 ands r4, r2, #3102 beq 3b103 mov r3, lr, lsl #2104 add r0, r3, r0105 add ip, r3, r1106 mov r2, #0107 108 7:109 ldrb r3, [r2, ip]110 strb r3, [r2, r0]111 add r2, r2, #1112 cmp r2, r4113 bne 7b114 b 3b115 116 56 jump_to_kernel: 117 57 # -
boot/arch/ia64/Makefile.inc
r1720cf9 r571addd 49 49 genarch/src/division.c \ 50 50 generic/src/balloc.c \ 51 generic/src/memstr.c \ 51 52 generic/src/printf_core.c \ 52 53 generic/src/vprintf.c \ -
boot/arch/ia64/src/asm.S
r1720cf9 r571addd 1 1 # 2 2 # Copyright (c) 2006 Martin Decky 3 # Copyright (c) 2006 Jakub Jermar 3 # Copyright (c) 2006 Jakub Jermar 4 4 # All rights reserved. 5 5 # … … 39 39 br halt 40 40 41 memcpy:42 alloc loc0 = ar.pfs, 3, 1, 0, 043 44 adds r14 = 7, in145 mov r2 = ar.lc46 mov r8 = in0 ;;47 and r14 = -8, r14 ;;48 cmp.ne p6, p7 = r14, in149 (p7) br.cond.dpnt 3f ;;50 0:51 cmp.ne p6, p7 = 0, in252 (p7) br.cond.dpnt 2f ;;53 (p6) adds r14 = -1, in254 (p6) mov r16 = r055 (p6) mov r17 = r0 ;;56 (p6) mov ar.lc = r1457 1:58 add r14 = r16, in159 add r15 = r16, in060 adds r17 = 1, r17 ;;61 ld1 r14 = [r14]62 mov r16 = r17 ;;63 st1 [r15] = r1464 br.cloop.sptk.few 1b ;;65 2:66 mov ar.lc = r267 mov ar.pfs = loc068 br.ret.sptk.many rp69 3:70 adds r14 = 7, in0 ;;71 and r14 = -8, r14 ;;72 cmp.eq p6, p7 = r14, in073 (p7) br.cond.dptk 0b74 shr.u r18 = in2, 3 ;;75 cmp.ne p6, p7 = 0, r1876 (p7) br.cond.dpnt 5f ;;77 (p6) adds r14 = -1, r1878 (p6) mov r16 = r079 (p6) mov r17 = r0 ;;80 (p6) mov ar.lc = r1481 4:82 shladd r14 = r16, 3, r083 adds r16 = 1, r17 ;;84 add r15 = in1, r1485 add r14 = in0, r1486 mov r17 = r16 ;;87 ld8 r15 = [r15] ;;88 st8 [r14] = r1589 br.cloop.sptk.few 4b90 5:91 and r15 = 7, in292 shladd r14 = r18, 3, r093 mov r16 = r094 mov r18 = r0 ;;95 cmp.eq p6, p7 = 0, r1596 add in0 = r14, in097 adds r15 = -1, r1598 add r17 = r14, in199 (p6) br.cond.dpnt 2b ;;100 mov ar.lc = r15101 6:102 add r14 = r16, r17103 add r15 = r16, in0104 adds r16 = 1, r18 ;;105 ld1 r14 = [r14]106 mov r18 = r16 ;;107 st1 [r15] = r14108 br.cloop.sptk.few 6b ;;109 mov ar.lc = r2110 mov ar.pfs = loc0111 br.ret.sptk.many rp112 113 41 jump_to_kernel: 114 42 alloc loc0 = ar.pfs, 1, 1, 0, 0 -
boot/arch/mips32/Makefile.inc
r1720cf9 r571addd 61 61 genarch/src/division.c \ 62 62 genarch/src/multiplication.c \ 63 generic/src/memstr.c \ 63 64 generic/src/printf_core.c \ 64 65 generic/src/vprintf.c \ -
boot/arch/mips32/src/asm.S
r1720cf9 r571addd 36 36 .global start 37 37 .global halt 38 .global memcpy39 38 .global jump_to_kernel 40 39 … … 127 126 nop 128 127 129 memcpy:130 addiu $v0, $a1, 3131 li $v1, -4132 and $v0, $v0, $v1133 beq $a1, $v0, 3f134 move $t0, $a0135 move $t2, $a0136 137 0:138 beq $a2, $zero, 2f139 move $a3, $zero140 141 1:142 addu $v0, $a1, $a3143 lbu $a0, 0($v0)144 addu $v1, $t0, $a3145 addiu $a3, $a3, 1146 bne $a3, $a2, 1b147 sb $a0, 0($v1)148 149 2:150 jr $ra151 move $v0, $t2152 153 3:154 addiu $v0, $a0, 3155 and $v0, $v0, $v1156 bne $a0, $v0, 0b157 srl $t1, $a2, 2158 159 beq $t1, $zero, 5f160 move $a3, $zero161 162 move $a3, $zero163 move $a0, $zero164 165 4:166 addu $v0, $a1, $a0167 lw $v1, 0($v0)168 addiu $a3, $a3, 1169 addu $v0, $t0, $a0170 sw $v1, 0($v0)171 bne $a3, $t1, 4b172 addiu $a0, $a0, 4173 174 5:175 andi $a2, $a2, 0x3176 beq $a2, $zero, 2b177 nop178 179 sll $v0, $a3, 2180 addu $t1, $v0, $t0181 move $a3, $zero182 addu $t0, $v0, $a1183 184 6:185 addu $v0, $t0, $a3186 lbu $a0, 0($v0)187 addu $v1, $t1, $a3188 addiu $a3, $a3, 1189 bne $a3, $a2, 6b190 sb $a0, 0($v1)191 192 jr $ra193 move $v0, $t2194 195 128 jump_to_kernel: 196 129 # -
boot/arch/ppc32/Makefile.inc
r1720cf9 r571addd 56 56 genarch/src/multiplication.c \ 57 57 generic/src/balloc.c \ 58 generic/src/memstr.c \ 58 59 generic/src/printf_core.c \ 59 60 generic/src/vprintf.c \ -
boot/arch/ppc32/src/asm.S
r1720cf9 r571addd 60 60 .global start 61 61 .global halt 62 .global memcpy63 62 .global jump_to_kernel 64 63 .global real_mode … … 78 77 halt: 79 78 b halt 80 81 memcpy:82 srwi. r7, r5, 383 addi r6, r3, -484 addi r4, r4, -485 beq 2f86 87 andi. r0, r6, 388 mtctr r789 bne 5f90 91 1:92 lwz r7, 4(r4)93 lwzu r8, 8(r4)94 stw r7, 4(r6)95 stwu r8, 8(r6)96 bdnz 1b97 98 andi. r5, r5, 799 100 2:101 cmplwi 0, r5, 4102 blt 3f103 104 lwzu r0, 4(r4)105 addi r5, r5, -4106 stwu r0, 4(r6)107 108 3:109 cmpwi 0, r5, 0110 beqlr111 mtctr r5112 addi r4, r4, 3113 addi r6, r6, 3114 115 4:116 lbzu r0, 1(r4)117 stbu r0, 1(r6)118 bdnz 4b119 blr120 121 5:122 subfic r0, r0, 4123 mtctr r0124 125 6:126 lbz r7, 4(r4)127 addi r4, r4, 1128 stb r7, 4(r6)129 addi r6, r6, 1130 bdnz 6b131 subf r5, r0, r5132 rlwinm. r7, r5, 32-3, 3, 31133 beq 2b134 mtctr r7135 b 1b136 79 137 80 jump_to_kernel: -
boot/arch/sparc64/Makefile.inc
r1720cf9 r571addd 54 54 genarch/src/ofw_tree.c \ 55 55 generic/src/balloc.c \ 56 generic/src/memstr.c \ 56 57 generic/src/printf_core.c \ 57 58 generic/src/vprintf.c \ -
boot/arch/sparc64/src/asm.S
r1720cf9 r571addd 42 42 .global start 43 43 .global halt 44 .global memcpy45 44 .global jump_to_kernel 46 45 … … 98 97 ba %xcc, halt 99 98 nop 100 101 memcpy:102 ! Save dst103 104 mov %o0, %o3105 add %o1, 7, %g1106 and %g1, -8, %g1107 cmp %o1, %g1108 be,pn %xcc, 3f109 add %o0, 7, %g1110 mov 0, %g3111 112 0:113 brz,pn %o2, 2f114 mov 0, %g2115 116 1:117 ldub [%g3 + %o1], %g1118 add %g2, 1, %g2119 cmp %o2, %g2120 stb %g1, [%g3 + %o0]121 bne,pt %xcc, 1b122 mov %g2, %g3123 124 2:125 ! Exit point126 127 jmp %o7 + 8128 mov %o3, %o0129 130 3:131 and %g1, -8, %g1132 cmp %o0, %g1133 bne,pt %xcc, 0b134 mov 0, %g3135 srlx %o2, 3, %g4136 brz,pn %g4, 5f137 mov 0, %g5138 139 4:140 sllx %g3, 3, %g2141 add %g5, 1, %g3142 ldx [%o1 + %g2], %g1143 mov %g3, %g5144 cmp %g4, %g3145 bne,pt %xcc, 4b146 stx %g1, [%o0 + %g2]147 148 5:149 and %o2, 7, %o2150 brz,pn %o2, 2b151 sllx %g4, 3, %g1152 mov 0, %g2153 add %g1, %o0, %o0154 add %g1, %o1, %g4155 mov 0, %g3156 157 6:158 ldub [%g2 + %g4], %g1159 stb %g1, [%g2 + %o0]160 add %g3, 1, %g2161 cmp %o2, %g2162 bne,pt %xcc, 6b163 mov %g2, %g3164 165 ! Exit point166 167 jmp %o7 + 8168 mov %o3, %o0169 99 170 100 jump_to_kernel: -
kernel/Makefile
r1720cf9 r571addd 120 120 ifeq ($(CONFIG_LTO),y) 121 121 GCC_CFLAGS += -flto 122 endif 123 124 ifeq ($(CONFIG_LINE_DEBUG),y) 125 GCC_CFLAGS += -g 126 ICC_CFLAGS += -g 127 SUNCC_CFLAGS += -g 128 CLANG_CFLAGS += -g 122 129 endif 123 130 … … 401 408 402 409 $(DISASM): $(RAW) 410 ifeq ($(CONFIG_LINE_DEBUG),y) 411 $(OBJDUMP) -d -S $< > $@ 412 else 403 413 $(OBJDUMP) -d $< > $@ 414 endif 404 415 405 416 $(RAW): $(LINK) $(ARCH_OBJECTS) $(GENARCH_OBJECTS) $(GENERIC_OBJECTS) $(SYMTAB_OBJECTS) -
kernel/arch/abs32le/src/debug/stacktrace.c
r1720cf9 r571addd 37 37 #include <typedefs.h> 38 38 39 bool kernel_ frame_pointer_validate(uintptr_t fp)39 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 40 40 { 41 41 return true; 42 42 } 43 43 44 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)44 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 45 45 { 46 46 return true; 47 47 } 48 48 49 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)49 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 50 50 { 51 51 return true; 52 52 } 53 53 54 bool uspace_ frame_pointer_validate(uintptr_t fp)54 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 55 55 { 56 56 return true; 57 57 } 58 58 59 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)59 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 60 60 { 61 61 return true; 62 62 } 63 63 64 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)64 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 65 65 { 66 66 return true; -
kernel/arch/amd64/_link.ld.in
r1720cf9 r571addd 53 53 } 54 54 55 #ifdef CONFIG_LINE_DEBUG 56 .comment 0 : { *(.comment); } 57 .debug_abbrev 0 : { *(.debug_abbrev); } 58 .debug_aranges 0 : { *(.debug_aranges); } 59 .debug_info 0 : { *(.debug_info); } 60 .debug_line 0 : { *(.debug_line); } 61 .debug_loc 0 : { *(.debug_loc); } 62 .debug_pubnames 0 : { *(.debug_pubnames); } 63 .debug_pubtypes 0 : { *(.debug_pubtypes); } 64 .debug_ranges 0 : { *(.debug_ranges); } 65 .debug_str 0 : { *(.debug_str); } 66 #endif 67 55 68 /DISCARD/ : { 56 69 *(*); -
kernel/arch/amd64/src/debug/stacktrace.c
r1720cf9 r571addd 40 40 #define FRAME_OFFSET_RA 1 41 41 42 bool kernel_ frame_pointer_validate(uintptr_t fp)42 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 43 43 { 44 return fp != 0;44 return ctx->fp != 0; 45 45 } 46 46 47 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)47 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 48 48 { 49 uint64_t *stack = (void *) fp;49 uint64_t *stack = (void *) ctx->fp; 50 50 *prev = stack[FRAME_OFFSET_FP_PREV]; 51 51 … … 53 53 } 54 54 55 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)55 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 56 56 { 57 uint64_t *stack = (void *) fp;57 uint64_t *stack = (void *) ctx->fp; 58 58 *ra = stack[FRAME_OFFSET_RA]; 59 59 … … 61 61 } 62 62 63 bool uspace_ frame_pointer_validate(uintptr_t fp)63 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 64 64 { 65 return fp != 0;65 return ctx->fp != 0; 66 66 } 67 67 68 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)68 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 69 69 { 70 70 return !copy_from_uspace((void *) prev, 71 (uint64_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));71 (uint64_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev)); 72 72 } 73 73 74 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)74 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 75 75 { 76 return !copy_from_uspace((void *) ra, (uint64_t *) fp + FRAME_OFFSET_RA,77 sizeof(*ra));76 return !copy_from_uspace((void *) ra, 77 (uint64_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra)); 78 78 } 79 79 -
kernel/arch/arm32/src/debug/stacktrace.c
r1720cf9 r571addd 40 40 #define FRAME_OFFSET_RA -1 41 41 42 bool kernel_ frame_pointer_validate(uintptr_t fp)42 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 43 43 { 44 return fp != 0;44 return ctx->fp != 0; 45 45 } 46 46 47 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)47 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 48 48 { 49 uint32_t *stack = (void *) fp;49 uint32_t *stack = (void *) ctx->fp; 50 50 51 51 *prev = stack[FRAME_OFFSET_FP_PREV]; … … 53 53 } 54 54 55 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)55 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 56 56 { 57 uint32_t *stack = (void *) fp;57 uint32_t *stack = (void *) ctx->fp; 58 58 59 59 *ra = stack[FRAME_OFFSET_RA]; … … 61 61 } 62 62 63 bool uspace_ frame_pointer_validate(uintptr_t fp)63 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 64 64 { 65 return fp != 0;65 return ctx->fp != 0; 66 66 } 67 67 68 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)68 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 69 69 { 70 70 return !copy_from_uspace((void *) prev, 71 (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));71 (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev)); 72 72 } 73 73 74 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)74 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 75 75 { 76 return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,77 sizeof(*ra));76 return !copy_from_uspace((void *) ra, 77 (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra)); 78 78 } 79 79 -
kernel/arch/ia32/src/debug/stacktrace.c
r1720cf9 r571addd 40 40 #define FRAME_OFFSET_RA 1 41 41 42 bool kernel_ frame_pointer_validate(uintptr_t fp)42 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 43 43 { 44 return fp != 0;44 return ctx->fp != 0; 45 45 } 46 46 47 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)47 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 48 48 { 49 uint32_t *stack = (void *) fp;49 uint32_t *stack = (void *) ctx->fp; 50 50 *prev = stack[FRAME_OFFSET_FP_PREV]; 51 51 return true; 52 52 } 53 53 54 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)54 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 55 55 { 56 uint32_t *stack = (void *) fp;56 uint32_t *stack = (void *) ctx->fp; 57 57 *ra = stack[FRAME_OFFSET_RA]; 58 58 return true; 59 59 } 60 60 61 bool uspace_ frame_pointer_validate(uintptr_t fp)61 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 62 62 { 63 return fp != 0;63 return ctx->fp != 0; 64 64 } 65 65 66 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)66 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 67 67 { 68 68 return !copy_from_uspace((void *) prev, 69 (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));69 (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev)); 70 70 } 71 71 72 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)72 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 73 73 { 74 return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,75 sizeof(*ra));74 return !copy_from_uspace((void *) ra, 75 (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra)); 76 76 } 77 77 -
kernel/arch/ia32/src/mm/frame.c
r1720cf9 r571addd 131 131 if (last_frame < ALIGN_UP(new_base + new_size, FRAME_SIZE)) 132 132 last_frame = ALIGN_UP(new_base + new_size, FRAME_SIZE); 133 } 134 135 if (e820table[i].type == MEMMAP_MEMORY_RESERVED) { 133 } else if ((e820table[i].type == MEMMAP_MEMORY_ACPI) || 134 (e820table[i].type == MEMMAP_MEMORY_NVS)) { 135 /* To be safe, make the firmware zone possibly larger */ 136 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); 137 uint64_t new_size = ALIGN_UP(size + (base - new_base), 138 FRAME_SIZE); 139 140 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 141 ZONE_FIRMWARE); 142 } else { 136 143 /* To be safe, make the reserved zone possibly larger */ 137 144 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE); … … 141 148 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0, 142 149 ZONE_RESERVED); 143 }144 145 if (e820table[i].type == MEMMAP_MEMORY_ACPI) {146 /* To be safe, make the firmware zone possibly larger */147 uint64_t new_base = ALIGN_DOWN(base, FRAME_SIZE);148 uint64_t new_size = ALIGN_UP(size + (base - new_base),149 FRAME_SIZE);150 151 zone_create(ADDR2PFN(new_base), SIZE2FRAMES(new_size), 0,152 ZONE_FIRMWARE);153 150 } 154 151 } … … 203 200 #ifdef CONFIG_SMP 204 201 /* Reserve AP real mode bootstrap memory */ 205 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 202 frame_mark_unavailable(AP_BOOT_OFFSET >> FRAME_WIDTH, 206 203 (hardcoded_unmapped_ktext_size + 207 204 hardcoded_unmapped_kdata_size) >> FRAME_WIDTH); -
kernel/arch/ia64/src/debug/stacktrace.c
r1720cf9 r571addd 37 37 #include <typedefs.h> 38 38 39 bool kernel_ frame_pointer_validate(uintptr_t fp)39 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 40 40 { 41 41 return false; 42 42 } 43 43 44 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)44 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 45 45 { 46 46 return false; 47 47 } 48 48 49 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)49 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 50 50 { 51 51 return false; 52 52 } 53 53 54 bool uspace_ frame_pointer_validate(uintptr_t fp)54 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 55 55 { 56 56 return false; 57 57 } 58 58 59 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)59 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 60 60 { 61 61 return false; 62 62 } 63 63 64 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)64 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 65 65 { 66 66 return false; -
kernel/arch/mips32/include/debugger.h
r1720cf9 r571addd 68 68 extern bpinfo_t breakpoints[BKPOINTS_MAX]; 69 69 70 extern bool is_jump(unative_t); 71 70 72 extern void debugger_init(void); 71 73 extern void debugger_bpoint(istate_t *); -
kernel/arch/mips32/src/debug/stacktrace.c
r1720cf9 r571addd 36 36 #include <syscall/copy.h> 37 37 #include <typedefs.h> 38 39 bool kernel_frame_pointer_validate(uintptr_t fp) 38 #include <arch/debugger.h> 39 #include <print.h> 40 41 #define R0 0U 42 #define SP 29U 43 #define RA 31U 44 45 #define OP_SHIFT 26 46 #define RS_SHIFT 21 47 #define RT_SHIFT 16 48 #define RD_SHIFT 11 49 50 #define HINT_SHIFT 6 51 #define BASE_SHIFT RS_SHIFT 52 #define IMM_SHIFT 0 53 #define OFFSET_SHIFT IMM_SHIFT 54 55 #define RS_MASK (0x1f << RS_SHIFT) 56 #define RT_MASK (0x1f << RT_SHIFT) 57 #define RD_MASK (0x1f << RD_SHIFT) 58 #define HINT_MASK (0x1f << HINT_SHIFT) 59 #define BASE_MASK RS_MASK 60 #define IMM_MASK (0xffff << IMM_SHIFT) 61 #define OFFSET_MASK IMM_MASK 62 63 #define RS_GET(inst) (((inst) & RS_MASK) >> RS_SHIFT) 64 #define RD_GET(inst) (((inst) & RD_MASK) >> RD_SHIFT) 65 #define IMM_GET(inst) (int16_t)(((inst) & IMM_MASK) >> IMM_SHIFT) 66 #define BASE_GET(inst) RS_GET(inst) 67 #define OFFSET_GET(inst) IMM_GET(inst) 68 69 #define ADDU_R_SP_R0_TEMPL \ 70 ((0x0 << OP_SHIFT) | (SP << RS_SHIFT) | (R0 << RT_SHIFT) | 0x21) 71 #define ADDU_SP_R_R0_TEMPL \ 72 ((0x0 << OP_SHIFT) | (SP << RD_SHIFT) | (R0 << RT_SHIFT) | 0x21) 73 #define ADDI_SP_SP_IMM_TEMPL \ 74 ((0x8 << OP_SHIFT) | (SP << RS_SHIFT) | (SP << RT_SHIFT)) 75 #define ADDIU_SP_SP_IMM_TEMPL \ 76 ((0x9 << OP_SHIFT) | (SP << RS_SHIFT) | (SP << RT_SHIFT)) 77 #define JR_RA_TEMPL \ 78 ((0x0 << OP_SHIFT) | (RA << RS_SHIFT) | (0x0 << HINT_SHIFT) | 0x8) 79 #define SW_RA_TEMPL \ 80 ((0x2b << OP_SHIFT) | (RA << RT_SHIFT)) 81 82 #define IS_ADDU_R_SP_R0(inst) \ 83 (((inst) & ~RD_MASK) == ADDU_R_SP_R0_TEMPL) 84 #define IS_ADDU_SP_R_R0(inst) \ 85 (((inst) & ~RS_MASK) == ADDU_SP_R_R0_TEMPL) 86 #define IS_ADDI_SP_SP_IMM(inst) \ 87 (((inst) & ~IMM_MASK) == ADDI_SP_SP_IMM_TEMPL) 88 #define IS_ADDIU_SP_SP_IMM(inst) \ 89 (((inst) & ~IMM_MASK) == ADDIU_SP_SP_IMM_TEMPL) 90 #define IS_JR_RA(inst) \ 91 (((inst) & ~HINT_MASK) == JR_RA_TEMPL) 92 #define IS_SW_RA(inst) \ 93 (((inst) & ~(BASE_MASK | OFFSET_MASK)) == SW_RA_TEMPL) 94 95 extern char ktext_start; 96 extern char ktext_end; 97 98 static bool 99 scan(stack_trace_context_t *ctx, uintptr_t *prev_fp, uintptr_t *prev_ra) 100 { 101 uint32_t *inst = (void *) ctx->pc; 102 bool has_fp = false; 103 size_t frame_size; 104 unsigned int fp = SP; 105 106 do { 107 inst--; 108 #if 0 109 /* 110 * This is one of the situations in which the theory (ABI) does 111 * not meet the practice (GCC). GCC simply does not place the 112 * JR $ra instruction as dictated by the ABI, rendering the 113 * official stack tracing algorithm somewhat unapplicable. 114 */ 115 116 if (IS_ADDU_R_SP_R0(*inst)) { 117 uint32_t *cur; 118 fp = RD_GET(*inst); 119 /* 120 * We have a candidate for frame pointer. 121 */ 122 123 /* Seek to the end of this function. */ 124 for (cur = inst + 1; !IS_JR_RA(*cur); cur++) 125 ; 126 /* Scan the last basic block */ 127 for (cur--; !is_jump(*(cur - 1)); cur--) { 128 if (IS_ADDU_SP_R_R0(*cur) && 129 (fp == RS_GET(*cur))) { 130 has_fp = true; 131 } 132 } 133 continue; 134 } 135 136 if (IS_JR_RA(*inst)) { 137 if (!ctx->istate) 138 return false; 139 /* 140 * No stack frame has been allocated yet. 141 * Use the values stored in istate. 142 */ 143 if (prev_fp) 144 *prev_fp = ctx->istate->sp; 145 if (prev_ra) 146 *prev_ra = ctx->istate->ra - 8; 147 ctx->istate = NULL; 148 return true; 149 } 150 #endif 151 152 } while ((!IS_ADDIU_SP_SP_IMM(*inst) && !IS_ADDI_SP_SP_IMM(*inst)) || 153 (IMM_GET(*inst) >= 0)); 154 155 /* 156 * We are at the instruction which allocates the space for the current 157 * stack frame. 158 */ 159 frame_size = -IMM_GET(*inst); 160 if (prev_fp) 161 *prev_fp = ctx->fp + frame_size; 162 163 /* 164 * Scan the first basic block for the occurrence of 165 * SW $ra, OFFSET($base). 166 */ 167 for (inst++; !is_jump(*(inst - 1)) && (uintptr_t) inst < ctx->pc; 168 inst++) { 169 if (IS_SW_RA(*inst)) { 170 unsigned int base = BASE_GET(*inst); 171 int16_t offset = OFFSET_GET(*inst); 172 173 if (base == SP || (has_fp && base == fp)) { 174 uint32_t *addr = (void *) (ctx->fp + offset); 175 176 if (offset % 4 != 0) 177 return false; 178 /* cannot store below current stack pointer */ 179 if (offset < 0) 180 return false; 181 /* too big offsets are suspicious */ 182 if (offset > 32 * 4) 183 return false; 184 185 if (prev_ra) 186 *prev_ra = *addr; 187 return true; 188 } 189 } 190 } 191 192 /* 193 * The first basic block does not save the return address or saves it 194 * after ctx->pc, which means that the correct value is in istate. 195 */ 196 if (prev_ra) { 197 if (!ctx->istate) 198 return false; 199 *prev_ra = ctx->istate->ra - 8; 200 ctx->istate = NULL; 201 } 202 return true; 203 } 204 205 206 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 207 { 208 return !((ctx->fp == 0) || ((ctx->fp % 8) != 0) || 209 (ctx->pc % 4 != 0) || (ctx->pc < (uintptr_t) &ktext_start) || 210 (ctx->pc >= (uintptr_t) &ktext_end)); 211 } 212 213 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 214 { 215 return scan(ctx, prev, NULL); 216 } 217 218 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 219 { 220 return scan(ctx, NULL, ra); 221 } 222 223 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 40 224 { 41 225 return false; 42 226 } 43 227 44 bool kernel_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)228 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 45 229 { 46 230 return false; 47 231 } 48 232 49 bool kernel_return_address_get(uintptr_t fp, uintptr_t *ra)233 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 50 234 { 51 235 return false; 52 236 } 53 237 54 bool uspace_frame_pointer_validate(uintptr_t fp)55 {56 return false;57 }58 59 bool uspace_frame_pointer_prev(uintptr_t fp, uintptr_t *prev)60 {61 return false;62 }63 64 bool uspace_return_address_get(uintptr_t fp, uintptr_t *ra)65 {66 return false;67 }68 69 238 /** @} 70 239 */ -
kernel/arch/mips32/src/debug/stacktrace_asm.S
r1720cf9 r571addd 37 37 frame_pointer_get: 38 38 j $ra 39 xor $v0, $v039 move $v0, $sp 40 40 41 41 program_counter_get: 42 42 j $ra 43 xor $v0, $v043 move $v0, $ra -
kernel/arch/mips32/src/debugger.c
r1720cf9 r571addd 134 134 * 135 135 */ 136 staticbool is_jump(unative_t instr)136 bool is_jump(unative_t instr) 137 137 { 138 138 unsigned int i; -
kernel/arch/ppc32/src/debug/stacktrace.c
r1720cf9 r571addd 40 40 #define FRAME_OFFSET_RA 1 41 41 42 bool kernel_ frame_pointer_validate(uintptr_t fp)42 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 43 43 { 44 return fp != 0;44 return ctx->fp != 0; 45 45 } 46 46 47 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)47 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 48 48 { 49 uint32_t *stack = (void *) fp;49 uint32_t *stack = (void *) ctx->fp; 50 50 *prev = stack[FRAME_OFFSET_FP_PREV]; 51 51 return true; 52 52 } 53 53 54 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)54 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 55 55 { 56 uint32_t *stack = (void *) fp;56 uint32_t *stack = (void *) ctx->fp; 57 57 *ra = stack[FRAME_OFFSET_RA]; 58 58 return true; 59 59 } 60 60 61 bool uspace_ frame_pointer_validate(uintptr_t fp)61 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 62 62 { 63 return fp != 0;63 return ctx->fp != 0; 64 64 } 65 65 66 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)66 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 67 67 { 68 68 return !copy_from_uspace((void *) prev, 69 (uint32_t *) fp + FRAME_OFFSET_FP_PREV, sizeof(*prev));69 (uint32_t *) ctx->fp + FRAME_OFFSET_FP_PREV, sizeof(*prev)); 70 70 } 71 71 72 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)72 bool uspace_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 73 73 { 74 return !copy_from_uspace((void *) ra, (uint32_t *) fp + FRAME_OFFSET_RA,75 sizeof(*ra));74 return !copy_from_uspace((void *) ra, 75 (uint32_t *) ctx->fp + FRAME_OFFSET_RA, sizeof(*ra)); 76 76 } 77 77 -
kernel/arch/sparc64/src/debug/stacktrace.c
r1720cf9 r571addd 50 50 extern void alloc_window_and_flush(void); 51 51 52 bool kernel_ frame_pointer_validate(uintptr_t fp)52 bool kernel_stack_trace_context_validate(stack_trace_context_t *ctx) 53 53 { 54 54 uintptr_t kstack; … … 63 63 kstack -= PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE; 64 64 65 if (THREAD && ( fp == kstack))65 if (THREAD && (ctx->fp == kstack)) 66 66 return false; 67 return fp != 0;67 return ctx->fp != 0; 68 68 } 69 69 70 bool kernel_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)70 bool kernel_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 71 71 { 72 uint64_t *stack = (void *) fp;72 uint64_t *stack = (void *) ctx->fp; 73 73 alloc_window_and_flush(); 74 74 *prev = stack[FRAME_OFFSET_FP_PREV] + STACK_BIAS; … … 76 76 } 77 77 78 bool kernel_return_address_get( uintptr_t fp, uintptr_t *ra)78 bool kernel_return_address_get(stack_trace_context_t *ctx, uintptr_t *ra) 79 79 { 80 uint64_t *stack = (void *) fp;80 uint64_t *stack = (void *) ctx->fp; 81 81 alloc_window_and_flush(); 82 82 *ra = stack[FRAME_OFFSET_RA]; … … 84 84 } 85 85 86 bool uspace_ frame_pointer_validate(uintptr_t fp)86 bool uspace_stack_trace_context_validate(stack_trace_context_t *ctx) 87 87 { 88 88 return false; 89 89 } 90 90 91 bool uspace_frame_pointer_prev( uintptr_t fp, uintptr_t *prev)91 bool uspace_frame_pointer_prev(stack_trace_context_t *ctx, uintptr_t *prev) 92 92 { 93 93 return false; 94 94 } 95 95 96 bool uspace_return_address_get( uintptr_t fp, uintptr_t *ra)96 bool uspace_return_address_get(stack_trace_context_t *ctx , uintptr_t *ra) 97 97 { 98 98 return false; -
kernel/generic/include/macros.h
r1720cf9 r571addd 47 47 * @param s2 Start address of the second interval. 48 48 * @param sz2 Size of the second interval. 49 * 49 50 */ 50 NO_TRACE static inline int overlaps(uint ptr_t s1, size_t sz1, uintptr_t s2,51 size_t sz2)51 NO_TRACE static inline int overlaps(uint64_t s1, uint64_t sz1, uint64_t s2, 52 uint64_t sz2) 52 53 { 53 uint ptr_t e1 = s1 + sz1;54 uint ptr_t e2 = s2 + sz2;54 uint64_t e1 = s1 + sz1; 55 uint64_t e2 = s2 + sz2; 55 56 56 57 return ((s1 < e2) && (s2 < e1)); 58 } 59 60 /** Return true if the second interval is within the first interval. 61 * 62 * @param s1 Start address of the first interval. 63 * @param sz1 Size of the first interval. 64 * @param s2 Start address of the second interval. 65 * @param sz2 Size of the second interval. 66 * 67 */ 68 NO_TRACE static inline int iswithin(uint64_t s1, uint64_t sz1, uint64_t s2, 69 uint64_t sz2) 70 { 71 uint64_t e1 = s1 + sz1; 72 uint64_t e2 = s2 + sz2; 73 74 return ((s1 <= s2) && (e1 >= e2)); 57 75 } 58 76 … … 74 92 75 93 /* Compute overlapping of physical addresses */ 76 #define PA_ overlaps(x, szx, y, szy) \94 #define PA_OVERLAPS(x, szx, y, szy) \ 77 95 overlaps(KA2PA((x)), (szx), KA2PA((y)), (szy)) 78 96 -
kernel/generic/include/stacktrace.h
r1720cf9 r571addd 42 42 43 43 typedef struct { 44 bool (* frame_pointer_validate)(uintptr_t); 45 bool (* frame_pointer_prev)(uintptr_t, uintptr_t *); 46 bool (* return_address_get)(uintptr_t, uintptr_t *); 44 uintptr_t fp; 45 uintptr_t pc; 46 struct istate *istate; 47 } stack_trace_context_t; 48 49 typedef struct { 50 bool (* stack_trace_context_validate)(stack_trace_context_t *); 51 bool (* frame_pointer_prev)(stack_trace_context_t *, uintptr_t *); 52 bool (* return_address_get)(stack_trace_context_t *, uintptr_t *); 47 53 bool (* symbol_resolve)(uintptr_t, const char **, uintptr_t *); 48 54 } stack_trace_ops_t; … … 53 59 extern void stack_trace(void); 54 60 extern void stack_trace_istate(struct istate *); 55 extern void stack_trace_ fp_pc(stack_trace_ops_t *, uintptr_t, uintptr_t);61 extern void stack_trace_ctx(stack_trace_ops_t *, stack_trace_context_t *); 56 62 57 63 /* … … 61 67 extern uintptr_t program_counter_get(void); 62 68 63 extern bool kernel_ frame_pointer_validate(uintptr_t);64 extern bool kernel_frame_pointer_prev( uintptr_t, uintptr_t *);65 extern bool kernel_return_address_get( uintptr_t, uintptr_t *);69 extern bool kernel_stack_trace_context_validate(stack_trace_context_t *); 70 extern bool kernel_frame_pointer_prev(stack_trace_context_t *, uintptr_t *); 71 extern bool kernel_return_address_get(stack_trace_context_t *, uintptr_t *); 66 72 67 extern bool uspace_ frame_pointer_validate(uintptr_t);68 extern bool uspace_frame_pointer_prev( uintptr_t, uintptr_t *);69 extern bool uspace_return_address_get( uintptr_t, uintptr_t *);73 extern bool uspace_stack_trace_context_validate(stack_trace_context_t *); 74 extern bool uspace_frame_pointer_prev(stack_trace_context_t *, uintptr_t *); 75 extern bool uspace_return_address_get(stack_trace_context_t *, uintptr_t *); 70 76 71 77 #endif -
kernel/generic/src/debug/stacktrace.c
r1720cf9 r571addd 27 27 */ 28 28 29 /** @addtogroup genericdebug 29 /** @addtogroup genericdebug 30 30 * @{ 31 31 */ … … 42 42 43 43 void 44 stack_trace_ fp_pc(stack_trace_ops_t *ops, uintptr_t fp, uintptr_t pc)44 stack_trace_ctx(stack_trace_ops_t *ops, stack_trace_context_t *ctx) 45 45 { 46 46 int cnt = 0; 47 47 const char *symbol; 48 48 uintptr_t offset; 49 uintptr_t fp; 50 uintptr_t pc; 49 51 50 while (cnt++ < STACK_FRAMES_MAX && ops->frame_pointer_validate(fp)) { 52 while (cnt++ < STACK_FRAMES_MAX && 53 ops->stack_trace_context_validate(ctx)) { 51 54 if (ops->symbol_resolve && 52 ops->symbol_resolve( pc, &symbol, &offset)) {55 ops->symbol_resolve(ctx->pc, &symbol, &offset)) { 53 56 if (offset) 54 printf("%p: %s+%" PRIp "()\n", fp, symbol, offset); 57 printf("%p: %s+%" PRIp "()\n", 58 ctx->fp, symbol, offset); 55 59 else 56 printf("%p: %s()\n", fp, symbol); 60 printf("%p: %s()\n", 61 ctx->fp, symbol); 57 62 } else { 58 printf("%p: %p()\n", fp,pc);63 printf("%p: %p()\n", ctx->fp, ctx->pc); 59 64 } 60 if (!ops->return_address_get( fp, &pc))65 if (!ops->return_address_get(ctx, &pc)) 61 66 break; 62 if (!ops->frame_pointer_prev( fp, &fp))67 if (!ops->frame_pointer_prev(ctx, &fp)) 63 68 break; 69 ctx->fp = fp; 70 ctx->pc = pc; 64 71 } 65 72 } … … 67 74 void stack_trace(void) 68 75 { 69 stack_trace_fp_pc(&kst_ops, frame_pointer_get(), program_counter_get()); 76 stack_trace_context_t ctx = { 77 .fp = frame_pointer_get(), 78 .pc = program_counter_get(), 79 .istate = NULL 80 }; 81 82 stack_trace_ctx(&kst_ops, &ctx); 70 83 71 84 /* … … 78 91 void stack_trace_istate(istate_t *istate) 79 92 { 93 stack_trace_context_t ctx = { 94 .fp = istate_get_fp(istate), 95 .pc = istate_get_pc(istate), 96 .istate = istate 97 }; 98 80 99 if (istate_from_uspace(istate)) 81 stack_trace_fp_pc(&ust_ops, istate_get_fp(istate), 82 istate_get_pc(istate)); 100 stack_trace_ctx(&ust_ops, &ctx); 83 101 else 84 stack_trace_fp_pc(&kst_ops, istate_get_fp(istate), 85 istate_get_pc(istate)); 102 stack_trace_ctx(&kst_ops, &ctx); 86 103 } 87 104 88 static bool kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op) 105 static bool 106 kernel_symbol_resolve(uintptr_t addr, const char **sp, uintptr_t *op) 89 107 { 90 108 return (symtab_name_lookup(addr, sp, op) == 0); … … 92 110 93 111 stack_trace_ops_t kst_ops = { 94 . frame_pointer_validate = kernel_frame_pointer_validate,112 .stack_trace_context_validate = kernel_stack_trace_context_validate, 95 113 .frame_pointer_prev = kernel_frame_pointer_prev, 96 114 .return_address_get = kernel_return_address_get, … … 99 117 100 118 stack_trace_ops_t ust_ops = { 101 . frame_pointer_validate = uspace_frame_pointer_validate,119 .stack_trace_context_validate = uspace_stack_trace_context_validate, 102 120 .frame_pointer_prev = uspace_frame_pointer_prev, 103 121 .return_address_get = uspace_return_address_get, -
kernel/generic/src/main/main.c
r1720cf9 r571addd 147 147 size_t i; 148 148 for (i = 0; i < init.cnt; i++) { 149 if (PA_ overlaps(config.stack_base, config.stack_size,149 if (PA_OVERLAPS(config.stack_base, config.stack_size, 150 150 init.tasks[i].addr, init.tasks[i].size)) 151 151 config.stack_base = ALIGN_UP(init.tasks[i].addr + … … 155 155 /* Avoid placing stack on top of boot allocations. */ 156 156 if (ballocs.size) { 157 if (PA_ overlaps(config.stack_base, config.stack_size,157 if (PA_OVERLAPS(config.stack_base, config.stack_size, 158 158 ballocs.base, ballocs.size)) 159 159 config.stack_base = ALIGN_UP(ballocs.base + -
kernel/generic/src/mm/frame.c
r1720cf9 r571addd 121 121 * 122 122 */ 123 NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count) 123 NO_TRACE static size_t zones_insert_zone(pfn_t base, size_t count, 124 zone_flags_t flags) 124 125 { 125 126 if (zones.count + 1 == ZONES_MAX) { … … 131 132 for (i = 0; i < zones.count; i++) { 132 133 /* Check for overlap */ 133 if (overlaps(base, count, 134 zones.info[i].base, zones.info[i].count)) { 135 printf("Zone (%p, %p) overlaps with zone (%p, %p)!\n", 136 PFN2ADDR(base), PFN2ADDR(base + count), 137 PFN2ADDR(zones.info[i].base), 138 PFN2ADDR(zones.info[i].base + zones.info[i].count)); 134 if (overlaps(zones.info[i].base, zones.info[i].count, 135 base, count)) { 136 137 /* 138 * If the overlaping zones are of the same type 139 * and the new zone is completely within the previous 140 * one, then quietly ignore the new zone. 141 * 142 */ 143 144 if ((zones.info[i].flags != flags) || 145 (!iswithin(zones.info[i].base, zones.info[i].count, 146 base, count))) { 147 printf("Zone (%p, %p) overlaps with previous zone (%p, %p)!\n", 148 PFN2ADDR(base), PFN2ADDR(count), 149 PFN2ADDR(zones.info[i].base), 150 PFN2ADDR(zones.info[i].count)); 151 } 152 139 153 return (size_t) -1; 140 154 } … … 147 161 for (j = zones.count; j > i; j--) { 148 162 zones.info[j] = zones.info[j - 1]; 149 zones.info[j].buddy_system->data = 150 (void *) &zones.info[j - 1]; 163 if (zones.info[j].buddy_system != NULL) 164 zones.info[j].buddy_system->data = 165 (void *) &zones.info[j]; 151 166 } 152 167 … … 748 763 for (i = z2 + 1; i < zones.count; i++) { 749 764 zones.info[i - 1] = zones.info[i]; 750 zones.info[i - 1].buddy_system->data = 751 (void *) &zones.info[i - 1]; 765 if (zones.info[i - 1].buddy_system != NULL) 766 zones.info[i - 1].buddy_system->data = 767 (void *) &zones.info[i - 1]; 752 768 } 753 769 … … 898 914 } 899 915 900 size_t znum = zones_insert_zone(start, count );916 size_t znum = zones_insert_zone(start, count, flags); 901 917 if (znum == (size_t) -1) { 902 918 irq_spinlock_unlock(&zones.lock, true); … … 921 937 922 938 /* Non-available zone */ 923 size_t znum = zones_insert_zone(start, count );939 size_t znum = zones_insert_zone(start, count, flags); 924 940 if (znum == (size_t) -1) { 925 941 irq_spinlock_unlock(&zones.lock, true); -
uspace/Makefile.common
r1720cf9 r571addd 172 172 ifneq ($(BINARY),) 173 173 %.disasm: $(BINARY) 174 ifeq ($(CONFIG_LINE_DEBUG),y) 175 $(OBJDUMP) -d -S $< > $@ 176 else 174 177 $(OBJDUMP) -d $< > $@ 178 endif 175 179 176 180 $(BINARY): $(LINKER_SCRIPT) $(OBJECTS) $(LIBS) $(BASE_LIBS) -
uspace/app/klog/klog.c
r1720cf9 r571addd 43 43 #include <event.h> 44 44 #include <errno.h> 45 #include <str_error.h> 45 46 #include <io/klog.h> 46 47 47 #define NAME "klog" 48 #define NAME "klog" 49 #define LOG_FNAME "/log/klog" 48 50 49 51 /* Pointer to klog area */ 50 52 static wchar_t *klog; 51 53 static size_t klog_length; 54 55 static FILE *log; 52 56 53 57 static void interrupt_received(ipc_callid_t callid, ipc_call_t *call) … … 58 62 size_t i; 59 63 60 for (i = klog_len - klog_stored; i < klog_len; i++) 61 putchar(klog[(klog_start + i) % klog_length]); 64 for (i = klog_len - klog_stored; i < klog_len; i++) { 65 wchar_t ch = klog[(klog_start + i) % klog_length]; 66 67 putchar(ch); 68 69 if (log != NULL) 70 fprintf(log, "%lc", ch); 71 } 72 73 if (log != NULL) { 74 fflush(log); 75 fsync(fileno(log)); 76 } 62 77 } 63 78 … … 91 106 } 92 107 108 /* 109 * Mode "a" would be definitively much better here, but it is 110 * not well supported by the FAT driver. 111 * 112 */ 113 log = fopen(LOG_FNAME, "w"); 114 if (log == NULL) 115 printf("%s: Unable to create log file %s (%s)\n", NAME, LOG_FNAME, 116 str_error(errno)); 117 93 118 async_set_interrupt_received(interrupt_received); 94 119 klog_update(); -
uspace/lib/c/generic/io/io.c
r1720cf9 r571addd 757 757 } 758 758 759 int fileno(FILE *stream) 760 { 761 if (stream->klog) { 762 errno = EBADF; 763 return -1; 764 } 765 766 return stream->fd; 767 } 768 759 769 int fphone(FILE *stream) 760 770 { -
uspace/lib/c/include/stdio.h
r1720cf9 r571addd 171 171 extern off64_t ftell(FILE *); 172 172 extern int feof(FILE *); 173 extern int fileno(FILE *); 173 174 174 175 extern int fflush(FILE *);
Note:
See TracChangeset
for help on using the changeset viewer.