summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/asm/boot.h9
-rw-r--r--include/asm/interrupt.h1
-rw-r--r--include/console.h6
-rw-r--r--include/dma.h47
-rw-r--r--include/floppy.h30
-rw-r--r--include/keyboard.h35
-rw-r--r--include/system.h21
-rw-r--r--include/timer.h5
8 files changed, 154 insertions, 0 deletions
diff --git a/include/asm/boot.h b/include/asm/boot.h
new file mode 100644
index 0000000..690f698
--- /dev/null
+++ b/include/asm/boot.h
@@ -0,0 +1,9 @@
+#define KERNEL_START 0x500
+#define KERNEL_BLOCKS 24
+#define DISK_SECTORS_PER_TRACK 18
+
+#define CODE_SEL 0x08
+#define DATA_SEL 0x10
+#define STACK_SEL 0x18
+#define VRAM_SEL 0x20
+#define BIOS_SEL 0x28
diff --git a/include/asm/interrupt.h b/include/asm/interrupt.h
new file mode 100644
index 0000000..c6924a7
--- /dev/null
+++ b/include/asm/interrupt.h
@@ -0,0 +1 @@
+#define CUR_BLINK 50
diff --git a/include/console.h b/include/console.h
new file mode 100644
index 0000000..707fe3c
--- /dev/null
+++ b/include/console.h
@@ -0,0 +1,6 @@
+void console_cur_blink();
+void console_cursor_on();
+void console_cursor_off();
+
+
+#define FLAG_BLINK_ON 0x01
diff --git a/include/dma.h b/include/dma.h
new file mode 100644
index 0000000..3c45f7a
--- /dev/null
+++ b/include/dma.h
@@ -0,0 +1,47 @@
+#define PORT_DMA_BASE_ADDR0 0x00
+#define PORT_DMA_WORD_COUNT0 0x01
+#define PORT_DMA_BASE_ADDR1 0x02
+#define PORT_DMA_WORD_COUNT1 0x03
+#define PORT_DMA_BASE_ADDR2 0x04
+#define PORT_DMA_WORD_COUNT2 0x05
+#define PORT_DMA_BASE_ADDR3 0x06
+#define PORT_DMA_WORD_COUNT3 0x07
+
+#define PORT_DMA_COMMAND 0x08
+#define PORT_DMA_WRITE_REQUEST 0x09
+#define PORT_DMA_MASK 0x0A
+#define PORT_DMA_MODE 0x0B
+#define PORT_DMA_FF 0x0C
+
+#define PORT_DMA_PAGE0 0x87
+#define PORT_DMA_PAGE1 0x83
+#define PORT_DMA_PAGE2 0x81
+#define PORT_DMA_PAGE3 0x82
+
+#define DMA_MODE_DEMAND 0x00
+#define DMA_MODE_SINGLE 0x40
+#define DMA_MODE_BLOCK 0x80
+#define DMA_MODE_CASCADE 0xC0
+
+#define DMA_MODE_VERIFY 0x00
+#define DMA_MODE_READ 0x04
+#define DMA_MODE_WRITE 0x08
+
+#define DMA_MODE_INC_ADDR 0x00
+#define DMA_MODE_DEC_ADDR 0x20
+
+
+static unsigned char dma_page_ports[4] = {
+ PORT_DMA_PAGE0,
+ PORT_DMA_PAGE1,
+ PORT_DMA_PAGE2,
+ PORT_DMA_PAGE3
+};
+
+
+void dma_enable(unsigned char dma_nr);
+void dma_disable(unsigned char dma_nr);
+void dma_set_base_addr(unsigned char dma_nr, void *addr);
+void dma_set_word_count(unsigned char dma_nr, unsigned short words);
+void dma_set_mode(unsigned char dma_nr, unsigned char mode);
+void dma_clear_ff();
diff --git a/include/floppy.h b/include/floppy.h
new file mode 100644
index 0000000..8d526ef
--- /dev/null
+++ b/include/floppy.h
@@ -0,0 +1,30 @@
+#define PORT_FLOPPY_DOR 0x03F2
+#define PORT_FLOPPY_TAPE_DRIVE 0x03F3
+#define PORT_FLOPPY_SELECT_DATA_RATE 0x03F4
+#define PORT_FLOPPY_STATUS 0x03F4
+#define PORT_FLOPPY_COMMAND_DATA 0x03F5
+#define PORT_FLOPPY_DIR 0x03F7
+
+#define FLOPPY_STATE_IDLE 0
+#define FLOPPY_STATE_RECALIBRATE 1
+#define FLOPPY_STATE_SEEK 2
+#define FLOPPY_STATE_READ 3
+
+
+struct floppy_request {
+ unsigned char command;
+ unsigned char drive;
+ unsigned char cylinder;
+ unsigned char head;
+ unsigned char sector;
+ unsigned char sector_count;
+ void *buffer;
+};
+
+
+static unsigned char floppy_drive_types[6][8] = {"none", "360 KB", "1.2 MB", "720 KB", "1.44 MB", "2.88 MB"};
+
+
+void init_floppy();
+int read_floppy_sectors(unsigned char drive, unsigned char cylinder, unsigned char head, unsigned char sector, unsigned char sector_count);
+void floppy_IRQ();
diff --git a/include/keyboard.h b/include/keyboard.h
new file mode 100644
index 0000000..45c3c35
--- /dev/null
+++ b/include/keyboard.h
@@ -0,0 +1,35 @@
+#define LSHIFT_CODE 0x2A
+#define RSHIFT_CODE 0x36
+#define NUMLOCK_CODE 0x45
+#define SCROLLLOCK_CODE 0x46
+#define CAPSLOCK_CODE 0x3A
+#define ACKNOWLEDGE_CODE 0xFA
+#define EXTENDED0_CODE 0xE0
+#define EXTENDED1_CODE 0xE1
+#define LALT_CODE 0x38
+#define RALT_CODE 0xE038
+#define PAUSE_CODE 0x00E11D45
+#define LCTRL_CODE 0x1D
+#define RCTRL_CODE 0xE01D
+
+#define FLAG_BUFFER_FULL (1 << 0)
+#define FLAG_EXTENDED_KEY (1 << 1)
+#define FLAG_SCROLLLOCK_PRESSED (1 << 2)
+#define FLAG_NUMLOCK_PRESSED (1 << 3)
+#define FLAG_CAPSLOCK_PRESSED (1 << 4)
+#define FLAG_SCROLLLOCK_ACTIVE (1 << 5)
+#define FLAG_NUMLOCK_ACTIVE (1 << 6)
+#define FLAG_CAPSLOCK_ACTIVE (1 << 7)
+#define FLAG_LSHIFT_PRESSED (1 << 8)
+#define FLAG_RSHIFT_PRESSED (1 << 9)
+#define FLAG_LALT_PRESSED (1 << 10)
+#define FLAG_RALT_PRESSED (1 << 11)
+#define FLAG_LCTRL_PRESSED (1 << 12)
+#define FLAG_RCTRL_PRESSED (1 << 13)
+
+#define KEY_RELEASE 0x80
+#define KEY_CODE 0x7F
+
+
+void kb_write_keycode();
+void kb_read_keycode();
diff --git a/include/system.h b/include/system.h
new file mode 100644
index 0000000..9440d6b
--- /dev/null
+++ b/include/system.h
@@ -0,0 +1,21 @@
+#define IN_PORT(p,b) asm("in %1,%0" : "=a" ((unsigned char)(b)) : "d" ((unsigned short)(p)) )
+#define IN_PORT_P(p,b) asm("in %1,%0;in $0x80,%%al" : "=a" ((unsigned char)(b)) : "d" ((unsigned short)(p)) )
+#define IN_PORT_PP(p,b) asm("in %1,%0;in $0x80,%%al;in $0x80,%%al;in $0x80,%%al;in $0x80,%%al" \
+ : "=a" ((unsigned char)(b)) : "d" ((unsigned short)(p)) )
+#define OUT_PORT(b,p) asm("out %0,%1" : : "a" ((unsigned char)(b)), "d" ((unsigned short)(p)) )
+#define OUT_PORT_P(b,p) asm("out %0,%1;in $0x80,%%al" : : "a" ((unsigned char)(b)), "d" ((unsigned short)(p)) )
+#define OUT_PORT_PP(b,p) asm("out %0,%1;in $0x80,%%al;in $0x80,%%al;in $0x80,%%al;in $0x80,%%al" \
+ : : "a" ((unsigned char)(b)), "d" ((unsigned short)(p)) )
+
+#define ANSI2ASCII(x) asm ("mov %0,%%dl;call ansi2ascii;mov %%dl,%0\n" : "+m" (x))
+#define ASCII2ANSI(x) asm ("mov %0,%%dl;call ascii2ansi;mov %%dl,%0\n" : "+m" (x))
+
+
+void print(unsigned char * text);
+void print_attr(unsigned char * text, unsigned char attr);
+void print_char(unsigned char text);
+void print_char_attr(unsigned char text, unsigned char attr);
+
+void print_hex_byte(unsigned char hex);
+void print_hex_word(unsigned short hex);
+void print_hex_long(unsigned long hex);
diff --git a/include/timer.h b/include/timer.h
new file mode 100644
index 0000000..cfe05fc
--- /dev/null
+++ b/include/timer.h
@@ -0,0 +1,5 @@
+typedef struct _TIMER {
+ unsigned long time;
+} TIMER;
+
+void sleep(unsigned long ms);