Annotation of solidite/kernel/main/main.c, revision 1.1
1.1 ! user 1: /* Copyright (c) 2026 The Solidite Developers
! 2: *
! 3: * This program is free software: you can redistribute it and/or modify it
! 4: * under the terms of the GNU Affero General Public License as published by the
! 5: * Free Software Foundation, either version 3 of the License, or (at your
! 6: * option) any later version.
! 7: *
! 8: * This program is distributed in the hope that it will be useful, but WITHOUT
! 9: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
! 10: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
! 11: * for more details.
! 12: *
! 13: * You should have received a copy of the GNU Affero General Public License
! 14: * along with this program. If not, see <https://www.gnu.org/licenses/>. */
! 15:
! 16: #include "../../libc/include/stdint.h"
! 17:
! 18: #if defined(__riscv) && (__riscv_xlen == 64) /* 64-bit RISC-V */
! 19:
! 20: #include "../libkernel/riscv64.h"
! 21:
! 22: #define MODULED_ADDRESS 0x80400000
! 23:
! 24: asm (
! 25: ".section .text\n"
! 26: ".globl _start\n"
! 27:
! 28: "_start:\n"
! 29: "la sp, stack_top\n"
! 30: "tail main\n"
! 31:
! 32: ".section .bss\n"
! 33: ".align 12\n" /* 4 KiB stack alignment */
! 34: ".space 0x4000\n" /* 16 KiB stack allocation */
! 35:
! 36: "stack_top:\n"
! 37:
! 38: ".section .text\n"
! 39: );
! 40:
! 41: void main(unsigned long hartid, unsigned long dtb_pa) {
! 42: if (hartid != 0)
! 43: return; /* no SMP yet */
! 44: else
! 45: kwrite("[kernel] console init\n");
! 46:
! 47: ((void (*)(unsigned long))MODULED_ADDRESS)(dtb_pa);
! 48: return;
! 49: }
! 50:
! 51: #elif defined(__x86_64__) /* x86_64 */
! 52:
! 53: __attribute__((used, section(".limine_requests"))) static volatile uint64_t
! 54: limine_base_revision[] = {0xfacade934a3e2a22, 0x51da7bc4ced6c7c1, 0};
! 55: /* uses limine boot protocol for now, TODO: add multiboot v2 */
! 56:
! 57: void _start(void) {
! 58: for (;;) {}
! 59: }
! 60:
! 61: #else
! 62: #error "The kernel does not have support for your CPU architecture."
! 63: #error "Please check your C preprocessor if you believe this is a mistake."
! 64: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>