pc, pc64: use 64-bit physical addresses for vmap() and upaalloc()

This commit is contained in:
cinap_lenrek 2020-06-06 14:43:24 +02:00
parent 5f3e72eb84
commit 21e4d88a51
5 changed files with 23 additions and 21 deletions

View file

@ -192,10 +192,10 @@ int tas(void*);
uvlong tscticks(uvlong*); uvlong tscticks(uvlong*);
ulong umballoc(ulong, ulong, ulong); ulong umballoc(ulong, ulong, ulong);
void umbfree(ulong, ulong); void umbfree(ulong, ulong);
ulong upaalloc(ulong, ulong, ulong); uvlong upaalloc(uvlong, ulong, ulong);
void upafree(ulong, ulong); void upafree(uvlong, ulong);
void vectortable(void); void vectortable(void);
void* vmap(ulong, int); void* vmap(uvlong, int);
int vmapsync(ulong); int vmapsync(ulong);
void vmxprocrestore(Proc *); void vmxprocrestore(Proc *);
void vmxshutdown(void); void vmxshutdown(void);

View file

@ -244,14 +244,14 @@ rsdsearch(void)
* does not map the physical address into virtual memory. * does not map the physical address into virtual memory.
* Call vmap to do that. * Call vmap to do that.
*/ */
ulong uvlong
upaalloc(ulong pa, ulong size, ulong align) upaalloc(uvlong pa, ulong size, ulong align)
{ {
return (ulong)memmapalloc(pa == -1UL ? -1ULL : (uvlong)pa, size, align, MemUPA); return memmapalloc(pa, size, align, MemUPA);
} }
void void
upafree(ulong pa, ulong size) upafree(uvlong pa, ulong size)
{ {
memmapfree(pa, size, MemUPA); memmapfree(pa, size, MemUPA);
} }

View file

@ -71,7 +71,6 @@ mmuinit(void)
{ {
ulong x, *p; ulong x, *p;
ushort ptr[3]; ushort ptr[3];
vlong v;
if(0) print("vpt=%#.8ux vpd=%#p kmap=%#.8ux\n", if(0) print("vpt=%#.8ux vpd=%#p kmap=%#.8ux\n",
VPT, vpd, KMAP); VPT, vpd, KMAP);
@ -537,11 +536,16 @@ static void pdbunmap(ulong*, ulong, int);
* Add a device mapping to the vmap range. * Add a device mapping to the vmap range.
*/ */
void* void*
vmap(ulong pa, int size) vmap(uvlong pa, int size)
{ {
int osize; int osize;
ulong o, va; ulong o, va;
if(pa < BY2PG || size <= 0 || ((pa+size) >> 32) != 0 || size > VMAPSIZE){
print("vmap pa=%llux size=%d pc=%#p\n", pa, size, getcallerpc(&pa));
return nil;
}
/* /*
* might be asking for less than a page. * might be asking for less than a page.
*/ */
@ -549,17 +553,12 @@ vmap(ulong pa, int size)
o = pa & (BY2PG-1); o = pa & (BY2PG-1);
pa -= o; pa -= o;
size += o; size += o;
size = ROUND(size, BY2PG); size = ROUND(size, BY2PG);
if(pa == 0){
print("vmap pa=0 pc=%#p\n", getcallerpc(&pa));
return nil;
}
ilock(&vmaplock); ilock(&vmaplock);
if((va = vmapalloc(size)) == 0 if((va = vmapalloc(size)) == 0
|| pdbmap(MACHP(0)->pdb, pa|PTEUNCACHED|PTEWRITE, va, size) < 0){ || pdbmap(MACHP(0)->pdb, pa|PTEUNCACHED|PTEWRITE, va, size) < 0){
iunlock(&vmaplock); iunlock(&vmaplock);
return 0; return nil;
} }
iunlock(&vmaplock); iunlock(&vmaplock);
/* avoid trap on local processor /* avoid trap on local processor

View file

@ -191,12 +191,12 @@ int tas(void*);
uvlong tscticks(uvlong*); uvlong tscticks(uvlong*);
ulong umballoc(ulong, ulong, ulong); ulong umballoc(ulong, ulong, ulong);
void umbfree(ulong, ulong); void umbfree(ulong, ulong);
ulong upaalloc(ulong, ulong, ulong); uvlong upaalloc(uvlong, ulong, ulong);
void upafree(ulong, ulong); void upafree(uvlong, ulong);
void vectortable(void); void vectortable(void);
void vmxprocrestore(Proc *); void vmxprocrestore(Proc *);
void vmxshutdown(void); void vmxshutdown(void);
void* vmap(uintptr, int); void* vmap(uvlong, int);
void vunmap(void*, int); void vunmap(void*, int);
void wbinvd(void); void wbinvd(void);
void writeconf(void); void writeconf(void);

View file

@ -579,14 +579,17 @@ kunmap(KMap *k)
* synchronization is being done. * synchronization is being done.
*/ */
void* void*
vmap(uintptr pa, int size) vmap(uvlong pa, int size)
{ {
uintptr va; uintptr va;
int o; int o;
if(pa+size > VMAPSIZE) if(pa < BY2PG || size <= 0 || -pa < size || pa+size > VMAPSIZE){
return 0; print("vmap pa=%llux size=%d pc=%#p\n", pa, size, getcallerpc(&pa));
return nil;
}
va = pa+VMAP; va = pa+VMAP;
/* /*
* might be asking for less than a page. * might be asking for less than a page.
*/ */