Changeset View
Standalone View
sys/arm64/arm64/machdep.c
Show First 20 Lines • Show All 904 Lines • ▼ Show 20 Lines | #endif | ||||
CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_elr, | CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_elr, | ||||
tf->tf_sp); | tf->tf_sp); | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
mtx_lock(&psp->ps_mtx); | mtx_lock(&psp->ps_mtx); | ||||
} | } | ||||
/* return the number of physical address bits */ | |||||
static inline u_int | |||||
get_physaddr_bits(void) | |||||
{ | |||||
uint64_t mmfr0, parange; | |||||
const int mapping[] = { | |||||
[ID_AA64MMFR0_PARange_4G] = 32, | |||||
[ID_AA64MMFR0_PARange_64G] = 36, | |||||
[ID_AA64MMFR0_PARange_1T] = 40, | |||||
[ID_AA64MMFR0_PARange_4T] = 42, | |||||
[ID_AA64MMFR0_PARange_16T] = 44, | |||||
[ID_AA64MMFR0_PARange_256T] = 48, | |||||
[ID_AA64MMFR0_PARange_4P] = 52, | |||||
/* ensure the last entry is defined */ | |||||
mhorne: IMO the `switch` was much more readable. Unless you have a specific need for `get_physaddr_bits… | |||||
Done Inline ActionsYes, this was bothering me. I've been unsure of the best option. Due to ID_AA64MMFR0_PARange_SHIFT being zero, the current one is possible. This is gross since the shifts should be taken out, but it does work. I think this really points at a problem with armreg.h. Most of the values are available only with the left shift included which only works for switch() { } constructs and is poor for arrays. Really armreg.h should include the constants both with and without the left shift included. Worse, all the ID_AA64MMFR0_PARange_* values include the shift, but a few do not include the shift (the EXCP_* constants for ESR_ELx_EXCEPTION()). ehem_freebsd_m5p.com: Yes, this was bothering me. I've been unsure of the best option.
Due to… | |||||
Not Done Inline ActionsDo you need get_physaddr_bits() for something? If not, please don't provide it. It is complicating an otherwise simple move of code from one place to another. I would go further to say that we need only one of get_physaddr_max/get_physaddr_count. mhorne: Do you need `get_physaddr_bits()` for something? If not, please don't provide it. It is… | |||||
Done Inline ActionsNo, I don't presently have plans for get_physaddr_bits(). My concern is the bit count is near certain to be useful to someone. I don't know who. I don't know when. Someone will want the bit count and this will cause a larger diff down the line. If you really want, I can reduce it to get_physaddr_count() and only that, but please mark my words the additional functions will be desired enough that later they will be (re)added. ehem_freebsd_m5p.com: No, I don't //presently// have plans for get_physaddr_bits(). My concern is the bit count is… | |||||
[ID_AA64MMFR0_PARange_MASK] = 0 | |||||
}; | |||||
if (!get_kernel_reg(ID_AA64MMFR0_EL1, &mmfr0)) { | |||||
printf("WARNING: Unable to retrieve MMRF0 register!\n"); | |||||
/* a conservative default */ | |||||
return (40); | |||||
} | |||||
parange = ID_AA64MMFR0_PARange_VAL(mmfr0) >> ID_AA64MMFR0_PARange_SHIFT; | |||||
if (mapping[parange] == 0) { | |||||
printf("WARNING: Unknown value for PARange in MMFR0 (%#lx)\n", mmfr0); | |||||
/* a conservative default */ | |||||
return (40); | |||||
} | |||||
return (mapping[parange]); | |||||
} | |||||
/* return the number of physical addresses */ | |||||
static inline uint64_t | |||||
get_physaddr_count(void) | |||||
{ | |||||
return (1ul << get_physaddr_bits()); | |||||
} | |||||
/* return the maximum valid physical address */ | |||||
uint64_t | |||||
get_physaddr_max(void) | |||||
{ | |||||
return (get_physaddr_count() - 1); | |||||
} | |||||
static void | static void | ||||
init_proc0(vm_offset_t kstack) | init_proc0(vm_offset_t kstack) | ||||
{ | { | ||||
struct pcpu *pcpup = &__pcpu[0]; | struct pcpu *pcpup = &__pcpu[0]; | ||||
proc_linkup0(&proc0, &thread0); | proc_linkup0(&proc0, &thread0); | ||||
thread0.td_kstack = kstack; | thread0.td_kstack = kstack; | ||||
thread0.td_kstack_pages = KSTACK_PAGES; | thread0.td_kstack_pages = KSTACK_PAGES; | ||||
▲ Show 20 Lines • Show All 573 Lines • Show Last 20 Lines |
IMO the switch was much more readable. Unless you have a specific need for get_physaddr_bits() in mind I would rather you keep the original logic.