From 5e1ef5e23dd3e594072f8f32cbb4a6f392d36e55 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 4 Apr 2025 09:05:35 +0200 Subject: fw/modules: add astdx for embdfs. Signed-off-by: Amlal El Mahrouss --- .gitmodules | 3 ++ CREDITS | 2 + compile_flags.txt | 1 + docs/SPECIFICATION_FIRMWARE.md | 39 -------------- docs/drawio/FIRMWARE.drawio | 43 +++++++++++++++ docs/md/SPECIFICATION_FIRMWARE.md | 39 ++++++++++++++ format.sh | 2 +- lib/ppc64/processor.h | 2 - mmap/aarch64-epm.json | 9 ++++ pci-map/.gitkeep | 0 pci-map/standard.json | 11 ---- src/coreboot-ahci-driver.c | 108 -------------------------------------- src/custom_hw/coreboot-flash.c | 10 ---- src/hal/coreboot-ahci-driver.c | 108 ++++++++++++++++++++++++++++++++++++++ src/hal/coreboot-flash.c | 10 ++++ vendor/astdx | 1 + 16 files changed, 217 insertions(+), 171 deletions(-) create mode 100644 CREDITS delete mode 100644 docs/SPECIFICATION_FIRMWARE.md create mode 100644 docs/drawio/FIRMWARE.drawio create mode 100644 docs/md/SPECIFICATION_FIRMWARE.md create mode 100644 mmap/aarch64-epm.json delete mode 100644 pci-map/.gitkeep delete mode 100644 pci-map/standard.json delete mode 100644 src/coreboot-ahci-driver.c delete mode 100644 src/custom_hw/coreboot-flash.c create mode 100644 src/hal/coreboot-ahci-driver.c create mode 100644 src/hal/coreboot-flash.c create mode 160000 vendor/astdx diff --git a/.gitmodules b/.gitmodules index 8624630..a055e73 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "meta/css"] path = meta/css url = https://github.com/jothepro/doxygen-awesome-css.git +[submodule "vendor/astdx"] + path = vendor/astdx + url = git@github.com:amlel-el-mahrouss/astdx.git diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..91be5d4 --- /dev/null +++ b/CREDITS @@ -0,0 +1,2 @@ +lib/ppc64/: Forked from a repository, which I can't recall. +vendor/astdx: Amlal El Mahrouss \ No newline at end of file diff --git a/compile_flags.txt b/compile_flags.txt index 26d546d..4e3bed0 100644 --- a/compile_flags.txt +++ b/compile_flags.txt @@ -1,2 +1,3 @@ -I./ -std=c17 +-I./vendor/ diff --git a/docs/SPECIFICATION_FIRMWARE.md b/docs/SPECIFICATION_FIRMWARE.md deleted file mode 100644 index b0b40b4..0000000 --- a/docs/SPECIFICATION_FIRMWARE.md +++ /dev/null @@ -1,39 +0,0 @@ -================================================================== - - Multi Platform Firmware - -================================================================== - -================================================================== -0. What we want: -================================================================== - -- Optimized for each target. -- EPM/GPT compilant. -- AMD64, PowerPC, RISC-V, 64x0, 32x0 support. -- SMP support. - -================================================================== -1. How we're going to do that: -================================================================== - -- Abstract Memory and I/O. (pci-tree) -- Platform Independent Device Tree. (pci-tree) -- Common Starting point for each core (smp) - -================================================================== -2. Executable Layout: -================================================================== - -- 0x80000000/0x00FF/0x1000: Firmware Startup Code -- 0x90000000/0x7c00: Executable Information Header or equivalent. - -================================================================== -3. Error Codes: -================================================================== - -- CB0001: Not bootable to Stage2 (or bootloader). -- CB0003: Bad arch. -- CB0002: Context returned early. - - diff --git a/docs/drawio/FIRMWARE.drawio b/docs/drawio/FIRMWARE.drawio new file mode 100644 index 0000000..7cfc174 --- /dev/null +++ b/docs/drawio/FIRMWARE.drawio @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/docs/md/SPECIFICATION_FIRMWARE.md b/docs/md/SPECIFICATION_FIRMWARE.md new file mode 100644 index 0000000..39aa2a0 --- /dev/null +++ b/docs/md/SPECIFICATION_FIRMWARE.md @@ -0,0 +1,39 @@ +================================================================== + + Multi Platform Firmware + +================================================================== + +================================================================== +0. What the objective: +================================================================== + +- Optimized for each target. +- EPM/GPT compilant. +- AMD64, PowerPC, RISC-V, 64x0, 32x0 support. +- SMP support. + +================================================================== +1. How we're going to do that: +================================================================== + +- Abstract Memory and I/O. (pci-tree) +- Platform Independent Device Tree. (pci-tree) +- Common Starting point for each core (smp) + +================================================================== +2. Executable Layout: +================================================================== + +- 0x80000000/0x00FF/0x0000: Firmware Startup Code +- 0x90000000/0x7c00: Linear Header or EPM partition. + +================================================================== +3. Error Codes: +================================================================== + +- CB0001: Not bootable to Stage2 (or bootloader). +- CB0003: Bad arch. +- CB0002: Context returned early. + + diff --git a/format.sh b/format.sh index 0bfa3e0..145caf5 100755 --- a/format.sh +++ b/format.sh @@ -7,7 +7,7 @@ THIS_DIR="$(dirname "$THIS_PATH")" # in the regular expression just below FILE_LIST="$(find "$THIS_DIR" | grep -E ".*(\.cc|\.c|\.h)$")" -echo -e "Files found to format = \n\"\"\"\n$FILE_LIST\n\"\"\"" +echo -e "Files found to format: \n\"\"\"\n$FILE_LIST\n\"\"\"" # Format each file. # - NB: do NOT put quotes around `$FILE_LIST` below or else the `clang-format` command will diff --git a/lib/ppc64/processor.h b/lib/ppc64/processor.h index 602ff08..c0d7b03 100644 --- a/lib/ppc64/processor.h +++ b/lib/ppc64/processor.h @@ -1,8 +1,6 @@ #ifndef __ASM_PPC_PROCESSOR_H #define __ASM_PPC_PROCESSOR_H -/// ! @note The NeWS SoC is based on the e5500 core. - /* * Default implementation of macro that returns current * instruction pointer ("program counter"). diff --git a/mmap/aarch64-epm.json b/mmap/aarch64-epm.json new file mode 100644 index 0000000..8311a52 --- /dev/null +++ b/mmap/aarch64-epm.json @@ -0,0 +1,9 @@ +{ + "machine": "EPM AARCH64", + "type": "Generic", + "vendor": "Amlal El Mahrouss", + "fb": "0x1000000", + "boot": "0x4000000", + "pci-tree": "0x8002000", + "eeprom": "0x0000000" +} \ No newline at end of file diff --git a/pci-map/.gitkeep b/pci-map/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/pci-map/standard.json b/pci-map/standard.json deleted file mode 100644 index cf9c334..0000000 --- a/pci-map/standard.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "Machine": "Standard PC", - "Type": "Desktop", - "Vendor": "Amlal EL Mahrouss.", - "FrameBuffer": "0x1000000", - "BootLoader": "0x4000000", - "PCITree": "0x8002000", - "ROM": "0xFFFF000" - } -] diff --git a/src/coreboot-ahci-driver.c b/src/coreboot-ahci-driver.c deleted file mode 100644 index 2ef2098..0000000 --- a/src/coreboot-ahci-driver.c +++ /dev/null @@ -1,108 +0,0 @@ -/* ------------------------------------------- - - Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -/** - * @file coreboot-ahci-driver.cc - * @author Amlal EL Mahrouss (amlal@nekernel.org) - * @brief SATA Disk support, via AHCI. - * @version 0.2 - * @date 2024-01-16 - * - * @copyright Copyright (c) 2024-2025, Amlal EL Mahrouss. - * - */ - -#include -#include - -#define CB_AHCI_DRIVER_NAME ("@sata") - -/// BUGS: 0 -/// @brief AHCI support for PowerPC. - -/// @brief AHCI HBA port. -typedef struct cb_hba_port -{ - uint32_t clb; // 0x00, command list base address, 1K-byte aligned - uint32_t clbu; // 0x04, command list base address upper 32 bits - uint32_t fb; // 0x08, FIS base address, 256-byte aligned - uint32_t fbu; // 0x0C, FIS base address upper 32 bits - uint32_t is; // 0x10, interrupt status - uint32_t ie; // 0x14, interrupt enable - uint32_t cmd; // 0x18, command and status - uint32_t reserved0; // 0x1C, Reserved - uint32_t tfd; // 0x20, task file data - uint32_t sig; // 0x24, signature - uint32_t ssts; // 0x28, SATA status (SCR0:SStatus) - uint32_t sctl; // 0x2C, SATA control (SCR2:SControl) - uint32_t serr; // 0x30, SATA error (SCR1:SError) - uint32_t sact; // 0x34, SATA active (SCR3:SActive) - uint32_t ci; // 0x38, command issue - uint32_t sntf; // 0x20, SATA notification (SCR4:SNotification) - uint32_t fbs; // 0x40, FIS-based switch control - uint32_t reserved1[11]; // 0x44 ~ 0x6F, Reserved - uint32_t vendor[4]; // 0x70 ~ 0x7F, vendor specific -} cb_hba_port_t; - -/// @brief Check if port is active. -/// @param port host bus address port. -/// @return whether sact is active or not. -static boolean cb_hba_port_active(volatile cb_hba_port_t* port) -{ - if (!port) - return false; - - return port->sact; -} - -/// @brief Start HBA command processor. -/// @param port host bus address port. -/// @return whether it was successful or not. -static boolean cb_hba_start_cmd(volatile cb_hba_port_t* port) -{ - if (!port) - return false; - - size_t timeout = 1000000; - - while ((port->cmd & 0x8000)) - { - if (!timeout) - return false; - - --timeout; - } - - port->cmd |= 0x0001; - port->cmd |= 0x0010; - - return true; -} - -/// @brief Stop HBA command from processing. -/// @param port host bus address port. -/// @return whether it was successful or not. -static boolean cb_hba_stop_cmd(volatile cb_hba_port_t* port) -{ - if (!port) - return false; - - port->cmd &= ~0x0001; - port->cmd &= ~0x0010; - - while (yes) - { - if ((port->cmd & 0x8000)) - continue; - - if ((port->cmd & 0x4000)) - continue; - - break; - } - - return true; -} diff --git a/src/custom_hw/coreboot-flash.c b/src/custom_hw/coreboot-flash.c deleted file mode 100644 index 1416bc3..0000000 --- a/src/custom_hw/coreboot-flash.c +++ /dev/null @@ -1,10 +0,0 @@ -/* ------------------------------------------- - -Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. - -------------------------------------------- */ - -#include -#include -#include -#include diff --git a/src/hal/coreboot-ahci-driver.c b/src/hal/coreboot-ahci-driver.c new file mode 100644 index 0000000..2ef2098 --- /dev/null +++ b/src/hal/coreboot-ahci-driver.c @@ -0,0 +1,108 @@ +/* ------------------------------------------- + + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +/** + * @file coreboot-ahci-driver.cc + * @author Amlal EL Mahrouss (amlal@nekernel.org) + * @brief SATA Disk support, via AHCI. + * @version 0.2 + * @date 2024-01-16 + * + * @copyright Copyright (c) 2024-2025, Amlal EL Mahrouss. + * + */ + +#include +#include + +#define CB_AHCI_DRIVER_NAME ("@sata") + +/// BUGS: 0 +/// @brief AHCI support for PowerPC. + +/// @brief AHCI HBA port. +typedef struct cb_hba_port +{ + uint32_t clb; // 0x00, command list base address, 1K-byte aligned + uint32_t clbu; // 0x04, command list base address upper 32 bits + uint32_t fb; // 0x08, FIS base address, 256-byte aligned + uint32_t fbu; // 0x0C, FIS base address upper 32 bits + uint32_t is; // 0x10, interrupt status + uint32_t ie; // 0x14, interrupt enable + uint32_t cmd; // 0x18, command and status + uint32_t reserved0; // 0x1C, Reserved + uint32_t tfd; // 0x20, task file data + uint32_t sig; // 0x24, signature + uint32_t ssts; // 0x28, SATA status (SCR0:SStatus) + uint32_t sctl; // 0x2C, SATA control (SCR2:SControl) + uint32_t serr; // 0x30, SATA error (SCR1:SError) + uint32_t sact; // 0x34, SATA active (SCR3:SActive) + uint32_t ci; // 0x38, command issue + uint32_t sntf; // 0x20, SATA notification (SCR4:SNotification) + uint32_t fbs; // 0x40, FIS-based switch control + uint32_t reserved1[11]; // 0x44 ~ 0x6F, Reserved + uint32_t vendor[4]; // 0x70 ~ 0x7F, vendor specific +} cb_hba_port_t; + +/// @brief Check if port is active. +/// @param port host bus address port. +/// @return whether sact is active or not. +static boolean cb_hba_port_active(volatile cb_hba_port_t* port) +{ + if (!port) + return false; + + return port->sact; +} + +/// @brief Start HBA command processor. +/// @param port host bus address port. +/// @return whether it was successful or not. +static boolean cb_hba_start_cmd(volatile cb_hba_port_t* port) +{ + if (!port) + return false; + + size_t timeout = 1000000; + + while ((port->cmd & 0x8000)) + { + if (!timeout) + return false; + + --timeout; + } + + port->cmd |= 0x0001; + port->cmd |= 0x0010; + + return true; +} + +/// @brief Stop HBA command from processing. +/// @param port host bus address port. +/// @return whether it was successful or not. +static boolean cb_hba_stop_cmd(volatile cb_hba_port_t* port) +{ + if (!port) + return false; + + port->cmd &= ~0x0001; + port->cmd &= ~0x0010; + + while (yes) + { + if ((port->cmd & 0x8000)) + continue; + + if ((port->cmd & 0x4000)) + continue; + + break; + } + + return true; +} diff --git a/src/hal/coreboot-flash.c b/src/hal/coreboot-flash.c new file mode 100644 index 0000000..1416bc3 --- /dev/null +++ b/src/hal/coreboot-flash.c @@ -0,0 +1,10 @@ +/* ------------------------------------------- + +Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#include +#include +#include +#include diff --git a/vendor/astdx b/vendor/astdx new file mode 160000 index 0000000..6dd868e --- /dev/null +++ b/vendor/astdx @@ -0,0 +1 @@ +Subproject commit 6dd868e57f32905e5e553f6e3ed5ef35ae5cae77 -- cgit v1.2.3