File tree Expand file tree Collapse file tree 3 files changed +29
-11
lines changed
Expand file tree Collapse file tree 3 files changed +29
-11
lines changed Original file line number Diff line number Diff line change 99#
1010
1111image () {
12- local arch=$( uname -m)
12+ local arch
13+ arch=" $( uname -m) "
1314 local kernel_arch=" $3 "
1415 local kernel_file=" $1 "
1516 local image_file=" $2 "
@@ -20,7 +21,7 @@ image() {
2021 # Create a folder whose structure mirrors that of the desired disk image
2122 mkdir -p " ${boot_files_dir} "
2223 sudo mkdir -p " ${boot_files_dir} /boot/grub"
23- sudo cp -r ./src/arch/${kernel_arch} /grub.cfg " ${boot_files_dir} /boot/grub/"
24+ sudo cp -r ./src/arch/" ${kernel_arch} " /grub.cfg " ${boot_files_dir} /boot/grub/"
2425 sudo cp -r " ${kernel_file} " " ${boot_files_dir} /boot/kiwirtos.bin"
2526 # Create a zeroed out disk image file
2627 dd if=/dev/zero of=" ${image_file} " bs=512 count=32768
@@ -82,7 +83,7 @@ image() {
8283}
8384
8485# Main script logic
85- set -e # Exit on error
86+ set -euo pipefail # Exit on error, print the error message
8687if [ $# -eq 3 ]; then
8788 image " $1 " " $2 " " $3 "
8889else
Original file line number Diff line number Diff line change 33const std = @import ("std" );
44const arch = @import ("arch.zig" );
55
6- // IDT entry types
7- pub const IDT_TASK_GATE = 0x5 ;
8- pub const IDT_INTERRUPT_GATE_16 = 0x6 ;
9- pub const IDT_TRAP_GATE_16 = 0x7 ;
10- pub const IDT_INTERRUPT_GATE_32 = 0xE ;
11- pub const IDT_TRAP_GATE_32 = 0xF ;
12-
136extern const isr_stub_table : []void ;
147
158// Number of entries in the IDT
@@ -54,6 +47,8 @@ pub const DPL = enum(u2) {
5447
5548// The type of gate the IDT entry represents
5649pub const GateType = enum (u4 ) {
50+ /// Task gate (system call)
51+ GATE_TASK = 0b0101 ,
5752 /// Interrupt gate (system call)
5853 GATE_INTERRUPT = 0b1110 ,
5954 /// Trap gate (exception)
@@ -108,7 +103,8 @@ pub const Idt = struct {
108103 /// Set the IDT entries
109104 pub fn setEntries (self : * Idt ) void {
110105 for (0.. IDT_ENTRIES ) | vector | {
111- self .setDescriptor (vector , @intFromPtr (isr_stub_table [vector ]), IdtAttributes {
106+ const addr = @intFromPtr (isr_stub_table [vector ]);
107+ self .setDescriptor (vector , addr , IdtAttributes {
112108 .present = 1 ,
113109 .dpl = DPL .KERNEL ,
114110 .gate_type = GateType .GATE_INTERRUPT ,
Original file line number Diff line number Diff line change @@ -325,4 +325,25 @@ pub const VgaTextDriver = struct {
325325 pub fn println (self : * VgaTextDriver , comptime format : []const u8 , args : anytype ) void {
326326 self .writer ().print (format ++ "\n " , args ) catch unreachable ;
327327 }
328+
329+ /// Put a character to the VGA buffer with race condition protection
330+ pub fn setCharSafe (self : * VgaTextDriver , ch : u8 ) void {
331+ arch .cli (); // Disable interrupts
332+ self .setChar (ch );
333+ arch .sti (); // Re-enable interrupts
334+ }
335+
336+ /// Update cursor position with race condition protection
337+ pub fn updateCursorSafe (self : * const VgaTextDriver ) void {
338+ arch .cli (); // Disable interrupts
339+ self .updateCursor ();
340+ arch .sti (); // Re-enable interrupts
341+ }
342+
343+ /// Scroll the VGA buffer with race condition protection
344+ pub fn scrollSafe (self : * VgaTextDriver ) void {
345+ arch .cli (); // Disable interrupts
346+ self .scroll ();
347+ arch .sti (); // Re-enable interrupts
348+ }
328349};
You can’t perform that action at this time.
0 commit comments