From 32ff44d9511bed86104698dff1907577dbd5a0f0 Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Wed, 15 Oct 2025 19:51:55 -0500 Subject: bootstrap: stage1: create a baseline environment Create a baseline booting environment in the first stage. This should allow booting on UEFI-aware systems and load the second stage in. Signed-off-by: Danny Holman --- bootstrap/stage1/include/alloc.h | 28 ++++++++++++++++++++++++++++ bootstrap/stage1/include/bprintf.h | 28 ++++++++++++++++++++++++++++ bootstrap/stage1/include/tty.h | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+) create mode 100644 bootstrap/stage1/include/alloc.h create mode 100644 bootstrap/stage1/include/bprintf.h create mode 100644 bootstrap/stage1/include/tty.h (limited to 'bootstrap/stage1/include') diff --git a/bootstrap/stage1/include/alloc.h b/bootstrap/stage1/include/alloc.h new file mode 100644 index 0000000..088b389 --- /dev/null +++ b/bootstrap/stage1/include/alloc.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2025 Danny Holman + * + * This file is part of BoxOS, a free and open-source Unix-like operating + * system. + * + * BoxOS is free software; you can redistribute it and/or modify under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * BoxOS; if not, see . + */ + +#ifndef BOOTSTRAP_ALLOC_H +#define BOOTSTRAP_ALLOC_H + +#include + +void* balloc(size_t len); +void bfree(void *ptr); + +#endif diff --git a/bootstrap/stage1/include/bprintf.h b/bootstrap/stage1/include/bprintf.h new file mode 100644 index 0000000..d67d518 --- /dev/null +++ b/bootstrap/stage1/include/bprintf.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2025 Danny Holman + * + * This file is part of BoxOS, a free and open-source Unix-like operating + * system. + * + * BoxOS is free software; you can redistribute it and/or modify under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * BoxOS; if not, see . + */ + +#ifndef BPRINTF_H +#define BPRINTF_H + +#include + +int vbprintf(const char *fmt, va_list args); +int bprintf(const char *fmt, ...); + +#endif diff --git a/bootstrap/stage1/include/tty.h b/bootstrap/stage1/include/tty.h new file mode 100644 index 0000000..af0d8f9 --- /dev/null +++ b/bootstrap/stage1/include/tty.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2025 Danny Holman + * + * This file is part of BoxOS, a free and open-source Unix-like operating + * system. + * + * BoxOS is free software; you can redistribute it and/or modify under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * BoxOS is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * BoxOS; if not, see . + */ + +#ifndef BOOTSTRAP_TTY_H +#define BOOTSTRAP_TTY_H + +#include + +void tty_putchar(char c); +char tty_getchar(void); + +static inline void tty_write(const char *data, size_t size) { + for (size_t i = 0; i < size; i++) + tty_putchar(data[i]); +} + +static inline void tty_read(char *data, size_t size) { + for (size_t i = 0; i < size; i++) + data[i] = tty_getchar(); +} + +#endif -- cgit v1.2.3