Changeset fe56c08a in mainline
- Timestamp:
- 2012-01-28T09:17:24Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ca3d77a
- Parents:
- 8da2c60 (diff), 9970a5a (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:
-
- 31 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/arm32/src/arm32.c
r8da2c60 rfe56c08a 57 57 size_t i; 58 58 for (i = 0; i < init.cnt; i++) { 59 init.tasks[i]. addr = (uintptr_t) bootinfo->tasks[i].addr;59 init.tasks[i].paddr = KA2PA(bootinfo->tasks[i].addr); 60 60 init.tasks[i].size = bootinfo->tasks[i].size; 61 61 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/arm32/src/mach/gta02/gta02.c
r8da2c60 rfe56c08a 38 38 #include <arch/mm/page.h> 39 39 #include <mm/page.h> 40 #include <mm/km.h> 40 41 #include <genarch/fb/fb.h> 41 42 #include <abi/fb/visuals.h> … … 101 102 s3c24xx_irqc_regs_t *irqc_regs; 102 103 103 gta02_timer = (void *) hw_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE); 104 irqc_regs = (void *) hw_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE); 104 gta02_timer = (void *) km_map(S3C24XX_TIMER_ADDRESS, PAGE_SIZE, 105 PAGE_NOT_CACHEABLE); 106 irqc_regs = (void *) km_map(S3C24XX_IRQC_ADDRESS, PAGE_SIZE, 107 PAGE_NOT_CACHEABLE); 105 108 106 109 /* Initialize interrupt controller. */ -
kernel/arch/arm32/src/mach/integratorcp/integratorcp.c
r8da2c60 rfe56c08a 45 45 #include <mm/page.h> 46 46 #include <mm/frame.h> 47 #include <mm/km.h> 47 48 #include <arch/mm/frame.h> 48 49 #include <arch/mach/integratorcp/integratorcp.h> … … 128 129 void icp_init(void) 129 130 { 130 icp_hw_map.uart = hw_map(ICP_UART, PAGE_SIZE); 131 icp_hw_map.kbd_ctrl = hw_map(ICP_KBD, PAGE_SIZE); 131 icp_hw_map.uart = km_map(ICP_UART, PAGE_SIZE, 132 PAGE_WRITE | PAGE_NOT_CACHEABLE); 133 icp_hw_map.kbd_ctrl = km_map(ICP_KBD, PAGE_SIZE, PAGE_NOT_CACHEABLE); 132 134 icp_hw_map.kbd_stat = icp_hw_map.kbd_ctrl + ICP_KBD_STAT; 133 135 icp_hw_map.kbd_data = icp_hw_map.kbd_ctrl + ICP_KBD_DATA; 134 136 icp_hw_map.kbd_intstat = icp_hw_map.kbd_ctrl + ICP_KBD_INTR_STAT; 135 icp_hw_map.rtc = hw_map(ICP_RTC, PAGE_SIZE); 137 icp_hw_map.rtc = km_map(ICP_RTC, PAGE_SIZE, 138 PAGE_WRITE | PAGE_NOT_CACHEABLE); 136 139 icp_hw_map.rtc1_load = icp_hw_map.rtc + ICP_RTC1_LOAD_OFFSET; 137 140 icp_hw_map.rtc1_read = icp_hw_map.rtc + ICP_RTC1_READ_OFFSET; … … 141 144 icp_hw_map.rtc1_intrstat = icp_hw_map.rtc + ICP_RTC1_INTRSTAT_OFFSET; 142 145 143 icp_hw_map.irqc = hw_map(ICP_IRQC, PAGE_SIZE); 146 icp_hw_map.irqc = km_map(ICP_IRQC, PAGE_SIZE, 147 PAGE_WRITE | PAGE_NOT_CACHEABLE); 144 148 icp_hw_map.irqc_mask = icp_hw_map.irqc + ICP_IRQC_MASK_OFFSET; 145 149 icp_hw_map.irqc_unmask = icp_hw_map.irqc + ICP_IRQC_UNMASK_OFFSET; 146 icp_hw_map.cmcr = hw_map(ICP_CMCR, PAGE_SIZE); 150 icp_hw_map.cmcr = km_map(ICP_CMCR, PAGE_SIZE, 151 PAGE_WRITE | PAGE_NOT_CACHEABLE); 147 152 icp_hw_map.sdramcr = icp_hw_map.cmcr + ICP_SDRAMCR_OFFSET; 148 icp_hw_map.vga = hw_map(ICP_VGA, PAGE_SIZE); 153 icp_hw_map.vga = km_map(ICP_VGA, PAGE_SIZE, 154 PAGE_WRITE | PAGE_NOT_CACHEABLE); 149 155 150 156 hw_map_init_called = true; -
kernel/arch/arm32/src/mach/testarm/testarm.c
r8da2c60 rfe56c08a 37 37 #include <arch/mach/testarm/testarm.h> 38 38 #include <mm/page.h> 39 #include <mm/km.h> 39 40 #include <genarch/fb/fb.h> 40 41 #include <abi/fb/visuals.h> … … 71 72 void gxemul_init(void) 72 73 { 73 gxemul_kbd = (void *) hw_map(GXEMUL_KBD_ADDRESS, PAGE_SIZE); 74 gxemul_rtc = (void *) hw_map(GXEMUL_RTC_ADDRESS, PAGE_SIZE); 75 gxemul_irqc = (void *) hw_map(GXEMUL_IRQC_ADDRESS, PAGE_SIZE); 74 gxemul_kbd = (void *) km_map(GXEMUL_KBD_ADDRESS, PAGE_SIZE, 75 PAGE_WRITE | PAGE_NOT_CACHEABLE); 76 gxemul_rtc = (void *) km_map(GXEMUL_RTC_ADDRESS, PAGE_SIZE, 77 PAGE_WRITE | PAGE_NOT_CACHEABLE); 78 gxemul_irqc = (void *) km_map(GXEMUL_IRQC_ADDRESS, PAGE_SIZE, 79 PAGE_WRITE | PAGE_NOT_CACHEABLE); 76 80 } 77 81 -
kernel/arch/ia32/src/smp/smp.c
r8da2c60 rfe56c08a 47 47 #include <debug.h> 48 48 #include <arch/asm.h> 49 #include <mm/page.h> 49 50 #include <mm/frame.h> 50 #include <mm/ page.h>51 #include <mm/km.h> 51 52 #include <mm/slab.h> 52 53 #include <mm/as.h> … … 72 73 73 74 if (config.cpu_count > 1) { 74 l_apic = (uint32_t *) hw_map((uintptr_t) l_apic, PAGE_SIZE); 75 io_apic = (uint32_t *) hw_map((uintptr_t) io_apic, PAGE_SIZE); 75 l_apic = (uint32_t *) km_map((uintptr_t) l_apic, PAGE_SIZE, 76 PAGE_WRITE | PAGE_NOT_CACHEABLE); 77 io_apic = (uint32_t *) km_map((uintptr_t) io_apic, PAGE_SIZE, 78 PAGE_WRITE | PAGE_NOT_CACHEABLE); 76 79 } 77 80 } -
kernel/arch/ia64/src/ia64.c
r8da2c60 rfe56c08a 53 53 #include <genarch/srln/srln.h> 54 54 #include <mm/page.h> 55 #include <mm/km.h> 55 56 56 57 #ifdef MACHINE_ski … … 69 70 void arch_pre_main(void) 70 71 { 71 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, CONFIG_INIT_TASKS); 72 init.cnt = min3(bootinfo->taskmap.cnt, TASKMAP_MAX_RECORDS, 73 CONFIG_INIT_TASKS); 72 74 size_t i; 75 73 76 for (i = 0; i < init.cnt; i++) { 74 init.tasks[i].addr = 75 ((unsigned long) bootinfo->taskmap.tasks[i].addr) | 76 VRN_MASK; 77 init.tasks[i].paddr = 78 (uintptr_t) bootinfo->taskmap.tasks[i].addr; 77 79 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 78 80 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, … … 87 89 static void iosapic_init(void) 88 90 { 89 uintptr_t IOSAPIC = hw_map(iosapic_base, PAGE_SIZE); 91 uintptr_t IOSAPIC = km_map(iosapic_base, PAGE_SIZE, 92 PAGE_WRITE | PAGE_NOT_CACHEABLE); 90 93 int i; 91 94 … … 115 118 if (config.cpu_active == 1) { 116 119 /* Map the page with legacy I/O. */ 117 legacyio_virt_base = hw_map(LEGACYIO_PHYS_BASE, LEGACYIO_SIZE); 120 legacyio_virt_base = km_map(LEGACYIO_PHYS_BASE, LEGACYIO_SIZE, 121 PAGE_WRITE | PAGE_NOT_CACHEABLE); 118 122 119 123 iosapic_init(); -
kernel/arch/mips32/src/mips32.c
r8da2c60 rfe56c08a 78 78 size_t i; 79 79 for (i = 0; i < init.cnt; i++) { 80 init.tasks[i]. addr = (uintptr_t) bootinfo->tasks[i].addr;80 init.tasks[i].paddr = KA2PA(bootinfo->tasks[i].addr); 81 81 init.tasks[i].size = bootinfo->tasks[i].size; 82 82 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/mips32/src/mm/frame.c
r8da2c60 rfe56c08a 123 123 for (i = 0; i < init.cnt; i++) 124 124 if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, 125 KA2PA(init.tasks[i].addr), init.tasks[i].size)) {125 init.tasks[i].paddr, init.tasks[i].size)) { 126 126 safe = false; 127 127 break; -
kernel/arch/mips64/src/mips64.c
r8da2c60 rfe56c08a 78 78 size_t i; 79 79 for (i = 0; i < init.cnt; i++) { 80 init.tasks[i]. addr = (uintptr_t) bootinfo->tasks[i].addr;80 init.tasks[i].paddr = KA2PA(bootinfo->tasks[i].addr); 81 81 init.tasks[i].size = bootinfo->tasks[i].size; 82 82 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/mips64/src/mm/frame.c
r8da2c60 rfe56c08a 115 115 for (i = 0; i < init.cnt; i++) 116 116 if (overlaps(frame << ZERO_PAGE_WIDTH, ZERO_PAGE_SIZE, 117 KA2PA(init.tasks[i].addr), init.tasks[i].size)) {117 init.tasks[i].paddr, init.tasks[i].size)) { 118 118 safe = false; 119 119 break; -
kernel/arch/ppc32/src/drivers/pic.c
r8da2c60 rfe56c08a 34 34 35 35 #include <arch/drivers/pic.h> 36 #include <mm/ page.h>36 #include <mm/km.h> 37 37 #include <byteorder.h> 38 38 #include <bitops.h> … … 42 42 void pic_init(uintptr_t base, size_t size, cir_t *cir, void **cir_arg) 43 43 { 44 pic = (uint32_t *) hw_map(base, size);44 pic = (uint32_t *) km_map(base, size, PAGE_WRITE | PAGE_NOT_CACHEABLE); 45 45 *cir = pic_ack_interrupt; 46 46 *cir_arg = NULL; -
kernel/arch/ppc32/src/ppc32.c
r8da2c60 rfe56c08a 46 46 #include <userspace.h> 47 47 #include <mm/page.h> 48 #include <mm/km.h> 48 49 #include <abi/proc/uarg.h> 49 50 #include <console/console.h> … … 71 72 size_t i; 72 73 for (i = 0; i < init.cnt; i++) { 73 init.tasks[i]. addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;74 init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr); 74 75 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 75 76 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, … … 208 209 size_t size = 2 * PAGE_SIZE; 209 210 210 cuda_t *cuda = (cuda_t *) 211 (hw_map(aligned_addr, offset + size) + offset);211 cuda_t *cuda = (cuda_t *) (km_map(aligned_addr, offset + size, 212 PAGE_WRITE | PAGE_NOT_CACHEABLE) + offset); 212 213 213 214 /* Initialize I/O controller */ -
kernel/arch/sparc64/src/drivers/kbd.c
r8da2c60 rfe56c08a 40 40 #include <mm/page.h> 41 41 #include <arch/mm/page.h> 42 #include <mm/km.h> 42 43 #include <typedefs.h> 43 44 #include <align.h> … … 113 114 size_t offset = pa - aligned_addr; 114 115 115 ns16550_t *ns16550 = (ns16550_t *) 116 (hw_map(aligned_addr, offset + size) + offset);116 ns16550_t *ns16550 = (ns16550_t *) (km_map(aligned_addr, offset + size, 117 PAGE_WRITE | PAGE_NOT_CACHEABLE) + offset); 117 118 118 119 ns16550_instance_t *ns16550_instance = ns16550_init(ns16550, inr, cir, cir_arg); -
kernel/arch/sparc64/src/drivers/pci.c
r8da2c60 rfe56c08a 39 39 #include <genarch/ofw/upa.h> 40 40 #include <arch/trap/interrupt.h> 41 #include <mm/ page.h>41 #include <mm/km.h> 42 42 #include <mm/slab.h> 43 43 #include <typedefs.h> … … 109 109 pci->model = PCI_SABRE; 110 110 pci->op = &pci_sabre_ops; 111 pci->reg = (uint64_t *) hw_map(paddr, reg[SABRE_INTERNAL_REG].size); 111 pci->reg = (uint64_t *) km_map(paddr, reg[SABRE_INTERNAL_REG].size, 112 PAGE_WRITE | PAGE_NOT_CACHEABLE); 112 113 113 114 /* … … 156 157 pci->model = PCI_PSYCHO; 157 158 pci->op = &pci_psycho_ops; 158 pci->reg = (uint64_t *) hw_map(paddr, reg[PSYCHO_INTERNAL_REG].size); 159 pci->reg = (uint64_t *) km_map(paddr, reg[PSYCHO_INTERNAL_REG].size, 160 PAGE_WRITE | PAGE_NOT_CACHEABLE); 159 161 160 162 /* -
kernel/arch/sparc64/src/sun4u/sparc64.c
r8da2c60 rfe56c08a 62 62 size_t i; 63 63 for (i = 0; i < init.cnt; i++) { 64 init.tasks[i]. addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;64 init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr); 65 65 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 66 66 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/arch/sparc64/src/sun4v/sparc64.c
r8da2c60 rfe56c08a 64 64 size_t i; 65 65 for (i = 0; i < init.cnt; i++) { 66 init.tasks[i]. addr = (uintptr_t) bootinfo->taskmap.tasks[i].addr;66 init.tasks[i].paddr = KA2PA(bootinfo->taskmap.tasks[i].addr); 67 67 init.tasks[i].size = bootinfo->taskmap.tasks[i].size; 68 68 str_cpy(init.tasks[i].name, CONFIG_TASK_NAME_BUFLEN, -
kernel/genarch/src/drivers/ega/ega.c
r8da2c60 rfe56c08a 37 37 #include <genarch/drivers/ega/ega.h> 38 38 #include <putchar.h> 39 #include <mm/ page.h>39 #include <mm/km.h> 40 40 #include <mm/as.h> 41 41 #include <mm/slab.h> 42 #include <arch/mm/page.h>43 42 #include <typedefs.h> 44 43 #include <arch/asm.h> … … 598 597 599 598 instance->base = base; 600 instance->addr = (uint8_t *) hw_map(addr, EGA_VRAM_SIZE); 599 instance->addr = (uint8_t *) km_map(addr, EGA_VRAM_SIZE, 600 PAGE_WRITE | PAGE_NOT_CACHEABLE); 601 601 if (!instance->addr) { 602 602 LOG("Unable to EGA video memory."); -
kernel/genarch/src/drivers/s3c24xx_uart/s3c24xx_uart.c
r8da2c60 rfe56c08a 45 45 #include <mm/slab.h> 46 46 #include <mm/page.h> 47 #include <mm/km.h> 47 48 #include <sysinfo/sysinfo.h> 48 49 #include <str.h> … … 113 114 uart_dev->data = uart; 114 115 115 uart->io = (s3c24xx_uart_io_t *) hw_map(paddr, PAGE_SIZE); 116 uart->io = (s3c24xx_uart_io_t *) km_map(paddr, PAGE_SIZE, 117 PAGE_WRITE | PAGE_NOT_CACHEABLE); 116 118 uart->indev = NULL; 117 119 -
kernel/genarch/src/fb/fb.c
r8da2c60 rfe56c08a 40 40 #include <console/console.h> 41 41 #include <sysinfo/sysinfo.h> 42 #include <mm/ page.h>42 #include <mm/km.h> 43 43 #include <mm/slab.h> 44 44 #include <align.h> … … 587 587 size_t glyphsize = FONT_GLYPHS * instance->glyphbytes; 588 588 589 instance->addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize); 589 instance->addr = (uint8_t *) km_map((uintptr_t) props->addr, fbsize, 590 PAGE_WRITE | PAGE_NOT_CACHEABLE); 590 591 if (!instance->addr) { 591 592 LOG("Unable to map framebuffer."); -
kernel/genarch/src/multiboot/multiboot.c
r8da2c60 rfe56c08a 77 77 break; 78 78 79 init.tasks[init.cnt]. addr = PA2KA(mods[i].start);79 init.tasks[init.cnt].paddr = mods[i].start; 80 80 init.tasks[init.cnt].size = mods[i].end - mods[i].start; 81 81 -
kernel/genarch/src/multiboot/multiboot2.c
r8da2c60 rfe56c08a 45 45 { 46 46 if (init.cnt < CONFIG_INIT_TASKS) { 47 init.tasks[init.cnt]. addr = PA2KA(module->start);47 init.tasks[init.cnt].paddr = module->start; 48 48 init.tasks[init.cnt].size = module->end - module->start; 49 49 multiboot_extract_command(init.tasks[init.cnt].name, -
kernel/generic/include/config.h
r8da2c60 rfe56c08a 53 53 54 54 typedef struct { 55 uintptr_t addr;55 uintptr_t paddr; 56 56 size_t size; 57 57 char name[CONFIG_TASK_NAME_BUFLEN]; -
kernel/generic/include/mm/km.h
r8da2c60 rfe56c08a 49 49 extern bool km_is_non_identity(uintptr_t); 50 50 51 extern uintptr_t km_map(uintptr_t, size_t, unsigned int); 52 51 53 extern uintptr_t km_temporary_page_get(uintptr_t *, frame_flags_t); 52 54 extern void km_temporary_page_put(uintptr_t); -
kernel/generic/include/mm/page.h
r8da2c60 rfe56c08a 66 66 extern void map_structure(uintptr_t, size_t); 67 67 68 extern uintptr_t hw_map(uintptr_t, size_t);69 70 68 extern int page_find_mapping(uintptr_t, void **); 71 69 extern sysarg_t sys_page_find_mapping(uintptr_t, void *); -
kernel/generic/src/lib/rd.c
r8da2c60 rfe56c08a 54 54 void init_rd(void *data, size_t size) 55 55 { 56 uintptr_t base = KA2PA((uintptr_t) data);56 uintptr_t base = (uintptr_t) data; 57 57 ASSERT((base % FRAME_SIZE) == 0); 58 58 -
kernel/generic/src/main/kinit.c
r8da2c60 rfe56c08a 57 57 #include <mm/as.h> 58 58 #include <mm/frame.h> 59 #include <mm/km.h> 59 60 #include <print.h> 60 61 #include <memstr.h> … … 68 69 #include <str.h> 69 70 #include <sysinfo/stats.h> 71 #include <align.h> 70 72 71 73 #ifdef CONFIG_SMP … … 178 180 179 181 for (i = 0; i < init.cnt; i++) { 180 if (init.tasks[i]. addr % FRAME_SIZE) {182 if (init.tasks[i].paddr % FRAME_SIZE) { 181 183 printf("init[%zu]: Address is not frame aligned\n", i); 182 184 programs[i].task = NULL; … … 199 201 str_cpy(namebuf + INIT_PREFIX_LEN, 200 202 TASK_NAME_BUFLEN - INIT_PREFIX_LEN, name); 201 202 int rc = program_create_from_image((void *) init.tasks[i].addr, 203 namebuf, &programs[i]); 203 204 /* 205 * Create virtual memory mappings for init task images. 206 */ 207 uintptr_t page = km_map(init.tasks[i].paddr, 208 init.tasks[i].size, 209 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 210 ASSERT(page); 211 212 int rc = program_create_from_image((void *) page, namebuf, 213 &programs[i]); 204 214 205 215 if (rc == 0) { … … 224 234 * Assume the last task is the RAM disk. 225 235 */ 226 init_rd((void *) init.tasks[i]. addr, init.tasks[i].size);236 init_rd((void *) init.tasks[i].paddr, init.tasks[i].size); 227 237 } else 228 238 printf("init[%zu]: Init binary load failed (error %d)\n", i, rc); -
kernel/generic/src/main/main.c
r8da2c60 rfe56c08a 151 151 size_t i; 152 152 for (i = 0; i < init.cnt; i++) { 153 if (PA_OVERLAPS(config.stack_base, config.stack_size, 154 init.tasks[i].addr, init.tasks[i].size)) 155 config.stack_base = ALIGN_UP(init.tasks[i].addr + 156 init.tasks[i].size, config.stack_size); 153 if (overlaps(KA2PA(config.stack_base), config.stack_size, 154 init.tasks[i].paddr, init.tasks[i].size)) { 155 /* 156 * The init task overlaps with the memory behind the 157 * kernel image so it must be in low memory and we can 158 * use PA2KA on the init task's physical address. 159 */ 160 config.stack_base = ALIGN_UP( 161 PA2KA(init.tasks[i].paddr) + init.tasks[i].size, 162 config.stack_size); 163 } 157 164 } 158 165 -
kernel/generic/src/mm/backend_elf.c
r8da2c60 rfe56c08a 318 318 dirty = true; 319 319 } else { 320 frame = KA2PA(base + i * FRAME_SIZE); 320 pte_t *pte = page_mapping_find(AS_KERNEL, 321 base + i * FRAME_SIZE, true); 322 323 ASSERT(pte); 324 ASSERT(PTE_PRESENT(pte)); 325 326 frame = PTE_GET_FRAME(pte); 321 327 } 322 328 } else if (upage >= start_anon) { -
kernel/generic/src/mm/frame.c
r8da2c60 rfe56c08a 924 924 for (i = 0; i < init.cnt; i++) 925 925 if (overlaps(addr, PFN2ADDR(confcount), 926 KA2PA(init.tasks[i].addr),926 init.tasks[i].paddr, 927 927 init.tasks[i].size)) { 928 928 overlap = true; … … 1251 1251 size_t i; 1252 1252 for (i = 0; i < init.cnt; i++) { 1253 pfn_t pfn = ADDR2PFN( KA2PA(init.tasks[i].addr));1253 pfn_t pfn = ADDR2PFN(init.tasks[i].paddr); 1254 1254 frame_mark_unavailable(pfn, 1255 1255 SIZE2FRAMES(init.tasks[i].size)); -
kernel/generic/src/mm/km.c
r8da2c60 rfe56c08a 46 46 #include <debug.h> 47 47 #include <arch.h> 48 #include <align.h> 49 #include <macros.h> 50 #include <bitops.h> 48 51 49 52 static ra_arena_t *km_ni_arena; … … 120 123 ra_free(km_ni_arena, page, size); 121 124 } 125 126 uintptr_t km_map(uintptr_t paddr, size_t size, unsigned int flags) 127 { 128 uintptr_t vaddr; 129 size_t asize; 130 size_t align; 131 uintptr_t offs; 132 133 asize = ALIGN_UP(size, PAGE_SIZE); 134 align = ispwr2(size) ? size : (1U << (fnzb(size) + 1)); 135 vaddr = km_page_alloc(asize, max(PAGE_SIZE, align)); 136 137 page_table_lock(AS_KERNEL, true); 138 for (offs = 0; offs < asize; offs += PAGE_SIZE) { 139 page_mapping_insert(AS_KERNEL, vaddr + offs, paddr + offs, 140 flags); 141 } 142 page_table_unlock(AS_KERNEL, true); 143 144 return vaddr; 145 } 146 122 147 123 148 /** Unmap kernen non-identity page. … … 165 190 FRAME_HIGHMEM | FRAME_ATOMIC | flags); 166 191 if (frame) { 167 page = km_page_alloc(PAGE_SIZE, PAGE_SIZE); 192 page = km_map(frame, PAGE_SIZE, 193 PAGE_READ | PAGE_WRITE | PAGE_CACHEABLE); 168 194 ASSERT(page); // FIXME 169 page_table_lock(AS_KERNEL, true);170 page_mapping_insert(AS_KERNEL, page, frame,171 PAGE_CACHEABLE | PAGE_READ | PAGE_WRITE);172 page_table_unlock(AS_KERNEL, true);173 195 } else { 174 196 frame = (uintptr_t) frame_alloc_noreserve(ONE_FRAME, -
kernel/generic/src/mm/page.c
r8da2c60 rfe56c08a 65 65 #include <arch/mm/asid.h> 66 66 #include <mm/as.h> 67 #include <mm/km.h>68 67 #include <mm/frame.h> 69 68 #include <arch/barrier.h> … … 76 75 #include <errno.h> 77 76 #include <align.h> 78 #include <macros.h>79 #include <bitops.h>80 77 81 78 /** Virtual operations for page subsystem. */ … … 193 190 } 194 191 195 uintptr_t hw_map(uintptr_t physaddr, size_t size)196 {197 uintptr_t virtaddr;198 size_t asize;199 size_t align;200 pfn_t i;201 202 asize = ALIGN_UP(size, PAGE_SIZE);203 align = ispwr2(size) ? size : (1U << (fnzb(size) + 1));204 virtaddr = km_page_alloc(asize, max(PAGE_SIZE, align));205 206 page_table_lock(AS_KERNEL, true);207 for (i = 0; i < ADDR2PFN(asize); i++) {208 uintptr_t addr = PFN2ADDR(i);209 page_mapping_insert(AS_KERNEL, virtaddr + addr, physaddr + addr,210 PAGE_NOT_CACHEABLE | PAGE_WRITE);211 }212 page_table_unlock(AS_KERNEL, true);213 214 return virtaddr;215 }216 217 192 int page_find_mapping(uintptr_t virt, void **phys) 218 193 {
Note:
See TracChangeset
for help on using the changeset viewer.