Merge pull request #159 from SamTebbs33/feature/serial-init-payload

Pass boot payload to serial init
This commit is contained in:
Sam Tebbs 2020-06-13 20:37:20 +01:00 committed by GitHub
commit c4083b0161
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 5 deletions

View file

@ -267,10 +267,13 @@ fn writeSerialCom1(byte: u8) void {
/// ///
/// Initialise serial communication using port COM1 and construct a Serial instance /// 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 /// Return: serial.Serial
/// The Serial instance constructed with the function used to write bytes /// 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| { serial.init(serial.DEFAULT_BAUDRATE, serial.Port.COM1) catch |e| {
panic(@errorReturnTrace(), "Failed to initialise serial: {}", .{e}); panic(@errorReturnTrace(), "Failed to initialise serial: {}", .{e});
}; };

View file

@ -37,7 +37,7 @@ pub fn panic(msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn
} }
export fn kmain(boot_payload: arch.BootPayload) void { export fn kmain(boot_payload: arch.BootPayload) void {
const serial_stream = serial.init(); const serial_stream = serial.init(boot_payload);
log.init(serial_stream); log.init(serial_stream);

View file

@ -23,11 +23,14 @@ pub const Serial = struct {
/// ///
/// Initialise the serial interface. The details of how this is done depends on the architecture. /// 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 /// Return: Serial
/// The serial interface constructed by the architecture /// The serial interface constructed by the architecture
/// ///
pub fn init() Serial { pub fn init(boot_payload: arch.BootPayload) Serial {
const serial = arch.initSerial(); const serial = arch.initSerial(boot_payload);
if (build_options.rt_test) runtimeTests(serial); if (build_options.rt_test) runtimeTests(serial);
return serial; return serial;
} }

View file

@ -102,7 +102,7 @@ pub fn haltNoInterrupts() noreturn {
while (true) {} while (true) {}
} }
pub fn initSerial() Serial { pub fn initSerial(boot_payload: BootPayload) Serial {
return .{ .write = undefined }; return .{ .write = undefined };
} }