Raspberry Pi Bare Bones: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
mNo edit summary |
|||
Line 224: | Line 224: | ||
#include <stdint.h> |
#include <stdint.h> |
||
static uint32_t MMIO_BASE; |
|||
// board type, raspi2 |
|||
int raspi = 2; |
|||
⚫ | |||
static inline void mmio_init(int raspi) |
|||
{ |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
|||
// Memory-Mapped I/O output |
// Memory-Mapped I/O output |
||
static inline void mmio_write(uint32_t reg, uint32_t data) |
static inline void mmio_write(uint32_t reg, uint32_t data) |
||
{ |
{ |
||
*(volatile uint32_t*)reg = data; |
*(volatile uint32_t*)(MMIO_BASE + reg) = data; |
||
} |
} |
||
Line 236: | Line 246: | ||
static inline uint32_t mmio_read(uint32_t reg) |
static inline uint32_t mmio_read(uint32_t reg) |
||
{ |
{ |
||
return *(volatile uint32_t*)reg; |
return *(volatile uint32_t*)(MMIO_BASE + reg); |
||
} |
} |
||
Line 248: | Line 258: | ||
enum |
enum |
||
{ |
{ |
||
⚫ | |||
//Who the heck put a switch statement in here? |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
// The offsets for reach register. |
// The offsets for reach register. |
||
GPIO_BASE = |
GPIO_BASE = 0x200000, |
||
// Controls actuation of pull up/down to ALL GPIO pins. |
// Controls actuation of pull up/down to ALL GPIO pins. |
||
Line 290: | Line 291: | ||
// The offsets for Mailbox registers |
// The offsets for Mailbox registers |
||
MBOX_BASE = |
MBOX_BASE = 0xB880, |
||
MBOX_READ = (MBOX_BASE + 0x00), |
MBOX_READ = (MBOX_BASE + 0x00), |
||
MBOX_STATUS = (MBOX_BASE + 0x18), |
MBOX_STATUS = (MBOX_BASE + 0x18), |
||
Line 386: | Line 387: | ||
#endif |
#endif |
||
{ |
{ |
||
// initialize MMIO_BASE address for Raspi2 |
|||
mmio_init(2); |
|||
uart_init(); |
uart_init(); |
||
uart_puts("Hello, kernel World!\r\n"); |
uart_puts("Hello, kernel World!\r\n"); |