Use a contrived 'tlb_entry' structure for passing the mappings for the

kernel text and data from the loader to the kernel, so that the tte format
is not part of the loader->kernel ABI.
This commit is contained in:
Jake Burkholder 2002-05-29 05:49:59 +00:00
parent b08270ba0f
commit 35738638d6
7 changed files with 31 additions and 23 deletions

View File

@ -92,7 +92,6 @@ ENTRY(dtlb_va_to_pa)
ENTRY(itlb_enter) ENTRY(itlb_enter)
rdpr %pstate, %o4 rdpr %pstate, %o4
wrpr %o4, PSTATE_IE, %pstate wrpr %o4, PSTATE_IE, %pstate
sllx %o0, PAGE_SHIFT, %o0
mov AA_IMMU_TAR, %o3 mov AA_IMMU_TAR, %o3
stxa %o0, [%o3] ASI_IMMU stxa %o0, [%o3] ASI_IMMU
stxa %o1, [%g0] ASI_ITLB_DATA_IN_REG stxa %o1, [%g0] ASI_ITLB_DATA_IN_REG
@ -103,7 +102,6 @@ ENTRY(itlb_enter)
ENTRY(dtlb_enter) ENTRY(dtlb_enter)
rdpr %pstate, %o4 rdpr %pstate, %o4
wrpr %o4, PSTATE_IE, %pstate wrpr %o4, PSTATE_IE, %pstate
sllx %o0, PAGE_SHIFT, %o0
mov AA_DMMU_TAR, %o3 mov AA_DMMU_TAR, %o3
stxa %o0, [%o3] ASI_DMMU stxa %o0, [%o3] ASI_DMMU
stxa %o1, [%g0] ASI_DTLB_DATA_IN_REG stxa %o1, [%g0] ASI_DTLB_DATA_IN_REG

View File

@ -63,8 +63,8 @@ static int mmu_mapin(vm_offset_t, vm_size_t);
char __progname[] = "FreeBSD/sparc64 loader"; char __progname[] = "FreeBSD/sparc64 loader";
struct tte *dtlb_store; struct tlb_entry *dtlb_store;
struct tte *itlb_store; struct tlb_entry *itlb_store;
int dtlb_slot; int dtlb_slot;
int itlb_slot; int itlb_slot;
@ -240,7 +240,7 @@ static int
mmu_mapin(vm_offset_t va, vm_size_t len) mmu_mapin(vm_offset_t va, vm_size_t len)
{ {
vm_offset_t pa, mva; vm_offset_t pa, mva;
struct tte tte; u_long data;
if (va + len > curkva) if (va + len > curkva)
curkva = va + len; curkva = va + len;
@ -275,13 +275,16 @@ mmu_mapin(vm_offset_t va, vm_size_t len)
panic("mmu_mapin: out of dtlb_slots"); panic("mmu_mapin: out of dtlb_slots");
if (itlb_slot >= itlb_slot_max) if (itlb_slot >= itlb_slot_max)
panic("mmu_mapin: out of itlb_slots"); panic("mmu_mapin: out of itlb_slots");
tte.tte_vpn = TV_VPN(va); data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP |
tte.tte_data = TD_V | TD_4M | TD_PA(pa) | TD_L | TD_CP |
TD_CV | TD_P | TD_W; TD_CV | TD_P | TD_W;
dtlb_store[dtlb_slot++] = tte; dtlb_store[dtlb_slot].te_pa = pa;
itlb_store[itlb_slot++] = tte; dtlb_store[dtlb_slot].te_va = va;
dtlb_enter(tte.tte_vpn, tte.tte_data); itlb_store[itlb_slot].te_pa = pa;
itlb_enter(tte.tte_vpn, tte.tte_data); itlb_store[itlb_slot].te_va = va;
dtlb_slot++;
itlb_slot++;
dtlb_enter(va, data);
itlb_enter(va, data);
pa = (vm_offset_t)-1; pa = (vm_offset_t)-1;
} }
len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len; len -= len > PAGE_SIZE_4M ? PAGE_SIZE_4M : len;

View File

