Deleted Added
sdiff udiff text old ( 265996 ) new ( 265998 )
full compact
1/*-
2 * Copyright (C) 2007-2009 Semihalf, Rafal Jaworowski <raj@semihalf.com>
3 * Copyright (C) 2006 Semihalf, Marian Balakowicz <m8@semihalf.com>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 35 unchanged lines hidden (view full) ---

44 * 0xc100_0000 - 0xc100_3fff : reserved for page zero/copy
45 * 0xc100_4000 - 0xc200_3fff : reserved for ptbl bufs
46 * 0xc200_4000 - 0xc200_8fff : guard page + kstack0
47 * 0xc200_9000 - 0xfeef_ffff : actual free KVA space
48 * 0xfef0_0000 - 0xffff_ffff : I/O devices region
49 */
50
51#include <sys/cdefs.h>
52__FBSDID("$FreeBSD: stable/10/sys/powerpc/booke/pmap.c 265996 2014-05-14 00:51:26Z ian $");
53
54#include <sys/param.h>
55#include <sys/malloc.h>
56#include <sys/ktr.h>
57#include <sys/proc.h>
58#include <sys/user.h>
59#include <sys/queue.h>
60#include <sys/systm.h>

--- 123 unchanged lines hidden (view full) ---

184
185#define TLB1_ENTRIES 16
186
187/* In-ram copy of the TLB1 */
188static tlb_entry_t tlb1[TLB1_ENTRIES];
189
190/* Next free entry in the TLB1 */
191static unsigned int tlb1_idx;
192
193static tlbtid_t tid_alloc(struct pmap *);
194
195static void tlb_print_entry(int, uint32_t, uint32_t, uint32_t, uint32_t);
196
197static int tlb1_set_entry(vm_offset_t, vm_offset_t, vm_size_t, uint32_t);
198static void tlb1_write_entry(unsigned int);
199static int tlb1_iomapped(int, vm_paddr_t, vm_size_t, vm_offset_t *);

--- 2476 unchanged lines hidden (view full) ---

2676 (pa + size) <= (tlb1[i].phys + tlb1[i].size))
2677 return (void *)(tlb1[i].virt +
2678 (pa - tlb1[i].phys));
2679 }
2680 }
2681
2682 size = roundup(size, PAGE_SIZE);
2683
2684 if (pa >= (VM_MAXUSER_ADDRESS + PAGE_SIZE) &&
2685 (pa + size - 1) < VM_MIN_KERNEL_ADDRESS)
2686 va = pa;
2687 else
2688 va = kva_alloc(size);
2689 res = (void *)va;
2690
2691 do {
2692 sz = 1 << (ilog2(size) & ~1);
2693 if (bootverbose)
2694 printf("Wiring VA=%x to PA=%x (size=%x), "
2695 "using TLB1[%d]\n", va, pa, sz, tlb1_idx);
2696 tlb1_set_entry(va, pa, sz, tlb_calc_wimg(pa, ma));

--- 383 unchanged lines hidden (view full) ---

3080 pgsz = pgs[idx];
3081 debugf("%u: %x -> %x, size=%x\n", idx, pa, va, pgsz);
3082 tlb1_set_entry(va, pa, pgsz, _TLB_ENTRY_MEM);
3083 pa += pgsz;
3084 va += pgsz;
3085 }
3086
3087 mapped = (va - base);
3088 debugf("mapped size 0x%08x (wasted space 0x%08x)\n",
3089 mapped, mapped - size);
3090 return (mapped);
3091}
3092
3093/*
3094 * TLB1 initialization routine, to be called after the very first
3095 * assembler level setup done in locore.S.
3096 */

--- 46 unchanged lines hidden (view full) ---

3143
3144 /* Setup TLB miss defaults */
3145 set_mas4_defaults();
3146}
3147
3148vm_offset_t
3149pmap_early_io_map(vm_paddr_t pa, vm_size_t size)
3150{
3151 static vm_offset_t early_io_map_base = VM_MAX_KERNEL_ADDRESS;
3152 vm_paddr_t pa_base;
3153 vm_offset_t va, sz;
3154 int i;
3155
3156 KASSERT(!pmap_bootstrapped, ("Do not use after PMAP is up!"));
3157
3158 for (i = 0; i < tlb1_idx; i++) {
3159 if (!(tlb1[i].mas1 & MAS1_VALID))
3160 continue;
3161 if (pa >= tlb1[i].phys && (pa + size) <=
3162 (tlb1[i].phys + tlb1[i].size))
3163 return (tlb1[i].virt + (pa - tlb1[i].phys));
3164 }
3165
3166 pa_base = trunc_page(pa);
3167 size = roundup(size + (pa - pa_base), PAGE_SIZE);
3168 va = early_io_map_base + (pa - pa_base);
3169
3170 do {
3171 sz = 1 << (ilog2(size) & ~1);
3172 tlb1_set_entry(early_io_map_base, pa_base, sz, _TLB_ENTRY_IO);
3173 size -= sz;
3174 pa_base += sz;
3175 early_io_map_base += sz;
3176 } while (size > 0);
3177
3178#ifdef SMP
3179 bp_ntlb1s = tlb1_idx;
3180#endif
3181
3182 return (va);
3183}

--- 105 unchanged lines hidden ---