|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 13/40] xen/mpu: introduce unified function setup_early_uart to map early UART
Hi Peny, On 13/01/2023 05:28, Penny Zheng wrote: This function is doing more than enable the early UART. It also setups the fixmap even earlyprintk is not configured. I am not entirely sure what could be the name. Maybe this needs to be split further.
Missing "Inputs: " + * x27: region selector + * x28: prbar + * x29: prlar + * + * Clobbers x0 - x4 + * + */ +ENTRY(setup_early_uart) +#ifdef CONFIG_EARLY_PRINTK + /* stack LR as write_pr will be called later like nested function */ + mov x3, lr + + /* + * MPU region for early UART is a transient region, since it will be + * replaced by specific device memory layout when FDT gets parsed. I would rather not mention "FDT" here because this code is independent to the firmware table used. However, any reason to use a transient region rather than the one that will be used for the UART driver? + */ + load_paddr x0, next_transient_region_idx + ldr x4, [x0] + + ldr x28, =CONFIG_EARLY_UART_BASE_ADDRESS + and x28, x28, #MPU_REGION_MASK + mov x1, #REGION_DEVICE_PRBAR + orr x28, x28, x1 This needs some documentation to explain the logic. Maybe even a macro. + + ldr x29, =(CONFIG_EARLY_UART_BASE_ADDRESS + EARLY_UART_SIZE) + roundup_section x29 Does this mean we could give access to more than necessary? Shouldn't instead prevent compilation if the size doesn't align with the section size? + /* Limit address is inclusive */ + sub x29, x29, #1 + and x29, x29, #MPU_REGION_MASK + mov x2, #REGION_DEVICE_PRLAR + orr x29, x29, x2 + + mov x27, x4 This needs some documentation like: x27: region selector See how we documented the existing helpers. + bl write_pr + + /* Create a new entry in xen_mpumap for early UART */ + create_mpu_entry xen_mpumap, x4, x28, x29, x1, x2 + + /* Update next_transient_region_idx */ + sub x4, x4, #1 + str x4, [x0] + + mov lr, x3 + ret +#endif +ENDPROC(setup_early_uart) + /* * Local variables: * mode: ASM diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h index 44a230853f..d87623e6d5 100644 --- a/xen/arch/arm/include/asm/early_printk.h +++ b/xen/arch/arm/include/asm/early_printk.h @@ -22,6 +22,7 @@ * for EARLY_UART_VIRTUAL_ADDRESS. */ #define EARLY_UART_VIRTUAL_ADDRESS CONFIG_EARLY_UART_BASE_ADDRESS +#define EARLY_UART_SIZE 0x1000 Shouldn't this be PAGE_SIZE? If not, how did you come up with the number? Cheers, -- Julien Grall
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |