This is my first time posting here, or making an OS, for that matter.
I've been working on a system for Raspberry Pis.
I've mostly followed the RPi Bare bones on the wiki to get an idea of the whole
process, and I have reorganised the code a bit to be more modular.
The issue is, that while running the program, trying to print out a simple
Hello world message, the results end up being mixed up.
I suspect it has something to do with the timing of the printing, since adding
a significant delay between the characters seems to fix the issue.
Here is my code:
Code: Select all
#include <sysdef.h>
#include <Drivers/RasPi/MMIO.h>
#include <Drivers/RasPi/UART.h>
#define RASPI_TYPE 3
static VOID InitEssentialDrivers(void);
static VOID UartPutString(PCSTR szMessage);
VOID KernelMain(DWORD dwDtbPtr32, DWORD dwX1, DWORD dwX2, DWORD dwX3)
{
BYTE byRead;
InitEssentialDrivers();
UartPutString("Hey there\n");
while (TRUE)
{
byRead = UartReadByte();
UartSendByte(byRead);
}
}
static VOID UartPutString(PCSTR szMessage)
{
SIZE i;
for (i = 0; szMessage[i]; ++i)
{
UartSendByte(szMessage[i]);
}
}
static VOID InitEssentialDrivers(void)
{
MmioInitDriver(RASPI_TYPE);
UartInitDriver(RASPI_TYPE);
}
The other two files, mmio.c and uart.c, are just adaptations of the wiki versions to fit the coding style, so I think it's unlikely that the issue is there.
The system is meant to run on 64-bit (AArch64 based) Raspberry Pis, mine is a Raspberry Pi 3B. However, I didn't yet test this project on the physical hardware, since I don't have the right cables to see the output.
A few examples of unexpected output:
Code: Select all
Hey there
e
Code: Select all
HHey there
eHey thee
r
Code: Select all
HHey there
ehere
00
P.S. One other thing I have noticed is that when you get to the echo part and type too fast, the echo gets messed up too, but permanently so.
When I try to press 'a', for example, I get back an 'a' and another random character, or sometimes too A's. This might be related.