When I introduced MMU support for inmates, I forgot to map the memory
for LEDs. Fix that by simply mapping it.

While at it, move the initalisation of led_reg to the top of the routine
where it should actually be - it should be initialised before the timer
is armed.

The mapper will take care that the address will be huge page aligned,
and the size will be aligned to HUGE_PAGE_SIZE, so there's no need to
align anything on caller site.

Fixes: bca43a784716 ("inmates: arm-common: add MMU support")
Signed-off-by: Ralf Ramsauer <[email protected]>
---
Only compile-time tested! I currently have no device where i could test
it.

Ralf

 inmates/demos/arm/gic-demo.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/inmates/demos/arm/gic-demo.c b/inmates/demos/arm/gic-demo.c
index 58feea3f..b0102615 100644
--- a/inmates/demos/arm/gic-demo.c
+++ b/inmates/demos/arm/gic-demo.c
@@ -56,6 +56,12 @@ static void handle_IRQ(unsigned int irqn)
 
 void inmate_main(void)
 {
+       led_reg = (void *)(unsigned long)cmdline_parse_int("led-reg", 0);
+       if (led_reg) {
+               map_range(led_reg, 4, MAP_UNCACHED);
+               led_pin = cmdline_parse_int("led-pin", 0);
+       }
+
        printk("Initializing the GIC...\n");
        irq_init(handle_IRQ);
        irq_enable(TIMER_IRQ);
@@ -65,8 +71,5 @@ void inmate_main(void)
        expected_ticks = timer_get_ticks() + ticks_per_beat;
        timer_start(ticks_per_beat);
 
-       led_reg = (void *)(unsigned long)cmdline_parse_int("led-reg", 0);
-       led_pin = cmdline_parse_int("led-pin", 0);
-
        halt();
 }
-- 
2.33.0

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/20210823130258.215378-1-ralf.ramsauer%40oth-regensburg.de.

Reply via email to