From d30ec5b5e9368e87d98cfd8c7dc025f7ef984217 Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Tue, 2 Nov 2010 19:53:32 +0200 Subject: [PATCH] Add ctaos-early: first hobby kernels 2009-2010 (source snapshots and help pages) --- exp/README.md | 20 + exp/ctaos-early/2009-10-25-ctaos/auto1.sh | 13 + exp/ctaos-early/2009-10-25-ctaos/auto2.sh | 7 + exp/ctaos-early/2009-10-25-ctaos/kernel.c | 75 + exp/ctaos-early/2009-10-25-ctaos/linker.ld | 24 + exp/ctaos-early/2009-10-25-ctaos/loader.s | 34 + exp/ctaos-early/2009-10-28-ctaos++/auto1.sh | 14 + exp/ctaos-early/2009-10-28-ctaos++/auto2.sh | 13 + exp/ctaos-early/2009-10-28-ctaos++/console.h | 124 ++ exp/ctaos-early/2009-10-28-ctaos++/kernel.cpp | 30 + exp/ctaos-early/2009-10-28-ctaos++/linker.ld | 30 + exp/ctaos-early/2009-10-28-ctaos++/loader.s | 63 + exp/ctaos-early/2009-10-28-ctaos++/startup.h | 61 + exp/ctaos-early/2009-10-30-ctaos++/auto1.sh | 14 + exp/ctaos-early/2009-10-30-ctaos++/auto2.sh | 13 + exp/ctaos-early/2009-10-30-ctaos++/console.h | 124 ++ exp/ctaos-early/2009-10-30-ctaos++/kernel.cpp | 31 + exp/ctaos-early/2009-10-30-ctaos++/keyboard.h | 96 ++ exp/ctaos-early/2009-10-30-ctaos++/linker.ld | 30 + exp/ctaos-early/2009-10-30-ctaos++/loader.s | 63 + exp/ctaos-early/2009-10-30-ctaos++/startup.h | 63 + exp/ctaos-early/2009-10-31-tctaos/auto.sh | 9 + exp/ctaos-early/2009-10-31-tctaos/auto2.sh | 13 + exp/ctaos-early/2009-10-31-tctaos/kernel.cpp | 46 + exp/ctaos-early/2009-10-31-tctaos/linker.ld | 30 + exp/ctaos-early/2009-10-31-tctaos/loader.s | 56 + exp/ctaos-early/2010-11-ctaos++/auto1.sh | 14 + exp/ctaos-early/2010-11-ctaos++/auto2.sh | 13 + exp/ctaos-early/2010-11-ctaos++/console.h | 192 +++ .../2010-11-ctaos++/drivers/drivers.h | 1 + .../2010-11-ctaos++/drivers/floppy.h | 108 ++ exp/ctaos-early/2010-11-ctaos++/kernel.cpp | 64 + exp/ctaos-early/2010-11-ctaos++/keyboard.h | 169 ++ exp/ctaos-early/2010-11-ctaos++/linker.ld | 30 + exp/ctaos-early/2010-11-ctaos++/loader.s | 63 + exp/ctaos-early/2010-11-ctaos++/new/script.sh | 59 + exp/ctaos-early/2010-11-ctaos++/system.h | 165 ++ exp/ctaos-early/help/CONIOH~1.HT~ | 1392 +++++++++++++++++ exp/ctaos-early/help/INDEX~1.HT~ | 26 + exp/ctaos-early/help/filelist.txt | 26 + .../help/index_files/colorschememapping.xml | 2 + exp/ctaos-early/help/index_files/filelist.xml | 8 + exp/ctaos-early/help/index_files/item0006.xml | 1 + .../help/index_files/props0007.xml | 2 + .../help/index_files/themedata.thmx | Bin 0 -> 3084 bytes exp/ctaos-early/help/pages/KERNEL~1.HT~ | 30 + exp/ctaos-early/help/pages/bootload.html | 30 + 47 files changed, 3491 insertions(+) create mode 100644 exp/ctaos-early/2009-10-25-ctaos/auto1.sh create mode 100644 exp/ctaos-early/2009-10-25-ctaos/auto2.sh create mode 100644 exp/ctaos-early/2009-10-25-ctaos/kernel.c create mode 100644 exp/ctaos-early/2009-10-25-ctaos/linker.ld create mode 100644 exp/ctaos-early/2009-10-25-ctaos/loader.s create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/auto1.sh create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/auto2.sh create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/console.h create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/kernel.cpp create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/linker.ld create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/loader.s create mode 100644 exp/ctaos-early/2009-10-28-ctaos++/startup.h create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/auto1.sh create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/auto2.sh create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/console.h create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/kernel.cpp create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/keyboard.h create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/linker.ld create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/loader.s create mode 100644 exp/ctaos-early/2009-10-30-ctaos++/startup.h create mode 100644 exp/ctaos-early/2009-10-31-tctaos/auto.sh create mode 100644 exp/ctaos-early/2009-10-31-tctaos/auto2.sh create mode 100644 exp/ctaos-early/2009-10-31-tctaos/kernel.cpp create mode 100644 exp/ctaos-early/2009-10-31-tctaos/linker.ld create mode 100644 exp/ctaos-early/2009-10-31-tctaos/loader.s create mode 100644 exp/ctaos-early/2010-11-ctaos++/auto1.sh create mode 100644 exp/ctaos-early/2010-11-ctaos++/auto2.sh create mode 100644 exp/ctaos-early/2010-11-ctaos++/console.h create mode 100644 exp/ctaos-early/2010-11-ctaos++/drivers/drivers.h create mode 100644 exp/ctaos-early/2010-11-ctaos++/drivers/floppy.h create mode 100644 exp/ctaos-early/2010-11-ctaos++/kernel.cpp create mode 100644 exp/ctaos-early/2010-11-ctaos++/keyboard.h create mode 100644 exp/ctaos-early/2010-11-ctaos++/linker.ld create mode 100644 exp/ctaos-early/2010-11-ctaos++/loader.s create mode 100644 exp/ctaos-early/2010-11-ctaos++/new/script.sh create mode 100644 exp/ctaos-early/2010-11-ctaos++/system.h create mode 100644 exp/ctaos-early/help/CONIOH~1.HT~ create mode 100644 exp/ctaos-early/help/INDEX~1.HT~ create mode 100644 exp/ctaos-early/help/filelist.txt create mode 100644 exp/ctaos-early/help/index_files/colorschememapping.xml create mode 100644 exp/ctaos-early/help/index_files/filelist.xml create mode 100644 exp/ctaos-early/help/index_files/item0006.xml create mode 100644 exp/ctaos-early/help/index_files/props0007.xml create mode 100644 exp/ctaos-early/help/index_files/themedata.thmx create mode 100644 exp/ctaos-early/help/pages/KERNEL~1.HT~ create mode 100644 exp/ctaos-early/help/pages/bootload.html diff --git a/exp/README.md b/exp/README.md index ea01635..8bac9ae 100644 --- a/exp/README.md +++ b/exp/README.md @@ -34,3 +34,23 @@ into the kernel (2011). - `ctaos/` (Nov 2010 - Mar 2011): NetBeans project shell for an earlier, tutorial-based kernel (kernel.c, interrupt, PIT, GDT/IDT/IRQ/PIC sources). Only the project files survive, the sources are not included. + +## Earlier hobby kernels + +- `ctaos-early/` (Oct 2009 - Nov 2010): the first hobby-OS attempts, the + predecessor of luxOS. A GRUB (stage1/stage2 on a floppy image) booted kernel + that starts as plain C and moves to C++ with a text console and keyboard + driver. Source only; floppy/disk images, GRUB stages and compiled output + were left out. Each folder is one snapshot, oldest first: + - `2009-10-25-ctaos/`: first kernel, C (`kernel.c`), loader and linker script. + - `2009-10-28-ctaos++/`: moved to C++ (`kernel.cpp`, `console.h`, `startup.h`). + - `2009-10-30-ctaos++/`: adds `keyboard.h`; changed `kernel.cpp` and `startup.h`. + - `2009-10-31-tctaos/`: separate test copy (`TCTAOS~1`, original name lost) with a + smaller kernel and different loader. + - `2010-11-ctaos++/`: last version (`CTAOS_~1`, probably `ctaos++`): bigger + `console.h`, `keyboard.h`, `system.h`, floppy driver header, and a script + that builds a bootable GRUB hard disk image for qemu. + - `help/`: the hand-written pages of the OS guide (index, bootloader, kernel, + `conio.h` reference), 2010. The files with a `.HT~` extension are 8.3-mangled + names (probably `.html~` backups); the CKEditor copy that came with them is not included. + The Nov 2010 - Mar 2011 NetBeans project shell is in `ctaos/` above. diff --git a/exp/ctaos-early/2009-10-25-ctaos/auto1.sh b/exp/ctaos-early/2009-10-25-ctaos/auto1.sh new file mode 100644 index 0000000..921ef91 --- /dev/null +++ b/exp/ctaos-early/2009-10-25-ctaos/auto1.sh @@ -0,0 +1,13 @@ +cd /home/tiberiu/Desktop/ctaos +echo "Compiling..." +echo "gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs" +gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nodefaultlibs +echo "" +echo "nasm -f elf -o loader.o loader.s" +nasm -f elf -o loader.o loader.s +echo "" +echo "ld -T linker.ld -o kernel.bin loader.o kernel.o" +ld -T linker.ld -o kernel.bin loader.o kernel.o +echo "" + + diff --git a/exp/ctaos-early/2009-10-25-ctaos/auto2.sh b/exp/ctaos-early/2009-10-25-ctaos/auto2.sh new file mode 100644 index 0000000..6a8b7a7 --- /dev/null +++ b/exp/ctaos-early/2009-10-25-ctaos/auto2.sh @@ -0,0 +1,7 @@ +echo "Making floppy image..." +echo "dd if=/dev/zero of=pad bs=1 count=750" +dd if=/dev/zero of=pad bs=1 count=750 +echo "dd if=/dev/zero of=pad2 bs=1 count=(userspecified)" +dd if=/dev/zero of=pad2 bs=1 count=1358807 +cat stage1 stage2 pad kernel.bin pad2 > floppy.img +echo "cat stage1 stage2 pad kernel.bin pad2 > floppy.img" diff --git a/exp/ctaos-early/2009-10-25-ctaos/kernel.c b/exp/ctaos-early/2009-10-25-ctaos/kernel.c new file mode 100644 index 0000000..1c3b0e4 --- /dev/null +++ b/exp/ctaos-early/2009-10-25-ctaos/kernel.c @@ -0,0 +1,75 @@ +unsigned char *videoram = (unsigned char*) 0xb8000; + +void ctamain(); +void cout(char string[]); +void cout_style (char string[], unsigned char style); +void cls(); + +void kmain (void* mdb, unsigned int magic) +{ + if (magic != 0x2BADB002) + { + cout ("Magic error. System halted!"); + } + + char* boot_loader_name = (char*) ((long*)mdb)[16]; + + ctamain(); +} + +void cls() +{ + int i; + for (i = 0; i <= 80*25; i++) + { + videoram[i*2] = 0; + videoram[i*2+1] = 0; + } +} + +void cout (char string[]) +{ + int offset=0, i; + while (videoram[offset*2]!=0) offset++; + + for (i=0; string[i]!=0; i++, offset++) { + if (string[i] == '\n') + do { videoram[offset*2] = ' '; + offset++; + } while (offset%80 != 0); + + else { + videoram[offset*2] = string[i]; + videoram[offset*2+1] = 0x07; + } + } +} + +void cout_style (char string[], unsigned char style) +{ + int offset=0, i; + while (videoram[offset*2]!=0) offset++; + + for (i=0; string[i]!=0; i++, offset++) { + if (string[i] == '\n') + do { videoram[offset*2] = ' '; + videoram[offset*2+1] = style; + offset++; + } while (offset-%80 != 0); + + else { + videoram[offset*2] = string[i]; + videoram[offset*2+1] = style; + } + } +} + + +void ctamain() +{ + cls(); + cout("Hello, world!!!\n"); + cout("Welcome to CTA OS 1.0\n"); + cout_style("MUHAHAHAHAHAHAHAHAHSfdHAHAHA\n", 0x1F); + cout("Good bye now."); +} diff --git a/exp/ctaos-early/2009-10-25-ctaos/linker.ld b/exp/ctaos-early/2009-10-25-ctaos/linker.ld new file mode 100644 index 0000000..d1866ad --- /dev/null +++ b/exp/ctaos-early/2009-10-25-ctaos/linker.ld @@ -0,0 +1,24 @@ +ENTRY (loader) + +SECTIONS { + . = 0x00100000; + + .text :{ + *(.text) + } + + .rodata ALIGN (0x1000) : { + *(.rodata) + } + + .data ALIGN (0x1000) : { + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } +} diff --git a/exp/ctaos-early/2009-10-25-ctaos/loader.s b/exp/ctaos-early/2009-10-25-ctaos/loader.s new file mode 100644 index 0000000..3b8f2e2 --- /dev/null +++ b/exp/ctaos-early/2009-10-25-ctaos/loader.s @@ -0,0 +1,34 @@ +global loader +extern kmain + +MODULEALIGN equ 1<<0 +MEMINFO equ 1<<1 +FLAGS equ MODULEALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC+FLAGS) + +section .text +align 4 +MultiBootHeader: + dd MAGIC + dd FLAGS + dd CHECKSUM + +STACKSIZE equ 0x4000 + +loader: + mov esp, stack+STACKSIZE + push eax + push ebx + + call kmain + + cli +hang: + hlt + jmp hang + +section .bss +align 4 +stack: + resb STACKSIZE diff --git a/exp/ctaos-early/2009-10-28-ctaos++/auto1.sh b/exp/ctaos-early/2009-10-28-ctaos++/auto1.sh new file mode 100644 index 0000000..d571f02 --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/auto1.sh @@ -0,0 +1,14 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Compiling..." +echo "gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs" +gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -fno-exceptions +echo "" +echo "nasm -f elf -o loader.o loader.s" +nasm -f elf -o loader.o loader.s +echo "" +echo "ld -T linker.ld -o kernel.bin loader.o kernel.o" +ld -T linker.ld -o kernel.bin loader.o kernel.o +echo "" + + diff --git a/exp/ctaos-early/2009-10-28-ctaos++/auto2.sh b/exp/ctaos-early/2009-10-28-ctaos++/auto2.sh new file mode 100644 index 0000000..48e56e3 --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/auto2.sh @@ -0,0 +1,13 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Making floppy image..." +echo "" +echo "dd if=/dev/zero of=pad bs=1 count=750" +dd if=/dev/zero of=pad bs=1 count=750 +echo "" +echo "dd if=/dev/zero of=pad2 bs=1 count=(userspecified)" +dd if=/dev/zero of=pad2 bs=1 count=1358451 +echo "" +echo "cat stage1 stage2 pad kernel.bin pad2 > floppy.img" +cat stage1 stage2 pad kernel.bin pad2 > floppy.img + diff --git a/exp/ctaos-early/2009-10-28-ctaos++/console.h b/exp/ctaos-early/2009-10-28-ctaos++/console.h new file mode 100644 index 0000000..195fa2c --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/console.h @@ -0,0 +1,124 @@ +unsigned char *videoram = (unsigned char*) 0xb8000; +static __inline__ void outb(unsigned short port, unsigned char val); +static __inline__ unsigned char inb(unsigned short port); +static __inline__ void io_wait(void); + +// update cursor position +void cupdate_cursor (int x, int y) +{ + unsigned short position = (y * 80) + x; + +// unsigned char word1, word2; + unsigned short word; + +/* word1 = inb (0x463); + word2 = inb (0x464);*/ + + word = (256 * inb (0x463)) + 256*inb (0x464); + + outb(word, 0x0F); + outb(word+1, (unsigned char)(position&0xFF)); + + outb(word, 0x0E); + outb(word+1, (unsigned char )((position>>8)&0xFF)); +} + +// Clear the screen +void cls() +{ + int i; + for (i = 0; i <= 80*25; i++) + { + videoram[i*2] = 0; + videoram[i*2+1] = 0; + } + cursor.x = 0; + cursor.y = 0; +} + +// Place a character on the screen +void cputchar (int x, int y, char c, unsigned char style) +{ + videoram[2*(y*80+x)] = c; + videoram[2*(y*80+x)+1] = style; +} + +// Return a character in a specified position +char cgetchar (int x, int y) +{ + return videoram[2*(y*80+x)]; +} + +// Return a style in specified position +unsigned char cgetstyle (int x, int y) +{ + return videoram[2*(y*80+x)+1]; +} + +// Scroll n lines +void scroll (int n) +{ + int x, y; + cursor.y -= n; + for (y = 0; y < 25-n; y++) + for (x = 0; x < 80; x++) + cputchar (x, y, cgetchar(x, y+n), cgetstyle(x, y+n)); + + while (y<25) { + for (x = 0; x < 80; x++) + cputchar (x, y, 0, 0); + y++; + } +} + + +// Display a string of text on the screen +void cout (const char string[]) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) scroll(1); + + // end of line character behavior + if (string[i] == '\n') { + cursor.y++; + cursor.x = 0; + } + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], 0x07); + if (++cursor.x >= 80) { + cursor.x = 0; + cursor.y++; + } + } + } + cupdate_cursor (cursor.x, cursor.y); +} + +void cout_style (const char string[], unsigned char style) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) scroll(1); + + // end of line character behavior + if (string[i] == '\n') { + cursor.y++; + cursor.x = 0; + } + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], style); + if (++cursor.x >= 80) { + cursor.x = 0; + cursor.y++; + } + } + } + cupdate_cursor (cursor.x, cursor.y); +} + + diff --git a/exp/ctaos-early/2009-10-28-ctaos++/kernel.cpp b/exp/ctaos-early/2009-10-28-ctaos++/kernel.cpp new file mode 100644 index 0000000..9ac84b3 --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/kernel.cpp @@ -0,0 +1,30 @@ +extern "C" int number(); + + +struct point {int x,y;} cursor; + +#include "console.h" +#include "startup.h" + +void ctamain() +{ + int no = number(); + char whatever[] = " is a number.\n"; + unsigned char c, temp = 2; + + whatever[0] = '0' + (char) (no/10); + whatever[1] = '0' + (char) (no%10); + + cls(); + cout("Hello, world!!!\n"); + cout("Welcome to CTA OS 1.0\n"); + cout_style("MUHAHAHAHAHAHAHAHAHSfdHAHAHA\n", 0x1F); + cout(whatever); + cout("Testing keyboard input:\n"); + + do { c = (char) KeyboardIsr(); + temp = c; + do { c = KeyboardIsr(); } while (c == temp); + cout ("This is another line...\n"); + } while (1); +} diff --git a/exp/ctaos-early/2009-10-28-ctaos++/linker.ld b/exp/ctaos-early/2009-10-28-ctaos++/linker.ld new file mode 100644 index 0000000..62d1114 --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/linker.ld @@ -0,0 +1,30 @@ +ENTRY (loader) + +SECTIONS { + . = 0x00100000; + + .text :{ + *(.text) + } + + .rodata ALIGN (0x1000) : { + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } +} diff --git a/exp/ctaos-early/2009-10-28-ctaos++/loader.s b/exp/ctaos-early/2009-10-28-ctaos++/loader.s new file mode 100644 index 0000000..920765e --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/loader.s @@ -0,0 +1,63 @@ +global loader +global number +extern _main +extern start_ctors, end_ctors, start_dtors, end_dtors + +MODULEALIGN equ 1<<0 +MEMINFO equ 1<<1 +FLAGS equ MODULEALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC+FLAGS) + +section .text +align 4 +MultiBootHeader: + dd MAGIC + dd FLAGS + dd CHECKSUM + +STACKSIZE equ 0x4000 + +; Loader +loader: + mov esp, stack+STACKSIZE + push eax + push ebx + +static_ctors_loop: + mov ebx, start_ctors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_ctors + jb .body + + call _main + +static_dtors_loop: + mov ebx, start_dtors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_dtors + jb .body + +hang: + hlt + jmp hang + +; Number function, returns 12 +number: + mov eax, 12 + ret + + + +section .bss +align 4 +stack: + resb STACKSIZE diff --git a/exp/ctaos-early/2009-10-28-ctaos++/startup.h b/exp/ctaos-early/2009-10-28-ctaos++/startup.h new file mode 100644 index 0000000..1047ef4 --- /dev/null +++ b/exp/ctaos-early/2009-10-28-ctaos++/startup.h @@ -0,0 +1,61 @@ +#define PIC1 0x20 /* IO base address for master PIC */ +#define PIC2 0xA0 /* IO base address for slave PIC */ +#define PIC1_COMMAND PIC1 +#define PIC1_DATA (PIC1+1) +#define PIC2_COMMAND PIC2 +#define PIC2_DATA (PIC2+1) +#define NULL 0 + +extern "C" void _main (struct multiboot_data* mbd, unsigned int magic); +void ctamain(); + +typedef unsigned char byte; + +// Entrance point +void _main (struct multiboot_data* mdb, unsigned int magic) +{ + if (magic != 0x2BADB002) + { + cout ("Magic error. System halted!"); + } + + char* boot_loader_name = (char*) ((long*)mdb)[16]; + + ctamain(); + +} + +// sends a byte (or word or dword) on a I/O location +static __inline__ void outb(unsigned short port, unsigned char val) +{ + asm volatile("outb %0,%1"::"a"(val), "Nd" (port)); +} + +// receives a byte (or word or dword) from an I/O location +static __inline__ unsigned char inb(unsigned short port) +{ + unsigned char ret; + asm volatile ("inb %1,%0":"=a"(ret):"Nd"(port)); + return ret; +} + +// Forces the CPU to wait for an I/O operation to complete +static __inline__ void io_wait(void) +{ + asm volatile("outb %%al, $0x80" : : "a"(0)); +} + +// Keyboard input +byte KeyboardIsr() +{ + byte new_scan_code = inb(0x60); + /* Do something with the scancode. + * Remember you only get '''one''' byte of the scancode each time the ISR is invoked. + * (Though most of the times the scancode is only one byte.) + */ + + /* Acknowledge the IRQ, pretty much tells the PIC that we can accept >=priority IRQs now. */ + outb(0x20,0x20); + + return new_scan_code; +} diff --git a/exp/ctaos-early/2009-10-30-ctaos++/auto1.sh b/exp/ctaos-early/2009-10-30-ctaos++/auto1.sh new file mode 100644 index 0000000..d571f02 --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/auto1.sh @@ -0,0 +1,14 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Compiling..." +echo "gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs" +gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -fno-exceptions +echo "" +echo "nasm -f elf -o loader.o loader.s" +nasm -f elf -o loader.o loader.s +echo "" +echo "ld -T linker.ld -o kernel.bin loader.o kernel.o" +ld -T linker.ld -o kernel.bin loader.o kernel.o +echo "" + + diff --git a/exp/ctaos-early/2009-10-30-ctaos++/auto2.sh b/exp/ctaos-early/2009-10-30-ctaos++/auto2.sh new file mode 100644 index 0000000..48e56e3 --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/auto2.sh @@ -0,0 +1,13 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Making floppy image..." +echo "" +echo "dd if=/dev/zero of=pad bs=1 count=750" +dd if=/dev/zero of=pad bs=1 count=750 +echo "" +echo "dd if=/dev/zero of=pad2 bs=1 count=(userspecified)" +dd if=/dev/zero of=pad2 bs=1 count=1358451 +echo "" +echo "cat stage1 stage2 pad kernel.bin pad2 > floppy.img" +cat stage1 stage2 pad kernel.bin pad2 > floppy.img + diff --git a/exp/ctaos-early/2009-10-30-ctaos++/console.h b/exp/ctaos-early/2009-10-30-ctaos++/console.h new file mode 100644 index 0000000..195fa2c --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/console.h @@ -0,0 +1,124 @@ +unsigned char *videoram = (unsigned char*) 0xb8000; +static __inline__ void outb(unsigned short port, unsigned char val); +static __inline__ unsigned char inb(unsigned short port); +static __inline__ void io_wait(void); + +// update cursor position +void cupdate_cursor (int x, int y) +{ + unsigned short position = (y * 80) + x; + +// unsigned char word1, word2; + unsigned short word; + +/* word1 = inb (0x463); + word2 = inb (0x464);*/ + + word = (256 * inb (0x463)) + 256*inb (0x464); + + outb(word, 0x0F); + outb(word+1, (unsigned char)(position&0xFF)); + + outb(word, 0x0E); + outb(word+1, (unsigned char )((position>>8)&0xFF)); +} + +// Clear the screen +void cls() +{ + int i; + for (i = 0; i <= 80*25; i++) + { + videoram[i*2] = 0; + videoram[i*2+1] = 0; + } + cursor.x = 0; + cursor.y = 0; +} + +// Place a character on the screen +void cputchar (int x, int y, char c, unsigned char style) +{ + videoram[2*(y*80+x)] = c; + videoram[2*(y*80+x)+1] = style; +} + +// Return a character in a specified position +char cgetchar (int x, int y) +{ + return videoram[2*(y*80+x)]; +} + +// Return a style in specified position +unsigned char cgetstyle (int x, int y) +{ + return videoram[2*(y*80+x)+1]; +} + +// Scroll n lines +void scroll (int n) +{ + int x, y; + cursor.y -= n; + for (y = 0; y < 25-n; y++) + for (x = 0; x < 80; x++) + cputchar (x, y, cgetchar(x, y+n), cgetstyle(x, y+n)); + + while (y<25) { + for (x = 0; x < 80; x++) + cputchar (x, y, 0, 0); + y++; + } +} + + +// Display a string of text on the screen +void cout (const char string[]) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) scroll(1); + + // end of line character behavior + if (string[i] == '\n') { + cursor.y++; + cursor.x = 0; + } + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], 0x07); + if (++cursor.x >= 80) { + cursor.x = 0; + cursor.y++; + } + } + } + cupdate_cursor (cursor.x, cursor.y); +} + +void cout_style (const char string[], unsigned char style) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) scroll(1); + + // end of line character behavior + if (string[i] == '\n') { + cursor.y++; + cursor.x = 0; + } + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], style); + if (++cursor.x >= 80) { + cursor.x = 0; + cursor.y++; + } + } + } + cupdate_cursor (cursor.x, cursor.y); +} + + diff --git a/exp/ctaos-early/2009-10-30-ctaos++/kernel.cpp b/exp/ctaos-early/2009-10-30-ctaos++/kernel.cpp new file mode 100644 index 0000000..ef9207d --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/kernel.cpp @@ -0,0 +1,31 @@ +extern "C" int number(); + + +struct point {int x,y;} cursor; + +#include "console.h" +#include "startup.h" +#include "keyboard.h" + +void ctamain() +{ + int no = number(); + char whatever[] = " is a number.\n"; + unsigned char c, temp = 2; + + whatever[0] = '0' + (char) (no/10); + whatever[1] = '0' + (char) (no%10); + + cls(); + cout("Hello, world!!!\n"); + cout("Welcome to CTA OS 1.0\n"); + cout_style("MUHAHAHAHAHAHAHAHAHSfdHAHAHA\n", 0x1F); + cout(whatever); + cout("Testing keyboard input:\n"); + + do { c = (char) KeyboardIsr(); + temp = c; + do { c = KeyboardIsr(); } while (c == temp); + cout ("This is another line...\n"); + } while (1); +} diff --git a/exp/ctaos-early/2009-10-30-ctaos++/keyboard.h b/exp/ctaos-early/2009-10-30-ctaos++/keyboard.h new file mode 100644 index 0000000..1d47ad7 --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/keyboard.h @@ -0,0 +1,96 @@ +#define SCROLL_LOCK 1 +#define NUM_LOCK 2 +#define CAPS_LOCK 4 + +#define _KEY_ESCAPE 1 +#define _KEY_BACKSPACE 14 +#define _KEY_TAB 15 +#define _KEY_ENTER 28 +#define _KEY_RETURN 28 +#define _KEY_LEFT_CTRL 29 +#define _KEY_LEFT_SHIFT 42 +#define _KEY_RIGHT_SHIFT 54 +#define _KEY_LEFT_ALT 56 +#define _KEY_SPACEBAR 57 +#define _KEY_CAPSLOCK 58 +#define _KEY_NUMLOCK 69 +#define _KEY_SCROLLLOCK 70 +#define _KEY_F1 59 +#define _KEY_F2 60 +#define _KEY_F3 61 +#define _KEY_F4 62 +#define _KEY_F5 63 +#define _KEY_F6 64 +#define _KEY_F7 65 +#define _KEY_F8 66 +#define _KEY_F9 67 +#define _KEY_F10 68 +#define _KEY_F11 87 +#define _KEY_F12 88 + +byte _ON_SHIFT, _ON_CTRL, _ON_CAPS, _ON_ALT, _ON_NUM; + +// Update keyboard LEDs +void KeyboardLED (uint8_t status) { + uint8_t tmp; + + while ((inb (0x64)&2)!=0) {} + outb (0x60, 0xED); + + while ((inb (0x64)&2)!=0) {} + outb (0x60, status); +} + +unsigned char KeyboardChar (byte scancode) +{ + unsigned char row1_h[] = "!@#$%^&*()_+"; + unsigned char row1_l[] = "1234567890-="; + + unsigned char row2_h [] = "QWERTYUIOP{}"; + unsigned char row2_l [] = "qwertyuiop[]"; + + unsigned char row3_h [] = "ASDFGHJKL:\"~"; + unsigned char row3_l [] = "asdfghjkl;'`"; + + unsigned char row4_h [] = "ZXCVBNM<>?"; + unsigned char row4_l [] = "zxcvbnm,./"; + + unsigned char numpad [] = "789-456+1230."; + + unsigned char spacebar = " "; + unsigned char numpad_asterisk = "*"; + + if (scancode > 1 && scancode < 14 && _ON_SHIFT) return row1_h[scancode-2]; + if (scancode > 1 && scancode < 14 && !_ON_SHIFT)return row1_l[scancode-2]; + + if (scancode > 15 && scancode < 28 && _ON_SHIFT) return row2_h[scancode-16]; + if (scancode > 15 && scancode < 28 && !_ON_SHIFT) return row2_l[scancode-16]; + + if (scancode > 29 && scancode < 42 && _ON_SHIFT) return row3_h[scancode-30]; + if (scancode > 29 && scancode < 42 && !_ON_SHIFT) return row3_l[scancode-30]; + + if (scancode > 43 && scancode < 54 && _ON_SHIFT) return row4_h[scancode-44]; + if (scancode > 43 && scancode < 54 && !_ON_SHIFT) return row4_l[scancode-44]; + + if (scancode > 70 && scancode < 87 && _ON_NUM) return numpad[scancode-71]; + + if (scancode == 57) return spacebar; + if (scancode == 55) return numpad_asterisk; + + return 0; +} + +// Keyboard input +byte KeyboardIsr() +{ + byte new_scan_code = inb(0x60); + /* Do something with the scancode. + * Remember you only get '''one''' byte of the scancode each time the ISR is invoked. + * (Though most of the times the scancode is only one byte.) + */ + + /* Acknowledge the IRQ, pretty much tells the PIC that we can accept >=priority IRQs now. */ + outb(0x20,0x20); + + return new_scan_code; +} \ No newline at end of file diff --git a/exp/ctaos-early/2009-10-30-ctaos++/linker.ld b/exp/ctaos-early/2009-10-30-ctaos++/linker.ld new file mode 100644 index 0000000..62d1114 --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/linker.ld @@ -0,0 +1,30 @@ +ENTRY (loader) + +SECTIONS { + . = 0x00100000; + + .text :{ + *(.text) + } + + .rodata ALIGN (0x1000) : { + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } +} diff --git a/exp/ctaos-early/2009-10-30-ctaos++/loader.s b/exp/ctaos-early/2009-10-30-ctaos++/loader.s new file mode 100644 index 0000000..920765e --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/loader.s @@ -0,0 +1,63 @@ +global loader +global number +extern _main +extern start_ctors, end_ctors, start_dtors, end_dtors + +MODULEALIGN equ 1<<0 +MEMINFO equ 1<<1 +FLAGS equ MODULEALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC+FLAGS) + +section .text +align 4 +MultiBootHeader: + dd MAGIC + dd FLAGS + dd CHECKSUM + +STACKSIZE equ 0x4000 + +; Loader +loader: + mov esp, stack+STACKSIZE + push eax + push ebx + +static_ctors_loop: + mov ebx, start_ctors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_ctors + jb .body + + call _main + +static_dtors_loop: + mov ebx, start_dtors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_dtors + jb .body + +hang: + hlt + jmp hang + +; Number function, returns 12 +number: + mov eax, 12 + ret + + + +section .bss +align 4 +stack: + resb STACKSIZE diff --git a/exp/ctaos-early/2009-10-30-ctaos++/startup.h b/exp/ctaos-early/2009-10-30-ctaos++/startup.h new file mode 100644 index 0000000..d041ae7 --- /dev/null +++ b/exp/ctaos-early/2009-10-30-ctaos++/startup.h @@ -0,0 +1,63 @@ +#define PIC1 0x20 /* IO base address for master PIC */ +#define PIC2 0xA0 /* IO base address for slave PIC */ +#define PIC1_COMMAND PIC1 +#define PIC1_DATA (PIC1+1) +#define PIC2_COMMAND PIC2 +#define PIC2_DATA (PIC2+1) +#define NULL 0 +#define true 1 +#define false 0 + +extern "C" void _main (struct multiboot_data* mbd, unsigned int magic); +void ctamain(); + +typedef unsigned char byte; + +// Entrance point +void _main (struct multiboot_data* mdb, unsigned int magic) +{ + if (magic != 0x2BADB002) + { + cout ("Magic error. System halted!"); + } + + char* boot_loader_name = (char*) ((long*)mdb)[16]; + + ctamain(); + +} + +// sends a byte (or word or dword) on a I/O location +static __inline__ void outb(unsigned short port, unsigned char val) +{ + asm volatile("outb %0,%1"::"a"(val), "Nd" (port)); +} + +// receives a byte (or word or dword) from an I/O location +static __inline__ unsigned char inb(unsigned short port) +{ + unsigned char ret; + asm volatile ("inb %1,%0":"=a"(ret):"Nd"(port)); + return ret; +} + +// Forces the CPU to wait for an I/O operation to complete +static __inline__ void io_wait(void) +{ + asm volatile("outb %%al, $0x80" : : "a"(0)); +} + +// Keyboard input +byte KeyboardIsr() +{ + byte new_scan_code = inb(0x60); + /* Do something with the scancode. + * Remember you only get '''one''' byte of the scancode each time the ISR is invoked. + * (Though most of the times the scancode is only one byte.) + */ + + /* Acknowledge the IRQ, pretty much tells the PIC that we can accept >=priority IRQs now. */ + outb(0x20,0x20); + + return new_scan_code; +} diff --git a/exp/ctaos-early/2009-10-31-tctaos/auto.sh b/exp/ctaos-early/2009-10-31-tctaos/auto.sh new file mode 100644 index 0000000..a242de0 --- /dev/null +++ b/exp/ctaos-early/2009-10-31-tctaos/auto.sh @@ -0,0 +1,9 @@ +echo "" +echo "GCC compiling... " +gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -fno-exceptions +echo "" +echo "NASM compiling... " +nasm -f elf -o loader.o loader.s +echo "" +echo "Linking... " +ld -T linker.ld -o kernel.bin kernel.o loader.o diff --git a/exp/ctaos-early/2009-10-31-tctaos/auto2.sh b/exp/ctaos-early/2009-10-31-tctaos/auto2.sh new file mode 100644 index 0000000..91a09cb --- /dev/null +++ b/exp/ctaos-early/2009-10-31-tctaos/auto2.sh @@ -0,0 +1,13 @@ +cd /home/tiberiu/Desktop/tctaos++ +echo "" +echo "Making floppy image..." +echo "" +echo "dd if=/dev/zero of=pad bs=1 count=750" +dd if=/dev/zero of=pad bs=1 count=750 +echo "" +echo "dd if=/dev/zero of=pad bs=1 count=1358454" +dd if=/dev/zero of=pad2 bs=1 count=1358454 +echo "" +echo "cat stage1 stage2 pad kernel.bin > floppy.img" +cat stage1 stage2 pad kernel.bin pad2 > floppy.img + diff --git a/exp/ctaos-early/2009-10-31-tctaos/kernel.cpp b/exp/ctaos-early/2009-10-31-tctaos/kernel.cpp new file mode 100644 index 0000000..11948f3 --- /dev/null +++ b/exp/ctaos-early/2009-10-31-tctaos/kernel.cpp @@ -0,0 +1,46 @@ +extern "C" void _main (struct multiboot_data* mbd, unsigned int magic); + +unsigned char *videoram = (unsigned char *) 0xb8000; + +void ctamain(); +void putchar(int x, int y, char c, unsigned char style); +void cls(); + +void _main (struct multiboot_data* mbd, unsigned int magic) +{ + if (magic != 0x2BADB002) + { //Error behaviour + } + + char* boot_loader_name = (char*) ((long*)mbd)[16]; + + ctamain(); +} + +void putchar(int x, int y, char c, unsigned char style) +{ + videoram[2*((80*y)+x)] = c; + videoram[2*((80*y)+x)+1] = style; +} + +void cls() +{ + for (int x = 0; x < 80; x ++) + for (int y = 0; y < 25; y++) + putchar (x, y, 0, 0); +} + +void cout(int x, int y, char str[]) +{ + int i = 0; + while (str[i] != 0) { + putchar (i+x, y, str[i], 0x07); + i++; + } +} + +void ctamain() +{ + cls(); + cout (0, 0, "Hello world!"); +} diff --git a/exp/ctaos-early/2009-10-31-tctaos/linker.ld b/exp/ctaos-early/2009-10-31-tctaos/linker.ld new file mode 100644 index 0000000..62d1114 --- /dev/null +++ b/exp/ctaos-early/2009-10-31-tctaos/linker.ld @@ -0,0 +1,30 @@ +ENTRY (loader) + +SECTIONS { + . = 0x00100000; + + .text :{ + *(.text) + } + + .rodata ALIGN (0x1000) : { + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } +} diff --git a/exp/ctaos-early/2009-10-31-tctaos/loader.s b/exp/ctaos-early/2009-10-31-tctaos/loader.s new file mode 100644 index 0000000..1310d07 --- /dev/null +++ b/exp/ctaos-early/2009-10-31-tctaos/loader.s @@ -0,0 +1,56 @@ +global loader +extern _main +extern start_ctors, end_ctors, start_dtors, end_dtors + +MODULEALIGN equ 1<<0 +MEMINFO equ 1<<1 +FLAGS equ MODULEALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC+FLAGS) + +section .text +align 4 +MultiBootHeader: + dd MAGIC + dd FLAGS + dd CHECKSUM + +STACKSIZE equ 0x4000 + +; Loader +loader: + mov esp, stack+STACKSIZE + push eax + push ebx + +static_ctors_loop: + mov ebx, start_ctors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_ctors + jb .body + + call _main + +static_dtors_loop: + mov ebx, start_dtors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_dtors + jb .body + +hang: + hlt + jmp hang + + +section .bss +align 4 +stack: + resb STACKSIZE diff --git a/exp/ctaos-early/2010-11-ctaos++/auto1.sh b/exp/ctaos-early/2010-11-ctaos++/auto1.sh new file mode 100644 index 0000000..d571f02 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/auto1.sh @@ -0,0 +1,14 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Compiling..." +echo "gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs" +gcc -o kernel.o -c kernel.cpp -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs -fno-exceptions +echo "" +echo "nasm -f elf -o loader.o loader.s" +nasm -f elf -o loader.o loader.s +echo "" +echo "ld -T linker.ld -o kernel.bin loader.o kernel.o" +ld -T linker.ld -o kernel.bin loader.o kernel.o +echo "" + + diff --git a/exp/ctaos-early/2010-11-ctaos++/auto2.sh b/exp/ctaos-early/2010-11-ctaos++/auto2.sh new file mode 100644 index 0000000..48e56e3 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/auto2.sh @@ -0,0 +1,13 @@ +cd /home/tiberiu/Desktop/ctaos++ +echo "" +echo "Making floppy image..." +echo "" +echo "dd if=/dev/zero of=pad bs=1 count=750" +dd if=/dev/zero of=pad bs=1 count=750 +echo "" +echo "dd if=/dev/zero of=pad2 bs=1 count=(userspecified)" +dd if=/dev/zero of=pad2 bs=1 count=1358451 +echo "" +echo "cat stage1 stage2 pad kernel.bin pad2 > floppy.img" +cat stage1 stage2 pad kernel.bin pad2 > floppy.img + diff --git a/exp/ctaos-early/2010-11-ctaos++/console.h b/exp/ctaos-early/2010-11-ctaos++/console.h new file mode 100644 index 0000000..8d30a4a --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/console.h @@ -0,0 +1,192 @@ +unsigned char *videoram = (unsigned char*) 0xb8000; // Video memory +struct unsigned_point {unsigned int x,y;} cursor; // Cursor position in a point structure +char hex[] = "0123456789ABCDEF"; // Hex chars + +void cDetectVideo(); +void cendl(); +void cFillStyle(byte style); +char cgetchar (int x, int y); +unsigned char cgetstyle (int x, int y); +void cls(); +void cout (const char string[]); +void cout_hex (int no); +void cout_hex (short no); +void cout_hex (unsigned short no); +void cout_hex (char no); +void cout_style (const char string[], unsigned char style); +void cputchar (int x, int y, char c, unsigned char style); +void cscroll (int n); +void cUpdateCursor (); + +void cDetectVideo() +{ + char c; + c = (*(volatile unsigned short*)0x410)&0x30; + + //c can be 0x00 or 0x20 for colour, 0x30 for mono. + if (c==0x30) { + video_mode_colors = 0; + videoram = (unsigned char*) 0xb0000; + } + else video_mode_colors = 1; +} + + +// update cursor position +void cUpdateCursor (int x, int y) +{ + unsigned position = (y * 80) + x; + unsigned short address = 0x3D4; + + outb(address, 0x0E); + outb(address+1, (position >> 8) & 0xFF); + + outb(address, 0x0F); + outb(address+1, position & 0xFF); +} + +// Clear the screen +void cls() +{ + int i; + for (i = 0; i <= 80*25; i++) + { + videoram[i*2] = 0; + videoram[i*2+1] = 0; + } + cursor.x = 0; + cursor.y = 0; +} + + +// Fill the screen with a style +void cFillStyle(byte style) +{ + for (int i = 0; i <= 80*25; i++) + videoram[i*2+1] = style; +} + +// Place a character on the screen +void cputchar (int x, int y, char c, unsigned char style) +{ + videoram[2*(y*80+x)] = c; + videoram[2*(y*80+x)+1] = style; +} + +// Return a character in a specified position +char cgetchar (int x, int y) +{ + return videoram[2*(y*80+x)]; +} + +// Return a style in specified position +unsigned char cgetstyle (int x, int y) +{ + return videoram[2*(y*80+x)+1]; +} + +// Scroll n lines +void cscroll (int n) +{ + int x, y; + cursor.y -= n; + for (y = 0; y < 25-n; y++) + for (x = 0; x < 80; x++) + cputchar (x, y, cgetchar(x, y+n), cgetstyle(x, y+n)); + + while (y<25) { + for (x = 0; x < 80; x++) + cputchar (x, y, 0, 0); + y++; + } +} + +void cendl() +{ + cursor.y++; cursor.x = 0; +} + +// Display a string of text on the screen +void cout (const char string[]) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) cscroll(1); + + // end of line character behavior + if (string[i] == '\n') + cendl(); + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], 0x07); + if (++cursor.x >= 80) cendl(); + } + } +} + +void cout_hex (char no) +{ + char str[] = "0x "; + str[3] = hex[no%16]; + str[2] = hex[no/16]; + cout (str); +} + +void cout_hex (short no) +{ + char str[] = "0x "; + str[5] = hex[no%16]; + str[4] = hex[(no/16)%16]; + str[3] = hex[(no/256)%16]; + str[2] = hex[no/(256*16)]; + cout (str); +} + +void cout_hex (unsigned short no) +{ + char str[] = "0x "; + str[5] = hex[no%16]; + str[4] = hex[(no/16)%16]; + str[3] = hex[(no/256)%16]; + str[2] = hex[no/(256*16)]; + cout (str); +} + + +void cout_hex (int no) +{ + char str[] = "0x "; + str[9] = hex[no%16]; + str[8] = hex[(no/16)%16]; + str[7] = hex[(no/(16*16))%16]; + str[6] = hex[(no/(16*16*16))%16]; + str[5] = hex[(no/(16*16*16*16))%16]; + str[4] = hex[(no/(16*16*16*16*16))%16]; + str[3] = hex[(no/(16*16*16*16*16*16))%16]; + str[2] = hex[no/(16*16*16*16*16*16*16)]; + cout (str); +} + +void cout_style (const char string[], unsigned char style) +{ + for (int i=0; string[i]!=0; i++) { + // scroll if necesary + if (cursor.y >= 25) cscroll(1); + + // end of line character behavior + if (string[i] == '\n') { + do cputchar (cursor.x, cursor.y, ' ', style); + while (++cursor.x < 80); + cendl(); + } + + // display text + else { + cputchar (cursor.x, cursor.y, string[i], style); + if (++cursor.x >= 80) cendl(); + } + } +} + + diff --git a/exp/ctaos-early/2010-11-ctaos++/drivers/drivers.h b/exp/ctaos-early/2010-11-ctaos++/drivers/drivers.h new file mode 100644 index 0000000..7e916c8 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/drivers/drivers.h @@ -0,0 +1 @@ +#include "floppy.h" diff --git a/exp/ctaos-early/2010-11-ctaos++/drivers/floppy.h b/exp/ctaos-early/2010-11-ctaos++/drivers/floppy.h new file mode 100644 index 0000000..2d38fab --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/drivers/floppy.h @@ -0,0 +1,108 @@ +#ifndef __FLOPPY_CONTROLLER +#define __FLOPPY_CONTROLLER + +#define FLOPPYDigitalOutputRegister 0x3F2 +#define FLOPPYMainStatusRegister 0x3F4 + +/******************************************************************************** + Byte to binary and binary to byte functions +********************************************************************************/ + +void byte_to_binary (unsigned char byt, bool array[]) +{ + int i = 0; + while (++i < 8) { + array[i] = byt%2; + byt /= 2; + } +} + +byte binary_to_byte (bool array[]) +{ + byte ret; + ret = array[0]; + ret += 2 * (byte)array[1]; + ret += 4 * (byte)array[2]; + ret += 8 * (byte)array[3]; + ret += 16 * (byte)array[4]; + ret += 32 * (byte)array[5]; + ret += 64 * (byte)array[6]; + ret += 128 * (byte)array[7]; + return ret; +} + + + + +/******************************************************************************** + Floppy functions +********************************************************************************/ +byte floppy_motor(char drive, bool state) +{ + byte status; + bool array[8]; + + status = inb (FLOPPYDigitalOutputRegister); + byte_to_binary (status, array); + + if (drive == 'A') array[4] = state; + if (drive == 'B') array[5] = state; + if (drive == 'C') array[6] = state; + if (drive == 'D') array[7] = state; + + + status = binary_to_byte (array); + outb (FLOPPYDigitalOutputRegister, status); + return status; +} + + +byte floppy_DMA(bool state) +{ + byte status; + bool array[8]; + + status = inb (FLOPPYDigitalOutputRegister); + byte_to_binary (status, array); + + array[3] = state; + + status = binary_to_byte (array); + outb (FLOPPYDigitalOutputRegister, status); + return status; +} + +void floppy_reset() +{ + outb (FLOPPYDigitalOutputRegister, 0); +} + +byte floppy_select (char drive) +{ + byte status; + bool array[8]; + + status = inb (FLOPPYDigitalOutputRegister); + byte_to_binary (status, array); + + array[0] = (drive - 'A')%2; + array[1] = (drive >= 'C'); + + status = binary_to_byte (array); + outb (FLOPPYDigitalOutputRegister, status); + return status; +} + +bool floppy_ready() +{ + byte status; + bool array[8]; + + status = inb (FLOPPYMainStatusRegister); + byte_to_binary (status, array); + + if (array[7] && !array[4]) return true; + else return false; +} + +#endif diff --git a/exp/ctaos-early/2010-11-ctaos++/kernel.cpp b/exp/ctaos-early/2010-11-ctaos++/kernel.cpp new file mode 100644 index 0000000..c79d760 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/kernel.cpp @@ -0,0 +1,64 @@ +#include "system.h" +#include "console.h" +#include "keyboard.h" +#include "drivers/drivers.h" + +void ctamain() +{ + //cls(); + char k; + cout_style("Welcome to CTA OS 1.0\n", 0x2A); + + floppy_motor('A', 0); + cout_style("Now you can eject your floppy :D\n", 0x1F); + + cout("Testing keyboard input:\n"); + + do { do { k = KeyboardUpdate(); } + while (k == -1); + + if (k<0) k*=-1; + + cputchar(60, 20, k, 0x2F); + cputchar(60, 21, hex[k/16], 0x1F); + cputchar(61, 21, hex[k%16], 0x1F); + + for (int i = 0; i < 0x80; i++) + { + cputchar(i, 10, keyboard[i]+'0', 0x0F); + cputchar(i, 12, keyboard_special[i]+'0', 0x0F); + } + cursor.x = 0; cursor.y = 14; + cout ("Special: "); cputchar (15, 14, keyb_specialON+'0', 0x03); + + cursor.x = 0; cursor.y = 16; + cout ("LShift: "); cputchar (15, 16, keyb_LSHIFT+'0', 0x03); + cursor.x = 40; cursor.y = 16; + cout ("RShift: "); cputchar (55, 16, keyb_RSHIFT+'0', 0x03); + + cursor.x = 0; cursor.y = 17; + cout ("LAlt: "); cputchar (15, 17, keyb_LALT+'0', 0x03); + cursor.x = 40; cursor.y = 17; + cout ("RAlt: "); cputchar (55, 17, keyb_RALT+'0', 0x03); + + cursor.x = 0; cursor.y = 18; + cout ("LCTRL: "); cputchar (15, 18, keyb_LCTRL+'0', 0x03); + cursor.x = 40; cursor.y = 18; + cout ("RCTRL: "); cputchar (55, 18, keyb_RCTRL+'0', 0x03); + + cursor.x = 0; cursor.y = 21; + cout ("STATUS: "); + for (int i = 0; i < 0x60; i++) { + if (keyboard[i] && !keyboard_special[i]) { + cout(keys_list[i]); + cout (" \n"); + } + } + + if (keyboard[1]) { + cout("Rebooting system..."); + SystemReboot(); + } + + } while (1); +} diff --git a/exp/ctaos-early/2010-11-ctaos++/keyboard.h b/exp/ctaos-early/2010-11-ctaos++/keyboard.h new file mode 100644 index 0000000..fef3056 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/keyboard.h @@ -0,0 +1,169 @@ +#ifndef __STANDARD_US_KEYBOARD +#define __STANDARD_US_KEYBOARD +#define SCROLL_LOCK 1 +#define NUM_LOCK 2 +#define CAPS_LOCK 4 + +unsigned char keyboard[0x60]; // All keys pressed/released list +unsigned char keyboard_special[128]; // All special keys pressed/released list +bool keyb_specialON; // Other special keys +bool keyb_LSHIFT, keyb_RSHIFT, keyb_FAKESHIFT, + keyb_LALT, keyb_RALT, + keyb_LCTRL, keyb_RCTRL; + +bool keyb_NUMLOCK, keyb_SCROLLLOCK, keyb_CAPSLOCK; +unsigned char keyb_pause; // Pause/break key +byte prev; + +char keys_list[0x60][0x1F] = { "ERROR", "Escape", "1 !", "2 @", "3 #", + "4 $", "5 %", "6 ^", "7 &", "8 *", "9 (", "0 )", "- _", + "= +", "Backspace", "Tab", "q Q", "w W", "e E", "r R", "t T", "y Y", + "u U", "i I", "o O", "p P", "[ {", "] }" ,"Enter", "LCtrl", "a A", "s S", + "d D", "f F", "g G", "h H", "j J", "k K", "l L", "; :", "' \"", "` ~", + "LShift", "\\ |", "z Z", "x X", "c C", "v V", "b B", "n N", "m M", ", <", + ". >", "/ ?", "RShift", "Keypad-*/PrtScn", "LAlt", "Space bar", + "CapsLock", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", + "F9", "F10", "NumLock", "ScrollLock", "Keypad-7/Home", + "Keypad-8/Up", "Keypad-9/PgUp", "Keypad--", "Keypad-4/Left", + "Keypad-5", "Keypad-6/Right", "Keypad-+", "Keypad-1/End", + "Keypad-2/Down", "Keypad-3/PgDn", "Keypad-0/Ins", "Keypad-./Del", + "Alt-SysRq", " ", "BLANK", "F11", "F12" }; + + +// Update keyboard LEDs +void KeyboardLED (uint8_t status) { + while ((inb (0x64)&2)!=0) {} + outb (0x60, 0xED); + + while ((inb (0x64)&2)!=0) {} + outb (0x60, status); +} + + +byte KeyboardGetInput() +{ byte scan = inb(0x60); + outb (0x20, 0x20); + return scan; +} + +char scancode_to_ASCII(byte scancode, bool shift) +{ + // Ignore break code + if (scancode >= 0x80) scancode-=0x80; + + + if (scancode == 0x01) return 0x00; // Escape + else if (scancode >= 0x02 && scancode <= 0x0D) { // First row on the keyboard + unsigned char str0[] = "1234567890-="; + unsigned char str1[] = "!@#$%^&*()_+"; + if (shift) return str1[scancode-0x02]; + else return str0[scancode-0x02]; + } + else if (scancode == 0x0E) return 0x08; // Backspace + else if (scancode == 0x0F) return 0x09; // Tab + else if (scancode >= 0x10 && scancode <= 0x1b) { // Second row on the keyboard + unsigned char str0[] = "qwertyuiop[]"; + unsigned char str1[] = "QWERTYUIOP{}"; + if (shift) return str1[scancode-0x10]; + else return str0[scancode-0x10]; + } + else if (scancode == 0x1C) return 0x0D; // Enter (Carrige return) + else if (scancode >= 0x1E && scancode <= 0x29) { // Third row on the keyboard + unsigned char str0[] = "asdfghjkl;'`"; + unsigned char str1[] = "ASDFGHJKL:\"~"; + if (shift) return str1[scancode-0x1E]; + else return str0[scancode-0x1E]; + } + else if (scancode == 0x2B) { // | key + unsigned char str0[] = "\\|"; + return str0[shift]; + } + else if (scancode >= 0x2C && scancode <= 0x35) { // Forth row on the keyboard + unsigned char str0[] = "zxcvbnm,./"; + unsigned char str1[] = "ZXCVBNM<>?"; + if (shift) return str1[scancode-0x2C]; + else return str0[scancode-0x2C]; + } + else if (scancode == 0x37) return '*'; + else if (scancode == 0x39) return ' '; + else if (scancode >= 0x47 && scancode <= 0x53) { // Numpad keys + unsigned char str0[] = "789-456+1230."; + return str0[scancode-0x47]; + } + return 0; +} + +// Keyboard input +byte KeyboardUpdate() +{ + byte new_scan_code = KeyboardGetInput(); + + if (new_scan_code == prev) return -1; // 1: Nothing new + switch (new_scan_code) { + case 0x00: return -2; break; // 2: Keyboard error + case 0xFF: return -2; break; + case 0xAA: return -3; break; // 3: BAT (Basic Assurance Test) OK + case 0xFA: return -4; break; // 4: Acknowledge from kbd + case 0xFC: return -5; break; // 5: BAT error or Mouse transmit error + case 0xFD: return -6; break; // 6: Internal failure + case 0xFE: return -7; break; // 7: Keyboard fails to ack, please resend + + case 0xE1: keyb_specialON = true; return 0; break; + case 0xE0: keyb_specialON = true; return 0; break; + } + + if (keyb_specialON) { + // FAKE SHIFT + if (new_scan_code == 0x2A) keyb_FAKESHIFT = true; + else if (new_scan_code == 0xAA) keyb_FAKESHIFT = false; + // Right Alt + else if (new_scan_code == 0x38) keyb_RALT = true; + else if (new_scan_code == 0x38+0x80) keyb_RALT = false; + // Right Control + else if (new_scan_code == 0x1D) keyb_RCTRL = true; + else if (new_scan_code == 0x1D+0x80) keyb_RCTRL = false; + + else if (new_scan_code < 0x80) keyboard_special[new_scan_code] = true; + else keyboard_special[new_scan_code-0x80] = false; + + keyb_specialON = false; + } + + else { + // Left Shift + if (new_scan_code == 0x2A) keyb_LSHIFT = true; + else if (new_scan_code == 0xAA) keyb_LSHIFT = false; + // Right Shift + else if (new_scan_code == 0x36) keyb_RSHIFT = true; + else if (new_scan_code == 0x36+0x80) keyb_RSHIFT = false; + // Left Alt + else if (new_scan_code == 0x38) keyb_LALT = true; + else if (new_scan_code == 0x38+0x80) keyb_LALT = false; + // Left Control + else if (new_scan_code == 0x1D) keyb_LCTRL = true; + else if (new_scan_code == 0x1D+0x80) keyb_LCTRL = false; + + else if (new_scan_code < 0x80) keyboard[new_scan_code] = true; + else keyboard[new_scan_code - 0x80] = false; + + if (new_scan_code == 0x45) { + keyb_NUMLOCK = 1-keyb_NUMLOCK; + KeyboardLED((keyb_NUMLOCK*2) | (keyb_SCROLLLOCK*1) | (keyb_CAPSLOCK*4)); + } + if (new_scan_code == 0x46) { + keyb_SCROLLLOCK = 1-keyb_SCROLLLOCK; + KeyboardLED((keyb_NUMLOCK*2) | (keyb_SCROLLLOCK*1) | (keyb_CAPSLOCK*4)); + } + if (new_scan_code == 0x3A) { + keyb_CAPSLOCK = 1-keyb_CAPSLOCK; + KeyboardLED((keyb_NUMLOCK*2) | (keyb_SCROLLLOCK*1) | (keyb_CAPSLOCK*4)); + } + } + + prev = new_scan_code; + + return scancode_to_ASCII(new_scan_code, keyb_RSHIFT); +} + + +#endif diff --git a/exp/ctaos-early/2010-11-ctaos++/linker.ld b/exp/ctaos-early/2010-11-ctaos++/linker.ld new file mode 100644 index 0000000..62d1114 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/linker.ld @@ -0,0 +1,30 @@ +ENTRY (loader) + +SECTIONS { + . = 0x00100000; + + .text :{ + *(.text) + } + + .rodata ALIGN (0x1000) : { + *(.rodata) + } + + .data ALIGN (0x1000) : { + start_ctors = .; + *(.ctor*) + end_ctors = .; + start_dtors = .; + *(.dtor*) + end_dtors = .; + *(.data) + } + + .bss : { + sbss = .; + *(COMMON) + *(.bss) + ebss = .; + } +} diff --git a/exp/ctaos-early/2010-11-ctaos++/loader.s b/exp/ctaos-early/2010-11-ctaos++/loader.s new file mode 100644 index 0000000..920765e --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/loader.s @@ -0,0 +1,63 @@ +global loader +global number +extern _main +extern start_ctors, end_ctors, start_dtors, end_dtors + +MODULEALIGN equ 1<<0 +MEMINFO equ 1<<1 +FLAGS equ MODULEALIGN | MEMINFO +MAGIC equ 0x1BADB002 +CHECKSUM equ -(MAGIC+FLAGS) + +section .text +align 4 +MultiBootHeader: + dd MAGIC + dd FLAGS + dd CHECKSUM + +STACKSIZE equ 0x4000 + +; Loader +loader: + mov esp, stack+STACKSIZE + push eax + push ebx + +static_ctors_loop: + mov ebx, start_ctors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_ctors + jb .body + + call _main + +static_dtors_loop: + mov ebx, start_dtors + jmp .test +.body: + call [ebx] + add ebx, 4 +.test: + cmp ebx, end_dtors + jb .body + +hang: + hlt + jmp hang + +; Number function, returns 12 +number: + mov eax, 12 + ret + + + +section .bss +align 4 +stack: + resb STACKSIZE diff --git a/exp/ctaos-early/2010-11-ctaos++/new/script.sh b/exp/ctaos-early/2010-11-ctaos++/new/script.sh new file mode 100644 index 0000000..05f94a7 --- /dev/null +++ b/exp/ctaos-early/2010-11-ctaos++/new/script.sh @@ -0,0 +1,59 @@ +#!/bin/bash + +# This script can be used to quickly test MultiBoot-compliant +# kernels. The kernel filename is required to be kernel.bin. +# Also, this script requires the file 'stage1' and 'stage2' +# from GRUB to be in the current directory. + + +# config params here +image_size=$((4*1024*1024)) # 4 megabytes +qemu_cmdline="qemu -hda harddisk.img" + + + +stage1_size=`stat -c %s stage1` || echo "file 'stage1' required" # steal these from GRUB +stage2_size=`stat -c %s stage2` || echo "file 'stage2' required" +kernel_size=`stat -c %s kernel.bin` || echo "file 'kernel.bin' required" + +kernel_begin_block=$(((stage1_size+stage2_size+511)/512)) + +padding_size=$((kernel_begin_block*512 - stage1_size - stage2_size)) +padding2_size=$((image_size - kernel_begin_block*512 - kernel_size)) + + +dd if=/dev/zero of=padding.tmp count=1 bs=$padding_size 2>/dev/null +dd if=/dev/zero of=padding2.tmp count=1 bs=$padding2_size 2>/dev/null + +cat stage1 stage2 padding.tmp kernel.bin padding2.tmp > harddisk.img + +rm padding.tmp padding2.tmp + + +( stty cbreak ; stty -echo ; python -c "`cat < + + CKEditor Sample + + +

+      CONIO.H

+

+
+   Functions
+   ¯¯¯¯¯¯¯¯¯
+    cgets            clreol           clrscr           cprintf
+    cputs            cscanf           delline          getch
+    getche           getpass          gettext          gettextinfo
+    gotoxy           highvideo        insline          inp
+    inport           inportb          inpw             kbhit
+    lowvideo         movetext         normvideo        outp
+    outport          outportb         outpw            putch
+    puttext          _setcursortype   textattr         textbackground
+    textcolor        textmode         ungetch          wherex
+    wherey           window
+
+   Constants, data types, and global variables
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    BLINK           COLORS          directvideo     _NOCURSOR
+    _NORMALCURSOR   _SOLIDCURSOR    text_info       text_modes
+    _wscroll
+
+
+
+
+
+   _______
+   ¦cgets¦                           <CONIO.H>
+   ¯¯¯¯¯¯¯
+   Reads string from console
+
+   Declaration:  char *cgets(char *str);
+
+   Remarks:
+  cgets reads a string of characters from the console and stores the string
+  (and the string length) in the location *str.
+
+  Before you call cgets, set str[0] to the maximum length of the string to be
+  read.
+
+  cgets reads characters until it encounters a carriage-return/linefeed
+  combination (CR/LF), or until the maximum allowable number of characters
+  have been read.
+
+  If cgets reads a CR/LF, it replaces the CR/LF with a \0 (null terminator)
+  before storing the string.
+
+  On return, str[1] is set to the number of characters actually read.
+
+  The characters read start at str[2] and end with a null terminator, so str
+  must be at least (str[0] + 2) bytes long.
+
+   Return Value:
+    ¦ On success, returns a pointer to str[2].
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    cputs    fgets    getch    getche   gets
+
+   Example:
+
+   #include <stdio.h>
+   #include <conio.h>
+
+   int main(void)
+   {
+      char buffer[83];
+      char *p;
+
+      /* There's space for 80 characters plus the NULL terminator */
+      buffer[0] = 81;
+
+      printf("Input some chars:");
+      p = cgets(buffer);
+      printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
+      printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
+
+      /* Leave room for 5 characters plus the NULL terminator */
+      buffer[0] = 6;
+
+      printf("Input some chars:");
+      p = cgets(buffer);
+      printf("\ncgets read %d characters: \"%s\"\n", buffer[1], p);
+      printf("The returned pointer is %p, buffer[0] is at %p\n", p, &buffer);
+      return 0;
+   }
+
+
+
+
+   ________
+   ¦clreol¦                           <CONIO.H>
+   ¯¯¯¯¯¯¯¯
+   Clears to end of line in text window
+
+   Declaration:  void clreol(void);
+
+   Remarks:
+  clreol clears all characters from the cursor position to the end of the line
+  within the current text window, without moving the cursor.
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    clrscr    delline   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+
+   {
+      clrscr();
+      cprintf("The function CLREOL clears all characters from the\r\n");
+      cprintf("cursor position to the end of the line within the\r\n");
+      cprintf("current text window, without moving the cursor.\r\n");
+      cprintf("Press any key to continue . . .");
+      gotoxy(14, 4);
+      getch();
+
+      clreol();
+      getch();
+
+      return 0;
+   }
+
+
+
+
+
+   ________
+   ¦clrscr¦                           <CONIO.H>
+   ¯¯¯¯¯¯¯¯
+   Clears text mode window
+
+   Declaration:  void clrscr(void);
+
+   Remarks:
+  clrscr clears the current text window and places the cursor in the upper
+  left-hand corner (at position 1,1).
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    clreol    delline   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      int i;
+
+      clrscr();
+      for (i = 0; i < 20; i++)
+         cprintf("%d\r\n", i);
+      cprintf("\r\nPress any key to clear screen");
+      getch();
+
+      clrscr();
+      cprintf("The screen has been cleared!");
+      getch();
+
+      return 0;
+   }
+
+
+
+
+   _______
+   ¦cputs¦                            <CONIO.H>
+   ¯¯¯¯¯¯¯
+   Writes a string to the text window on the screen
+
+   Declaration:  int cputs(const char *str);
+
+   Remarks:
+  cputs writes the null-terminated string str to the current text window. It
+  does not append a newline character.
+
+  The string is written either directly to screen memory or by way of a BIOS
+  call, depending on the value of directvideo.
+
+  cputs does not translate linefeed characters (\n) into
+  carriage-return/linefeed character pairs (\r\n).
+
+   Return Value:
+  Returns the last character printed.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    cgets   fputs   putch   puts
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      /* clear the screen */
+      clrscr();
+
+      /* create a text window */
+      window(10, 10, 80, 25);
+
+      /* output some text in the window */
+      cputs("This is within the window\r\n");
+
+      /* wait for a key */
+      getch();
+      return 0;
+   }
+
+
+
+
+   _________
+   ¦delline¦                          <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯
+   (Text mode): Deletes line in text window
+
+   Declaration:  void delline(void);
+
+   Remarks:
+  delline deletes the line containing the cursor and moves all lines below it
+  one line up.
+
+  delline operates within the currently active text window.
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    clreol    clrscr    insline   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      clrscr();
+      cprintf("The function DELLINE deletes the line containing the\r\n");
+      cprintf("cursor and moves all lines below it one line up.\r\n");
+      cprintf("DELLINE operates within the currently active text\r\n");
+      cprintf("window.  Press any key to continue . . .");
+      gotoxy(1,2);  /* Move the cursor to the second line and first column */
+      getch();
+
+      delline();
+      getch();
+
+      return 0;
+   }
+
+
+
+
+   __________________
+   ¦getch and getche¦                 <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    ¦ getch gets a character from console but does not echo to the screen
+    ¦ getche gets a character from console, and echoes to the screen
+
+   Declaration:
+    ¦ int getch(void);
+    ¦ int getche(void);
+
+   Remarks:
+  getch reads a single character directly from the keyboard, without echoing
+  to the screen.
+
+  getche reads a single character from the keyboard and echoes it to the
+  current text window, using direct video or BIOS.
+
+   Return Value:
+  Both functions return the character read from the keyboard.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    cgets     cscanf    fgetc     getc      getchar   getpass   kbhit
+    putch     ungetch
+
+   Examples:
+    getch example    getche example
+
+
+    getch example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <conio.h>
+   #include <stdio.h>
+
+   int main(void)
+   {
+     int c;
+     int extended = 0;
+     c = getch();
+     if (!c)
+       extended = getch();
+     if (extended)
+       printf("The character is extended\n");
+     else
+       printf("The character isn't extended\n");
+
+     return 0;
+   }
+
+
+    getche example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <stdio.h>
+   #include <conio.h>
+
+   int main(void)
+   {
+      char ch;
+
+      printf("Input a character:");
+      ch = getche();
+      printf("\nYou input a '%c'\n", ch);
+      return 0;
+   }
+
+
+
+
+   _________
+   ¦getpass¦                          <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯
+   Reads a password
+
+   Declaration:  char *getpass(const char *prompt);
+
+   Remarks:
+  getpass reads a password from the system console, after prompting with the
+  null-terminated string prompt and disabling the echo.
+
+  It returns a pointer to a null-terminated string of up to eight characters
+  (not counting the null terminator).
+
+   Return Value:
+  Returns a pointer to a static string that is overwritten with each call.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦  Yes ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    getch
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      char *password;
+
+      password = getpass("Input a password:");
+      cprintf("The password is: %s\r\n", password);
+      return 0;
+   }
+
+
+
+   __________________
+   ¦gettext, puttext¦                 <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    ¦ gettext copies text from text-mode screen to memory
+    ¦ puttext copies text from memory to text-mode screen
+
+   Declaration:
+    ¦ int gettext(int left, int top, int right, int bottom, void*destin);
+    ¦ int puttext(int left, int top, int right, int bottom, void*source);
+
+   Remarks:
+  ¦ gettext stores the contents of an onscreen text rectangle defined by
+  (left, top) and (right, bottom) into the area of memory *destin.
+
+  ¦ puttext writes the contents of the memory area *source out to the onscreen
+  rectangle defined by (left, top) and (right, bottom). puttext is a text-mode
+  function performing direct video output.
+
+  gettext reads the rectangle's contents into memory (and puttext puts the
+  stored contents into the rectangle) SEQUENTIALLY from left to right and top
+  to bottom.
+
+  All coordinates are absolute screen coordinates, not window-relative. The
+  upper left corner is (1,1).
+
+  Each position onscreen takes 2 bytes of memory.
+   ¦ The first byte is the character in the cell.
+   ¦ The second byte is the cell's video attribute.
+
+  The space required for a rectangle w columns wide by h rows high is
+
+     bytes = (h rows) x (w columns) x 2
+
+   Return Value:
+    ¦ On success,
+       ¦ gettext returns 1
+       ¦ puttext returns a non-zero value
+    ¦ On error, both functions return 0 (for
+      example, if you gave coordinates outside
+      the range of the current screen mode)
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   Examples:  gettext  puttext
+
+
+    gettext example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <conio.h>
+
+   char buffer[4096];
+
+   int main(void)
+   {
+      int i;
+
+      clrscr();
+      for (i = 0; i <= 20; i++)
+         cprintf("Line #%d\r\n", i);
+      gettext(1, 1, 80, 25, buffer);
+
+      gotoxy(1, 25);
+      cprintf("Press any key to clear screen...");
+      getch();
+      clrscr();
+      gotoxy(1, 25);
+      cprintf("Press any key to restore screen...");
+      getch();
+      puttext(1, 1, 80, 25, buffer);
+      gotoxy(1, 25);
+      cprintf("Press any key to quit...");
+      getch();
+
+      return 0;
+   }
+
+
+    puttext example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      char buffer[512];
+
+      /* put some text to the console */
+      clrscr();
+      gotoxy(20, 12);
+      cprintf("This is a test.  Press any key to continue ...");
+      getch();
+
+      /* grab screen contents */
+      gettext(20, 12, 36, 21,buffer);
+      clrscr();
+
+      /* put selected characters back to the screen */
+      gotoxy(20, 12);
+      puttext(20, 12, 36, 21, buffer);
+      getch();
+
+      return 0;
+   }
+
+
+
+
+   _____________
+   ¦gettextinfo¦                      <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯
+   Gets text-mode video information
+
+   Declaration:  void gettextinfo(struct text_info *r);
+
+   Remarks:
+  gettextinfo fills in a structure with the current text video information.
+
+   Arg¦ What It Is/Does
+   ---+----------------------------------------
+    r ¦ Points to the text_info structure that
+      ¦ gettextinfo fills in
+
+   Return Value:
+  gettextinfo does not return. The results are returned in the structure *r.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    textattr         textbackground   textcolor        textmode
+    wherex           wherey           window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      struct text_info ti;
+      gettextinfo(&ti);
+      cprintf("window left      %2d\r\n",ti.winleft);
+      cprintf("window top       %2d\r\n",ti.wintop);
+      cprintf("window right     %2d\r\n",ti.winright);
+      cprintf("window bottom    %2d\r\n",ti.winbottom);
+      cprintf("attribute        %2d\r\n",ti.attribute);
+      cprintf("normal attribute %2d\r\n",ti.normattr);
+      cprintf("current mode     %2d\r\n",ti.currmode);
+      cprintf("screen height    %2d\r\n",ti.screenheight);
+      cprintf("screen width     %2d\r\n",ti.screenwidth);
+      cprintf("current x        %2d\r\n",ti.curx);
+      cprintf("current y        %2d\r\n",ti.cury);
+      return 0;
+   }
+
+
+
+   ________
+   ¦gotoxy¦                           <CONIO.H>
+   ¯¯¯¯¯¯¯¯
+   Positions cursor in text window
+
+   Declaration:  void gotoxy(int x, int y);
+
+   Remarks:
+  gotoxy moves the cursor to the given position in the current text window.
+
+  If the coordinates are invalid, the call to gotoxy is ignored.
+
+  Example of invalid coordinates:
+    gotoxy(40,30)  /* (35,25) = window's bottom right position */
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    wherex/wherey   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      clrscr();
+      gotoxy(35, 12);
+      cprintf("Hello world");
+      getch();
+      return 0;
+   }
+
+
+   ________________________________
+   ¦highvideo, lowvideo, normvideo¦   <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    ¦ highvideo selects high-intensity text characters
+    ¦ lowvideo selects low-intensity text characters
+    ¦ normvideo selects normal-intensity text characters
+
+   Declaration:
+    ¦ void highvideo(void);
+    ¦ void lowvideo(void);
+    ¦ void normvideo(void);
+
+   Remarks:
+  ¦ highvideo selects high-intensity characters by setting the high-intensity
+  bit of the currently selected foreground color.
+
+  ¦ lowvideo selects low-intensity characters by clearing the high-intensity
+  bit of the currently selected foreground color.
+
+  ¦ normvideo selects normal characters by returning the text attribute
+  (foreground and background) to the value it had when the program started.
+
+  These functions do not affect any characters currently on the screen.
+
+  They only affect characters displayed by functions that perform text-mode,
+  direct console output AFTER these ...video functions are called (such as
+  cprintf).
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    cprintf       cputs         gettextinfo   textattr      textcolor
+
+   Example (for all three functions):
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      normvideo();
+      cprintf("NORMAL Intensity Text\r\n");
+      return 0;
+   }
+
+
+
+   _________
+   ¦insline¦                          <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯
+   (Text mode): Inserts blank line in text window at cursor position
+
+   Declaration:  void insline(void);
+
+   Remarks:
+  insline inserts an empty line in the text window at the cursor position
+  using the current text background color.
+
+  All lines below the empty one move down one line, and the bottom line
+  scrolls off the bottom of the window.
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    clreol    delline   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      clrscr();
+      cprintf("INSLINE inserts an empty line in the text window\r\n");
+      cprintf("at the cursor position using the current text\r\n");
+      cprintf("background color.  All lines below the empty one\r\n");
+      cprintf("move down one line and the bottom line scrolls\r\n");
+      cprintf("off the bottom of the window.\r\n");
+      cprintf("\r\nPress any key to continue:");
+      gotoxy(1, 3);
+      getch();
+      insline();
+      getch();
+      return 0;
+   }
+
+
+
+   _______
+   ¦kbhit¦                            <CONIO.H>
+   ¯¯¯¯¯¯¯
+   Checks for currently available keystrokes
+
+   Declaration:  int kbhit(void);
+
+   Remarks:
+  kbhit checks to see if a keystroke is currently available.
+
+  Any available keystrokes can be retrieved with getch or getche.
+
+   Return Value:
+    ¦ On success (if a keystroke is available),
+      returns a non-zero integer
+    ¦ If a keystroke is not available, returns 0.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      cprintf("Press any key to continue:");
+      while (!kbhit()) /* do nothing */ ;
+      cprintf("\r\nA key was pressed...\r\n");
+      return 0;
+   }
+
+
+   __________
+   ¦movetext¦                         <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯
+   Copies text on screen from one rectangle to another
+
+   Declaration:
+     int movetext(int left, int top, int right,
+       int bottom, int destleft, int desttop);
+
+   Remarks:
+  movetext copies the contents of the onscreen rectangle defined by left, top,
+  right, and bottom to a new rectangle of the same dimensions.
+
+  The new rectangle's upper left corner is position (destleft, desttop).
+
+  All coordinates are absolute screen coordinates. Rectangles that overlap are
+  moved correctly.
+
+  movetext is a text mode function performing direct video output.
+
+   Return Value:
+  movetext returns non-zero if the operation succeeded.
+
+  If the operation failed (for example, if you gave coordinates outside the
+  range of the current screen mode), movetext returns 0.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    gettext   puttext
+
+   Example:
+
+   #include <conio.h>
+   #include <string.h>
+
+   int main(void)
+   {
+      char *str = "This is a test string";
+
+      clrscr();
+      cputs(str);
+      getch();
+
+      movetext(1, 1, strlen(str), 2, 10, 10);
+      getch();
+
+      return 0;
+   }
+
+
+
+   _______
+   ¦putch¦                            <CONIO.H>
+   ¯¯¯¯¯¯¯
+   Oututs character to the text window on the screen
+
+   Declaration:  int putch(int ch);
+
+   Remarks:
+  putch outputs the character c to the current text window. It is a text-mode
+  function that performs direct video output to the console.
+
+  putch does not translate linefeed characters (\n) into
+  carriage-return/linefeed pairs.
+
+  The string is written either directly to screen memory or by way of a BIOS
+  call, depending on the value of directvideo.
+
+   Return Value
+    ¦ On success, putch returns the character printed, c.
+    ¦ On error, it returns EOF.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦  Yes ¦   Yes   ¦   Yes  ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    cprintf   cputs     getch     getche    putc      putchar
+
+   Example:
+
+   #include <stdio.h>
+   #include <conio.h>
+
+   int main(void)
+   {
+      char ch = 0;
+
+      printf("Input a string:");
+      while ((ch != '\r'))
+      {
+         ch = getch();
+         putch(ch);
+      }
+      return 0;
+   }
+
+
+
+   ¦¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¦
+   ¦ _setcursortype ¦                 <CONIO.H>
+   ¦________________¦
+
+   Selects cursor appearance
+
+   Declaration:  void _setcursortype(int cur_t);
+
+   Remarks:
+  Sets the cursor type to one of the following:
+    ¦ _NOCURSOR     (turns off the cursor)
+    ¦ _SOLIDCURSOR  (solid block cursor)
+    ¦ _NORMALCURSOR (normal underscore cursor)
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      /* Display the normal cursor */
+      cprintf("\n\rNormal Cursor: "); getch();
+
+      /* Turn off the cursor */
+      _setcursortype(_NOCURSOR);
+      cprintf("\n\rNo Cursor    : "); getch();
+
+      /* Switch to a solid cursor */
+      _setcursortype(_SOLIDCURSOR);
+      cprintf("\n\rSolid Cursor : "); getch();
+
+      /* Switch back to the normal cursor */
+      _setcursortype(_NORMALCURSOR);
+      cprintf("\n\rNormal Cursor: "); getch();
+
+      return 0;
+   }
+
+
+
+   _____________________________________
+   ¦textattr, textbackground, textcolor¦ <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    ¦ textattr sets text attributes for text-window functions
+    ¦ textbackground selects a new text background color
+    ¦ textcolor selects a new character color in text mode
+
+   Declaration:
+    ¦ void textattr(int newattr);
+    ¦ void textbackground(int newcolor);
+    ¦ void textcolor(int newcolor);
+
+   Remarks:
+  These functions work for functions that produce text-mode output directly to
+  the screen (console output functions).
+
+  ¦ textattr sets both the foreground and background colors in a single call.
+
+  (Normally, you set the attributes with textcolor and textbackground.)
+
+  ¦ textbackground selects the background color.
+
+  ¦ textcolor selects the foreground character color.
+
+  These functions do not affect any characters currently on the screen. Once
+  you have called one of these three functions, all subsequent functions using
+  direct video output (such as cprintf) will use the new attributes or colors.
+
+  If you use symbolic color constants, the following limitations apply to the
+  background colors you select:
+    ¦ You can only select one of the first eight colors (0--7).
+    ¦ With textattr, you must shift the selected background color left by
+      4 bits to move it into the correct "bbb" bit positions.
+
+  ¦ NOTE: If you use the symbolic color constants, you must include CONIO.H.
+
+   newattr
+   ¯¯¯¯¯¯¯
+  This is how color information is encoded in the newattr argument of
+  textattr:
+
+     7   6   5   4 ¦ 3   2   1   0
+   +---------------+---------------+
+   ¦ B ¦ b ¦ b ¦ b ¦ f ¦ f ¦ f ¦ f ¦
+   +---------------+---------------+
+                   ¦
+
+  In this 8-bit newattr parameter,
+    ¦ ffff = 4-bit foreground color (0 to 15)
+    ¦ bbb  = 3-bit background color (0 to 7)
+    ¦ B    = blink-enable bit
+
+   Blinking characters
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+  If the blink-enable bit is on, the character blinks. To turn the bit on in a
+  call to textattr, you add the constant BLINK to the attribute.
+
+  To make the characters blink in a call to textcolor, you add 128 to the
+  foreground color. The predefined constant BLINK exists for this purpose; for
+  example,
+
+    textcolor(CYAN + BLINK);
+
+   Light colors
+   ¯¯¯¯¯¯¯¯¯¯¯¯
+  Some monitors do not recognize the intensity signal used to create the eight
+  "light" colors (8-15). On such monitors, the light colors are displayed as
+  their "dark" equivalents (0-7).
+
+  Also, systems that do not display in color can treat these numbers as shades
+  of one color, special patterns, or special attributes (such as underlined,
+  bold, italics, etc.).
+
+  Exactly what you'll see on such systems depends on your hardware.
+
+
+  Return Value:  None
+
+  Portability:
+  + DOS - UNIX - Windows - ANSI C - C++ Only +
+  ¦ Yes ¦      ¦         ¦        ¦          ¦
+  +------------------------------------------+
+
+    textattr example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      int i;
+
+      clrscr();
+      for (i=0; i<9; i++)
+      {
+          textattr(i + ((i+1) << 4));
+          cprintf("This is a test\r\n");
+      }
+
+      return 0;
+   }
+
+    textbackground and textcolor example
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      int i, j;
+
+      clrscr();
+      for (i=0; i<9; i++)
+      {
+          for (j=0; j<80; j++)
+             cprintf("C");
+          cprintf("\r\n");
+          textcolor(i+1);
+          textbackground(i);
+      }
+
+      return 0;
+   }
+
+
+   __________
+   ¦textmode¦                         <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯
+   Changes screen mode (in text mode)
+
+   Declaration:  void textmode(int newmode);
+
+   Remarks:
+  textmode selects a specific text mode.
+
+  You can give the text mode (the argument newmode) by using a symbolic
+  constant from the enumeration type text_modes (defined in CONIO.H).
+
+  If you use these constants, you must include CONIO.H.
+
+  When textmode is called, the current window is reset to the entire screen,
+  and the current text attributes are reset to normal, corresponding to a call
+  to normvideo.
+
+  Specifying LASTMODE to textmode causes the most recently selected text mode
+  to be reselected.
+
+  textmode should be used only when the screen is in text mode (presumably to
+  change to a different text mode).
+
+  When the screen is in graphics mode, use restorecrtmode to escape
+  temporarily to text mode.
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    gettextinfo   window
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      textmode(BW40);
+      cprintf("ABC");
+      getch();
+
+      textmode(C40);
+      cprintf("ABC");
+      getch();
+
+      textmode(BW80);
+      cprintf("ABC");
+      getch();
+
+      textmode(C80);
+      cprintf("ABC");
+      getch();
+
+      textmode(MONO);
+      cprintf("ABC");
+      getch();
+
+      return 0;
+   }
+
+
+
+   _________
+   ¦ungetch¦                          <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯
+   Pushes a character back to the keyboard
+
+   Declaration:  int ungetch(int ch);
+
+   Remarks:
+  ungetch pushes the character ch back to the console, causing ch to be the
+  next character read.
+
+  ungetch fails if it is called more than once before the next read.
+
+   Return Value:
+    ¦ On success, returns the character ch.
+    ¦ On error, returns EOF.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦  Yes ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    getch    getche
+
+   Example:
+
+   #include <stdio.h>
+   #include <ctype.h>
+   #include <conio.h>
+
+   int main( void )
+   {
+      int i=0;
+      char ch;
+
+      puts("Input an integer followed by a char:");
+
+      /* read chars until non digit or EOF */
+      while((ch = getche()) != EOF && isdigit(ch))
+         i = 10 * i + ch - 48; /* convert ASCII into int value */
+
+      /* if non digit char was read, push it back into input buffer */
+      if (ch != EOF)
+         ungetch(ch);
+      printf("\n\ni = %d, next char in buffer = %c\n", i, getch());
+      return 0;
+   }
+
+
+
+   ________________
+   ¦wherex, wherey¦                   <CONIO.H>
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+    ¦ wherex gives current horizontal cursor position
+    ¦ wherey gives current vertical cursor position
+
+   Declaration:
+    ¦ int wherex(void);
+    ¦ int wherey(void);
+
+   Remarks:
+  ¦ wherex returns the x-coordinate of the current cursor position (within the
+  current text window).
+
+  ¦ wherey returns the y-coordinate of the current cursor position (within the
+  current text window).
+
+   Return Value:
+    ¦ wherex returns an integer in the range 1 to 80.
+    ¦ wherey returns an integer in the range 1 to 25,
+      1 to 43, or 1 to 50.
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    gettextinfo   gotoxy
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+      clrscr();
+      gotoxy(10,10);
+      cprintf("Current location is X: %d  Y: %d\r\n", wherex(), wherey());
+      getch();
+
+      return 0;
+   }
+
+
+   ________
+   ¦window¦                           <conIO.H>
+   ¯¯¯¯¯¯¯¯
+   Defines active text-mode window
+
+   Declaration:  void window(int left, int top, int right, int bottom);
+
+  The top left corner of the screen is (1,1).
+
+   Remarks:
+  window defines a text window onscreen. If the coordinates are in any way
+  invalid, the call to window is ignored.
+
+  (left, top) is the (x, y) position of the window's upper left corner.
+
+  (right, bottom) is the (x, y) position of the window's lower right corner.
+
+  The minimum size of the text window is one column by one line.
+
+  The default window is full screen, with these coordinates:
+    ¦ 80-column mode:  (1, 1, 80, 25)
+    ¦ 40-column mode:  (1, 1, 40, 25)
+
+   Return Value:  None
+
+   Portability:
+   + DOS - UNIX - Windows - ANSI C - C++ Only +
+   ¦ Yes ¦      ¦         ¦        ¦          ¦
+   +------------------------------------------+
+
+   See Also:
+    clreol        clrscr        delline       gettextinfo   gotoxy
+    insline       puttext       textmode
+
+   Example:
+
+   #include <conio.h>
+
+   int main(void)
+   {
+
+      window(10,10,40,11);
+      textcolor(BLACK);
+      textbackground(WHITE);
+      cprintf("This is a test\r\n");
+
+      return 0;
+   }
+
+
+
+    COLORS, CGA_COLORS, and EGA_COLORS
+    (Enumerated Constants for Colors)
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
+  These tables show
+    ¦ the symbolic constants used to set text attributes on CGA and EGA
+      monitors. (Defined in CONIO.H.)
+    ¦ the drawing colors available for BGI functions running on CGA and EGA
+      monitors. (Defined in GRAPHICS.H.)
+
+  The COLORS constants are used by these text mode functions:   textattr
+    textbackground   textcolor
+
+  The CGA_COLORS and EGA_COLORS constants are used by these BGI graphics
+  functions:   setallpalette    setbkcolor       setcolor
+    setpalette
+
+  Valid colors depend on the current graphics driver and
+  current graphics mode.
+
+
+    COLORS (text mode)
+   ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¦Back-¦Fore-
+    Constant     ¦Value¦grnd?¦grnd?
+   --------------+-----+-----+-----
+    BLACK        ¦  0  ¦ Yes ¦ Yes
+    BLUE         ¦  1  ¦ Yes ¦ Yes
+    GREEN        ¦  2  ¦ Yes ¦ Yes
+    CYAN         ¦  3  ¦ Yes ¦ Yes
+    RED          ¦  4  ¦ Yes ¦ Yes
+    MAGENTA      ¦  5  ¦ Yes ¦ Yes
+    BROWN        ¦  6  ¦ Yes ¦ Yes
+    LIGHTGRAY    ¦  7  ¦ Yes ¦ Yes
+    DARKGRAY     ¦  8  ¦ No  ¦ Yes
+    LIGHTBLUE    ¦  9  ¦ No  ¦ Yes
+    LIGHTGREEN   ¦ 10  ¦ No  ¦ Yes
+    LIGHTCYAN    ¦ 11  ¦ No  ¦ Yes
+    LIGHTRED     ¦ 12  ¦ No  ¦ Yes
+    LIGHTMAGENTA ¦ 13  ¦ No  ¦ Yes
+    YELLOW       ¦ 14  ¦ No  ¦ Yes
+    WHITE        ¦ 15  ¦ No  ¦ Yes
+   --------------+-----+-----+------
+    BLINK        ¦128  ¦ No  ¦ ***
+
+  *** To display blinking characters in text mode, add BLINK to the foreground
+  color. (Defined in CONIO.H.)
+
+
+    CGA_COLORS (graphics mode)
+   ____________________________
+
+  In this table, the palette listings CGA0, CGA1, CGA2, and CGA3 refer to the
+  four predefined four-color palettes available on CGA (and compatible)
+  systems.
+
+    Palette¦ Constant assigned to this color number (pixel value)
+    Number ¦       1        ¦        2         ¦        3
+   --------+----------------+------------------+-----------------
+     CGA0  ¦ CGA_LIGHTGREEN ¦ CGA_LIGHTRED     ¦ CGA_YELLOW
+     CGA1  ¦ CGA_LIGHTCYAN  ¦ CGA_LIGHTMAGENTA ¦ CGA_WHITE
+     CGA2  ¦ CGA_GREEN      ¦ CGA_RED          ¦ CGA_BROWN
+     CGA3  ¦ CGA_CYAN       ¦ CGA_MAGENTA      ¦ CGA_LIGHTGRAY
+
+  You can select the background color (entry #0) in each of these palettes,
+  but the other colors are fixed.
+
+
+    EGA_ COLORS (graphics mode)
+   _____________________________
+
+    Constant      ¦Value¦ Constant         ¦Value
+   ---------------+-----+------------------+-----
+    EGA_BLACK     ¦  0  ¦ EGA_DARKGRAY     ¦ 56
+    EGA_BLUE      ¦  1  ¦ EGA_LIGHTBLUE    ¦ 57
+    EGA_GREEN     ¦  2  ¦ EGA_LIGHTGREEN   ¦ 58
+    EGA_CYAN      ¦  3  ¦ EGA_LIGHTCYAN    ¦ 59
+    EGA_RED       ¦  4  ¦ EGA_LIGHTRED     ¦ 60
+    EGA_MAGENTA   ¦  5  ¦ EGA_LIGHTMAGENTA ¦ 61
+    EGA_LIGHTGRAY ¦  7  ¦ EGA_YELLOW       ¦ 62
+    EGA_BROWN     ¦ 20  ¦ EGA_WHITE        ¦ 63
+
+
+
+   directvideo                       <CONIO.H>
+  ¯¯¯¯¯¯¯¯¯¯¯¯¯
+ Controls video output
+
+  Declaration:  int directvideo
+
+ directvideo controls where your program's console output goes:
+
+  Value¦ Meaning
+  -----+-------------------------------------
+    0  ¦ (Default) Goes via ROM BIOS calls
+    1  ¦ Goes directly to the video RAM
+
+ To use directvideo = 1, your system's video hardware must be identical to
+ IBM display adapters.
+
+ If directvideo = 0, your console output will work on any IBM BIOS-compatible
+ system.
+
+
+
+    text_info                         <CONIO.H>
+   ___________
+
+  Current text window information.
+
+  Used by the gettextinfo function.
+
+    struct text_info {
+      unsigned char winleft;        /* left window coordinate */
+      unsigned char wintop;         /* top window coordinate */
+      unsigned char winright;       /* right window coordinate */
+      unsigned char winbottom;      /* bottom window coordinate */
+      unsigned char attribute;      /* text attribute */
+      unsigned char normattr;       /* normal attribute */
+      unsigned char currmode;       /* current video mode:
+                                       BW40, BW80, C40, C80, or C4350 */
+      unsigned char screenheight;   /* text screen's height */
+      unsigned char screenwidth;    /* text screen's width */
+      unsigned char curx;           /* x-coordinate in current window */
+      unsigned char cury;           /* y-coordinate in current window */
+    };
+
+
+
+
+    text_modes                        <CONIO.H>
+   ___________________
+
+   Enum: Standard video modes
+
+    Constant ¦Value¦ Text Mode
+   ----------+-----+----------------------------------
+    LASTMODE ¦ -1  ¦ Previous text mode
+    BW40     ¦  0  ¦ Black and white       40 columns
+    C40      ¦  1  ¦ Color                 40 columns
+    BW80     ¦  2  ¦ Black and white       80 columns
+    C80      ¦  3  ¦ Color                 80 columns
+    MONO     ¦  7  ¦ Monochrome            80 columns
+    C4350    ¦ 64  ¦ EGA and               43-line
+             ¦     ¦ VGA                   50-line
+
+
+
+
+    _wscroll                          <CONIO.H>
+   __________
+
+  Enables or disables scrolling in console I/O functions.
+
+   Declaration:  extern int_wscroll
+
+  _wscroll is a console I/O flag. You can use it to draw along the edges of a
+  window without having the screen scroll.
+
+  Default = 1 (scrolling enabled)
+
+   See Also:
+    List of all global variables

+
+  

+ + diff --git a/exp/ctaos-early/help/INDEX~1.HT~ b/exp/ctaos-early/help/INDEX~1.HT~ new file mode 100644 index 0000000..c687431 --- /dev/null +++ b/exp/ctaos-early/help/INDEX~1.HT~ @@ -0,0 +1,26 @@ + +
CTA 32bit Operating System guide
+ + + + + + +

+ ctaos

+ + + + + \ No newline at end of file diff --git a/exp/ctaos-early/help/filelist.txt b/exp/ctaos-early/help/filelist.txt new file mode 100644 index 0000000..78d5d0f --- /dev/null +++ b/exp/ctaos-early/help/filelist.txt @@ -0,0 +1,26 @@ +Filelist: +========= + +clock/pictimer.c 76 +clock/cmos.h 25 +clock/time.c 143 + +include/console.h 153 +include/system.h 111 + +kernel/gdt.c 78 +kernel/idt.c 63 +kernel/init.c 60 +kernel/irq.c 126 +kernel/isrs.c 164 +kernel/memory.c 4 + +keyboard/keyus.c 293 +keyboard/keyus.h 117 + +loader.asm 478 +main.c 63 +link.ld 25 +compile.bat 23 + +Total lines of code: \ No newline at end of file diff --git a/exp/ctaos-early/help/index_files/colorschememapping.xml b/exp/ctaos-early/help/index_files/colorschememapping.xml new file mode 100644 index 0000000..b200daa --- /dev/null +++ b/exp/ctaos-early/help/index_files/colorschememapping.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/exp/ctaos-early/help/index_files/filelist.xml b/exp/ctaos-early/help/index_files/filelist.xml new file mode 100644 index 0000000..78ad782 --- /dev/null +++ b/exp/ctaos-early/help/index_files/filelist.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/exp/ctaos-early/help/index_files/item0006.xml b/exp/ctaos-early/help/index_files/item0006.xml new file mode 100644 index 0000000..627b86b --- /dev/null +++ b/exp/ctaos-early/help/index_files/item0006.xml @@ -0,0 +1 @@ + diff --git a/exp/ctaos-early/help/index_files/props0007.xml b/exp/ctaos-early/help/index_files/props0007.xml new file mode 100644 index 0000000..a7daa9c --- /dev/null +++ b/exp/ctaos-early/help/index_files/props0007.xml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/exp/ctaos-early/help/index_files/themedata.thmx b/exp/ctaos-early/help/index_files/themedata.thmx new file mode 100644 index 0000000000000000000000000000000000000000..0334c3bb57e377f9a71df4d1dfc152ac8b6982ec GIT binary patch literal 3084 zcmaKu2{hDw7srR}(%AQ%>=|1|J=q${STe?z2s4r0Sh5@2m@s7>iKvLlI)h}1tV75W z6-E*wQr3qodFY*<=RI%b?S22h^IQJs_q*S7?>+aN`+=Dpq2mTH0GI#(fCL~8_mt}^ z^(0IS0B})vdkD(+nyc?MC#x_&*TBolp+4Rf>3yDL6?VgI>;Yz|juOx)N1zNofQF!z zUIO{&s!w>P#%nP5PK7Krz#5rOT$5r)4(3EylTv5%kMZL-tQM^u-LWp{*^=_jy%qVU zF$GoF5sYlbCNth~Y|Qq<3b%@U&O@ukd#BFuqAm>p@a@|X0PL4k5k`v_+Ndegq~5Ypcc%bX??909_ccEC1vN!S6IQX! zm|?WVOEUlQU=Se<0xCoUX5^yXC50x0K2Ml;Gq5x<#TTt^muer7ZtTuvE{OBqDPthN zhv@dX&jf3?M#uGHi;9mk*@yaFFN~O|b$SXLE<7`!Dnu}2&5fs~FePWN{j6U)9QFs*6&>I*M?4D3uwE$RJMLssd(XWkxNsr12+&KI0%>M@5b zC;`n{Hm8-imc14os%_XE-T!T%USV0h7;1nx>J+BVYwoT-uArY*GlVa~%{AbAaUAV8 zV&>7GLej>;SDNGuk&pUFO%FlV;^QQ;K3>Gkz5ltJEc5EHk|8# za$@~jq*Ad^$r~f#E+y}oZl3wYQ2yS>$y`&=o6;+xk(5P&JSY8TYPhYE*G0z+O$v^vBh9%xyZ230tW?o#}rc~W!>M2s*} z$fL_%kAK`OpZ;!SV0)@54s2zBjB`dyg8e3LWEz9BvWkG@i;na1P-owM!<#%$aengb zJ4_#+d3!vuvA>K{H9M0z&ENA*FtyZt2!`L(41BN6P??kw-sXnPhjO`L+Zh;xlG7~5 zU1>#-qgyfNZK>DiTK;4w!`tcH$J}3!);%Q*D4K*y*>}ErISWXt%% zIFIHjccKs9CRnd1UZu`^l9u3|Rbz(_QlR*rjqdK9n9u zVQ;%|BSUMHZlR;zv%F=ijxm}R$G&NGZUYF%zlc^Q(H=&^{E|T-uw)uzjuszwuFyezI^m8XFjTTaZJ^!!nl6*k;jrG_5q`{2FiJ` zug529DA_O12EnM2^qc~mqluS07vW&t9`Ynt;;YDCF?j4s3nXcF zrtw?HGd+uGyES&30{Z1%UlBUOXPZ(0XxaJdZ|KrY#D=nN6_uG%PFY0p&0OG}ROX{W z?|H3g-jj}?>xhh+4YLiHy5+E{>lDEEVZ)AfxuWju_y`)~gEPA!3|dO-&a95TqZRi3VWZJGE%BVx z$L}_D%7kP;R3m+9#e)?hi-2Lp7m1xjLT?LAeT`OWKdCzA@=7y!9WL6g4qAMwot~m3 zFDq*@WHI4&@^-H1pZ;&Qp7}k*c5BgBnoMpWcssh%D&yJqEb-$myZyOD2URfhCqFa9 zvQBZ8B_mv7L^CU$jZOU)7GRg1q$+5@(wi3d#$y^d&&TPrC$@;d?!z)+5Uds(?+tRG2^+$@G z;7rBaPuv6Q;~i$Ad}`VC8KL?1gr##&Hp-FkgE%Ysg!ONxJk9sp%-W6fwWrA^No__8 zUK6ut4TZ~Kf)=fye1DbNBM<0TkO;vz7G?ZEwEnR#(Yb+H*P&ioYo%yGNqvMaJYC!c z_&g)2#WHcErnxV}ML>ef;<&%7XP0O?q~m%c1L;%qB!nZru~f!RK&1h{zR=<(purM^ zw;Ti)U+0df9Ego>+^Ft7YWyUKqM`9*pOr%~*t+SR(u?hPk0is9qgPMtd0+*t#cKV}ohJ-$)twMYZ*9!ExFjcW7 zEiOX9BGw`iVf|SbMjsUq_~>K1&qc&6)F|KEMcznretVN(-st!>$E)IKeHsG0qPAAfh{pZf8?am0+JLxnqjJ1&F?g?iPjeE?$dh>ru0%k%_g(3ieo;og5qt9Xa{`W7gO*xAI literal 0 HcmV?d00001 diff --git a/exp/ctaos-early/help/pages/KERNEL~1.HT~ b/exp/ctaos-early/help/pages/KERNEL~1.HT~ new file mode 100644 index 0000000..3111b1b --- /dev/null +++ b/exp/ctaos-early/help/pages/KERNEL~1.HT~ @@ -0,0 +1,30 @@ + + + CTA 32bit Operating System guide ## THE KERNEL
+ + + + + + +

+ ctaos

+ + + + \ No newline at end of file diff --git a/exp/ctaos-early/help/pages/bootload.html b/exp/ctaos-early/help/pages/bootload.html new file mode 100644 index 0000000..7af2550 --- /dev/null +++ b/exp/ctaos-early/help/pages/bootload.html @@ -0,0 +1,30 @@ + + + CTA 32bit Operating System guide ## THE BOOTLOADER
+ + + + + + +

+ ctaos

+ + + + \ No newline at end of file