- Timestamp:
- 2011-12-18T14:02:30Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c868e2d
- Parents:
- 3b71e84d (diff), 1761268 (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:
-
- 5 added
- 35 edited
- 3 moved
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/abs32le/src/abs32le.c
r3b71e84d r7aaed09 86 86 } 87 87 88 sysarg_t sys_tls_set( sysarg_t addr)88 sysarg_t sys_tls_set(uintptr_t addr) 89 89 { 90 90 return EOK; -
kernel/arch/amd64/Makefile.inc
r3b71e84d r7aaed09 72 72 ARCH_SOURCES = \ 73 73 arch/$(KARCH)/src/fpu_context.c \ 74 arch/$(KARCH)/src/boot/boot.S \ 74 arch/$(KARCH)/src/boot/multiboot.S \ 75 arch/$(KARCH)/src/boot/multiboot2.S \ 75 76 arch/$(KARCH)/src/boot/memmap.c \ 76 77 arch/$(KARCH)/src/debug/stacktrace.c \ … … 79 80 arch/$(KARCH)/src/context.S \ 80 81 arch/$(KARCH)/src/ddi/ddi.c \ 81 arch/$(KARCH)/src/drivers/vesa.c \82 82 arch/$(KARCH)/src/drivers/i8254.c \ 83 83 arch/$(KARCH)/src/drivers/i8259.c \ -
kernel/arch/amd64/include/arch.h
r3b71e84d r7aaed09 38 38 #include <genarch/multiboot/multiboot.h> 39 39 40 extern void arch_pre_main(uint32_t, const multiboot_info_t*);40 extern void arch_pre_main(uint32_t, void *); 41 41 42 42 #endif -
kernel/arch/amd64/include/boot/boot.h
r3b71e84d r7aaed09 40 40 #define BOOT_STACK_SIZE 0x000400 41 41 42 #define MULTIBOOT_HEADER_MAGIC 0x1BADB00243 #define MULTIBOOT_HEADER_FLAGS 0x0001000344 45 42 #ifndef __ASM__ 46 43 -
kernel/arch/amd64/src/amd64.c
r3b71e84d r7aaed09 34 34 35 35 #include <arch.h> 36 37 36 #include <typedefs.h> 38 39 #include <config.h> 40 41 #include <proc/thread.h> 42 #include <genarch/multiboot/multiboot.h> 43 #include <genarch/drivers/legacy/ia32/io.h> 44 #include <genarch/drivers/ega/ega.h> 45 #include <arch/drivers/vesa.h> 46 #include <genarch/drivers/i8042/i8042.h> 47 #include <genarch/kbrd/kbrd.h> 37 #include <errno.h> 38 #include <memstr.h> 39 #include <interrupt.h> 40 #include <console/console.h> 41 #include <syscall/syscall.h> 42 #include <sysinfo/sysinfo.h> 43 #include <arch/bios/bios.h> 44 #include <arch/boot/boot.h> 45 #include <arch/debugger.h> 48 46 #include <arch/drivers/i8254.h> 49 47 #include <arch/drivers/i8259.h> 50 #include <arch/boot/boot.h> 48 #include <arch/syscall.h> 49 #include <genarch/acpi/acpi.h> 50 #include <genarch/drivers/ega/ega.h> 51 #include <genarch/drivers/i8042/i8042.h> 52 #include <genarch/drivers/legacy/ia32/io.h> 53 #include <genarch/fb/bfb.h> 54 #include <genarch/kbrd/kbrd.h> 55 #include <genarch/multiboot/multiboot.h> 56 #include <genarch/multiboot/multiboot2.h> 51 57 52 58 #ifdef CONFIG_SMP 53 59 #include <arch/smp/apic.h> 54 60 #endif 55 56 #include <arch/bios/bios.h>57 #include <arch/cpu.h>58 #include <print.h>59 #include <arch/cpuid.h>60 #include <genarch/acpi/acpi.h>61 #include <panic.h>62 #include <interrupt.h>63 #include <arch/syscall.h>64 #include <arch/debugger.h>65 #include <syscall/syscall.h>66 #include <console/console.h>67 #include <ddi/irq.h>68 #include <sysinfo/sysinfo.h>69 #include <memstr.h>70 61 71 62 /** Disable I/O on non-privileged levels … … 101 92 /** Perform amd64-specific initialization before main_bsp() is called. 102 93 * 103 * @param signature Should contain the multiboot signature. 104 * @param mi Pointer to the multiboot information structure. 105 */ 106 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) 94 * @param signature Multiboot signature. 95 * @param info Multiboot information structure. 96 * 97 */ 98 void arch_pre_main(uint32_t signature, void *info) 107 99 { 108 100 /* Parse multiboot information obtained from the bootloader. */ 109 multiboot_info_parse(signature, mi); 101 multiboot_info_parse(signature, (multiboot_info_t *) info); 102 multiboot2_info_parse(signature, (multiboot2_info_t *) info); 110 103 111 104 #ifdef CONFIG_SMP … … 153 146 154 147 #if (defined(CONFIG_FB) || defined(CONFIG_EGA)) 155 bool vesa= false;148 bool bfb = false; 156 149 #endif 157 150 158 151 #ifdef CONFIG_FB 159 vesa = vesa_init();152 bfb = bfb_init(); 160 153 #endif 161 154 162 155 #ifdef CONFIG_EGA 163 if (! vesa) {156 if (!bfb) { 164 157 outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM); 165 158 if (egadev) … … 261 254 * we need not to go to CPL0 to read it. 262 255 */ 263 sysarg_t sys_tls_set( sysarg_t addr)256 sysarg_t sys_tls_set(uintptr_t addr) 264 257 { 265 258 THREAD->arch.tls = addr; 266 259 write_msr(AMD_MSR_FS, addr); 267 260 268 return 0;261 return EOK; 269 262 } 270 263 -
kernel/arch/amd64/src/boot/memmap.c
r3b71e84d r7aaed09 35 35 #include <arch/boot/memmap.h> 36 36 37 uint8_t e820counter = 0 xffU;37 uint8_t e820counter = 0; 38 38 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 39 39 -
kernel/arch/amd64/src/boot/multiboot.S
r3b71e84d r7aaed09 30 30 31 31 #include <arch/boot/boot.h> 32 #include <arch/boot/memmap.h>33 32 #include <arch/mm/page.h> 34 33 #include <arch/mm/ptl.h> 35 34 #include <arch/pm.h> 35 #include <genarch/multiboot/multiboot.h> 36 #include <arch/cpuid.h> 36 37 #include <arch/cpu.h> 37 #include <arch/cpuid.h>38 38 39 39 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) … … 101 101 multiboot_meeting_point: 102 102 103 /* Save GRUB arguments */ 104 movl %eax, grub_eax 105 movl %ebx, grub_ebx 103 /* 104 * Protected 32-bit. We want to reuse the code-seg descriptor, 105 * the Default operand size must not be 1 when entering long mode. 106 */ 107 108 /* Save multiboot arguments */ 109 movl %eax, multiboot_eax 110 movl %ebx, multiboot_ebx 106 111 107 112 pm_status $status_prot … … 149 154 150 155 #include "vesa_prot.inc" 151 152 /*153 * Protected 32-bit. We want to reuse the code-seg descriptor,154 * the Default operand size must not be 1 when entering long mode.155 */156 156 157 157 pm2_status $status_prot2 … … 422 422 long_status $status_long 423 423 424 /* Call arch_pre_main( grub_eax, grub_ebx) */424 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */ 425 425 xorq %rdi, %rdi 426 movl grub_eax, %edi426 movl multiboot_eax, %edi 427 427 xorq %rsi, %rsi 428 movl grub_ebx, %esi428 movl multiboot_ebx, %esi 429 429 430 430 movabsq $arch_pre_main, %rax … … 645 645 .section K_DATA_START, "aw", @progbits 646 646 647 .global bootstrap_gdtr 647 648 bootstrap_gdtr: 648 649 .word GDT_SELECTOR(GDT_ITEMS) 649 650 .long KA2PA(gdt) 650 651 651 grub_eax: 652 .global multiboot_eax 653 multiboot_eax: 652 654 .long 0 653 655 654 grub_ebx: 656 .global multiboot_ebx 657 multiboot_ebx: 655 658 .long 0 656 659 … … 670 673 status_vesa_copy: 671 674 .asciz "[vesa_copy] " 672 status_ grub_cmdline:673 .asciz "[ grub_cmdline] "675 status_multiboot_cmdline: 676 .asciz "[multiboot_cmdline] " 674 677 status_vesa_real: 675 678 .asciz "[vesa_real] " -
kernel/arch/ia32/Makefile.inc
r3b71e84d r7aaed09 107 107 arch/$(KARCH)/src/drivers/i8254.c \ 108 108 arch/$(KARCH)/src/drivers/i8259.c \ 109 arch/$(KARCH)/src/ drivers/vesa.c\110 arch/$(KARCH)/src/boot/ boot.S \109 arch/$(KARCH)/src/boot/multiboot.S \ 110 arch/$(KARCH)/src/boot/multiboot2.S \ 111 111 arch/$(KARCH)/src/boot/memmap.c \ 112 112 arch/$(KARCH)/src/fpu_context.c \ -
kernel/arch/ia32/include/arch.h
r3b71e84d r7aaed09 36 36 #define KERN_ia32_ARCH_H_ 37 37 38 #include < genarch/multiboot/multiboot.h>38 #include <typedefs.h> 39 39 40 extern void arch_pre_main(uint32_t, const multiboot_info_t*);40 extern void arch_pre_main(uint32_t, void *); 41 41 42 42 #endif -
kernel/arch/ia32/include/boot/boot.h
r3b71e84d r7aaed09 40 40 #define BOOT_STACK_SIZE 0x0400 41 41 42 #define MULTIBOOT_HEADER_MAGIC 0x1BADB00243 #define MULTIBOOT_HEADER_FLAGS 0x0001000344 45 #define MULTIBOOT_LOADER_MAGIC 0x2BADB00246 47 42 #ifndef __ASM__ 48 43 -
kernel/arch/ia32/src/boot/memmap.c
r3b71e84d r7aaed09 35 35 #include <arch/boot/memmap.h> 36 36 37 uint8_t e820counter = 0 xffU;37 uint8_t e820counter = 0; 38 38 e820memmap_t e820table[MEMMAP_E820_MAX_RECORDS]; 39 39 -
kernel/arch/ia32/src/boot/multiboot.S
r3b71e84d r7aaed09 30 30 31 31 #include <arch/boot/boot.h> 32 #include <arch/boot/memmap.h>33 32 #include <arch/mm/page.h> 34 33 #include <arch/pm.h> 34 #include <genarch/multiboot/multiboot.h> 35 35 #include <arch/cpuid.h> 36 36 … … 92 92 multiboot_meeting_point: 93 93 94 /* Save GRUBarguments */95 movl %eax, grub_eax96 movl %ebx, grub_ebx94 /* Save multiboot arguments */ 95 movl %eax, multiboot_eax 96 movl %ebx, multiboot_ebx 97 97 98 98 pm_status $status_prot … … 135 135 pm2_status $status_prot3 136 136 137 /* Call arch_pre_main( grub_eax, grub_ebx) */138 pushl grub_ebx139 pushl grub_eax137 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */ 138 pushl multiboot_ebx 139 pushl multiboot_eax 140 140 call arch_pre_main 141 141 … … 196 196 * 197 197 */ 198 .global map_kernel_non_pse 198 199 map_kernel_non_pse: 199 200 /* Paging features */ … … 299 300 find_mem_for_pt: 300 301 /* Check if multiboot info is present */ 301 cmpl $MULTIBOOT_LOADER_MAGIC, grub_eax302 cmpl $MULTIBOOT_LOADER_MAGIC, multiboot_eax 302 303 je check_multiboot_map 303 304 … … 307 308 308 309 /* Copy address of the multiboot info to ebx */ 309 movl grub_ebx, %ebx310 movl multiboot_ebx, %ebx 310 311 311 312 /* Check if memory map flag is present */ … … 701 702 .space 4096, 0 702 703 704 .global bootstrap_gdtr 703 705 bootstrap_gdtr: 704 706 .word GDT_SELECTOR(GDT_ITEMS) 705 707 .long KA2PA(gdt) 706 708 707 grub_eax: 709 .global multiboot_eax 710 multiboot_eax: 708 711 .long 0 709 grub_ebx: 712 713 .global multiboot_ebx 714 multiboot_ebx: 710 715 .long 0 711 716 … … 725 730 status_vesa_copy: 726 731 .asciz "[vesa_copy] " 727 status_ grub_cmdline:728 .asciz "[ grub_cmdline] "732 status_multiboot_cmdline: 733 .asciz "[multiboot_cmdline] " 729 734 status_vesa_real: 730 735 .asciz "[vesa_real] " -
kernel/arch/ia32/src/boot/vesa_prot.inc
r3b71e84d r7aaed09 1 1 #ifdef CONFIG_FB 2 2 3 #define MULTIBOOT_LOADER_MAGIC 0x2BADB0024 3 #define MBINFO_BIT_CMDLINE 2 5 4 #define MBINFO_OFFSET_CMDLINE 16 … … 14 13 rep movsb 15 14 16 /* Check for GRUBcommand line */15 /* Check for multiboot command line */ 17 16 18 pm_status $status_ grub_cmdline17 pm_status $status_multiboot_cmdline 19 18 20 mov grub_eax, %eax19 mov multiboot_eax, %eax 21 20 cmp $MULTIBOOT_LOADER_MAGIC, %eax 22 21 jne no_cmdline 23 22 24 mov grub_ebx, %ebx23 mov multiboot_ebx, %ebx 25 24 mov (%ebx), %eax 26 25 bt $MBINFO_BIT_CMDLINE, %eax … … 89 88 /* Returned back to protected mode */ 90 89 91 mov %ax, KA2PA(vesa_scanline) 90 movzx %ax, %ecx 91 mov %ecx, KA2PA(bfb_scanline) 92 92 93 shr $16, %eax 93 mov %ax, KA2PA( vesa_bpp)94 mov %ax, KA2PA(bfb_bpp) 94 95 95 mov %bx, KA2PA(vesa_height) 96 movzx %bx, %ecx 97 mov %ecx, KA2PA(bfb_height) 98 96 99 shr $16, %ebx 97 mov % bx, KA2PA(vesa_width)100 mov %ebx, KA2PA(bfb_width) 98 101 99 mov %dl, KA2PA(vesa_green_pos) 102 mov %dl, KA2PA(bfb_green_pos) 103 100 104 shr $8, %edx 101 mov %dl, KA2PA(vesa_green_mask) 105 mov %dl, KA2PA(bfb_green_size) 106 102 107 shr $8, %edx 103 mov %dl, KA2PA(vesa_red_pos) 108 mov %dl, KA2PA(bfb_red_pos) 109 104 110 shr $8, %edx 105 mov %dl, KA2PA( vesa_red_mask)111 mov %dl, KA2PA(bfb_red_size) 106 112 107 113 mov %esi, %edx 108 mov %dl, KA2PA(vesa_blue_pos) 114 mov %dl, KA2PA(bfb_blue_pos) 115 109 116 shr $8, %edx 110 mov %dl, KA2PA( vesa_blue_mask)117 mov %dl, KA2PA(bfb_blue_size) 111 118 112 mov %edi, KA2PA( vesa_ph_addr)119 mov %edi, KA2PA(bfb_addr) 113 120 #endif -
kernel/arch/ia32/src/boot/vesa_real.inc
r3b71e84d r7aaed09 304 304 /* 305 305 * Store mode parameters: 306 * eax = bpp[ 8] scanline[16]306 * eax = bpp[16] scanline[16] 307 307 * ebx = width[16] height[16] 308 308 * edx = red_mask[8] red_pos[8] green_mask[8] green_pos[8] … … 328 328 shl $8, %edx 329 329 mov VESA_MODE_RED_POS_OFFSET(%di), %dl 330 330 331 shl $8, %edx 331 332 mov VESA_MODE_GREEN_MASK_OFFSET(%di), %dl … … 369 370 mov $0x0003, %ax 370 371 int $0x10 371 mov $0xffffffff, %edi 372 xor %ax, %ax 372 373 xor %eax, %eax 374 xor %ebx, %ebx 375 xor %edx, %edx 376 xor %edi, %edi 377 373 378 jz vesa_leave_real /* force relative jump */ 374 379 … … 386 391 387 392 default_mode: 388 .ascii STRING(CONFIG_ VESA_MODE)393 .ascii STRING(CONFIG_BFB_MODE) 389 394 .ascii "-" 390 .asciz STRING(CONFIG_ VESA_BPP)395 .asciz STRING(CONFIG_BFB_BPP) 391 396 .fill 24 392 397 -
kernel/arch/ia32/src/ia32.c
r3b71e84d r7aaed09 36 36 37 37 #include <arch.h> 38 39 38 #include <typedefs.h> 40 41 #include < arch/pm.h>42 43 #include < genarch/multiboot/multiboot.h>44 #include < genarch/drivers/legacy/ia32/io.h>45 #include < genarch/drivers/ega/ega.h>46 #include <arch/ drivers/vesa.h>47 #include < genarch/drivers/i8042/i8042.h>48 #include < genarch/kbrd/kbrd.h>39 #include <errno.h> 40 #include <memstr.h> 41 #include <interrupt.h> 42 #include <console/console.h> 43 #include <syscall/syscall.h> 44 #include <sysinfo/sysinfo.h> 45 #include <arch/bios/bios.h> 46 #include <arch/boot/boot.h> 47 #include <arch/debugger.h> 49 48 #include <arch/drivers/i8254.h> 50 49 #include <arch/drivers/i8259.h> 51 52 #include <arch/context.h>53 54 #include <config.h>55 56 #include <arch/interrupt.h>57 #include <arch/asm.h>58 50 #include <genarch/acpi/acpi.h> 59 60 #include <arch/bios/bios.h> 61 62 #include <interrupt.h> 63 #include <ddi/irq.h> 64 #include <arch/debugger.h> 65 #include <proc/thread.h> 66 #include <syscall/syscall.h> 67 #include <console/console.h> 68 #include <sysinfo/sysinfo.h> 69 #include <arch/boot/boot.h> 70 #include <memstr.h> 51 #include <genarch/drivers/ega/ega.h> 52 #include <genarch/drivers/i8042/i8042.h> 53 #include <genarch/drivers/legacy/ia32/io.h> 54 #include <genarch/fb/bfb.h> 55 #include <genarch/kbrd/kbrd.h> 56 #include <genarch/multiboot/multiboot.h> 57 #include <genarch/multiboot/multiboot2.h> 71 58 72 59 #ifdef CONFIG_SMP … … 76 63 /** Perform ia32-specific initialization before main_bsp() is called. 77 64 * 78 * @param signature Should contain the multiboot signature. 79 * @param mi Pointer to the multiboot information structure. 80 */ 81 void arch_pre_main(uint32_t signature, const multiboot_info_t *mi) 65 * @param signature Multiboot signature. 66 * @param info Multiboot information structure. 67 * 68 */ 69 void arch_pre_main(uint32_t signature, void *info) 82 70 { 83 71 /* Parse multiboot information obtained from the bootloader. */ 84 multiboot_info_parse(signature, mi); 72 multiboot_info_parse(signature, (multiboot_info_t *) info); 73 multiboot2_info_parse(signature, (multiboot2_info_t *) info); 85 74 86 75 #ifdef CONFIG_SMP … … 114 103 115 104 #if (defined(CONFIG_FB) || defined(CONFIG_EGA)) 116 bool vesa= false;105 bool bfb = false; 117 106 #endif 118 107 119 108 #ifdef CONFIG_FB 120 vesa = vesa_init();109 bfb = bfb_init(); 121 110 #endif 122 111 123 112 #ifdef CONFIG_EGA 124 if (! vesa) {113 if (!bfb) { 125 114 outdev_t *egadev = ega_init(EGA_BASE, EGA_VIDEORAM); 126 115 if (egadev) … … 216 205 * selector, and the descriptor->base is the correct address. 217 206 */ 218 sysarg_t sys_tls_set( sysarg_t addr)207 sysarg_t sys_tls_set(uintptr_t addr) 219 208 { 220 209 THREAD->arch.tls = addr; 221 210 set_tls_desc(addr); 222 211 223 return 0;212 return EOK; 224 213 } 225 214 -
kernel/arch/ia64/include/asm.h
r3b71e84d r7aaed09 38 38 #include <config.h> 39 39 #include <typedefs.h> 40 #include <typedefs.h>41 40 #include <arch/register.h> 42 41 #include <trace.h> -
kernel/arch/ia64/src/ia64.c
r3b71e84d r7aaed09 34 34 35 35 #include <arch.h> 36 #include <arch/drivers/ski.h>37 #include <arch/drivers/it.h>38 #include <arch/interrupt.h>39 #include <arch/barrier.h>40 #include <arch/asm.h>41 #include <arch/register.h>42 36 #include <typedefs.h> 43 #include <arch/context.h> 44 #include <arch/stack.h> 45 #include <arch/mm/page.h> 37 #include <errno.h> 46 38 #include <interrupt.h> 47 #include <mm/as.h>48 #include <config.h>49 39 #include <macros.h> 40 #include <str.h> 50 41 #include <userspace.h> 51 42 #include <console/console.h> 52 #include <abi/proc/uarg.h>53 43 #include <syscall/syscall.h> 54 #include <ddi/irq.h> 55 #include <arch/bootinfo.h> 44 #include <sysinfo/sysinfo.h> 45 #include <arch/drivers/it.h> 46 #include <arch/drivers/kbd.h> 47 #include <genarch/drivers/ega/ega.h> 48 #include <genarch/drivers/i8042/i8042.h> 49 #include <genarch/drivers/ns16550/ns16550.h> 56 50 #include <genarch/drivers/legacy/ia32/io.h> 57 #include <genarch/drivers/ega/ega.h>58 51 #include <genarch/kbrd/kbrd.h> 59 52 #include <genarch/srln/srln.h> 60 #include <genarch/drivers/i8042/i8042.h>61 #include <genarch/drivers/ns16550/ns16550.h>62 #include <arch/drivers/kbd.h>63 #include <smp/smp.h>64 #include <smp/ipi.h>65 #include <arch/atomic.h>66 #include <panic.h>67 #include <print.h>68 #include <sysinfo/sysinfo.h>69 #include <str.h>70 53 71 54 /* NS16550 as a COM 1 */ … … 262 245 * We use r13 (a.k.a. tp) for this purpose. 263 246 */ 264 sysarg_t sys_tls_set( sysarg_t addr)265 { 266 return 0;247 sysarg_t sys_tls_set(uintptr_t addr) 248 { 249 return EOK; 267 250 } 268 251 … … 270 253 { 271 254 pio_write_8((ioport8_t *)0x64, 0xfe); 272 while (1) 273 ; 255 while (1); 274 256 } 275 257 -
kernel/arch/ia64/src/start.S
r3b71e84d r7aaed09 174 174 mov ar.bspstore = r8 175 175 loadrs 176 176 177 177 # 178 178 # Initialize memory stack to some sane value and allocate a scratch area … … 196 196 srlz.i 197 197 srlz.d ;; 198 198 199 199 br.call.sptk.many b0 = arch_pre_main 200 200 0: -
kernel/arch/mips32/src/mips32.c
r3b71e84d r7aaed09 34 34 35 35 #include <arch.h> 36 #include <arch/cp0.h> 37 #include <arch/exception.h> 38 #include <arch/debug.h> 39 #include <mm/as.h> 36 #include <typedefs.h> 37 #include <errno.h> 38 #include <interrupt.h> 39 #include <macros.h> 40 #include <str.h> 41 #include <memstr.h> 40 42 #include <userspace.h> 41 #include <memstr.h>42 #include <proc/thread.h>43 #include <abi/proc/uarg.h>44 #include <print.h>45 43 #include <console/console.h> 46 44 #include <syscall/syscall.h> 47 45 #include <sysinfo/sysinfo.h> 48 #include <arch/interrupt.h> 49 #include <interrupt.h> 50 #include <console/chardev.h> 51 #include <arch/barrier.h> 46 #include <arch/debug.h> 52 47 #include <arch/debugger.h> 48 #include <arch/drivers/msim.h> 53 49 #include <genarch/fb/fb.h> 54 #include <abi/fb/visuals.h>55 50 #include <genarch/drivers/dsrln/dsrlnin.h> 56 51 #include <genarch/drivers/dsrln/dsrlnout.h> 57 52 #include <genarch/srln/srln.h> 58 #include <macros.h>59 #include <config.h>60 #include <str.h>61 #include <arch/drivers/msim.h>62 #include <arch/asm/regname.h>63 53 64 54 /* Size of the code jumping to the exception handler code … … 248 238 * possible to have it separately in the future. 249 239 */ 250 sysarg_t sys_tls_set( sysarg_t addr)251 { 252 return 0;240 sysarg_t sys_tls_set(uintptr_t addr) 241 { 242 return EOK; 253 243 } 254 244 -
kernel/arch/mips64/src/mips64.c
r3b71e84d r7aaed09 34 34 35 35 #include <arch.h> 36 #include <arch/cp0.h> 37 #include <arch/exception.h> 38 #include <arch/debug.h> 39 #include <mm/as.h> 36 #include <typedefs.h> 37 #include <errno.h> 38 #include <interrupt.h> 39 #include <macros.h> 40 #include <str.h> 41 #include <memstr.h> 40 42 #include <userspace.h> 41 #include <memstr.h>42 #include <proc/thread.h>43 #include <abi/proc/uarg.h>44 #include <print.h>45 43 #include <console/console.h> 46 44 #include <syscall/syscall.h> 47 45 #include <sysinfo/sysinfo.h> 48 #include <arch/interrupt.h> 49 #include <interrupt.h> 50 #include <console/chardev.h> 51 #include <arch/barrier.h> 46 #include <arch/debug.h> 52 47 #include <arch/debugger.h> 48 #include <arch/drivers/msim.h> 53 49 #include <genarch/fb/fb.h> 54 #include <abi/fb/visuals.h>55 50 #include <genarch/drivers/dsrln/dsrlnin.h> 56 51 #include <genarch/drivers/dsrln/dsrlnout.h> 57 52 #include <genarch/srln/srln.h> 58 #include <macros.h>59 #include <config.h>60 #include <str.h>61 #include <arch/drivers/msim.h>62 #include <arch/asm/regname.h>63 53 64 54 /* Size of the code jumping to the exception handler code … … 226 216 * possible to have it separately in the future. 227 217 */ 228 sysarg_t sys_tls_set( sysarg_t addr)229 { 230 return 0;218 sysarg_t sys_tls_set(uintptr_t addr) 219 { 220 return EOK; 231 221 } 232 222 -
kernel/genarch/Makefile.inc
r3b71e84d r7aaed09 67 67 genarch/src/fb/font-8x16.c \ 68 68 genarch/src/fb/logo-196x66.c \ 69 genarch/src/fb/fb.c 69 genarch/src/fb/fb.c \ 70 genarch/src/fb/bfb.c 70 71 endif 71 72 … … 143 144 ifeq ($(CONFIG_MULTIBOOT), y) 144 145 GENARCH_SOURCES += \ 145 genarch/src/multiboot/multiboot.c 146 genarch/src/multiboot/multiboot.c \ 147 genarch/src/multiboot/multiboot2.c 146 148 endif 147 149 -
kernel/genarch/include/multiboot/multiboot.h
r3b71e84d r7aaed09 36 36 #define KERN_MULTIBOOT_H_ 37 37 38 #define MULTIBOOT_HEADER_MAGIC 0x1badb002 39 #define MULTIBOOT_HEADER_FLAGS 0x00010003 40 41 #define MULTIBOOT_LOADER_MAGIC 0x2badb002 42 43 #ifndef __ASM__ 44 38 45 #include <typedefs.h> 39 46 #include <arch/boot/memmap.h> 47 48 /** Convert 32-bit multiboot address to a pointer. */ 49 #define MULTIBOOT_PTR(mba) ((void *) (uintptr_t) (mba)) 40 50 41 51 /** Multiboot 32-bit address. */ 42 52 typedef uint32_t mbaddr_t; 43 53 44 /** Multiboot mod structure */54 /** Multiboot module structure */ 45 55 typedef struct { 46 56 mbaddr_t start; … … 48 58 mbaddr_t string; 49 59 uint32_t reserved; 50 } __attribute__ ((packed)) multiboot_mod_t;60 } __attribute__((packed)) multiboot_module_t; 51 61 52 62 /** Multiboot mmap structure */ … … 54 64 uint32_t size; 55 65 e820memmap_t mm_info; 56 } __attribute__ ((packed)) multiboot_mmap_t;66 } __attribute__((packed)) multiboot_memmap_t; 57 67 58 68 /** Multiboot information structure */ … … 74 84 75 85 /* ... */ 76 } __attribute__ 86 } __attribute__((packed)) multiboot_info_t; 77 87 78 88 enum multiboot_info_flags { 79 M BINFO_FLAGS_MEM = 0x01,80 M BINFO_FLAGS_BOOT = 0x02,81 M BINFO_FLAGS_CMDLINE = 0x04,82 M BINFO_FLAGS_MODS = 0x08,83 M BINFO_FLAGS_SYMS1 = 0x10,84 M BINFO_FLAGS_SYMS2 = 0x20,85 M BINFO_FLAGS_MMAP = 0x4089 MULTIBOOT_INFO_FLAGS_MEM = 0x01, 90 MULTIBOOT_INFO_FLAGS_BOOT = 0x02, 91 MULTIBOOT_INFO_FLAGS_CMDLINE = 0x04, 92 MULTIBOOT_INFO_FLAGS_MODS = 0x08, 93 MULTIBOOT_INFO_FLAGS_SYMS1 = 0x10, 94 MULTIBOOT_INFO_FLAGS_SYMS2 = 0x20, 95 MULTIBOOT_INFO_FLAGS_MMAP = 0x40 86 96 87 97 /* ... */ 88 98 }; 89 99 90 #define MULTIBOOT_LOADER_MAGIC 0x2BADB002 100 extern void multiboot_extract_command(char *, size_t, const char *); 101 extern void multiboot_info_parse(uint32_t, const multiboot_info_t *); 91 102 92 /** Convert 32-bit multiboot address to a pointer. */ 93 #define MULTIBOOT_PTR(mba) ((void *)(uintptr_t) (mba)) 94 95 extern void multiboot_info_parse(uint32_t, const multiboot_info_t *); 103 #endif /* __ASM__ */ 96 104 97 105 #endif -
kernel/genarch/src/drivers/i8042/i8042.c
r3b71e84d r7aaed09 44 44 #include <mm/slab.h> 45 45 #include <ddi/device.h> 46 #include <time/delay.h> 46 47 47 48 #define i8042_SET_COMMAND 0x60 … … 51 52 #define i8042_BUFFER_FULL_MASK 0x01 52 53 #define i8042_WAIT_MASK 0x02 54 55 #define i8042_TIMEOUT 65536 53 56 54 57 static irq_ownership_t i8042_claim(irq_t *irq) … … 77 80 static void i8042_clear_buffer(i8042_t *dev) 78 81 { 79 while (pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) 82 for (uint32_t i = 0; i < i8042_TIMEOUT; i++) { 83 if ((pio_read_8(&dev->status) & i8042_BUFFER_FULL_MASK) == 0) 84 break; 85 80 86 (void) pio_read_8(&dev->data); 87 delay(50); /* 50 us think time */ 88 } 89 } 90 91 static void i8042_send_command(i8042_t *dev, uint8_t cmd) 92 { 93 for (uint32_t i = 0; i < i8042_TIMEOUT; i++) { 94 if ((pio_read_8(&dev->status) & i8042_WAIT_MASK) == 0) 95 break; 96 97 delay(50); /* 50 us think time */ 98 } 99 100 pio_write_8(&dev->status, cmd); 101 delay(10000); /* 10 ms think time */ 81 102 } 82 103 … … 84 105 i8042_instance_t *i8042_init(i8042_t *dev, inr_t inr) 85 106 { 86 i8042_instance_t *instance 87 =malloc(sizeof(i8042_instance_t), FRAME_ATOMIC);107 i8042_instance_t *instance = 108 malloc(sizeof(i8042_instance_t), FRAME_ATOMIC); 88 109 if (instance) { 89 110 instance->i8042 = dev; … … 96 117 instance->irq.handler = i8042_irq_handler; 97 118 instance->irq.instance = instance; 98 99 119 } 100 120 … … 107 127 ASSERT(kbrdin); 108 128 129 i8042_clear_buffer(instance->i8042); 130 109 131 instance->kbrdin = kbrdin; 110 132 irq_register(&instance->irq); 111 i8042_clear_buffer(instance->i8042);112 133 } 113 134 … … 116 137 { 117 138 interrupts_disable(); 118 119 139 i8042_clear_buffer(dev); 120 121 /* Reset CPU */ 122 pio_write_8(&dev->status, i8042_CPU_RESET); 140 i8042_send_command(dev, i8042_CPU_RESET); 123 141 } 124 142 -
kernel/genarch/src/fb/bfb.c
r3b71e84d r7aaed09 27 27 */ 28 28 29 /** @addtogroup ia3229 /** @addtogroup genarch 30 30 * @{ 31 31 */ 32 32 /** 33 33 * @file 34 * @brief VESA framebuffer driver.34 * @brief Boot framebuffer driver. 35 35 */ 36 36 37 #ifdef CONFIG_FB 37 #include <typedefs.h> 38 #include <genarch/fb/fb.h> 39 #include <genarch/fb/bfb.h> 40 #include <console/console.h> 38 41 39 #include <genarch/fb/fb.h> 40 #include <arch/drivers/vesa.h> 41 #include <console/chardev.h> 42 #include <console/console.h> 43 #include <putchar.h> 44 #include <mm/page.h> 45 #include <mm/frame.h> 46 #include <mm/as.h> 47 #include <arch/mm/page.h> 48 #include <synch/spinlock.h> 49 #include <arch/asm.h> 50 #include <typedefs.h> 51 #include <memstr.h> 52 #include <bitops.h> 42 uintptr_t bfb_addr = 0; 43 uint32_t bfb_width = 0; 44 uint32_t bfb_height = 0; 45 uint16_t bfb_bpp = 0; 46 uint32_t bfb_scanline = 0; 53 47 54 uint32_t vesa_ph_addr; 55 uint16_t vesa_width; 56 uint16_t vesa_height; 57 uint16_t vesa_bpp; 58 uint16_t vesa_scanline; 48 uint8_t bfb_red_pos = 0; 49 uint8_t bfb_red_size = 0; 59 50 60 uint8_t vesa_red_mask;61 uint8_t vesa_red_pos;51 uint8_t bfb_green_pos = 0; 52 uint8_t bfb_green_size = 0; 62 53 63 uint8_t vesa_green_mask;64 uint8_t vesa_green_pos;54 uint8_t bfb_blue_pos = 0; 55 uint8_t bfb_blue_size = 0; 65 56 66 uint8_t vesa_blue_mask; 67 uint8_t vesa_blue_pos; 68 69 bool vesa_init(void) 57 bool bfb_init(void) 70 58 { 71 if ((vesa_width == 0xffffU) || (vesa_height == 0xffffU)) 59 if ((bfb_addr == 0) || (bfb_width == 0) || (bfb_height == 0) || 60 (bfb_bpp == 0) || (bfb_scanline == 0)) 72 61 return false; 73 62 74 visual_t visual; 63 fb_properties_t bfb_props = { 64 .addr = bfb_addr, 65 .offset = 0, 66 .x = bfb_width, 67 .y = bfb_height, 68 .scan = bfb_scanline 69 }; 75 70 76 switch ( vesa_bpp) {71 switch (bfb_bpp) { 77 72 case 8: 78 visual = VISUAL_INDIRECT_8;73 bfb_props.visual = VISUAL_INDIRECT_8; 79 74 break; 80 75 case 16: 81 if (( vesa_red_mask == 5) && (vesa_red_pos == 10)82 && (vesa_green_mask == 5) && (vesa_green_pos == 5)83 && (vesa_blue_mask == 5) && (vesa_blue_pos == 0))84 visual = VISUAL_RGB_5_5_5_LE;76 if ((bfb_red_pos == 10) && (bfb_red_size == 5) && 77 (bfb_green_pos == 5) && (bfb_green_size == 5) && 78 (bfb_blue_pos == 0) && (bfb_blue_size == 5)) 79 bfb_props.visual = VISUAL_RGB_5_5_5_LE; 85 80 else 86 visual = VISUAL_RGB_5_6_5_LE;81 bfb_props.visual = VISUAL_RGB_5_6_5_LE; 87 82 break; 88 83 case 24: 89 visual = VISUAL_BGR_8_8_8;84 bfb_props.visual = VISUAL_BGR_8_8_8; 90 85 break; 91 86 case 32: 92 visual = VISUAL_BGR_8_8_8_0;87 bfb_props.visual = VISUAL_BGR_8_8_8_0; 93 88 break; 94 89 default: … … 97 92 } 98 93 99 fb_properties_t vesa_props = { 100 .addr = vesa_ph_addr, 101 .offset = 0, 102 .x = vesa_width, 103 .y = vesa_height, 104 .scan = vesa_scanline, 105 .visual = visual, 106 }; 107 108 outdev_t *fbdev = fb_init(&vesa_props); 94 outdev_t *fbdev = fb_init(&bfb_props); 109 95 if (!fbdev) 110 96 return false; … … 114 100 } 115 101 116 #endif117 118 102 /** @} 119 103 */ -
kernel/genarch/src/multiboot/multiboot.c
r3b71e84d r7aaed09 33 33 */ 34 34 35 #include <typedefs.h> 35 36 #include <genarch/multiboot/multiboot.h> 36 #include <typedefs.h>37 37 #include <config.h> 38 38 #include <str.h> 39 #include <macros.h>40 39 41 40 /** Extract command name from the multiboot module command line. 42 41 * 43 * @param buf Destination buffer (will always NULL-terminate).44 * @param s zSize of destination buffer (in bytes).42 * @param buf Destination buffer (will be always NULL-terminated). 43 * @param size Size of destination buffer (in bytes). 45 44 * @param cmd_line Input string (the command line). 46 45 * 47 46 */ 48 static void extract_command(char *buf, size_t sz, const char *cmd_line)47 void multiboot_extract_command(char *buf, size_t size, const char *cmd_line) 49 48 { 50 49 /* Find the first space. */ … … 69 68 70 69 /* Copy the command. */ 71 str_ncpy(buf, sz, start, (size_t) (end - start)); 70 str_ncpy(buf, size, start, (size_t) (end - start)); 71 } 72 73 static void multiboot_modules(uint32_t count, multiboot_module_t *mods) 74 { 75 for (uint32_t i = 0; i < count; i++) { 76 if (init.cnt >= CONFIG_INIT_TASKS) 77 break; 78 79 init.tasks[init.cnt].addr = PA2KA(mods[i].start); 80 init.tasks[init.cnt].size = mods[i].end - mods[i].start; 81 82 /* Copy command line, if available. */ 83 if (mods[i].string) { 84 multiboot_extract_command(init.tasks[init.cnt].name, 85 CONFIG_TASK_NAME_BUFLEN, MULTIBOOT_PTR(mods[i].string)); 86 } else 87 init.tasks[init.cnt].name[0] = 0; 88 89 init.cnt++; 90 } 91 } 92 93 static void multiboot_memmap(uint32_t length, multiboot_memmap_t *memmap) 94 { 95 uint32_t pos = 0; 96 97 while ((pos < length) && (e820counter < MEMMAP_E820_MAX_RECORDS)) { 98 e820table[e820counter] = memmap->mm_info; 99 100 /* Compute address of next structure. */ 101 uint32_t size = sizeof(memmap->size) + memmap->size; 102 memmap = (multiboot_memmap_t *) ((uintptr_t) memmap + size); 103 pos += size; 104 105 e820counter++; 106 } 72 107 } 73 108 … … 78 113 * 79 114 * @param signature Should contain the multiboot signature. 80 * @param mi Pointer to the multiboot information structure. 115 * @param info Multiboot information structure. 116 * 81 117 */ 82 void multiboot_info_parse(uint32_t signature, const multiboot_info_t * mi)118 void multiboot_info_parse(uint32_t signature, const multiboot_info_t *info) 83 119 { 84 uint32_t flags; 120 if (signature != MULTIBOOT_LOADER_MAGIC) 121 return; 85 122 86 if (signature == MULTIBOOT_LOADER_MAGIC) 87 flags = mi->flags; 88 else { 89 /* No multiboot info available. */ 90 flags = 0; 91 } 92 93 /* Copy module information. */ 94 uint32_t i; 95 if ((flags & MBINFO_FLAGS_MODS) != 0) { 96 init.cnt = min(mi->mods_count, CONFIG_INIT_TASKS); 97 multiboot_mod_t *mods 98 = (multiboot_mod_t *) MULTIBOOT_PTR(mi->mods_addr); 99 100 for (i = 0; i < init.cnt; i++) { 101 init.tasks[i].addr = PA2KA(mods[i].start); 102 init.tasks[i].size = mods[i].end - mods[i].start; 103 104 /* Copy command line, if available. */ 105 if (mods[i].string) { 106 extract_command(init.tasks[i].name, 107 CONFIG_TASK_NAME_BUFLEN, 108 MULTIBOOT_PTR(mods[i].string)); 109 } else 110 init.tasks[i].name[0] = 0; 111 } 112 } else 113 init.cnt = 0; 123 /* Copy modules information. */ 124 if ((info->flags & MULTIBOOT_INFO_FLAGS_MODS) != 0) 125 multiboot_modules(info->mods_count, 126 (multiboot_module_t *) MULTIBOOT_PTR(info->mods_addr)); 114 127 115 128 /* Copy memory map. */ 116 117 if ((flags & MBINFO_FLAGS_MMAP) != 0) { 118 int32_t mmap_length = mi->mmap_length; 119 multiboot_mmap_t *mme = MULTIBOOT_PTR(mi->mmap_addr); 120 e820counter = 0; 121 122 i = 0; 123 while ((mmap_length > 0) && (i < MEMMAP_E820_MAX_RECORDS)) { 124 e820table[i++] = mme->mm_info; 125 126 /* Compute address of next structure. */ 127 uint32_t size = sizeof(mme->size) + mme->size; 128 mme = ((void *) mme) + size; 129 mmap_length -= size; 130 } 131 132 e820counter = i; 133 } else 134 e820counter = 0; 129 if ((info->flags & MULTIBOOT_INFO_FLAGS_MMAP) != 0) 130 multiboot_memmap(info->mmap_length, 131 (multiboot_memmap_t *) MULTIBOOT_PTR(info->mmap_addr)); 135 132 } 136 133 -
kernel/generic/include/ddi/ddi.h
r3b71e84d r7aaed09 55 55 extern void ddi_parea_register(parea_t *); 56 56 57 extern sysarg_t sys_physmem_map(sysarg_t, sysarg_t, sysarg_t, sysarg_t); 57 extern sysarg_t sys_physmem_map(uintptr_t, uintptr_t, size_t, unsigned int); 58 59 extern sysarg_t sys_dmamem_map(uintptr_t, size_t, unsigned int, unsigned int, 60 void *); 61 extern sysarg_t sys_dmamem_unmap(uintptr_t, size_t, unsigned int); 62 58 63 extern sysarg_t sys_iospace_enable(ddi_ioarg_t *); 59 64 -
kernel/generic/include/lib/rd.h
r3b71e84d r7aaed09 38 38 #include <typedefs.h> 39 39 40 /** 41 * RAM disk version 42 */ 43 #define RD_VERSION 1 44 45 /** 46 * RAM disk magic number 47 */ 48 #define RD_MAGIC_SIZE 4 49 #define RD_MAG0 'H' 50 #define RD_MAG1 'O' 51 #define RD_MAG2 'R' 52 #define RD_MAG3 'D' 53 54 /** 55 * RAM disk data encoding types 56 */ 57 #define RD_DATA_NONE 0 58 #define RD_DATA_LSB 1 /* Least significant byte first (little endian) */ 59 #define RD_DATA_MSB 2 /* Most signigicant byte first (big endian) */ 60 61 /** 62 * RAM disk error return codes 63 */ 64 #define RE_OK 0 /* No error */ 65 #define RE_INVALID 1 /* Invalid RAM disk image */ 66 #define RE_UNSUPPORTED 2 /* Non-supported image (e.g. wrong version) */ 67 68 /** RAM disk header */ 69 struct rd_header { 70 uint8_t magic[RD_MAGIC_SIZE]; 71 uint8_t version; 72 uint8_t data_type; 73 uint32_t header_size; 74 uint64_t data_size; 75 } __attribute__ ((packed)); 76 77 typedef struct rd_header rd_header_t; 78 79 extern int init_rd(rd_header_t *addr, size_t size); 40 extern void init_rd(void *, size_t); 80 41 81 42 #endif -
kernel/generic/include/mm/page.h
r3b71e84d r7aaed09 66 66 extern uintptr_t hw_map(uintptr_t, size_t); 67 67 68 extern sysarg_t sys_page_find_mapping(uintptr_t, uintptr_t *); 68 extern int page_find_mapping(uintptr_t, void **); 69 extern sysarg_t sys_page_find_mapping(uintptr_t, void *); 69 70 70 71 #endif -
kernel/generic/include/synch/smc.h
r3b71e84d r7aaed09 36 36 #define KERN_SMC_H_ 37 37 38 extern sysarg_t sys_smc_coherence(uintptr_t va, size_t size);38 extern sysarg_t sys_smc_coherence(uintptr_t, size_t); 39 39 40 40 #endif -
kernel/generic/include/syscall/syscall.h
r3b71e84d r7aaed09 45 45 extern sysarg_t syscall_handler(sysarg_t, sysarg_t, sysarg_t, sysarg_t, 46 46 sysarg_t, sysarg_t, sysarg_t); 47 extern sysarg_t sys_tls_set( sysarg_t);47 extern sysarg_t sys_tls_set(uintptr_t); 48 48 49 49 #endif -
kernel/generic/src/ddi/ddi.c
r3b71e84d r7aaed09 45 45 #include <mm/frame.h> 46 46 #include <mm/as.h> 47 #include <mm/page.h> 47 48 #include <synch/mutex.h> 48 49 #include <syscall/copy.h> … … 52 53 #include <errno.h> 53 54 #include <trace.h> 55 #include <bitops.h> 54 56 55 57 /** This lock protects the parea_btree. */ … … 87 89 /** Map piece of physical memory into virtual address space of current task. 88 90 * 89 * @param p fPhysical address of the starting frame.90 * @param v pVirtual address of the starting page.91 * @param phys Physical address of the starting frame. 92 * @param virt Virtual address of the starting page. 91 93 * @param pages Number of pages to map. 92 94 * @param flags Address space area flags for the mapping. 93 95 * 94 * @return 0 on success, EPERM if the caller lacks capabilities to use this 95 * syscall, EBADMEM if pf or vf is not page aligned, ENOENT if there 96 * is no task matching the specified ID or the physical address space 97 * is not enabled for mapping and ENOMEM if there was a problem in 98 * creating address space area. 99 * 100 */ 101 NO_TRACE static int ddi_physmem_map(uintptr_t pf, uintptr_t vp, size_t pages, 96 * @return EOK on success. 97 * @return EPERM if the caller lacks capabilities to use this syscall. 98 * @return EBADMEM if phys or virt is not page aligned. 99 * @return ENOENT if there is no task matching the specified ID or 100 * the physical address space is not enabled for mapping. 101 * @return ENOMEM if there was a problem in creating address space area. 102 * 103 */ 104 NO_TRACE static int ddi_physmem_map(uintptr_t phys, uintptr_t virt, size_t pages, 102 105 unsigned int flags) 103 106 { 104 107 ASSERT(TASK); 105 108 106 if ((p f% FRAME_SIZE) != 0)109 if ((phys % FRAME_SIZE) != 0) 107 110 return EBADMEM; 108 111 109 if ((v p% PAGE_SIZE) != 0)112 if ((virt % PAGE_SIZE) != 0) 110 113 return EBADMEM; 111 114 … … 118 121 119 122 mem_backend_data_t backend_data; 120 backend_data.base = p f;123 backend_data.base = phys; 121 124 backend_data.frames = pages; 122 125 … … 129 132 btree_node_t *nodep; 130 133 parea_t *parea = (parea_t *) btree_search(&parea_btree, 131 (btree_key_t) p f, &nodep);134 (btree_key_t) phys, &nodep); 132 135 133 136 if ((parea != NULL) && (parea->frames >= pages)) { … … 149 152 150 153 irq_spinlock_lock(&zones.lock, true); 151 size_t znum = find_zone(ADDR2PFN(p f), pages, 0);154 size_t znum = find_zone(ADDR2PFN(phys), pages, 0); 152 155 153 156 if (znum == (size_t) -1) { … … 182 185 183 186 map: 184 if (!as_area_create(TASK->as, flags, pages * PAGE_SIZE, vp,187 if (!as_area_create(TASK->as, flags, FRAMES2SIZE(pages), virt, 185 188 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { 186 189 /* … … 253 256 /** Wrapper for SYS_PHYSMEM_MAP syscall. 254 257 * 255 * @param phys _basePhysical base address to map256 * @param virt _baseDestination virtual address258 * @param phys Physical base address to map 259 * @param virt Destination virtual address 257 260 * @param pages Number of pages 258 261 * @param flags Flags of newly mapped pages … … 261 264 * 262 265 */ 263 sysarg_t sys_physmem_map( sysarg_t phys_base, sysarg_t virt_base,264 s ysarg_t pages, sysarg_t flags)265 { 266 return (sysarg_t) ddi_physmem_map(ALIGN_DOWN((uintptr_t) phys_base,267 FRAME_SIZE), ALIGN_DOWN((uintptr_t) virt_base, PAGE_SIZE),268 (size_t) pages, (int)flags);266 sysarg_t sys_physmem_map(uintptr_t phys, uintptr_t virt, 267 size_t pages, unsigned int flags) 268 { 269 return (sysarg_t) 270 ddi_physmem_map(ALIGN_DOWN(phys, FRAME_SIZE), 271 ALIGN_DOWN(virt, PAGE_SIZE), pages, flags); 269 272 } 270 273 … … 287 290 } 288 291 292 NO_TRACE static int dmamem_map(uintptr_t virt, size_t size, 293 unsigned int map_flags, unsigned int flags, void **phys) 294 { 295 ASSERT(TASK); 296 297 if ((flags & DMAMEM_FLAGS_ANONYMOUS) == 0) { 298 // TODO: implement locking of non-anonymous mapping 299 return page_find_mapping(virt, phys); 300 } else { 301 // TODO: implement locking 302 303 if ((virt % PAGE_SIZE) != 0) 304 return EBADMEM; 305 306 size_t pages = SIZE2FRAMES(size); 307 uint8_t order; 308 309 /* We need the 2^order >= pages */ 310 if (pages == 1) 311 order = 0; 312 else 313 order = fnzb(pages - 1) + 1; 314 315 *phys = frame_alloc_noreserve(order, 0); 316 if (*phys == NULL) 317 return ENOMEM; 318 319 mem_backend_data_t backend_data; 320 backend_data.base = (uintptr_t) *phys; 321 backend_data.frames = pages; 322 323 if (!as_area_create(TASK->as, map_flags, size, virt, 324 AS_AREA_ATTR_NONE, &phys_backend, &backend_data)) { 325 frame_free_noreserve((uintptr_t) *phys); 326 return ENOMEM; 327 } 328 329 return EOK; 330 } 331 } 332 333 NO_TRACE static int dmamem_unmap(uintptr_t virt, size_t size, 334 unsigned int flags) 335 { 336 // TODO: implement unlocking & unmap 337 return EOK; 338 } 339 340 sysarg_t sys_dmamem_map(uintptr_t virt, size_t size, unsigned int map_flags, 341 unsigned int flags, void *phys_ptr) 342 { 343 void *phys; 344 int rc = dmamem_map(virt, size, map_flags, flags, &phys); 345 if (rc != EOK) 346 return rc; 347 348 rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys)); 349 if (rc != EOK) { 350 dmamem_unmap(virt, size, flags); 351 return rc; 352 } 353 354 return EOK; 355 } 356 357 sysarg_t sys_dmamem_unmap(uintptr_t virt, size_t size, unsigned int flags) 358 { 359 return dmamem_unmap(virt, size, flags); 360 } 361 289 362 /** @} 290 363 */ -
kernel/generic/src/ipc/irq.c
r3b71e84d r7aaed09 365 365 return IRQ_DECLINE; 366 366 367 #define CMD_MEM_READ(target) \368 do { \369 void *va = code->cmds[i].addr; \370 if (AS != irq->driver_as) \371 as_switch(AS, irq->driver_as); \372 memcpy_from_uspace(&target, va, (sizeof(target))); \373 if (dstarg) \374 scratch[dstarg] = target; \375 } while(0)376 377 #define CMD_MEM_WRITE(val) \378 do { \379 void *va = code->cmds[i].addr; \380 if (AS != irq->driver_as) \381 as_switch(AS, irq->driver_as); \382 memcpy_to_uspace(va, &val, sizeof(val)); \383 } while (0)384 385 367 as_t *current_as = AS; 386 size_t i; 387 for (i = 0; i < code->cmdcount; i++) { 368 if (current_as != irq->driver_as) 369 as_switch(AS, irq->driver_as); 370 371 for (size_t i = 0; i < code->cmdcount; i++) { 388 372 uint32_t dstval; 373 void *va; 374 uint8_t val8; 375 uint16_t val16; 376 uint32_t val32; 377 389 378 uintptr_t srcarg = code->cmds[i].srcarg; 390 379 uintptr_t dstarg = code->cmds[i].dstarg; … … 442 431 } 443 432 break; 444 case CMD_MEM_READ_8: { 445 uint8_t val; 446 CMD_MEM_READ(val); 447 break; 448 } 449 case CMD_MEM_READ_16: { 450 uint16_t val; 451 CMD_MEM_READ(val); 452 break; 453 } 454 case CMD_MEM_READ_32: { 455 uint32_t val; 456 CMD_MEM_READ(val); 457 break; 458 } 459 case CMD_MEM_WRITE_8: { 460 uint8_t val = code->cmds[i].value; 461 CMD_MEM_WRITE(val); 462 break; 463 } 464 case CMD_MEM_WRITE_16: { 465 uint16_t val = code->cmds[i].value; 466 CMD_MEM_WRITE(val); 467 break; 468 } 469 case CMD_MEM_WRITE_32: { 470 uint32_t val = code->cmds[i].value; 471 CMD_MEM_WRITE(val); 472 break; 473 } 433 case CMD_MEM_READ_8: 434 va = code->cmds[i].addr; 435 memcpy_from_uspace(&val8, va, sizeof(val8)); 436 if (dstarg) 437 scratch[dstarg] = val8; 438 break; 439 case CMD_MEM_READ_16: 440 va = code->cmds[i].addr; 441 memcpy_from_uspace(&val16, va, sizeof(val16)); 442 if (dstarg) 443 scratch[dstarg] = val16; 444 break; 445 case CMD_MEM_READ_32: 446 va = code->cmds[i].addr; 447 memcpy_from_uspace(&val32, va, sizeof(val32)); 448 if (dstarg) 449 scratch[dstarg] = val32; 450 break; 451 case CMD_MEM_WRITE_8: 452 val8 = code->cmds[i].value; 453 va = code->cmds[i].addr; 454 memcpy_to_uspace(va, &val8, sizeof(val8)); 455 break; 456 case CMD_MEM_WRITE_16: 457 val16 = code->cmds[i].value; 458 va = code->cmds[i].addr; 459 memcpy_to_uspace(va, &val16, sizeof(val16)); 460 break; 461 case CMD_MEM_WRITE_32: 462 val32 = code->cmds[i].value; 463 va = code->cmds[i].addr; 464 memcpy_to_uspace(va, &val32, sizeof(val32)); 465 break; 474 466 case CMD_MEM_WRITE_A_8: 475 467 if (srcarg) { 476 uint8_t val = scratch[srcarg]; 477 CMD_MEM_WRITE(val); 468 val8 = scratch[srcarg]; 469 va = code->cmds[i].addr; 470 memcpy_to_uspace(va, &val8, sizeof(val8)); 478 471 } 479 472 break; 480 473 case CMD_MEM_WRITE_A_16: 481 474 if (srcarg) { 482 uint16_t val = scratch[srcarg]; 483 CMD_MEM_WRITE(val); 475 val16 = scratch[srcarg]; 476 va = code->cmds[i].addr; 477 memcpy_to_uspace(va, &val16, sizeof(val16)); 484 478 } 485 479 break; 486 480 case CMD_MEM_WRITE_A_32: 487 481 if (srcarg) { 488 uint32_t val = scratch[srcarg]; 489 CMD_MEM_WRITE(val); 482 val32 = scratch[srcarg]; 483 va = code->cmds[i].addr; 484 memcpy_to_uspace(va, &val32, sizeof(val32)); 490 485 } 491 486 break; … … 513 508 } 514 509 } 510 515 511 if (AS != current_as) 516 512 as_switch(AS, current_as); -
kernel/generic/src/ipc/sysipc.c
r3b71e84d r7aaed09 278 278 } 279 279 } else if (IPC_GET_IMETHOD(*olddata) == IPC_M_SHARE_IN) { 280 if (!IPC_GET_RETVAL(answer->data)) { 280 if (!IPC_GET_RETVAL(answer->data)) { 281 281 irq_spinlock_lock(&answer->sender->lock, true); 282 282 as_t *as = answer->sender->as; -
kernel/generic/src/lib/rd.c
r3b71e84d r7aaed09 33 33 /** 34 34 * @file 35 * @brief 35 * @brief RAM disk support. 36 36 * 37 37 * Support for RAM disk images. … … 39 39 40 40 #include <lib/rd.h> 41 #include <byteorder.h>42 41 #include <mm/frame.h> 43 42 #include <sysinfo/sysinfo.h> 44 43 #include <ddi/ddi.h> 45 #include <align.h>46 44 47 static parea_t rd_parea; /**< Physical memory area for rd. */ 45 /** Physical memory area for RAM disk. */ 46 static parea_t rd_parea; 48 47 49 /** 50 * RAM disk initialization routine. At this point, the RAM disk memory is shared 51 * and information about the share is provided as sysinfo values to the 52 * userspace tasks. 53 */ 54 int init_rd(rd_header_t *header, size_t size) 48 /** RAM disk initialization routine 49 * 50 * The information about the RAM disk is provided as sysinfo 51 * values to the uspace tasks. 52 * 53 */ 54 void init_rd(void *data, size_t size) 55 55 { 56 /* Identify RAM disk */ 57 if ((header->magic[0] != RD_MAG0) || (header->magic[1] != RD_MAG1) || 58 (header->magic[2] != RD_MAG2) || (header->magic[3] != RD_MAG3)) 59 return RE_INVALID; 56 uintptr_t base = KA2PA((uintptr_t) data); 57 ASSERT((base % FRAME_SIZE) == 0); 60 58 61 /* Identify version */ 62 if (header->version != RD_VERSION) 63 return RE_UNSUPPORTED; 64 65 uint32_t hsize; 66 uint64_t dsize; 67 switch (header->data_type) { 68 case RD_DATA_LSB: 69 hsize = uint32_t_le2host(header->header_size); 70 dsize = uint64_t_le2host(header->data_size); 71 break; 72 case RD_DATA_MSB: 73 hsize = uint32_t_be2host(header->header_size); 74 dsize = uint64_t_be2host(header->data_size); 75 break; 76 default: 77 return RE_UNSUPPORTED; 78 } 79 80 if ((hsize % FRAME_SIZE) || (dsize % FRAME_SIZE)) 81 return RE_UNSUPPORTED; 82 83 if (hsize > size) 84 return RE_INVALID; 85 86 if ((uint64_t) hsize + dsize > size) 87 dsize = size - hsize; 88 89 rd_parea.pbase = ALIGN_DOWN((uintptr_t) KA2PA((void *) header + hsize), 90 FRAME_SIZE); 91 rd_parea.frames = SIZE2FRAMES(dsize); 59 rd_parea.pbase = base; 60 rd_parea.frames = SIZE2FRAMES(size); 92 61 rd_parea.unpriv = false; 93 62 rd_parea.mapped = false; 94 63 ddi_parea_register(&rd_parea); 95 64 96 65 sysinfo_set_item_val("rd", NULL, true); 97 sysinfo_set_item_val("rd.header_size", NULL, hsize); 98 sysinfo_set_item_val("rd.size", NULL, dsize); 99 sysinfo_set_item_val("rd.address.physical", NULL, 100 (sysarg_t) KA2PA((void *) header + hsize)); 101 102 return RE_OK; 66 sysinfo_set_item_val("rd.size", NULL, size); 67 sysinfo_set_item_val("rd.address.physical", NULL, (sysarg_t) base); 103 68 } 104 69 -
kernel/generic/src/main/kinit.c
r3b71e84d r7aaed09 179 179 for (i = 0; i < init.cnt; i++) { 180 180 if (init.tasks[i].addr % FRAME_SIZE) { 181 printf("init[%zu] .addris not frame aligned\n", i);181 printf("init[%zu]: Address is not frame aligned\n", i); 182 182 programs[i].task = NULL; 183 183 continue; … … 203 203 namebuf, &programs[i]); 204 204 205 if ((rc == 0) && (programs[i].task != NULL)) { 205 if (rc == 0) { 206 if (programs[i].task != NULL) { 207 /* 208 * Set capabilities to init userspace tasks. 209 */ 210 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER | 211 CAP_IO_MANAGER | CAP_IRQ_REG); 212 213 if (!ipc_phone_0) 214 ipc_phone_0 = &programs[i].task->answerbox; 215 } 216 206 217 /* 207 * Set capabilities to init userspace tasks. 218 * If programs[i].task == NULL then it is 219 * the program loader and it was registered 220 * successfully. 208 221 */ 209 cap_set(programs[i].task, CAP_CAP | CAP_MEM_MANAGER | 210 CAP_IO_MANAGER | CAP_IRQ_REG); 211 212 if (!ipc_phone_0) 213 ipc_phone_0 = &programs[i].task->answerbox; 214 } else if (rc == 0) { 215 /* It was the program loader and was registered */ 216 } else { 217 /* RAM disk image */ 218 int rd = init_rd((rd_header_t *) init.tasks[i].addr, init.tasks[i].size); 219 220 if (rd != RE_OK) 221 printf("Init binary %zu not used (error %d)\n", i, rd); 222 } 222 } else if (i == init.cnt - 1) { 223 /* 224 * Assume the last task is the RAM disk. 225 */ 226 init_rd((void *) init.tasks[i].addr, init.tasks[i].size); 227 } else 228 printf("init[%zu]: Init binary load failed (error %d)\n", i, rc); 223 229 } 224 230 -
kernel/generic/src/main/main.c
r3b71e84d r7aaed09 268 268 * Create the first thread. 269 269 */ 270 thread_t *kinit_thread 271 =thread_create(kinit, NULL, kernel, 0, "kinit", true);270 thread_t *kinit_thread = 271 thread_create(kinit, NULL, kernel, 0, "kinit", true); 272 272 if (!kinit_thread) 273 273 panic("Cannot create kinit thread."); -
kernel/generic/src/mm/page.c
r3b71e84d r7aaed09 53 53 * We assume that the other processors are either not using the mapping yet 54 54 * (i.e. during the bootstrap) or are executing the TLB shootdown code. While 55 * we don't care much about the former case, the processors in the latter case 55 * we don't care much about the former case, the processors in the latter case 56 56 * will do an implicit serialization by virtue of running the TLB shootdown 57 57 * interrupt handler. … … 198 198 } 199 199 200 int page_find_mapping(uintptr_t virt, void **phys) 201 { 202 mutex_lock(&AS->lock); 203 204 pte_t *pte = page_mapping_find(AS, virt, false); 205 if ((!PTE_VALID(pte)) || (!PTE_PRESENT(pte))) { 206 mutex_unlock(&AS->lock); 207 return ENOENT; 208 } 209 210 *phys = (void *) PTE_GET_FRAME(pte) + 211 (virt - ALIGN_DOWN(virt, PAGE_SIZE)); 212 213 mutex_unlock(&AS->lock); 214 215 return EOK; 216 } 200 217 201 218 /** Syscall wrapper for getting mapping of a virtual page. 202 * 203 * @retval EOK Everything went find, @p uspace_frame and @p uspace_node 204 * contains correct values. 205 * @retval ENOENT Virtual address has no mapping. 206 */ 207 sysarg_t sys_page_find_mapping(uintptr_t virt_address, 208 uintptr_t *uspace_frame) 209 { 210 mutex_lock(&AS->lock); 211 212 pte_t *pte = page_mapping_find(AS, virt_address, false); 213 if (!PTE_VALID(pte) || !PTE_PRESENT(pte)) { 214 mutex_unlock(&AS->lock); 215 216 return (sysarg_t) ENOENT; 217 } 218 219 uintptr_t phys_address = PTE_GET_FRAME(pte); 220 221 mutex_unlock(&AS->lock); 222 223 int rc = copy_to_uspace(uspace_frame, 224 &phys_address, sizeof(phys_address)); 225 if (rc != EOK) { 226 return (sysarg_t) rc; 227 } 228 229 return EOK; 219 * 220 * @return EOK on success. 221 * @return ENOENT if no virtual address mapping found. 222 * 223 */ 224 sysarg_t sys_page_find_mapping(uintptr_t virt, void *phys_ptr) 225 { 226 void *phys; 227 int rc = page_find_mapping(virt, &phys); 228 if (rc != EOK) 229 return rc; 230 231 rc = copy_to_uspace(phys_ptr, &phys, sizeof(phys)); 232 return (sysarg_t) rc; 230 233 } 231 234 -
kernel/generic/src/syscall/syscall.c
r3b71e84d r7aaed09 176 176 (syshandler_t) sys_device_assign_devno, 177 177 (syshandler_t) sys_physmem_map, 178 (syshandler_t) sys_dmamem_map, 179 (syshandler_t) sys_dmamem_unmap, 178 180 (syshandler_t) sys_iospace_enable, 179 181 (syshandler_t) sys_register_irq,
Note:
See TracChangeset
for help on using the changeset viewer.