Skip to content

Commit

Permalink
[Kernel] Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
codyd51 committed Jan 7, 2023
1 parent d1cac20 commit 19cb4b3
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ RESOURCES = resources
ISO_DIR = isodir
ISO_NAME = axle.iso

OBJ_DIR = .objs
OBJ_DIR = .kernel_objs
SRC_DIR = kernel
COMPILED_RUST_KERNEL_LIBS_DIR = compiled_rust_kernel_libs
COMPILED_RUST_KERNEL_LIBS_DIR = .compiled_rust_kernel_libs

ARCH = x86_64

Expand Down
10 changes: 6 additions & 4 deletions bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool map_file(const char* file_path, uint64_t* out_base, uint64_t* out_size) {
printf(": Reading %s buffer...\n", file_path);
fread((void*)file_buf, file_size, 1, file);
print_time();
printf(": Mapped initrd\n");
printf(": Mapped %s\n", file_path);
fclose(file);

*out_base = file_buf;
Expand Down Expand Up @@ -353,7 +353,7 @@ int main(int argc, char** argv) {
efi_configuration_table_t* table = &config_table[i];
//printf("Looking at table %d at %x\n", i, table);
efi_guid_t* guid = &table->VendorGuid;
printf("guid %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x\n", guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
//printf("guid %08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x\n", guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7]);
if (!memcmp(guid, &acpi_1_0_rsdp_guid, sizeof(acpi_1_0_rsdp_guid))) {
printf("\tFound ACPI 1.0 RSDP at index %d\n", i);
}
Expand All @@ -367,9 +367,11 @@ int main(int argc, char** argv) {
// Finally, exit UEFI-land and jump to the kernel
printf("Jumping to kernel entry point at %p\n", kernel_entry_point);

if (exit_bs()) {
status = exit_bs();
if (status != 0) {
printf("Status %d\n", status);
// Red
draw(boot_info, 0x00ff0000);
draw(boot_info, 0x0000ffff);
printf("Failed to exit boot services!\n");
while (1) {}
return 0;
Expand Down
2 changes: 1 addition & 1 deletion kernel/kernel/segmentation/gdt.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void gdt_init() {
.base_middle = 0x0,
.accessed = 0,
.readable = 1,
// In the code segment, "Conforming": Whether code in this segment can be run in less-priviliged rings
// In the code segment, "Conforming": Whether code in this segment can be run in less-privileged rings
.contextual = 0,
.is_code = 1,
.belongs_to_os = 1,
Expand Down
2 changes: 2 additions & 0 deletions kernel/kernel/util/unistd/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ int stdout_write(task_small_t* task, int fd, const void* buf, int len) {
}

int write(int fd, char* buf, int len) {
// TODO(PT): Handle clearly invalid buf pointers. Perhaps enumerate each page in the slice and ensure that each
// is mapped and readable.
//printf("write(%d, %x, %d)\n", fd, buf, len);
assert(tasking_is_active(), "Can't write via fd until multitasking is active");
if (!len) return 0;
Expand Down
1 change: 0 additions & 1 deletion kernel/std/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ __BEGIN_DECLS
#define kernel_end_critical() __asm__("sti");



//write byte to port
STDAPI void outb(uint16_t port, uint8_t val);
//write word to port
Expand Down
10 changes: 7 additions & 3 deletions scripts/build_os_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

ARCH = "x86_64"

_REPO_ROOT = Path(__file__).parents[1]


def _is_macos() -> bool:
return os.uname().sysname == 'Darwin'
Expand Down Expand Up @@ -50,15 +52,15 @@ def build_iso() -> Path:
if not bootloader_binary_path.exists():
raise ValueError(f"Bootloader binary missing: {bootloader_binary_path}")

kernel_binary_path = Path(__file__).parents[1] / "isodir" / "boot" / "axle.bin"
kernel_binary_path = _REPO_ROOT / "isodir" / "boot" / "axle.bin"
if not kernel_binary_path.exists():
raise ValueError(f"Kernel binary missing: {kernel_binary_path}")

fs_server_path = Path(__file__).parents[1] / "axle-sysroot" / "usr" / "applications" / "initrd_fs"
fs_server_path = _REPO_ROOT / "axle-sysroot" / "usr" / "applications" / "initrd_fs"
if not fs_server_path.exists():
raise ValueError(f"fs_server missing: {fs_server_path}")

initrd_path = Path(__file__).parents[1] / "isodir" / "boot" / "initrd.img"
initrd_path = _REPO_ROOT / "isodir" / "boot" / "initrd.img"
if not initrd_path.exists():
raise ValueError(f"initrd missing: {initrd_path}")

Expand All @@ -84,6 +86,8 @@ def build_initrd() -> None:

# This will also build mkinitrd, if necessary
run_and_check(['cargo', 'run', '--release'], cwd=mkinitrd_path)
# TODO(PT): How to select whether to build or not?
# run_and_check(["./target/release/mkinitrd"], cwd=mkinitrd_path)

generated_initrd = mkinitrd_path / "output.img"
if not generated_initrd.exists():
Expand Down
2 changes: 1 addition & 1 deletion scripts/build_rust_toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

_RUST_KERNEL_LIBS_DIR = _REPO_ROOT / "rust_kernel_libs"
_KERNEL_TARGET_SPEC_FILE = _RUST_KERNEL_LIBS_DIR / "x86_64-unknown-axle_kernel.json"
_COMPILED_RUST_KERNEL_LIBS_DIR = _REPO_ROOT / "compiled_rust_kernel_libs"
_COMPILED_RUST_KERNEL_LIBS_DIR = _REPO_ROOT / ".compiled_rust_kernel_libs"

_CACHE_DIR = Path(__file__).parent / "caches"

Expand Down
2 changes: 1 addition & 1 deletion scripts/mkinitrd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fn main() -> Result<(), Box<dyn error::Error>> {
let fs_image = traverse(&sysroot, &sysroot).expect("traverse failed");
println!("Finished generating directory image");

let mut file = std::io::BufWriter::new(std::fs::File::create("./output.img").unwrap());
let mut file = io::BufWriter::new(std::fs::File::create("./output.img").unwrap());
let v = postcard::to_allocvec(&fs_image).expect("Failed to encode");
file.write(&v).expect("Failed to write to file");

Expand Down
2 changes: 1 addition & 1 deletion scripts/run_axle.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def run_iso(image_path: Path) -> None:
"hvf",
"-cpu",
"host",
# Capture data sent to serial port
# Capture data sent to serial port
"-serial",
"file:syslog.log",
# SATA drive
Expand Down

0 comments on commit 19cb4b3

Please sign in to comment.