twizzler-operating-system / twizzler

The Twizzler Operating System
BSD 3-Clause "New" or "Revised" License
68 stars 15 forks source link

Fix PL011 baud configuration #185

Closed PandaZ3D closed 3 months ago

PandaZ3D commented 3 months ago

This PR fixes two minor bugs that only manifested on real hardware. The first bug was that the arguments in the init were passed in the wrong order. https://github.com/twizzler-operating-system/twizzler/blob/eceaf1eb8a78ae72d48ecfbb6962fc5eb38722a0/src/kernel/src/machine/arm/common/uart.rs#L70

The second bug had to do with the way we computed the values for the registers controlling the baud rate. The method of scaling the clock value is correct, but since it is integer division we need to use parenthesis. This causes the values for the baud configuration registers to be zero. https://github.com/twizzler-operating-system/twizzler/blob/eceaf1eb8a78ae72d48ecfbb6962fc5eb38722a0/src/kernel/src/machine/arm/common/uart.rs#L106-L108

These bugs didn't stop the qemu device from working, but it did on real hardware (e.g., RPi4). With these two fixes we can configure a PL011 device and perform reads/writes. This was tested on a Raspberry Pi 4.