mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[bootloader] Added userland header, rewrote lernel header
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
|
||||
bootloader_src += $(addprefix bootloader/,\
|
||||
main.cpp \
|
||||
slot.cpp \
|
||||
kernel_header.cpp \
|
||||
userland_header.cpp \
|
||||
interface.cpp \
|
||||
jump_to_firmware.s \
|
||||
trampoline.cpp \
|
||||
|
||||
29
bootloader/kernel_header.cpp
Normal file
29
bootloader/kernel_header.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <bootloader/kernel_header.h>
|
||||
|
||||
extern "C" void jump_to_firmware(const uint32_t* stackPtr, const void(*startPtr)(void));
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
|
||||
const KernelHeader* s_kernelHeaderA = reinterpret_cast<const struct KernelHeader*>(0x90000000);
|
||||
const KernelHeader* s_kernelHeaderB = reinterpret_cast<const struct KernelHeader*>(0x90400000);
|
||||
|
||||
const char * KernelHeader::version() const {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
const char * KernelHeader::patchLevel() const {
|
||||
return m_patchLevel;
|
||||
}
|
||||
|
||||
const bool KernelHeader::isValid() const {
|
||||
return m_header == Magic && m_footer == Magic;
|
||||
}
|
||||
|
||||
[[ noreturn ]] void KernelHeader::boot() const {
|
||||
jump_to_firmware(m_stackPointer, m_startPointer);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
#ifndef BOOTLOADER_SLOT
|
||||
#define BOOTLOADER_SLOT
|
||||
#ifndef BOOTLOADER_KERNEL_HEADER_H
|
||||
#define BOOTLOADER_KERNEL_HEADER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
class Slot {
|
||||
class KernelHeader {
|
||||
public:
|
||||
const char * version() const;
|
||||
const char * patchLevel() const;
|
||||
@@ -13,7 +13,7 @@ public:
|
||||
[[ noreturn ]] void boot() const;
|
||||
|
||||
private:
|
||||
Slot();
|
||||
KernelHeader();
|
||||
constexpr static uint32_t Magic = 0xDEC00DF0;
|
||||
const uint32_t m_unknown;
|
||||
const uint32_t m_signature;
|
||||
@@ -25,8 +25,8 @@ private:
|
||||
const void(*m_startPointer)();
|
||||
};
|
||||
|
||||
extern const Slot* s_slotA;
|
||||
extern const Slot* s_slotB;
|
||||
extern const KernelHeader* s_kernelHeaderA;
|
||||
extern const KernelHeader* s_kernelHeaderB;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
#include <ion.h>
|
||||
#include <bootloader/slot.h>
|
||||
#include <bootloader/kernel_header.h>
|
||||
#include <assert.h>
|
||||
#include <ion/src/device/shared/drivers/board.h>
|
||||
|
||||
@@ -25,5 +25,5 @@ void ion_main(int argc, const char * const argv[]) {
|
||||
}
|
||||
|
||||
Ion::Device::Board::bootloaderMPU();
|
||||
Bootloader::s_slotA->boot();
|
||||
Bootloader::s_kernelHeaderA->boot();
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
#include <bootloader/slot.h>
|
||||
|
||||
extern "C" void jump_to_firmware(const uint32_t* stackPtr, const void(*startPtr)(void));
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
|
||||
const Slot* s_slotA = reinterpret_cast<const struct Slot*>(0x90000000);
|
||||
const Slot* s_slotB = reinterpret_cast<const struct Slot*>(0x90400000);
|
||||
|
||||
const char * Slot::version() const {
|
||||
return m_version;
|
||||
}
|
||||
|
||||
const char * Slot::patchLevel() const {
|
||||
return m_patchLevel;
|
||||
}
|
||||
|
||||
const bool Slot::isValid() const {
|
||||
return m_header == Magic && m_footer == Magic;
|
||||
}
|
||||
|
||||
[[ noreturn ]] void Slot::boot() const {
|
||||
jump_to_firmware(m_stackPointer, m_startPointer);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
20
bootloader/userland_header.cpp
Normal file
20
bootloader/userland_header.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include <bootloader/userland_header.h>
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
const UserlandHeader* s_UserlandHeaderA = reinterpret_cast<const struct UserlandHeader*>(0x90010000);
|
||||
const UserlandHeader* s_UserlandHeaderB = reinterpret_cast<const struct UserlandHeader*>(0x90410000);
|
||||
|
||||
const char * UserlandHeader::version() const {
|
||||
return m_expectedEpsilonVersion;
|
||||
}
|
||||
|
||||
const bool UserlandHeader::isValid() const {
|
||||
return m_header == Magic && m_footer == Magic;
|
||||
}
|
||||
|
||||
const bool UserlandHeader::isOmega() const {
|
||||
return m_ohm_header == OmegaMagic && m_ohm_footer == OmegaMagic;
|
||||
}
|
||||
|
||||
}
|
||||
42
bootloader/userland_header.h
Normal file
42
bootloader/userland_header.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef BOOTLOADER_USERLAND_HEADER_H
|
||||
#define BOOTLOADER_USERLAND_HEADER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace Bootloader {
|
||||
|
||||
class UserlandHeader {
|
||||
public:
|
||||
const char * version() const;
|
||||
const bool isValid() const;
|
||||
const bool isOmega() const;
|
||||
|
||||
private:
|
||||
UserlandHeader();
|
||||
constexpr static uint32_t Magic = 0xDEC0EDFE;
|
||||
constexpr static uint32_t OmegaMagic = 0xEFBEADDE;
|
||||
uint32_t m_header;
|
||||
const char m_expectedEpsilonVersion[8];
|
||||
void * m_storageAddressRAM;
|
||||
size_t m_storageSizeRAM;
|
||||
/* We store the range addresses of external apps memory because storing the
|
||||
* size is complicated due to c++11 constexpr. */
|
||||
uint32_t m_externalAppsFlashStart;
|
||||
uint32_t m_externalAppsFlashEnd;
|
||||
uint32_t m_externalAppsRAMStart;
|
||||
uint32_t m_externalAppsRAMEnd;
|
||||
uint32_t m_footer;
|
||||
uint32_t m_ohm_header;
|
||||
const char m_omegaVersion[16];
|
||||
const volatile char m_username[16];
|
||||
uint32_t m_ohm_footer;
|
||||
};
|
||||
|
||||
extern const UserlandHeader* s_userlandHeaderA;
|
||||
extern const UserlandHeader* s_userlandHeaderB;
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user