Starting kyOSPi//64
My back's been in a lot of pain, but I've slowly started working on kOS//pi64.
I'm starting off by writing out a bunch of mechanical translations of register [1] addresses. They look a lot like [2]
namespace peripheral::uart {
typedef Address UARTAddress;
volatile UARTAddress UART0 = 0x7e201000;
// more UART base addresses
enum class Register : RegisterOffset {
DR = 0x00, // DR Data Register
RSRECR = 0x04,
FR = 0x18, // FR Flag register
// the rest of the registers.
};
inline Address
UARTRegisterAddress(UARTAddress uart, Register r)
{
return uart + static_cast<RegisterOffset>(r);
}
} // namespace peripheral::uart
I do want this to be useful for some other platforms later [3], so I've added some configuration set up as well [4].
/*
* bcm2711/config.h
*
* Configuration definitiosn for the BCM2711 systems.
*/
#ifndef __BCM2711_CONFIG_H__
#define __BCM2711_CONFIG_H__
typedef unsigned long Address;
typedef unsigned long AddressValue;
typedef unsigned long RegisterValue;
typedef unsigned char RegisterOffset;
#if PLATFORM == pi4
typedef unsigned char GPIOPin;
constexpr GPIOPin UART_TX = 0;
constexpr GPIOPin UART_TX = 0;
#endif
#endif// __BCM2711_CONFIG_H__
I'm thinking that the use of specific types for data and addresses might be helpful later for type-checking things.
With this basic framework, it's time to start translating GPIO pins over.
| [1] | Register as in data registers, not processor registers. |
| [2] | https://git.wntrmute.dev/kyle/kospi64/src/commit/b61b0ddf34aa03c30d697da48012806e487d6c74/inc/bcm2711/peripheral/uart.h |
| [3] | I also have a directory with the start of kOS//86, and it would be interesting to merge them. |
| [4] | https://git.wntrmute.dev/kyle/kospi64/src/commit/b61b0ddf34aa03c30d697da48012806e487d6c74/inc/bcm2711/config.h |