From e2b45d3971b579f5f6af1dffa953720c10c35b10 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Sat, 28 May 2016 15:21:24 +0200 Subject: [PATCH] Fix minor errors in code snippets --- blog/post/2016-05-28-catching-exceptions.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/blog/post/2016-05-28-catching-exceptions.md b/blog/post/2016-05-28-catching-exceptions.md index fb7f0e73..a6afdac4 100644 --- a/blog/post/2016-05-28-catching-exceptions.md +++ b/blog/post/2016-05-28-catching-exceptions.md @@ -83,7 +83,7 @@ Now we create types for the IDT and its entries: ```rust // src/interrupts/idt.rs -use x86::segmentation::SegmentSelector; +use x86::segmentation::{self, SegmentSelector}; pub struct Idt([Entry; 16]); @@ -222,7 +222,7 @@ We take a GDT selector and a handler function as arguments and create a new IDT The `HandlerFunc` type is a type alias for a function type: ``` rust -type HandlerFunc = extern "C" fn() -> !; +pub type HandlerFunc = extern "C" fn() -> !; ``` It needs to be a function with a defined [calling convention], as it called directly by the hardware. The C calling convention is the de facto standard in OS development, so we're using it, too. The function takes no arguments, since the hardware doesn't supply any arguments when jumping to the handler function. @@ -251,7 +251,7 @@ impl Idt { impl Entry { fn missing() -> Self { Entry { - gdt_selector: 0, + gdt_selector: SegmentSelector::new(0), pointer_low: 0, pointer_middle: 0, pointer_high: 0, @@ -583,6 +583,8 @@ Let's use the new `print_error` function to print the page fault error: ```rust // in src/interrupts/mod.rs +use vga_buffer::print_error; + extern "C" fn page_fault_handler() -> ! { unsafe { print_error(format_args!("EXCEPTION: PAGE FAULT")) }; loop {}