From 5101990044449691b738d915f41118e58640ce44 Mon Sep 17 00:00:00 2001 From: Sam Tebbs Date: Tue, 9 Jun 2020 13:47:06 +0100 Subject: [PATCH] Pass boot payload to serial init --- src/kernel/arch/x86/arch.zig | 5 ++++- src/kernel/kmain.zig | 2 +- src/kernel/serial.zig | 7 +++++-- test/mock/kernel/arch_mock.zig | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/kernel/arch/x86/arch.zig b/src/kernel/arch/x86/arch.zig index 88397d1..cd92cdd 100644 --- a/src/kernel/arch/x86/arch.zig +++ b/src/kernel/arch/x86/arch.zig @@ -267,10 +267,13 @@ fn writeSerialCom1(byte: u8) void { /// /// Initialise serial communication using port COM1 and construct a Serial instance /// +/// Arguments: +/// IN boot_payload: arch.BootPayload - The payload passed at boot. Not currently used by x86 +/// /// Return: serial.Serial /// The Serial instance constructed with the function used to write bytes /// -pub fn initSerial() Serial { +pub fn initSerial(boot_payload: BootPayload) Serial { serial.init(serial.DEFAULT_BAUDRATE, serial.Port.COM1) catch |e| { panic(@errorReturnTrace(), "Failed to initialise serial: {}", .{e}); }; diff --git a/src/kernel/kmain.zig b/src/kernel/kmain.zig index 4d6e895..f496994 100644 --- a/src/kernel/kmain.zig +++ b/src/kernel/kmain.zig @@ -37,7 +37,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn } export fn kmain(boot_payload: arch.BootPayload) void { - const serial_stream = serial.init(); + const serial_stream = serial.init(boot_payload); log.init(serial_stream); diff --git a/src/kernel/serial.zig b/src/kernel/serial.zig index cebe0e6..7cabc5e 100644 --- a/src/kernel/serial.zig +++ b/src/kernel/serial.zig @@ -23,11 +23,14 @@ pub const Serial = struct { /// /// Initialise the serial interface. The details of how this is done depends on the architecture. /// +/// Arguments: +/// IN boot_payload: arch.BootPayload - The payload passed to the kernel at boot. How this is used depends on the architecture +/// /// Return: Serial /// The serial interface constructed by the architecture /// -pub fn init() Serial { - const serial = arch.initSerial(); +pub fn init(boot_payload: arch.BootPayload) Serial { + const serial = arch.initSerial(boot_payload); if (build_options.rt_test) runtimeTests(serial); return serial; } diff --git a/test/mock/kernel/arch_mock.zig b/test/mock/kernel/arch_mock.zig index 0565a20..2cafebf 100644 --- a/test/mock/kernel/arch_mock.zig +++ b/test/mock/kernel/arch_mock.zig @@ -102,7 +102,7 @@ pub fn haltNoInterrupts() noreturn { while (true) {} } -pub fn initSerial() Serial { +pub fn initSerial(boot_payload: BootPayload) Serial { return .{ .write = undefined }; }