@ -31,15 +31,14 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/reboot.h> #include <sys/reboot.h>
#include <sys/linker.h> #include <sys/linker.h>
#include <machine/tte.h>
#include <machine/metadata.h> #include <machine/metadata.h>
#include "bootstrap.h" #include "bootstrap.h"
#include "libofw.h" #include "libofw.h"
extern struct tte *dtlb_store; extern struct tlb_entry *dtlb_store;
extern struct tte *itlb_store; extern struct tlb_entry *itlb_store;
extern int dtlb_slot; extern int dtlb_slot;
extern int itlb_slot; extern int itlb_slot;
@ -318,10 +317,10 @@ md_load(char *args, vm_offset_t *modulep)
file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend); file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
file_addmetadata(kfp, MODINFOMD_DTLB_SLOTS, sizeof dtlb_slots, &dtlb_slots); file_addmetadata(kfp, MODINFOMD_DTLB_SLOTS, sizeof dtlb_slots, &dtlb_slots);
file_addmetadata(kfp, MODINFOMD_ITLB_SLOTS, sizeof itlb_slots, &itlb_slots); file_addmetadata(kfp, MODINFOMD_ITLB_SLOTS, sizeof itlb_slots, &itlb_slots);
file_addmetadata(kfp, MODINFOMD_DTLB, dtlb_slots * sizeof(struct tte), file_addmetadata(kfp, MODINFOMD_DTLB,
dtlb_store); dtlb_slots * sizeof(*dtlb_store), dtlb_store);
file_addmetadata(kfp, MODINFOMD_ITLB, itlb_slots * sizeof(struct tte), file_addmetadata(kfp, MODINFOMD_ITLB,
itlb_store); itlb_slots * sizeof(*itlb_store), itlb_store);
*modulep = addr; *modulep = addr;
size = md_copymodules(0); size = md_copymodules(0);

View File

@ -37,6 +37,11 @@
#define MODINFOMD_DTLB 0x1006 #define MODINFOMD_DTLB 0x1006
#define MODINFOMD_ITLB 0x1007 #define MODINFOMD_ITLB 0x1007
struct tlb_entry {
vm_offset_t te_pa;
vm_offset_t te_va;
};
#define MD_FETCH(mdp, info, type) ({ \ #define MD_FETCH(mdp, info, type) ({ \
type *__p; \ type *__p; \
__p = (type *)preload_search_info((mdp), MODINFO_METADATA | (info)); \ __p = (type *)preload_search_info((mdp), MODINFO_METADATA | (info)); \

View File

@ -80,8 +80,10 @@
#define MMU_SFSR_W (1L << MMU_SFSR_W_SHIFT) #define MMU_SFSR_W (1L << MMU_SFSR_W_SHIFT)
struct tlb_entry;
extern int kernel_tlb_slots; extern int kernel_tlb_slots;
extern struct tte *kernel_ttes; extern struct tlb_entry *kernel_tlbs;
void tlb_context_demap(struct pmap *pm); void tlb_context_demap(struct pmap *pm);
void tlb_page_demap(u_int tlb, struct pmap *pm, vm_offset_t va); void tlb_page_demap(u_int tlb, struct pmap *pm, vm_offset_t va);

View File

@ -107,7 +107,7 @@
typedef int ofw_vec_t(void *); typedef int ofw_vec_t(void *);
struct tte *kernel_ttes; struct tlb_entry *kernel_tlbs;
int kernel_tlb_slots; int kernel_tlb_slots;
int physmem; int physmem;
@ -229,7 +229,7 @@ sparc64_init(caddr_t mdp, u_long o1, u_long o2, u_long o3, ofw_vec_t *vec)
end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t); end = MD_FETCH(kmdp, MODINFOMD_KERNEND, vm_offset_t);
kernel_tlb_slots = MD_FETCH(kmdp, MODINFOMD_DTLB_SLOTS, kernel_tlb_slots = MD_FETCH(kmdp, MODINFOMD_DTLB_SLOTS,
int); int);
kernel_ttes = (struct tte *)preload_search_info(kmdp, kernel_tlbs = (void *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_DTLB); MODINFO_METADATA | MODINFOMD_DTLB);
} }
} }

View File

@ -94,6 +94,7 @@
#include <machine/cache.h> #include <machine/cache.h>
#include <machine/frame.h> #include <machine/frame.h>
#include <machine/md_var.h> #include <machine/md_var.h>
#include <machine/metadata.h>
#include <machine/pv.h> #include <machine/pv.h>
#include <machine/smp.h> #include <machine/smp.h>
#include <machine/tlb.h> #include <machine/tlb.h>
@ -310,8 +311,8 @@ pmap_bootstrap(vm_offset_t ekva)
* pmap_kextract() will work for them. * pmap_kextract() will work for them.
*/ */
for (i = 0; i < kernel_tlb_slots; i++) { for (i = 0; i < kernel_tlb_slots; i++) {
va = TTE_GET_VA(&kernel_ttes[i]); pa = kernel_tlbs[i].te_pa;
pa = TTE_GET_PA(&kernel_ttes[i]); va = kernel_tlbs[i].te_va;
for (off = 0; off < PAGE_SIZE_4M; off += PAGE_SIZE) { for (off = 0; off < PAGE_SIZE_4M; off += PAGE_SIZE) {
tp = tsb_kvtotte(va + off); tp = tsb_kvtotte(va + off);
tp->tte_vpn = TV_VPN(va + off); tp->tte_vpn = TV_VPN(va + off);