From b9c333903610460e912bc8dc88b6d93b6b35bf28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Wed, 27 Aug 2014 22:42:19 +0200 Subject: [PATCH] Fix syntax for some code blocks --- Chapter-3/README.md | 14 ++++++------ Chapter-5/README.md | 12 +++++----- Chapter-7/README.md | 54 ++++++++++++++++++++++----------------------- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/Chapter-3/README.md b/Chapter-3/README.md index 837249d..7f5f4a2 100644 --- a/Chapter-3/README.md +++ b/Chapter-3/README.md @@ -37,7 +37,7 @@ This boot process also initializes some of our C++ runtime, it will be described Multiboot header structure: -``` +```cpp struct multiboot_info { u32 flags; u32 low_mem; @@ -82,7 +82,7 @@ qemu-img create c.img 2M We need now to partition the disk using fdisk: -``` +```bash fdisk ./c.img # Switch to Expert commands @@ -132,19 +132,19 @@ We need now to attach the created partition to the loop-device (which allows a f Using ```fdisk -l -u c.img```, you get: 63 * 512 = 32256. -``` +```bash losetup -o 32256 /dev/loop1 ./c.img ``` We create a EXT2 filesystem on this new device using: -``` +```bash mke2fs /dev/loop1 ``` We copy our files on a mounted disk: -``` +```bash mount /dev/loop1 /mnt/ cp -R bootdisk/* /mnt/ umount /mnt/ @@ -152,7 +152,7 @@ umount /mnt/ Install GRUB on the disk: -``` +```bash grub --device-map=/dev/null << EOF device (hd0) ./c.img geometry (hd0) 4 16 63 @@ -164,7 +164,7 @@ EOF And finally we detach the loop device: -``` +```bash losetup -d /dev/loop1 ``` diff --git a/Chapter-5/README.md b/Chapter-5/README.md index b25adae..703e2df 100644 --- a/Chapter-5/README.md +++ b/Chapter-5/README.md @@ -21,22 +21,22 @@ void Io::putc(char c){ unsigned char *video; video = (unsigned char *) (real_screen+ 2 * x + 160 * y); // newline - if (c == '\n') { + if (c == '\n') { x = 0; y++; // back space - } else if (c == '\b') { + } else if (c == '\b') { if (x) { *(video + 1) = 0x0; x--; } // horizontal tab - } else if (c == '\t') { + } else if (c == '\t') { x = x + 8 - (x % 8); // carriage return - } else if (c == '\r') { + } else if (c == '\r') { x = 0; - } else { + } else { *video = c; *(video + 1) = kattr; @@ -144,7 +144,7 @@ void Io::print(const char *s, ...){ print("0x%s", buf); } else if (c == 's') { print((char *) va_arg(ap, int)); - } + } } else putc(c); } diff --git a/Chapter-7/README.md b/Chapter-7/README.md index faf8ccb..12387f3 100644 --- a/Chapter-7/README.md +++ b/Chapter-7/README.md @@ -55,21 +55,21 @@ Here is a table of common interrupts (Maskable hardware interrupt are called IRQ | IRQ | Description | |:-----:| -------------------------- | -| 0 | Programmable Interrupt Timer Interrupt | -| 1 | Keyboard Interrupt | -| 2 | Cascade (used internally by the two PICs. never raised) | -| 3 | COM2 (if enabled) | -| 4 | COM1 (if enabled) | -| 5 | LPT2 (if enabled) | -| 6 | Floppy Disk | -| 7 | LPT1 | -| 8 | CMOS real-time clock (if enabled) | -| 9 | Free for peripherals / legacy SCSI / NIC | -| 10 | Free for peripherals / SCSI / NIC | -| 11 | Free for peripherals / SCSI / NIC | -| 12 | PS2 Mouse | -| 13 | FPU / Coprocessor / Inter-processor | -| 14 | Primary ATA Hard Disk | +| 0 | Programmable Interrupt Timer Interrupt | +| 1 | Keyboard Interrupt | +| 2 | Cascade (used internally by the two PICs. never raised) | +| 3 | COM2 (if enabled) | +| 4 | COM1 (if enabled) | +| 5 | LPT2 (if enabled) | +| 6 | Floppy Disk | +| 7 | LPT1 | +| 8 | CMOS real-time clock (if enabled) | +| 9 | Free for peripherals / legacy SCSI / NIC | +| 10 | Free for peripherals / SCSI / NIC | +| 11 | Free for peripherals / SCSI / NIC | +| 12 | PS2 Mouse | +| 13 | FPU / Coprocessor / Inter-processor | +| 14 | Primary ATA Hard Disk | | 15 | Secondary ATA Hard Disk | #### How to initialize the interrupts? @@ -101,23 +101,23 @@ void init_idt(void) { /* Init irq */ int i; - for (i = 0; i < IDTSIZE; i++) - init_idt_desc(0x08, (u32)_asm_schedule, INTGATE, &kidt[i]); // - + for (i = 0; i < IDTSIZE; i++) + init_idt_desc(0x08, (u32)_asm_schedule, INTGATE, &kidt[i]); // + /* Vectors 0 -> 31 are for exceptions */ init_idt_desc(0x08, (u32) _asm_exc_GP, INTGATE, &kidt[13]); /* #GP */ init_idt_desc(0x08, (u32) _asm_exc_PF, INTGATE, &kidt[14]); /* #PF */ - + init_idt_desc(0x08, (u32) _asm_schedule, INTGATE, &kidt[32]); init_idt_desc(0x08, (u32) _asm_int_1, INTGATE, &kidt[33]); - + init_idt_desc(0x08, (u32) _asm_syscalls, TRAPGATE, &kidt[48]); init_idt_desc(0x08, (u32) _asm_syscalls, TRAPGATE, &kidt[128]); //48 - + kidtr.limite = IDTSIZE * 8; kidtr.base = IDTBASE; - - + + /* Copy the IDT to the memory */ memcpy((char *) kidtr.base, (char *) kidt, kidtr.limite); @@ -175,7 +175,7 @@ The registries have to be configured in order. **ICW2 (port 0x21 / port 0xA1)** ``` -|x|x|x|x|x|0|0|0| +|x|x|x|x|x|0|0|0| | | | | | +----------------- base address for interrupts vectors ``` @@ -212,13 +212,13 @@ It is used to define in which mode the controller should work. You should have noticed that when I'm initializing our IDT segments, I'm using offsets to segment the code in Assembly. The different functions are defined in [x86int.asm](https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System/blob/master/src/kernel/arch/x86/x86int.asm) and are of the following scheme: -``` +```asm %macro SAVE_REGS 0 - pushad + pushad push ds push es push fs - push gs + push gs push ebx mov bx,0x10 mov ds,bx