address _offset functions
This commit is contained in:
parent
0014a79ecb
commit
ba6a17373e
3 changed files with 11 additions and 1 deletions
|
|
@ -26,6 +26,7 @@ struct va va_from_vpn(struct vpn vpn);
|
|||
struct va va_from_vpn_with_offset(struct vpn vpn, uint64_t offset);
|
||||
uint64_t va_to_value(struct va va);
|
||||
uint64_t va_to_canonical(struct va va);
|
||||
uint64_t va_offset(struct va va);
|
||||
|
||||
struct vpn vpn_from_pagenum(uint64_t pagenum);
|
||||
struct vpn vpn_from_aligned_va(struct va va);
|
||||
|
|
@ -37,6 +38,7 @@ struct pa pa_from_ppn(struct ppn ppn);
|
|||
struct pa pa_from_ppn_with_offset(struct ppn ppn, uint64_t offset);
|
||||
uint64_t pa_to_value(struct pa pa);
|
||||
void *pa_to_pointer(struct pa pa);
|
||||
uint64_t pa_offset(struct pa pa);
|
||||
|
||||
struct ppn ppn_from_pagenum(uint64_t pagenum);
|
||||
struct ppn ppn_from_aligned_pa(struct pa pa);
|
||||
|
|
|
|||
|
|
@ -41,6 +41,10 @@ uint64_t va_to_canonical(struct va va) {
|
|||
}
|
||||
}
|
||||
|
||||
uint64_t va_offset(struct va va) {
|
||||
return va.value & 0xfff;
|
||||
}
|
||||
|
||||
struct vpn vpn_from_pagenum(uint64_t pagenum) {
|
||||
ASSERT(pagenum < (1ull << 36));
|
||||
return (struct vpn){ .pagenum = pagenum };
|
||||
|
|
@ -81,6 +85,10 @@ void *pa_to_pointer(struct pa pa) {
|
|||
return (void*)PHYS_TO_IDMAPPED(pa.value);
|
||||
}
|
||||
|
||||
uint64_t pa_offset(struct pa pa) {
|
||||
return pa.value & 0xfff;
|
||||
}
|
||||
|
||||
struct ppn ppn_from_pagenum(uint64_t pagenum) {
|
||||
ASSERT(pagenum < (1ull << 24));
|
||||
return (struct ppn){ .pagenum = pagenum };
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ bool pt_translate(struct va va, struct ppn cr3, struct pa *pa_out) {
|
|||
}
|
||||
struct pt_entry ent;
|
||||
pt_entry_unpack(*leaf_ptr, &ent);
|
||||
*pa_out = pa_from_ppn_with_offset(ent.ppn, va_to_value(va) & 0xfff); // TODO offset func
|
||||
*pa_out = pa_from_ppn_with_offset(ent.ppn, va_offset(va));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue