It now runs in QEMU
This commit is contained in:
parent
0e99e762ff
commit
1b7ef1454e
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[submodule "raspi_fw"]
|
||||
path = raspi_fw
|
||||
url = https://github.com/raspberrypi/firmware
|
16
Makefile
16
Makefile
|
@ -14,9 +14,25 @@ kernel8.img: os.elf
|
|||
$(OBJCPY) os.elf -O binary kernel8.img
|
||||
|
||||
.PHONY: image kernel
|
||||
|
||||
image: kernel8.img
|
||||
|
||||
kernel: os.elf
|
||||
|
||||
real_hardware: kernel8.img
|
||||
mkdir -p staging
|
||||
cp -v raspi_fw/boot/bcm2710-rpi-3-b.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2710-rpi-3-b-plus.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2710-rpi-cm3.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2711-rpi-4-b.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2711-rpi-400.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2711-rpi-cm4.dtb staging
|
||||
cp -v raspi_fw/boot/bcm2711-rpi-cm4s.dtb staging
|
||||
cp -v raspi_fw/boot/*.dat staging
|
||||
cp -v raspi_fw/boot/*.elf staging
|
||||
cp -v raspi_fw/boot/bootcode.bin staging
|
||||
cp -v kernel8.img staging
|
||||
|
||||
clean:
|
||||
rm boot.o kernel.o os.elf kernel8.img
|
||||
rm -rf staging
|
||||
|
|
1
raspi_fw
Submodule
1
raspi_fw
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 79fda7c033649dc04993a3bb1534d2f83d46359c
|
|
@ -6,7 +6,6 @@
|
|||
// Make _start global.
|
||||
.globl _start
|
||||
|
||||
.org 0x80000
|
||||
// Entry point for the kernel. Registers:
|
||||
// x0 -> 32 bit pointer to DTB in memory (primary core only) / 0 (secondary cores)
|
||||
// x1 -> 0
|
||||
|
|
14
src/kernel.c
14
src/kernel.c
|
@ -9,21 +9,19 @@ volatile uint64_t** core_3 = (void*)0xF0;
|
|||
|
||||
|
||||
void _start_core_1(void* addr) {
|
||||
*core_1 = (uint32_t*)addr;
|
||||
*core_1 = (uint64_t*)addr;
|
||||
}
|
||||
|
||||
|
||||
void _start_core_2(void* addr) {
|
||||
*core_2 = (uint32_t*)addr;
|
||||
*core_2 = (uint64_t*)addr;
|
||||
}
|
||||
|
||||
|
||||
void _start_core_3(void* addr) {
|
||||
*core_3 = (uint32_t*)addr;
|
||||
*core_3 = (uint64_t*)addr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void kernel_main(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3) {
|
||||
uint32_t reg;
|
||||
char *board;
|
||||
|
@ -32,16 +30,16 @@ void kernel_main(uint64_t dtb_ptr32, uint64_t x1, uint64_t x2, uint64_t x3) {
|
|||
|
||||
switch ((reg >> 4) & 0xFFF) {
|
||||
case 0xD03:
|
||||
board = "Raspberry Pi 3";
|
||||
board = "Raspberry Pi 3\0";
|
||||
MMIO_BASE = 0x3F000000;
|
||||
break;
|
||||
case 0xD08:
|
||||
board = "Raspberry Pi 4";
|
||||
board = "Raspberry Pi 4\0";
|
||||
MMIO_BASE = 0xFE000000;
|
||||
break;
|
||||
}
|
||||
uart_init();
|
||||
uart_puts(board);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef MMIO_H
|
||||
#define MMIO_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static uint32_t MMIO_BASE;
|
||||
|
||||
static inline void mmio_write(uint32_t reg, uint32_t data)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#ifndef UART_H
|
||||
#define UART_H
|
||||
#include <stdint.h>
|
||||
|
||||
#include "mmio.h"
|
||||
|
||||
enum
|
||||
|
|
Loading…
Reference in New Issue
Block a user