From d605c6a0165c03b9cd222631ecaffb91f535979b Mon Sep 17 00:00:00 2001 From: Tiberiu Chibici Date: Tue, 14 Sep 2021 18:35:52 +0300 Subject: [PATCH] CTAOS v5 --- SysBoot/stage2/STAGE2.CTA | Bin 1630 -> 1805 bytes SysBoot/stage2/a20.inc | 17 +- SysBoot/stage2/bootinfo.inc | 65 ++-- SysBoot/stage2/common.inc | 13 +- SysBoot/stage2/fat12.inc | 19 +- SysBoot/stage2/floppy16.inc | 23 +- SysBoot/stage2/gdt.inc | 18 +- SysBoot/stage2/getdata.inc | 98 +++++ SysBoot/stage2/memory.inc | 115 +++--- SysBoot/stage2/paging.inc | 83 +++++ SysBoot/stage2/stage2.asm | 183 ++++++--- SysBoot/stage2/stdio.inc | 239 ++++++------ SysCore/hal/cmos/cmos.c | 141 ++++--- SysCore/hal/cmos/cmos.h | 15 +- SysCore/hal/cpu/cpu.c | 13 +- SysCore/hal/dma/compile.bat | 18 + SysCore/hal/dma/dma.c | 137 +++++++ SysCore/hal/dma/dma.h | 42 +++ SysCore/hal/floppy/compile.bat | 18 + SysCore/hal/floppy/floppy.c | 356 ++++++++++++++++++ SysCore/hal/floppy/floppy.h | 19 + SysCore/hal/gdt/gdt.c | 8 +- SysCore/hal/hal.c | 83 +---- SysCore/hal/irq/irq.h | 2 + SysCore/hal/isrs/BSOD.c | 19 +- SysCore/hal/keyboard/keyboard.h | 216 +++++------ SysCore/hal/keyboard/keyus.c | 43 ++- SysCore/hal/keyboard/keyus.h | 26 +- SysCore/hal/makeall.bat | 20 +- SysCore/hal/pit/pit.c | 5 + SysCore/hal/pit/pit.h | 2 +- SysCore/include/bootinfo.h | 199 ++++++++-- SysCore/include/conio.h | 122 ++++-- SysCore/include/ctype.h | 72 ++-- SysCore/include/hal.h | 228 ++++++------ SysCore/include/stdlib.h | 93 +++++ SysCore/include/time.h | 24 +- SysCore/lib/compile.bat | 11 + SysCore/lib/conio.c | 642 ++++++++++++++++++++++++++------ SysCore/lib/ctype.c | 146 ++++++++ SysCore/lib/stdlib.c | 286 ++++++++++++++ SysCore/lib/string.c | 4 +- SysCore/lib/system.c | 10 +- SysCore/lib/time.c | 24 +- SysCore/loader.asm | 4 +- SysCore/main.c | 94 +++-- SysCore/makeall.bat | 12 +- SysCore/makeallh.bat | 10 + SysCore/memory/lib/pte.c | 22 +- SysCore/memory/lib/pte.h | 2 + SysCore/memory/mmngr.asm | 3 +- SysCore/memory/mmngr_ph.c | 17 +- SysCore/memory/mmngr_vi.c | 103 +++-- SysCore/memory/mmngr_vi.h | 3 +- SysCore/objects/BSOD.O | Bin 3398 -> 1558 bytes SysCore/objects/CMOS.O | Bin 1429 -> 2617 bytes SysCore/objects/CONIO.O | Bin 4377 -> 7205 bytes SysCore/objects/CPU.O | Bin 774 -> 718 bytes SysCore/objects/CTYPE.O | Bin 0 -> 762 bytes SysCore/objects/DMA.O | Bin 0 -> 1325 bytes SysCore/objects/FLOPPY.O | Bin 0 -> 6709 bytes SysCore/objects/HAL.O | Bin 2247 -> 2217 bytes SysCore/objects/KERNEL.BIN | Bin 20480 -> 32768 bytes SysCore/objects/KEYUS.O | Bin 5096 -> 5096 bytes SysCore/objects/LOADER.O | Bin 152 -> 152 bytes SysCore/objects/MAIN.O | Bin 6778 -> 1172 bytes SysCore/objects/MMNGR_PH.O | Bin 3601 -> 3601 bytes SysCore/objects/PIT.O | Bin 1215 -> 1287 bytes SysCore/objects/SHELL.O | Bin 0 -> 8624 bytes SysCore/objects/STDLIB.O | Bin 0 -> 2717 bytes SysCore/objects/SYSTEM.O | Bin 751 -> 719 bytes SysCore/objects/TIME.O | Bin 1212 -> 1162 bytes SysCore/objects/link.ld | 10 +- SysCore/objects/mmngr_vi.o | Bin 2191 -> 2696 bytes SysCore/objects/video/VGA03H.O | Bin 0 -> 1071 bytes SysCore/shell/apps.h | 209 ++++++----- SysCore/shell/compile.bat | 26 ++ SysCore/shell/shell.c | 76 ++-- SysCore/video/color/color.c | 165 ++++++++ SysCore/video/color/color.h | 66 ++++ SysCore/video/compile.bat | 26 ++ SysCore/video/vga.h | 37 ++ SysCore/video/vga03h.c | 30 ++ SysCore/video/vga03h.h | 7 + 84 files changed, 3647 insertions(+), 1192 deletions(-) create mode 100644 SysBoot/stage2/getdata.inc create mode 100644 SysBoot/stage2/paging.inc create mode 100644 SysCore/hal/dma/compile.bat create mode 100644 SysCore/hal/dma/dma.c create mode 100644 SysCore/hal/dma/dma.h create mode 100644 SysCore/hal/floppy/compile.bat create mode 100644 SysCore/hal/floppy/floppy.c create mode 100644 SysCore/hal/floppy/floppy.h create mode 100644 SysCore/include/stdlib.h create mode 100644 SysCore/lib/ctype.c create mode 100644 SysCore/lib/stdlib.c create mode 100644 SysCore/objects/CTYPE.O create mode 100644 SysCore/objects/DMA.O create mode 100644 SysCore/objects/FLOPPY.O create mode 100644 SysCore/objects/SHELL.O create mode 100644 SysCore/objects/STDLIB.O create mode 100644 SysCore/objects/video/VGA03H.O create mode 100644 SysCore/shell/compile.bat create mode 100644 SysCore/video/color/color.c create mode 100644 SysCore/video/color/color.h create mode 100644 SysCore/video/compile.bat create mode 100644 SysCore/video/vga.h create mode 100644 SysCore/video/vga03h.c create mode 100644 SysCore/video/vga03h.h diff --git a/SysBoot/stage2/STAGE2.CTA b/SysBoot/stage2/STAGE2.CTA index 7931fd055f05c05ec4d885ede38b1d5d1e256295..1a688e14cde8ebb09231efe0556c89dc8d0fd5b7 100644 GIT binary patch delta 1034 zcmZ`%O-xi*6u$4hx%cs4{!;1d2xuo5Ck@1g*F@4TXhegFNp%>81&RyYoU*d1g(fv= z$1$Ph4S|HbxN+q`+_+*vr;uD4GEM+VeTmPcFbHjQa6Z+qDSg&Uj4J`G5lFn#^KPpYjQ&Qs72A1&F zu|#Va2f7R__wRub0#dBEs2&n6t@M+V9A!k>fuJU!*H)ZjN{h)Vd`{nggs? zjWQlDB?CMSL+}DAGDJi;j{rk$8WBy^2aMs@z zCIfEt|5+v|Xr!zQY?{3;%gwU<2c@m-1w^zo+dxCXMa+X6f>vxZz(6$?DntTfU$J9`XOaMrZAtnkv#~lSPf( zRnT-t6krA@N)k_rOiy3i3VJ7rqv5z#goY*9;^}K#MlKIRuOO98(1|4e|0KB}rL13E zofcz$A3s_um6D@arElgyo?1ax+e935cJrovdEv2B?xlYUM^HK{Kx>%5sUq>;L{VFB IaG=NE13=$!9smFU delta 897 zcmXX_Ur19?7(ct$eb-HQCzZ1Z?GhzHAe~4bA}NjjQOo@aYDly!4;ti5?;i4@+(WP} z3dVh^mo%xDiWW%CiSyPfTQI07kVb!&Pe!t)M=Wwp@A1j&6 zrVw-PB0}y-G+2SKJT`<78WQyg<7Zvpy?PT2TJP}+sm`7rTa$8l^eVI9W2Aj2HuvQ}}3?)$Ik>!*ZBkivN^iN+^_?BxA3*Q9djzkUPtjpO-3Yk~cMd|Hh?87Tso@ zoywK(pLh1EJE46zMwb^Vg$)u~f7=>J#g;|K>H@T)~P<-OI`~c0L z0>5P*ZvKS$q#oIvcIAUQ%7k^nhMy4Re?YKl9)gzFkX+eciRI+VHdp&G?{soCHEdl3 zc6~|2-GCGLO+-Ms`WWPzA`lvyfLwhXSQv+qSs4 z4qY|(|6w4J-&Dy$MAl{x+Vz;M9=<$d` zzqhy7(av;#X#MRVdRs6 zM6`acPEVpLMg2#nfHR^hIvSP(3K?OIN~%EU;_1x<+CtCR(Q^6>JO7aY-%;L-kXRYJ zWKjIl4SjVPS5b~=ZTJ4+4hk|qs*M2sB{Sn?l%88C#593PMCAjI7j8wE@V(6?<*t+g TA+=HCeAlw&$oEvEEdKfr@b+6a diff --git a/SysBoot/stage2/a20.inc b/SysBoot/stage2/a20.inc index a839634..2a35227 100644 --- a/SysBoot/stage2/a20.inc +++ b/SysBoot/stage2/a20.inc @@ -1,10 +1,13 @@ +;***** memory.inc **************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Enable A20 address line * +;* ======================= * +;* * +;************************************************************ cta os */ - -;******************************************** -; Enable A20 address line -; -; OS Development Series -;******************************************** +%ifndef __A20_INC_CTA000__ +%define __A20_INC_CTA000__ bits 16 ; real mode 16 bit code @@ -53,3 +56,5 @@ a20wait2: test al,1 jz a20wait2 ret + +%endif \ No newline at end of file diff --git a/SysBoot/stage2/bootinfo.inc b/SysBoot/stage2/bootinfo.inc index 1c40976..8bd7f9f 100644 --- a/SysBoot/stage2/bootinfo.inc +++ b/SysBoot/stage2/bootinfo.inc @@ -1,39 +1,38 @@ +;***** bootinfo.inc ************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Multiboot information structure * +;* =============================== * +;* * +;************************************************************ cta os */ -;******************************************************* -; -; bootinfo.inc -; multiboot information structure -; -; OS Development Series -;******************************************************* - -%ifndef __BOOTINFO_INC_67343546FDCC56AAB872_INCLUDED__ -%define __BOOTINFO_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __BOOTINFO_INC_CTA001__ +%define __BOOTINFO_INC_CTA001__ struc multiboot_info - .flags resd 1 - .memoryLo resd 1 - .memoryHi resd 1 - .bootDevice resd 1 - .cmdLine resd 1 - .mods_count resd 1 - .mods_addr resd 1 - .syms0 resd 1 - .syms1 resd 1 - .syms2 resd 1 - .mmap_length resd 1 - .mmap_addr resd 1 - .drives_length resd 1 - .drives_addr resd 1 - .config_table resd 1 - .bootloader_name resd 1 - .apm_table resd 1 - .vbe_control_info resd 1 - .vbe_mode_info resd 1 - .vbe_mode resw 1 - .vbe_interface_seg resw 1 - .vbe_interface_off resw 1 - .vbe_interface_len resw 1 + .flags resd 1 + .memoryLo resd 1 + .memoryHi resd 1 + .bootDevice resd 1 + .cmdLine resd 1 + .mods_count resd 1 + .mods_addr resd 1 + .syms0 resd 1 + .syms1 resd 1 + .syms2 resd 1 + .mmap_length resd 1 + .mmap_addr resd 1 + .drives_length resd 1 + .drives_addr resd 1 + .config_table resd 1 + .bootloader_name resd 1 + .apm_table resd 1 + .vbe_control_info resd 1 + .vbe_mode_info resd 1 + .vbe_mode resw 1 + .vbe_interface_seg resw 1 + .vbe_interface_off resw 1 + .vbe_interface_len resw 1 endstruc diff --git a/SysBoot/stage2/common.inc b/SysBoot/stage2/common.inc index 38bfda0..aeb3768 100644 --- a/SysBoot/stage2/common.inc +++ b/SysBoot/stage2/common.inc @@ -1,9 +1,16 @@ +;***** common.inc **************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Common definitions, variables * +;* ============================= * +;* * +;************************************************************ cta os */ -%ifndef _COMMON_INC_INCLUDED -%define _COMMON_INC_INCLUDED +%ifndef _COMMON_INC_CTA002__ +%define _COMMON_INC_CTA002__ ; where the kernel is to be loaded to in protected mode -%define IMAGE_PMODE_BASE 0x100000 +%define IMAGE_PMODE_BASE 0xC0000000 ; where the kernel is to be loaded to in real mode %define IMAGE_RMODE_BASE 0x3000 diff --git a/SysBoot/stage2/fat12.inc b/SysBoot/stage2/fat12.inc index c490509..a2abd25 100644 --- a/SysBoot/stage2/fat12.inc +++ b/SysBoot/stage2/fat12.inc @@ -1,14 +1,13 @@ +;***** FAT12.inc ***************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Fat12 filesystem for 3.5" floppies * +;* ================================== * +;* * +;************************************************************ cta os */ -;******************************************************* -; -; Fat12.inc -; FAT12 filesystem for 3-1/2 floppies -; -; OS Development Series -;******************************************************* - -%ifndef __FAT12_INC_67343546FDCC56AAB872_INCLUDED__ -%define __FAT12_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __FAT12_INC_CTA003__ +%define __FAT12_INC_CTA003__ bits 16 diff --git a/SysBoot/stage2/floppy16.inc b/SysBoot/stage2/floppy16.inc index 48779ca..3c08ac4 100644 --- a/SysBoot/stage2/floppy16.inc +++ b/SysBoot/stage2/floppy16.inc @@ -1,18 +1,17 @@ +;***** floppy16.inc ************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Floppy drive interface routines * +;* =============================== * +;* * +;************************************************************ cta os */ -;******************************************************* -; -; Floppy16.inc -; Floppy drive interface routines -; -; OS Development Series -;******************************************************* - -%ifndef __FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__ -%define __FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __FLOPPY16_INC_CTA004__ +%define __FLOPPY16_INC_CTA004__ bits 16 -bpbOEM db "My OS " +bpbOEM db "CTA OS " bpbBytesPerSector: DW 512 bpbSectorsPerCluster: DB 1 bpbReservedSectors: DW 1 @@ -29,7 +28,7 @@ bsDriveNumber: DB 0 bsUnused: DB 0 bsExtBootSignature: DB 0x29 bsSerialNumber: DD 0xa0a1a2a3 -bsVolumeLabel: DB "MOS FLOPPY " +bsVolumeLabel: DB "CTA OS " bsFileSystem: DB "FAT12 " datasector dw 0x0000 diff --git a/SysBoot/stage2/gdt.inc b/SysBoot/stage2/gdt.inc index 952d66f..45b9c7a 100644 --- a/SysBoot/stage2/gdt.inc +++ b/SysBoot/stage2/gdt.inc @@ -1,14 +1,14 @@ +;***** gdt.inc ******************************************************* +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Global Descriptor Table routines * +;* ===================== * +;* * +;************************************************************ cta os */ -;************************************************* -; Gdt.inc -; -GDT Routines -; -; OS Development Series -;************************************************* - -%ifndef __GDT_INC_67343546FDCC56AAB872_INCLUDED__ -%define __GDT_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __GDT_INC_CTA005__ +%define __GDT_INC_CTA005__ bits 16 diff --git a/SysBoot/stage2/getdata.inc b/SysBoot/stage2/getdata.inc new file mode 100644 index 0000000..6a5d44d --- /dev/null +++ b/SysBoot/stage2/getdata.inc @@ -0,0 +1,98 @@ + +gatherinfo: + pusha + push es + xor eax, eax + mov ebx, eax + mov ecx, eax + mov edx, eax +;Boot device + mov dword [multiboot_info_bootDevice], 0 ; drive 0 + +;Detect current video mode + mov ah, 0Fh + int 10h + mov byte [multiboot_info_video_mode], al + mov byte [multiboot_info_video_columns], ah + mov byte [multiboot_info_video_page], bh + +;Get VESA information + xor eax, eax + xor ebx, ebx + xor edx, edx + mov dword [TemporaryStorage], vbeControllerInfo + mov ax, word [TemporaryStorage] + mov dx, word [TemporaryStorage+2] + shl ax, 1 + mov es, ax + mov di, dx + mov ax, 0x4f00 + int 10h + cmp ax, 0x004F + + ; not correct + je vesa_00_ok + mov dword [multiboot_info_vbe_control_info], 0x0 ; failure + jmp vesa_00_done + + ; correct + vesa_00_ok: + mov dword [multiboot_info_vbe_control_info], vbeControllerInfo ; success + + vesa_00_done: +;Write VBE 2.0+ Interface pointers to 0 + mov word [multiboot_info_vbe_interface_seg], 0 + mov word [multiboot_info_vbe_interface_off], 0 + mov word [multiboot_info_vbe_interface_len], 0 + +;Get VESA Current mode + mov ax, 4f03h + int 10h + cmp ax, 004fh + je vesa_01_ok + + ; not ok: + mov word [multiboot_info_vbe_mode], 0 + jmp vesa_01_done + + vesa_01_ok: + mov word [multiboot_info_vbe_mode], bx + + vesa_01_done: + +;Get some info about current VESA mode + xor eax, eax + mov ebx, eax + mov edx, eax + + mov eax, vbeControllerInfo + push eax + and eax, 0fh + mov dx, ax + pop eax + + shr eax, 4 + + mov es, ax + mov di, dx + + + mov ax, 4f01h + mov cx, [multiboot_info_vbe_mode] + int 10h + + cmp ax, 004fh + je vesa_02_ok + + ; not ok: + mov word [multiboot_info_vbe_mode_info], 0 + jmp vesa_02_done + + vesa_02_ok: + mov word [multiboot_info_vbe_mode_info], vbeModeInfo + + vesa_02_done: + pop es + popa + ret + \ No newline at end of file diff --git a/SysBoot/stage2/memory.inc b/SysBoot/stage2/memory.inc index a78605c..eeff590 100644 --- a/SysBoot/stage2/memory.inc +++ b/SysBoot/stage2/memory.inc @@ -1,13 +1,13 @@ +;***** memory.inc **************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Basic memory routines * +;* ===================== * +;* * +;************************************************************ cta os */ -;************************************************* -; Memory.inc -; -Basic memory routines -; -; OS Development Series -;************************************************* - -%ifndef __MEMORY_INC_67343546FDCC56AAB872_INCLUDED__ -%define __MEMORY_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __MEMORY_INC_CTA006__ +%define __MEMORY_INC_CTA006__ bits 16 @@ -29,43 +29,50 @@ endstruc ;--------------------------------------------- BiosGetMemoryMap: - pushad + xor ebx, ebx - xor bp, bp ; number of entries stored here - mov edx, 'PAMS' ; 'SMAP' + xor bp, bp + mov edx, 0x0534D4150 ; Place "SMAP" into edx mov eax, 0xe820 - mov ecx, 24 ; memory map entry struct is 24 bytes - int 0x15 ; get first entry - jc .error - cmp eax, 'PAMS' ; bios returns SMAP in eax - jne .error - test ebx, ebx ; if ebx=0 then list is one entry long; bail out - je .error - jmp .start -.next_entry: - mov edx, 'PAMS' ; some bios's trash this register - mov ecx, 24 ; entry is 24 bytes - mov eax, 0xe820 - int 0x15 ; get next entry -.start: - jcxz .skip_entry ; if actual returned bytes is 0, skip entry + mov [es:di + 20], dword 1 ; force a valid ACPI 3.X entry + mov ecx, 24 + int 0x15 + jc short .failed ; carry set on first call means "unsupported function" + mov edx, 0x0534D4150 ; Some BIOSes apparently trash this register? + cmp eax, edx ; on success, eax must have been reset to "SMAP" + jne short .failed + test ebx, ebx ; ebx = 0 implies list is only 1 entry long (worthless) + je short .failed + jmp short .jmpin +.e820lp: + mov eax, 0xe820 ; eax, ecx get trashed on every int 0x15 call + mov [es:di + 20], dword 1 ; force a valid ACPI 3.X entry + mov ecx, 24 ; ask for 24 bytes again + int 0x15 + jc short .e820f ; carry set means "end of list already reached" + mov edx, 0x0534D4150 ; repair potentially trashed register +.jmpin: + jcxz .skipent ; skip any 0 length entries + cmp cl, 20 ; got a 24 byte ACPI 3.X response? + jbe short .notext + test byte [es:di + 20], 1 ; if so: is the "ignore this data" bit clear? + je short .skipent .notext: - mov ecx, [es:di + MemoryMapEntry.length] ; get length (low dword) - test ecx, ecx ; if length is 0 skip it - jne short .good_entry - mov ecx, [es:di + MemoryMapEntry.length + 4]; get length (upper dword) - jecxz .skip_entry ; if length is 0 skip it -.good_entry: - inc bp ; increment entry count - add di, 24 ; point di to next entry in buffer -.skip_entry: - cmp ebx, 0 ; if ebx return is 0, list is done - jne .next_entry ; get next entry - jmp .done -.error: - stc -.done: - popad + mov ecx, [es:di + 8] ; get lower dword of memory region length + test ecx, ecx ; is the qword == 0? + jne short .goodent + mov ecx, [es:di + 12] ; get upper dword of memory region length + jecxz .skipent ; if length qword is 0, skip entry +.goodent: + inc bp ; got a good entry: ++count, move to next storage spot + add di, 24 +.skipent: + test ebx, ebx ; if ebx resets to 0, list is complete + jne short .e820lp +.e820f: + ret ; bp=entry count +.failed: + stc ; "function unsupported" error exit ret ;--------------------------------------------- @@ -75,21 +82,17 @@ BiosGetMemoryMap: ; ret\ bx=0 and ax= -1 on error ;--------------------------------------------- -BiosGetMemorySize64MB_32Bit: +BiosGetMemorySize64MB_32bit: push ecx push edx xor ecx, ecx xor edx, edx - mov ax, 0xe881 - int 0x15 + mov eax, 0xe881 + int 0x15 jc .error - cmp ah, 0x86 ;unsupported function - je .error - cmp ah, 0x80 ;invalid command - je .error - jcxz .use_ax ;bios may have stored it in ax,bx or cx,dx. test if cx is 0 - mov ax, cx ;its not, so it should contain mem size; store it - mov bx, dx + jcxz .use_ax ;bios may have stored it in ax,bx or cx,dx. test if cx is 0 + mov eax, ecx ;its not, so it should contain mem size; store it + mov ebx, edx .use_ax: pop edx ;mem size is in ax and bx already, return it @@ -102,7 +105,7 @@ BiosGetMemorySize64MB_32Bit: pop edx pop ecx ret - + ;--------------------------------------------- ; Get memory size for >64M configuations ; ret\ ax=KB between 1MB and 16MB @@ -132,8 +135,6 @@ BiosGetMemorySize64MB: ret .error: - mov si, msgNotSupported - call Puts16 mov ax, -1 mov bx, 0 pop edx @@ -170,6 +171,4 @@ BiosGetExtendedMemorySize: ret -msgNotSupported db 0x0A, 0x0D, "BiosGetMemorySize64MB: function not supported.",0x0A, 0x0D, 0x00 - %endif diff --git a/SysBoot/stage2/paging.inc b/SysBoot/stage2/paging.inc new file mode 100644 index 0000000..d9f4c03 --- /dev/null +++ b/SysBoot/stage2/paging.inc @@ -0,0 +1,83 @@ +;***** paging.inc **************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Basic paging for bootloader * +;* =========================== * +;* * +;************************************************************ cta os */ + +%ifndef __PAGING_INC_CTA007__ +%define __PAGING_INC_CTA007__ + +[bits 32] + +%define PAGE_DIR 0x9C000 ; page directory table +%define PAGE_TABLE_0 0x9D000 ; 0th page table. Address must be 4KB aligned +%define PAGE_TABLE_768 0x9E000 ; 768th page table. Address must be 4KB aligned +%define PAGE_TABLE_ENTRIES 1024 ; each page table has 1024 entries +%define PRIV 3 ; attributes (page is present;page is writable; supervisor mode) + + +;**************************************** +; Enable Paging +;**************************************** + +EnablePaging: + pusha ; save stack frame + + ;------------------------------------------ + ; idenitity map 1st page table (4MB) + ;------------------------------------------ + + mov eax, PAGE_TABLE_0 ; first page table + mov ebx, 0x0 | PRIV ; starting physical address of page + mov ecx, PAGE_TABLE_ENTRIES ; for every page in table... +.loop: + mov dword [eax], ebx ; write the entry + add eax, 4 ; go to next page entry in table (Each entry is 4 bytes) + add ebx, 4096 ; go to next page address (Each page is 4Kb) + loop .loop ; go to next entry + + ;------------------------------------------ + ; set up the entries in the directory table + ;------------------------------------------ + + mov eax, PAGE_TABLE_0 | PRIV ; 1st table is directory entry 0 + mov dword [PAGE_DIR], eax + + mov eax, PAGE_TABLE_768 | PRIV ; 768th entry in directory table + mov dword [PAGE_DIR+(768*4)], eax + + ;------------------------------------------ + ; install directory table + ;------------------------------------------ + + mov eax, PAGE_DIR + mov cr3, eax + + ;------------------------------------------ + ; enable paging + ;------------------------------------------ + + mov eax, cr0 + or eax, 0x80000000 + mov cr0, eax + + ;------------------------------------------ + ; map the 768th table to physical addr 1MB + ; the 768th table starts the 3gb virtual address + ;------------------------------------------ + + mov eax, PAGE_TABLE_768 ; first page table + mov ebx, 0x100000 | PRIV ; starting physical address of page + mov ecx, PAGE_TABLE_ENTRIES ; for every page in table... +.loop2: + mov dword [eax], ebx ; write the entry + add eax, 4 ; go to next page entry in table (Each entry is 4 bytes) + add ebx, 4096 ; go to next page address (Each page is 4Kb) + loop .loop2 ; go to next entry + + popa + ret + +%endif diff --git a/SysBoot/stage2/stage2.asm b/SysBoot/stage2/stage2.asm index 6c52bca..7047472 100644 --- a/SysBoot/stage2/stage2.asm +++ b/SysBoot/stage2/stage2.asm @@ -1,12 +1,10 @@ - -;******************************************************* -; -; Stage2.asm -; Stage2 Bootloader -; -; OS Development Series -;******************************************************* - +;***** stage2.asm **************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Stage 2 Bootloader * +;* ================== * +;* * +;************************************************************ cta os */ bits 16 org 0x500 @@ -24,6 +22,7 @@ jmp main ; go to start %include "common.inc" ;%include "bootinfo.inc" %include "memory.inc" +%include "getdata.inc" ;******************************************************* ; Data Section @@ -32,28 +31,51 @@ jmp main ; go to start msgFailure db 0x0D, 0x0A, "FATAL ERROR: Kernel file KERNEL.CTA missing or corrupt. Press Any Key to Reboot.", 0x0D, 0x0A, 0x0A, 0x00 boot_info: - multiboot_info_flags dd 0 - multiboot_info_memoryLo dd 0 - multiboot_info_memoryHi dd 0 - multiboot_info_bootDevice dd 0 - multiboot_info_cmdLine dd 0 - multiboot_info_mods_count dd 0 - multiboot_info_mods_addr dd 0 - multiboot_info_syms0 dd 0 - multiboot_info_syms1 dd 0 - multiboot_info_syms2 dd 0 - multiboot_info_mmap_length dd 0 - multiboot_info_mmap_addr dd 0 - multiboot_info_drives_length dd 0 - multiboot_info_drives_addr dd 0 - multiboot_info_config_table dd 0 - multiboot_info_bootloader_name dd 0 - multiboot_info_apm_table dd 0 - multiboot_info_vbe_control_info dd 0 - multiboot_info_vbe_mode_info dw 0 - multiboot_info_vbe_interface_seg dw 0 - multiboot_info_vbe_interface_off dw 0 - multiboot_info_vbe_interface_len dw 0 + ; Memory + multiboot_info_memoryLo dd 0 + multiboot_info_memoryHi dd 0 + ; Boot device + multiboot_info_bootDevice dd 0 + ; Pointer to a char[] string. (not implemented) + multiboot_info_cmdLine dd 0 + ; Other modules loaded by bootloader. (not implemented + multiboot_info_mods_count dd 0 + multiboot_info_mods_addr dd 0 + ; Pointer to memory map + multiboot_info_mmap_length dd 0 + multiboot_info_mmap_addr dd 0 + ; TODO: + multiboot_info_drives_length dd 0 + multiboot_info_drives_addr dd 0 + ; BIOS ROM config table. TODO: + multiboot_info_config_table dd 0 + ; CTA bootloader name + multiboot_info_bootloader_name db "CTA", 0 + ; TODO: + multiboot_info_apm_table dd 0 + ; Returns VGA current video mode info + multiboot_info_video_mode db 0 + multiboot_info_video_columns db 0 + multiboot_info_video_page db 0 + ; Returns VESA information + multiboot_info_vbe_control_info dd 0 + multiboot_info_vbe_mode_info dd 0 + multiboot_info_vbe_mode dw 0 + multiboot_info_vbe_interface_seg dw 0 + multiboot_info_vbe_interface_off dw 0 + multiboot_info_vbe_interface_len dw 0 + + +vbeControllerInfo: + vbeControllerInfo_signature dd 0 ; "VESA", taken as 4 bytes + vbeControllerInfo_version dw 0 ; 0x0300 for VBE 3.0 + vbeControllerInfo_oemString dd 0 ; isa vbeFarPtr, taken as 2 shorts + vbeControllerInfo_capabilities dd 0 ; taken as 4 bytes + vbeControllerInfo_videomodes dd 0 ; isa vbeFarPtr, taken as 2 shorts + vbeControllerInfo_totalMemory dw 0 ; as # of 64k blocks + + +TemporaryStorage dd 0 ; temporary storage main: @@ -70,34 +92,48 @@ main: mov sp, 0xFFFF sti ; enable interrupts - mov [multiboot_info_bootDevice], dl - call _EnableA20 call InstallGDT sti + + ;-------------------------------; + ; Fill in the boot structure ; + ;-------------------------------; +; Memory Size xor eax, eax xor ebx, ebx call BiosGetMemorySize64MB - mov word [multiboot_info_memoryHi], bx - mov word [multiboot_info_memoryLo], ax - + push eax + mov eax, 64 + mul ebx + mov ecx, eax + pop eax + add eax, ecx + add eax, 1024 ; the routine doesnt add the KB between 0-1MB; add it + + mov dword [multiboot_info_memoryHi], 0 + mov dword [multiboot_info_memoryLo], eax + +;Memory map mov eax, 0x0 mov ds, ax mov di, 0x1000 call BiosGetMemoryMap - mov dword [multiboot_info_mmap_addr], 0x1000 + + mov dword [multiboot_info_mmap_addr], 0x1000 ; address xor eax, eax mov ax, bp - mov dword [multiboot_info_mmap_length], eax + mov dword [multiboot_info_mmap_length], eax ; length + + call gatherinfo - - call LoadRoot - mov ebx, 0 - mov ebp, IMAGE_RMODE_BASE - mov esi, ImageName - call LoadFile ; load our file + call LoadRoot + mov ebx, 0 + mov ebp, IMAGE_RMODE_BASE + mov esi, ImageName + call LoadFile ; load our file mov dword [ImageSize], ecx cmp ax, 0 je EnterStage3 @@ -129,6 +165,8 @@ EnterStage3: bits 32 +%include "paging.inc" + BadImage db "FATAL ERROR: Kernel file KERNEL.CTA missing or corrupt. Press Any Key to Reboot.", 0 Stage3: @@ -143,6 +181,7 @@ Stage3: mov es, ax mov esp, 90000h ; stack begins from 90000h + call EnablePaging CopyImage: mov eax, dword [ImageSize] @@ -156,7 +195,7 @@ CopyImage: mov ecx, eax rep movsd ; copy image to its protected mode address - mov eax, 0x2badb002 ; multiboot specs say eax should be this + mov eax, 0xC0DEcC7A ; cta bootloader specific mov ebx, 0 ;edx=8 @@ -169,4 +208,56 @@ CopyImage: cli hlt - \ No newline at end of file + + +vbeModeInfo: + vbeModeInfo_attributes dw 0 + vbeModeInfo_winA db 0 + vbeModeInfo_winB db 0 + vbeModeInfo_granularity dw 0 + vbeModeInfo_winsize dw 0 + vbeModeInfo_segmentA dw 0 + vbeModeInfo_segmentB dw 0 + vbeModeInfo_realFctPtr dd 0 + vbeModeInfo_pitc dw 0 ; // bytes per scanline + vbeModeInfo_Xres dw 0 + vbeModeInfo_Yres dw 0 + vbeModeInfo_Wchar db 0 + vbeModeInfo_Ychar db 0 + vbeModeInfo_planes db 0 + vbeModeInfo_bpp db 0 + vbeModeInfo_banks db 0 + vbeModeInfo_memory_model db 0 + vbeModeInfo_bank_size db 0 + vbeModeInfo_image_pages db 0 + vbeModeInfo_reserved0 db 0 + + ; VBE v1.2+ + vbeModeInfo_red_mask db 0 + vbeModeInfo_red_position db 0 + vbeModeInfo_green_mask db 0 + vbeModeInfo_green_position db 0 + vbeModeInfo_blue_mask db 0 + vbeModeInfo_blue_position db 0 + vbeModeInfo_rsv_mask db 0 + vbeModeInfo_rsv_position db 0 + vbeModeInfo_directcolor_attrib db 0 + + ; VBE v2.0+ + vbeModeInfo_physbase dd 0 + vbeModeInfo_start_offscreen_mem dd 0 + vbeModeInfo_size_offscreen_mem dw 0 + + ; VBE v3.0+ + vbeModeInfo_bytes_per_scanline dw 0 + vbeModeInfo_number_images_banked db 0 + vbeModeInfo_number_images_linear db 0 + vbeModeInfo_linear_red_mask db 0 + vbeModeInfo_linear_red_pos db 0 + vbeModeInfo_linear_green_mask db 0 + vbeModeInfo_linear_green_pos db 0 + vbeModeInfo_linear_blue_mask db 0 + vbeModeInfo_linear_blue_pos db 0 + vbeModeInfo_linear_res_mask db 0 + vbeModeInfo_linear_res_pos db 0 + vbeModeInfo_max_pixel_clock dd 0 \ No newline at end of file diff --git a/SysBoot/stage2/stdio.inc b/SysBoot/stage2/stdio.inc index d5e7eef..b86699f 100644 --- a/SysBoot/stage2/stdio.inc +++ b/SysBoot/stage2/stdio.inc @@ -1,13 +1,14 @@ +;***** stdio.inc ***************************************************** +;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * +;* * +;* Standard Input/Output routines * +;* ============================== * +;* * +;************************************************************ cta os */ -;************************************************* -; stdio.inc -; -Input/Output routines -; -; OS Development Series -;************************************************* -%ifndef __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ -%define __STDIO_INC_67343546FDCC56AAB872_INCLUDED__ +%ifndef __STDIO_INC_CTA008__ +%define __STDIO_INC_CTA008__ ;========================================================== @@ -82,15 +83,15 @@ PutINT: ; 32 Bit Protected Mode Routines ;========================================================== -bits 32 + ;bits 32 -%define VIDMEM 0xB8000 ; video memory -%define COLS 80 ; width and height of screen -%define LINES 25 -%define CHAR_ATTRIB 14 ; character attribute (White text on black background) +;%define VIDMEM 0xB8000 ; video memory +;%define COLS 80 ; width and height of screen +;%define LINES 25 +;%define CHAR_ATTRIB 14 ; character attribute (White text on black background) -_CurX db 0 ; current x/y location -_CurY db 0 +;_CurX db 0 ; current x/y location +;_CurY db 0 ;**************************************************; ; Putch32 () @@ -98,56 +99,56 @@ _CurY db 0 ; BL => Character to print ;**************************************************; -Putch32: - - pusha - mov edi, VIDMEM - - xor eax, eax ; clear eax - - ; y * screen width - - mov ecx, COLS*2 ; Mode 7 has 2 bytes per char, so its COLS*2 bytes per line - mov al, byte [_CurY] ; get y pos - mul ecx ; multiply y*COLS - push eax ; save eax--the multiplication +;Putch32: +; +; pusha +; mov edi, VIDMEM +; +; xor eax, eax ; clear eax +; +; ; y * screen width +; +; mov ecx, COLS*2 ; Mode 7 has 2 bytes per char, so its COLS*2 bytes per line +; mov al, byte [_CurY] ; get y pos +; mul ecx ; multiply y*COLS +; push eax ; save eax--the multiplication ; now add _CurX * 2 - mov al, byte [_CurX] ; multiply _CurX by 2 because it is 2 bytes per char - mov cl, 2 - mul cl - pop ecx ; pop y*COLS result - add eax, ecx +; mov al, byte [_CurX] ; multiply _CurX by 2 because it is 2 bytes per char +; mov cl, 2 +; mul cl +; pop ecx ; pop y*COLS result +; add eax, ecx ; add the position to draw to the base of vid memory - xor ecx, ecx - add edi, eax ; add it to the base address - +; xor ecx, ecx +; add edi, eax ; add it to the base address +; ; watch for new line - cmp bl, 0x0A ; is it a newline character? - je .Row ; yep--go to next row - +; cmp bl, 0x0A ; is it a newline character? +; je .Row ; yep--go to next row +; ; print the character - mov dl, bl ; Get character - mov dh, CHAR_ATTRIB ; the character attribute - mov word [edi], dx ; write to video display +; mov dl, bl ; Get character +; mov dh, CHAR_ATTRIB ; the character attribute +; mov word [edi], dx ; write to video display +; +; ; go to next location - ; go to next location +; inc byte [_CurX] ; go to next character +; jmp .done ; nope, bail out - inc byte [_CurX] ; go to next character - jmp .done ; nope, bail out +;.Row: +; mov byte [_CurX], 0 ; go back to col 0 +; inc byte [_CurY] ; go to next row -.Row: - mov byte [_CurX], 0 ; go back to col 0 - inc byte [_CurY] ; go to next row - -.done: - popa - ret +;.done: +; popa +; ret ;**************************************************; ; Puts32 () @@ -155,47 +156,47 @@ Putch32: ; parm\ EBX = address of string to print ;**************************************************; -Puts32: +;Puts32: - pusha - push ebx ; copy the string address - pop edi +; pusha +; push ebx ; copy the string address +; pop edi -.loop: +;.loop: ;-------------------------------; ; Get character ; ;-------------------------------; - mov bl, byte [edi] ; get next character - cmp bl, 0 ; is it 0 (Null terminator)? - je .done ; yep-bail out +; mov bl, byte [edi] ; get next character +; cmp bl, 0 ; is it 0 (Null terminator)? +; je .done ; yep-bail out ;-------------------------------; ; Print the character ; ;-------------------------------; - call Putch32 ; Nope-print it out +; call Putch32 ; Nope-print it out ;-------------------------------; ; Go to next character ; ;-------------------------------; - inc edi ; go to next character - jmp .loop +; inc edi ; go to next character +; jmp .loop -.done: +;.done: ;-------------------------------; ; Update hardware cursor ; ;-------------------------------; - mov bh, byte [_CurY] ; get current position - mov bl, byte [_CurX] - call MovCur ; update cursor +; mov bh, byte [_CurY] ; get current position +; mov bl, byte [_CurX] +; call MovCur ; update cursor - popa ; restore registers, and return - ret +; popa ; restore registers, and return +; ret ;**************************************************; ; MoveCur () @@ -206,74 +207,74 @@ Puts32: -bits 32 +;bits 32 -MovCur: - - pusha +;MovCur: +; pusha +; ;-------------------------------; ; Get current position ; ;-------------------------------; ; location = _CurX + _CurY * COLS - xor eax, eax - mov ecx, COLS - mov al, bh ; get y pos - mul ecx ; multiply y*COLS - add al, bl ; Now add x - mov ebx, eax - +; xor eax, eax +; mov ecx, COLS +; mov al, bh ; get y pos +; mul ecx ; multiply y*COLS +; add al, bl ; Now add x +; mov ebx, eax +; ;--------------------------------------; ; Set low byte index to VGA register ; ;--------------------------------------; - mov al, 0x0f - mov dx, 0x03D4 - out dx, al - - mov al, bl - mov dx, 0x03D5 - out dx, al ; low byte +; mov al, 0x0f +; mov dx, 0x03D4 +; out dx, al +; +; mov al, bl +; mov dx, 0x03D5 +; out dx, al ; low byte ;---------------------------------------; ; Set high byte index to VGA register ; ;---------------------------------------; - xor eax, eax +; xor eax, eax - mov al, 0x0e - mov dx, 0x03D4 - out dx, al +; mov al, 0x0e +; mov dx, 0x03D4 +; out dx, al - mov al, bh - mov dx, 0x03D5 - out dx, al ; high byte +; mov al, bh +; mov dx, 0x03D5 +; out dx, al ; high byte - popa - ret +; popa +; ret ;**************************************************; ; ClrScr32 () ; - Clears screen ;**************************************************; - -bits 32 - -ClrScr32: - - pusha - cld - mov edi, VIDMEM - mov cx, 2000 - mov ah, CHAR_ATTRIB - mov al, ' ' - rep stosw - mov byte [_CurX], 0 - mov byte [_CurY], 0 - popa - ret +; +;bits 32 +; +;ClrScr32: +; +; pusha +; cld +; mov edi, VIDMEM +; mov cx, 2000 +; mov ah, CHAR_ATTRIB +; mov al, ' ' +; rep stosw +; mov byte [_CurX], 0 +; mov byte [_CurY], 0 +; popa +; ret ;**************************************************; ; GotoXY () @@ -282,14 +283,14 @@ ClrScr32: ; parm\ AH=Y position ;**************************************************; -bits 32 +;bits 32 -GotoXY: - pusha - mov [_CurX], al - mov [_CurY], ah - popa - ret +;GotoXY: +; pusha +; mov [_CurX], al +; mov [_CurY], ah +; popa +; ret %endif ;__STDIO_INC_67343546FDCC56AAB872_INCLUDED__ diff --git a/SysCore/hal/cmos/cmos.c b/SysCore/hal/cmos/cmos.c index 4a05ac8..a272ae0 100644 --- a/SysCore/hal/cmos/cmos.c +++ b/SysCore/hal/cmos/cmos.c @@ -1,92 +1,81 @@ +/***** cmos.c ******************************************************** + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * CMOS I/O Routines * + * ================= * + * * + * ! IMPORTANT NOTE ! Close interrupts before any CMOS operation * + ************************************************************ cta os */ + #include #include #include "cmos.h" -volatile byte i86_cmos_data[128]; - -void i86_cmos_write () +/***************************************************************** + * !!!!!!!!!! IMPORTANT NOTE !!!!!!!!!! * + * You should close interrupts before any CMOS operation. * + *****************************************************************/ +inline unsigned char i86_cmos_read (unsigned char address) { - byte i; - for (i = 0; i < 128; i++) { - //asm volatile ("cli"); - outportb(0x70, i); - iowait(); - outportb(0x71, i86_cmos_data[i]); - //asm volatile ("sti"); - } + outportb(0x70, address); iowait(); + return inportb(0x71); } -void i86_cmos_read () +inline void i86_cmos_write (unsigned char address, unsigned char val) { - byte i; - for (i = 0; i < 128; i++) { - //asm volatile ("cli"); - outportb(0x70, i); - iowait(); - i86_cmos_data[i] = inportb(0x71); - //asm volatile ("sti"); - } + outportb(0x70, address); iowait(); + outportb(0x71, val); +} + +void i86_cmos_write_clock (const TIME* time) +{ + unsigned char BCD = ((i86_cmos_read(0x0b)&4)==0) ? 1 : 0; + unsigned char ampm = ((i86_cmos_read(0x0b)&2)==0) ? 1 : 0; + + i86_cmos_write (0, (BCD) ? (time->second%10) | (time->second/10*16) : time->second); // Seconds + i86_cmos_write (2, (BCD) ? (time->minute%10) | (time->minute/10*16) : time->minute); // Minutes + + if (ampm && time->hour > 12) // Hours + i86_cmos_write (4, (BCD) ? (((time->hour - 12) % 10) | ((time->hour - 12)/10*16) | 0x80) : (time->hour | 0x80) ); + + else if (ampm && time->hour == 0) // Midnight convention: 12 PM = 00:00 + i86_cmos_write (4, (BCD) ? 0x92 : 0x8C); + + else i86_cmos_write (4, (BCD) ? (time->hour%10) | (time->hour/10*16) : time->hour); // 24h / AM + + i86_cmos_write (6, (BCD) ? (time->weekday%10) | (time->weekday/10*16) : time->weekday); // Weekday + i86_cmos_write (7, (BCD) ? (time->day%10) | (time->day/10*16) : time->day); // Day + i86_cmos_write (8, (BCD) ? (time->month%10) | (time->month/10*16) : time->month); // Month + i86_cmos_write (9, (BCD) ? (time->year%10) | (time->year/10*16) : time->year); // Year + i86_cmos_write (0x32, (BCD) ? (time->century%10) | (time->century/10*16) : time->century); // Century } void i86_cmos_read_clock(TIME* tim) { - i86_cmos_read(); + unsigned char BCD = ((i86_cmos_read(0x0b)&4)==0) ? 1 : 0; + unsigned char am_pm = ((i86_cmos_read(0x0b)&2)==0) ? 1 : 0; - if ((i86_cmos_data[0x0b]&4)==0) // BCD = true; - { - tim->seconds = (i86_cmos_data[0x00]%16) + 10*(i86_cmos_data[0x00]/16); - tim->minutes = (i86_cmos_data[0x02]%16) + 10*(i86_cmos_data[0x02]/16); - if ((i86_cmos_data[0x0b]&2)==0) { // AM/PM - if (i86_cmos_data[0x04]&80) { // pm - tim->hours = ((i86_cmos_data[0x04]-0x80)%16) + 10*((i86_cmos_data[0x04]-0x80)/16); - tim->am_pm = 1; - } - else { // am - tim->hours = (i86_cmos_data[0x04]%16) + 10*(i86_cmos_data[0x04]/16); - tim->am_pm = 0; - } - } - else { // 24 hours - tim->hours = (i86_cmos_data[0x04]%16) + 10*(i86_cmos_data[0x04]/16); - if (tim->hours > 12) { - tim->am_pm = 1; - tim->hours -= 12; - } - else tim->am_pm = 0; - } + tim->second = (BCD) ? (i86_cmos_read(0x00)%16) + 10*(i86_cmos_read(0x00)/16): i86_cmos_read(0x00); + tim->minute = (BCD) ? (i86_cmos_read(0x02)%16) + 10*(i86_cmos_read(0x02)/16): i86_cmos_read(0x02); - tim->weekday = (i86_cmos_data[0x06]%16) + 10*(i86_cmos_data[0x06]/16); - tim->day = (i86_cmos_data[0x07]%16) + 10*(i86_cmos_data[0x07]/16); - tim->month = (i86_cmos_data[0x08]%16) + 10*(i86_cmos_data[0x08]/16); - tim->year = (i86_cmos_data[0x09]%16) + 10*(i86_cmos_data[0x09]/16); - tim->century = (i86_cmos_data[0x32]%16) + 10*(i86_cmos_data[0x32]/16); - } - - else {//BCD = false; - tim->seconds = i86_cmos_data[0x00]; - tim->minutes = i86_cmos_data[0x02]; - if ((i86_cmos_data[0x0b]&2)==0) { // AM/PM - if (i86_cmos_data[0x04]&80) { // pm - tim->hours = i86_cmos_data[0x04]-0x80; - tim->am_pm = 1; - } - else { // am - tim->hours = i86_cmos_data[0x04]; - tim->am_pm = 0; - } - } - else { // 24 hours - tim->hours = i86_cmos_data[0x02]; - if (tim->hours > 12) { - tim->am_pm = 1; - tim->hours -= 12; - } - else tim->am_pm = 0; - } - tim->weekday = i86_cmos_data[0x06]; - tim->day = i86_cmos_data[0x07]; - tim->month = i86_cmos_data[0x08]; - tim->year = i86_cmos_data[0x09]; - tim->century = i86_cmos_data[0x32]; + // Time is PM + if (am_pm && i86_cmos_read(0x04)&80) { + tim->hour = (BCD) ? ((i86_cmos_read(0x04)-0x80)%16) + 10*((i86_cmos_read(0x04)-0x80)/16): i86_cmos_read(0x04)-0x80; + tim->hour += 12; } + // 24Hour format, or AM + else tim->hour = (BCD) ? (i86_cmos_read(0x04)%16) + 10*(i86_cmos_read(0x04)/16): i86_cmos_read(0x04); + + tim->weekday = (BCD) ? (i86_cmos_read(0x06)%16) + 10*(i86_cmos_read(0x06)/16): i86_cmos_read(0x06); + tim->day = (BCD) ? (i86_cmos_read(0x07)%16) + 10*(i86_cmos_read(0x07)/16): i86_cmos_read(0x07); + tim->month = (BCD) ? (i86_cmos_read(0x08)%16) + 10*(i86_cmos_read(0x08)/16): i86_cmos_read(0x08); + tim->year = (BCD) ? (i86_cmos_read(0x09)%16) + 10*(i86_cmos_read(0x09)/16): i86_cmos_read(0x09); + tim->century = (BCD) ? (i86_cmos_read(0x32)%16) + 10*(i86_cmos_read(0x32)/16): i86_cmos_read(0x32); } + + +unsigned char i86_cmos_read_floppy_drives () +{ + outportb (0x70, 0x10); + return inportb(0x71); +} \ No newline at end of file diff --git a/SysCore/hal/cmos/cmos.h b/SysCore/hal/cmos/cmos.h index afc2a1b..ff21099 100644 --- a/SysCore/hal/cmos/cmos.h +++ b/SysCore/hal/cmos/cmos.h @@ -1,10 +1,17 @@ +/***** cmos.h ******************************************************** + * (c) 2010 CTA Systems Inc. All rights reserved. * + * * + * CMOS I/O Routines * + * ================= * + * * + * ! IMPORTANT NOTE ! Close interrupts before any CMOS operation * + ************************************************************ cta os */ + #ifndef __CMOS_H #define __CMOS_H -extern volatile byte i86_cmos_data[128]; - -extern void i86_cmos_write (); -extern void i86_cmos_read (); +extern void i86_cmos_write_clock (const TIME* time); extern void i86_cmos_read_clock (TIME *tim); +extern unsigned char i86_cmos_read_floppy_drives (); #endif \ No newline at end of file diff --git a/SysCore/hal/cpu/cpu.c b/SysCore/hal/cpu/cpu.c index aa12acf..a6b74c4 100644 --- a/SysCore/hal/cpu/cpu.c +++ b/SysCore/hal/cpu/cpu.c @@ -4,8 +4,6 @@ #include "../idt/idt.h" #define cpuid(in, a, b, c, d) __asm__("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (in)); - - // initializes cpu resources void i86_cpu_initialize() { @@ -21,15 +19,10 @@ void i86_cpu_shutdown() char* i86_cpu_get_vender() { - static char vender[13]; - dword unused, arr[3]; - int i; + dword unused; + dword static arr[3]; cpuid(0, unused, arr[0], arr[2], arr[1]); - for (i=0; i<12; i++) - vender[i] = (arr[i/4]>>(i%4*8)) && 0xFF; - - vender[12] = 0; - return vender; + return (char*) arr; } \ No newline at end of file diff --git a/SysCore/hal/dma/compile.bat b/SysCore/hal/dma/compile.bat new file mode 100644 index 0000000..d0d3910 --- /dev/null +++ b/SysCore/hal/dma/compile.bat @@ -0,0 +1,18 @@ +@echo off +rem The name of the loader assembly file (without extension, must be .asm): +set loader_name=loader + +rem NASM and DJGPP executable paths: +set nasm_path=C:\nasm +set djgpp_path=C:\DJGPP\bin +set objpath=../../objects +set incpath=../../include + +@echo on +%djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/dma.o dma.c + +@echo off +@echo . +@echo Done! + +@pause diff --git a/SysCore/hal/dma/dma.c b/SysCore/hal/dma/dma.c new file mode 100644 index 0000000..18d747b --- /dev/null +++ b/SysCore/hal/dma/dma.c @@ -0,0 +1,137 @@ +/***** dma.c ********************************************************* + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * Direct Memory Access (DMA) Routines * + * =================================== * + * * + ************************************************************ cta os */ + +#include "dma.h" +#include + +enum DMA0_IO { + DMA0_STATUS_REG = 0x08, + DMA0_COMMAND_REG = 0x08, + DMA0_REQUEST_REG = 0x09, + DMA0_CHANMASK_REG = 0x0a, + DMA0_MODE_REG = 0x0b, + DMA0_CLEARBYTE_FLIPFLOP_REG = 0x0c, + DMA0_TEMP_REG = 0x0d, + DMA0_MASTER_CLEAR_REG = 0x0d, + DMA0_CLEAR_MASK_REG = 0x0e, + DMA0_MASK_REG = 0x0f +}; + +enum DMA1_IO { + DMA1_STATUS_REG = 0xd0, + DMA1_COMMAND_REG = 0xd0, + DMA1_REQUEST_REG = 0xd2, + DMA1_CHANMASK_REG = 0xd4, + DMA1_MODE_REG = 0xd6, + DMA1_CLEARBYTE_FLIPFLOP_REG = 0xd8, + DMA1_INTER_REG = 0xda, + DMA1_UNMASK_ALL_REG = 0xdc, + DMA1_MASK_REG = 0xde +}; + +void i86_dma_set_address(unsigned short channel, unsigned char low, unsigned char high) +{ + if (channel > 7) return; // Ignore if channel > 7 + + // Calculate port + unsigned short port = (channel >= 4) ? 4*(channel - 4) + 0xc0 : 2*channel; + + // Set address + outportb (port, low); + outportb (port, high); +} + + +void i86_dma_set_count (unsigned short channel, unsigned char low, unsigned char high) +{ + if (channel > 7) return; // Ignore if channel > 7 + + // Calculate port + unsigned short port = (channel >= 4) ? 4*(channel - 4) + 0xc2 + : (2*channel) + 1; + + // Set count + outportb (port, low); + outportb (port, high); +} + + +void i86_dma_set_external_page_registers (unsigned char channel, unsigned char val) +{ + unsigned short port = 0; + + switch (channel) { + case 1: port = 0x83; break; + case 2: port = 0x81; break; + case 3: port = 0x82; break; + // <- nothing should ever write to chan 4 + case 5: port = 0x89; break; + case 6: port = 0x87; break; + case 7: port = 0x88; break; + default: if (channel == 4 || channel > 14) return; + } + + outportb(port, val); +} + + +void i86_dma_mask_channel (unsigned char channel) +{ + if (channel <= 4) outportb (DMA0_CHANMASK_REG, (1<< (channel -1))); + else outportb (DMA1_CHANMASK_REG, (1<< (channel -5))); +} + + +void i86_dma_unmask_channel (unsigned char channel) +{ + if (channel <= 4) outportb (DMA0_CHANMASK_REG, channel); + else outportb (DMA1_CHANMASK_REG, channel); +} + + +void i86_dma_unmask_all() +{ + outportb (DMA1_UNMASK_ALL_REG, 0xff); +} + + +void i86_dma_reset_flipflop (unsigned char dma) +{ + switch (dma) { + case 0: outportb (DMA0_CLEARBYTE_FLIPFLOP_REG, 0xff); + case 1: outportb (DMA1_CLEARBYTE_FLIPFLOP_REG, 0xff); + } +} + +void i86_dma_reset () +{ + outportb (DMA0_TEMP_REG, 0xff); +} + + +void i86_dma_set_mode(unsigned char channel, unsigned char mode) +{ + unsigned char dma = (channel < 4) ? 0:1; + unsigned char chan = (dma == 0) ? channel : channel-4; + + i86_dma_mask_channel (channel); + outportb ((channel < 4) ? DMA0_MODE_REG : DMA1_MODE_REG, chan | mode); + i86_dma_unmask_all (); +} + + +void i86_dma_set_read (unsigned char channel) +{ + i86_dma_set_mode (channel, DMA_MODE_READ_TRANSFER | DMA_MODE_TRANSFER_SINGLE); +} + + +void i86_dma_set_write (unsigned char channel) +{ + i86_dma_set_mode (channel, DMA_MODE_WRITE_TRANSFER | DMA_MODE_TRANSFER_SINGLE); +} diff --git a/SysCore/hal/dma/dma.h b/SysCore/hal/dma/dma.h new file mode 100644 index 0000000..19e73f7 --- /dev/null +++ b/SysCore/hal/dma/dma.h @@ -0,0 +1,42 @@ +/***** dma.h ********************************************************* + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * Direct Memory Access (DMA) Routines * + * =================================== * + * * + ************************************************************ cta os */ + +#ifndef __DMA__H__ +#define __DMA__H__ + +enum DMA_MODE_REG_MASK { + DMA_MODE_MASK_SEL = 3, + + DMA_MODE_MASK_TRA = 0xc, + DMA_MODE_SELF_TEST = 0, + DMA_MODE_READ_TRANSFER = 4, + DMA_MODE_WRITE_TRANSFER = 8, + + DMA_MODE_MASK_AUTO = 0x10, + DMA_MODE_MASK_IDEC = 0x20, + + DMA_MODE_MASK = 0xc0, + DMA_MODE_TRANSFER_ON_DEMAND = 0, + DMA_MODE_TRANSFER_SINGLE = 0x40, + DMA_MODE_TRANSFER_BLOCK = 0x80, + DMA_MODE_TRANSFER_CASCADE = 0xC0 +}; + +extern void i86_dma_set_address(unsigned short channel, unsigned char low, unsigned char high); +extern void i86_dma_set_count (unsigned short channel, unsigned char low, unsigned char high); +extern void i86_dma_set_external_page_registers (unsigned char channel, unsigned char val); +extern void i86_dma_mask_channel (unsigned char channel); +extern void i86_dma_unmask_channel (unsigned char channel); +extern void i86_dma_unmask_all(); +extern void i86_dma_reset_flipflop (unsigned char dma); +extern void i86_dma_reset (); +extern void i86_dma_set_mode(unsigned char channel, unsigned char mode); +extern void i86_dma_set_read (unsigned char channel); +extern void i86_dma_set_write (unsigned char channel); + +#endif \ No newline at end of file diff --git a/SysCore/hal/floppy/compile.bat b/SysCore/hal/floppy/compile.bat new file mode 100644 index 0000000..d1e618a --- /dev/null +++ b/SysCore/hal/floppy/compile.bat @@ -0,0 +1,18 @@ +@echo off +rem The name of the loader assembly file (without extension, must be .asm): +set loader_name=loader + +rem NASM and DJGPP executable paths: +set nasm_path=C:\nasm +set djgpp_path=C:\DJGPP\bin +set objpath=../../objects +set incpath=../../include + +@echo on +%djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/floppy.o floppy.c + +@echo off +@echo . +@echo Done! + +@pause diff --git a/SysCore/hal/floppy/floppy.c b/SysCore/hal/floppy/floppy.c new file mode 100644 index 0000000..46619eb --- /dev/null +++ b/SysCore/hal/floppy/floppy.c @@ -0,0 +1,356 @@ +/***** floppy.c ****************************************************** + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * Floppy Drive I/O Routines * + * ========================= * + * * + ************************************************************ cta os */ +#include "../irq/irq.h" +#include "../dma/dma.h" +#include +#include + + +// Used ports: +// *********** +// Digital Output Register (DOR): 0x3f2 +// Main Status Register (MSR): 0x3f4 +// Data Register (FIFO): 0x3f5 +// Configuration Control Register (CTRL): 0x3f7 + +unsigned char floppy_drives_installed; +volatile unsigned char i86_floppy_new_interrupt; +struct { + unsigned char type; + unsigned char data_rate; + unsigned char step_rate_time; + unsigned char head_load_time; + unsigned char head_unload_time; + unsigned char sectors_per_track; +} fd[2]; + + +// Initialize DMA +unsigned char i86_floppy_initialize_dma(unsigned char* buffer, unsigned length) +{ + union { unsigned char byt[4]; // Low[0], Mid[1], Hi[2] + unsigned long l; + } a, c; + + a.l = (unsigned) buffer; + c.l = (unsigned) length-1; + + // Check for buffer issues + if ((a.l >> 24) || (c.l >> 16) || (((a.l & 0xffff)+c.l) >> 16)) return 0; + + i86_dma_reset(); + i86_dma_mask_channel(2); // Mask channel 2 + i86_dma_reset_flipflop(1); // FlipFlop reset on DMA1 + + i86_dma_set_address(2, a.byt[0], a.byt[1]); // Buffer address + i86_dma_reset_flipflop(1); // FlipFlop reset on DMA2 + + i86_dma_set_count(2, c.byt[0], c.byt[1]); // Set count + i86_dma_set_read(2); + i86_dma_unmask_all(); + + return 1; +} + + + + +inline void i86_floppy_disable_controller() { + outportb (0x3F2, 0); +} + +inline void i86_floppy_enable_controller() { + outportb (0x3F2, 4 | 8); +} + + +inline unsigned char i86_floppy_send_command (unsigned char command) +{ + int i; + for (i = 0; i < 750; i++) + if (inportb(0x3F4) & 128) { + outportb(0x3F5, command); return 1; + } + return 0; +} + + +inline unsigned char i86_floppy_read_data () +{ + int i; + for (i = 0; i < 750; i++) + if (inportb(0x3F4) & 0x80) + return inportb(0x3F5); + return 0; +} + + +inline void i86_floppy_check_int(unsigned* st0, unsigned* cyl) +{ + i86_floppy_send_command(0x8); + *st0 = i86_floppy_read_data(); + *cyl = i86_floppy_read_data(); +} + + +extern unsigned i86_pit_get_tick_count(); +extern unsigned i86_pit_get_frequency(); + + +inline unsigned char i86_floppy_wait() +{ + unsigned temp = i86_pit_get_tick_count(); + unsigned freq = i86_pit_get_frequency(); + + while (i86_floppy_new_interrupt==0) + if (temp + (3*freq) == i86_pit_get_frequency()) return 0; // timeout + + i86_floppy_new_interrupt = 0; + return 1; +} + + +void i86_floppy_motor (unsigned char drive, unsigned char on) +{ + if (drive >= floppy_drives_installed) return; + + // Read DOR register + unsigned char dor = inportb(0x3F2); + + // Un/set selected drive motor + if (on) dor |= drive << 4; + else dor &= ~(drive << 4); + + // Write DOR + outportb (0x3F2, dor); + + // Wait a fifth of a second for motor to turn on + unsigned temp = i86_pit_get_tick_count(); + unsigned freq = i86_pit_get_frequency(); + while (temp + (freq/5) > i86_pit_get_tick_count()); +} + + +void i86_floppy_handler(ISR_stack_regs *r) +{ + i86_floppy_new_interrupt = 1; +} + + +void i86_floppy_drive_data (unsigned char drv, unsigned char dma) +{ + unsigned data = 0; + if (drv >= floppy_drives_installed) return; + + outportb(0x3F7, fd[drv].data_rate); + + i86_floppy_send_command (0x3); + + data = ((fd[drv].step_rate_time & 0xf) << 4) | (fd[drv].head_unload_time & 0xf); + i86_floppy_send_command (data); + + data = (fd[drv].head_load_time <<1 ) | (dma) ? 1 : 0; + i86_floppy_send_command (data); +} + + +inline void i86_floppy_select(unsigned char drive) +{ + if (drive >= floppy_drives_installed) return; + + // Send mechanical drive data + i86_floppy_drive_data(drive, 1); + + // Select drive in DOR register + outportb (0x3F2, 4 | 8 | drive); + +} + + +unsigned char i86_floppy_calibrate(unsigned drive) +{ + unsigned st0, cyl; + + if (drive >= floppy_drives_installed) return 0; + + i86_floppy_motor (drive, 1); + + int i; + for (i = 0; i < 15; i++) { + i86_floppy_new_interrupt = 0; + i86_floppy_send_command(0x7); + i86_floppy_send_command(drive); + i86_floppy_wait(); + i86_floppy_check_int(&st0, &cyl); + + if (!cyl) { + i86_floppy_motor(drive, 0); + return 1; + } + } + i86_floppy_motor(drive, 0); + return 0; +} + + +void i86_floppy_reset() +{ + unsigned st0, cyl; + + i86_floppy_new_interrupt = 0; + i86_floppy_disable_controller(); + i86_floppy_enable_controller(); + i86_floppy_wait(); + + int i; + for (i = 0; i < 4; i++) + i86_floppy_check_int(&st0, &cyl); + + unsigned char drive; + for (drive = 0; drive < floppy_drives_installed; drive++) { + i86_floppy_drive_data(drive, 1); + i86_floppy_calibrate(drive); + } +} + + +void i86_floppy_read_sector_imp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector) +{ + unsigned st0, cyl; + + i86_floppy_select (drive); + i86_floppy_initialize_dma((unsigned char*) where, 512); + i86_dma_set_read(2); + + i86_floppy_new_interrupt = 0; + + i86_floppy_send_command(0x06 | 0x80 | 0x40 ); + i86_floppy_send_command(head<<2 | drive); + i86_floppy_send_command(track); + i86_floppy_send_command(head); + i86_floppy_send_command(sector); + i86_floppy_send_command(0x02); + i86_floppy_send_command( ((sector+1) >= fd[drive].sectors_per_track) ? fd[drive].sectors_per_track : sector+1); + i86_floppy_send_command(0x1b); + i86_floppy_send_command(0xff); + + i86_floppy_wait(); + + int i; + for (i = 0; i < 7; i++) i86_floppy_read_data(); + + i86_floppy_check_int (&st0, &cyl); +} + + +unsigned char i86_floppy_seek (unsigned drive, unsigned cyl, unsigned head) +{ + unsigned st0, cyl0; + + if (drive >= floppy_drives_installed) return 0; + + i86_floppy_select (drive); + + int i; + for (i = 0; i < 20; i++) { + i86_floppy_new_interrupt = 0; + i86_floppy_send_command (0xF); + i86_floppy_send_command ( (head) << 2 | drive); + i86_floppy_send_command (cyl); + + i86_floppy_wait(); + i86_floppy_check_int(&st0, &cyl0); + + if (cyl0 == cyl) return 1; + } + return 0; +} + + +inline void i86_floppy_lba_to_chs (int lba, unsigned char drive, unsigned char *head, unsigned char *track, unsigned char *sectors) +{ + *head = (lba % (fd[drive].sectors_per_track * 2)) / fd[drive].sectors_per_track; + *track = lba / (fd[drive].sectors_per_track * 2); + *sectors = lba % fd[drive].sectors_per_track + 1; +} + +extern unsigned char i86_cmos_read_floppy_drives(); +const char* types[] = { + "Nonexistant", "5.25\", unsupported.", "5.25\", unsupported.", + "3.5\", 720kb", "3.5\", 1.44mb", "3.5\", 2.88 mb"}; + +void i86_floppy_install() +{ + unsigned char temp = i86_cmos_read_floppy_drives(); + int i; + + // Set fd0 and fd1 types + fd[1].type = temp & 0xf; + fd[0].type = temp >> 4; + + // SRT = 16 - (ms * datarate / 500000); + // HLT = ms * datarate / 1000000 + // HUT = ms * datarate / 8000000 + + // Set up + for (i = 0; i < 2; i++) { + if (fd[i].type >= 3) floppy_drives_installed++; // 5.25" drives unsupported + if (fd[i].type == 3) { // 720 kb, DD + fd[i].data_rate = 2; // speed = 250 kbps + fd[i].step_rate_time = 12; // 16 - (ms * 250000 / 500000), ms = 8 + fd[i].head_load_time = 7; + fd[i].head_unload_time = 7; + fd[i].sectors_per_track = 9; + } + else if (fd[i].type == 4) { // 1.44 MB, HD + fd[i].data_rate = 0; // speed = 500 kbps + fd[i].step_rate_time = 8; + fd[i].head_load_time = 15; + fd[i].head_unload_time = 15; + fd[i].sectors_per_track = 18; + } + else if (fd[i].type == 5) { // 2.88 MB, ED + fd[i].data_rate = 3; // speed = 1000 kbps; + fd[i].step_rate_time = 0; + fd[i].head_load_time = 30; + fd[i].head_unload_time = 30; + fd[i].sectors_per_track = 36; + } + } + if (floppy_drives_installed == 0) return; // No drives to set + + // Install handler + i86_irq_install_handler(6, i86_floppy_handler); + i86_floppy_reset(); +} + + +unsigned char i86_floppy_driver_enabled() +{ + return (floppy_drives_installed>0); +} + + +unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA) +{ + if (drive >= floppy_drives_installed) return 0; + if ((unsigned)(where) > (0xFFFF - 513)) return 0; + + // convert lba to chs + unsigned head, track, sector; + i86_floppy_lba_to_chs(sectorLBA, drive, (unsigned char*)&head, (unsigned char*)&track, (unsigned char*) §or); + + // start motor + i86_floppy_motor(drive, 1); + if (!i86_floppy_seek(drive, track, head)) return 0; + + i86_floppy_read_sector_imp(where, drive, head, track, sector); + i86_floppy_motor(drive, 0); + + return (unsigned*)where; +} diff --git a/SysCore/hal/floppy/floppy.h b/SysCore/hal/floppy/floppy.h new file mode 100644 index 0000000..0783474 --- /dev/null +++ b/SysCore/hal/floppy/floppy.h @@ -0,0 +1,19 @@ +/***** floppy.h ****************************************************** + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * Floppy Drive I/O Routines * + * ========================= * + * * + ************************************************************ cta os */ + +extern unsigned char i86_floppy_initialize_dma(unsigned char* buffer, unsigned length); +extern void i86_floppy_motor (unsigned char drive, unsigned char on); +extern void i86_floppy_handler(ISR_stack_regs *r); +extern void i86_floppy_drive_data (unsigned char drv, unsigned char dma); +extern unsigned char i86_floppy_calibrate(unsigned drive); +extern void i86_floppy_reset(); +extern void i86_floppy_read_sector_imp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector); +extern unsigned char i86_floppy_seek (unsigned drive, unsigned cyl, unsigned head); +extern void i86_floppy_install(); +extern unsigned char i86_floppy_driver_enabled(); +extern unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA); \ No newline at end of file diff --git a/SysCore/hal/gdt/gdt.c b/SysCore/hal/gdt/gdt.c index b773104..98984ed 100644 --- a/SysCore/hal/gdt/gdt.c +++ b/SysCore/hal/gdt/gdt.c @@ -2,7 +2,7 @@ * gdt.c - GLOBAL DESCRIPTOR TABLE * * Contains function prototypes for setting up the GDT * ******************************************************************/ -#define MAX_DESCRIPTORS 3 +#define MAX_DESCRIPTORS 5 #include "gdt.h" /* Our GDT, with 3 entries, and finally our special GDT pointer */ @@ -59,6 +59,12 @@ void i86_gdt_install() * this entry's access byte says it's a Data Segment */ i86_gdt_set_gate(2, 0, 0xFFFFFFFF, 0x92, 0xCF); + /* User mode Code segment*/ + i86_gdt_set_gate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF); + + /* User mode data segment*/ + i86_gdt_set_gate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF); + /* Flush out the old GDT and install the new changes! */ i86_gdt_flush(); } diff --git a/SysCore/hal/hal.c b/SysCore/hal/hal.c index ffcccfa..aa9755e 100644 --- a/SysCore/hal/hal.c +++ b/SysCore/hal/hal.c @@ -10,24 +10,26 @@ #include "irq/irq.h" #include "isrs/isrs.h" #include "keyboard/keyus.h" +#include "floppy/floppy.h" // initialize hardware devices void i86_hal_initialize () { - // initialize motherboard controllers and system timer - i86_cpu_initialize (); // (install GDT, IDT) - i86_isrs_install(); // (install ISR handler) - i86_irq_install(); // (install IRQ handler) + // initialize motherboard controllers and system timer + i86_cpu_initialize (); // (install GDT, IDT) + i86_isrs_install(); // (install ISR handler) + i86_irq_install(); // (install IRQ handler) - // install PIT and system clock; pit at 100 Hz - i86_kb_install_partone(); - i86_cmos_read_clock((TIME*)&_internal_clock); + // install PIT and system clock; pit at 100 Hz + i86_kb_install_partone(); + i86_cmos_read_clock((TIME*)&_internal_clock); i86_pit_install (100); i86_kb_install_parttwo(); + + // enable interrupts + i86_start_interrupts(); - // enable interrupts - i86_start_interrupts(); - + i86_floppy_install(); } // shutdown hardware devices @@ -46,58 +48,14 @@ void reboot() __asm__ __volatile__ ("hlt"); } -//! notifies hal interrupt is done -/*inline void interruptdone (unsigned int intno) { - - //! insure its a valid hardware irq - if (intno > 16) - return; - - //! test if we need to send end-of-interrupt to second pic - if (intno >= 8) - i86_pic_send_command (0x20, 0xA1); - - //! always send end-of-interrupt to primary pic - i86_pic_send_command (0x20, 0x21); -} -*/ - //! output sound to speaker void sound (unsigned frequency) { //! sets frequency for speaker. frequency of 0 disables speaker - outportb (0x61, 3 | (byte)(frequency<<2) ); + outportb (0x61, 3 | (unsigned char)(frequency<<2) ); } - - -//! sets new interrupt vector -/*void _cdecl setvect (int intno, void (_cdecl far &vect) ( ) ) { - - //! install interrupt handler! This overwrites prev interrupt descriptor - i86_install_ir (intno, I86_IDT_DESC_PRESENT | I86_IDT_DESC_BIT32, - 0x8, vect); -} - - -//! returns current interrupt vector -void (_cdecl far * _cdecl getvect (int intno)) ( ) { - - //! get the descriptor from the idt - idt_descriptor* desc = i86_get_ir (intno); - if (!desc) - return 0; - - //! get address of interrupt handler - uint32_t addr = desc->baseLo | (desc->baseHi << 16); - - //! return interrupt handler - I86_IRQ_HANDLER irq = (I86_IRQ_HANDLER)addr; - return irq; -} - -*/ //! returns cpu vender const char* get_cpu_vender () { @@ -108,19 +66,18 @@ const char* get_cpu_vender () { /*************************************************************************************** * Keyboard Routines * ***************************************************************************************/ -char getch() +/*char getch() { - kb_key alpha = getkey(); - return alpha.character; -} + -> moved in conio library +}*/ -char scancode_to_ascii(byte scancode, byte status) +char scancode_to_ascii(unsigned char scancode, unsigned char status) { if ((status&1) || (status&2)) return kbdus_map_shift[scancode]; else return kbdus_map[scancode]; } -byte get_key_status (byte scancode) +unsigned char get_key_status (unsigned char scancode) { if (scancode&0xF0) return kb_lights_status&0x0F; else if (scancode&0x80) return kb_modifier_status&0x7F; @@ -153,7 +110,7 @@ void kb_set_repeat(float rate, int delay){ 3.7, 3.3, 3.0, 2.7, 2.5, 2.3, 2.1, 2.0} ; - byte r,d; + unsigned char r,d; for (r = 0; rate != rates[r] && r < 32; r++) if (rate==32) return; @@ -179,6 +136,6 @@ void kb_set_repeat(float rate, int delay){ |(reserved) | lock | lock | lock | +-----------+-------+-------+--------+ ***************************************/ -void kb_set_LEDs(byte status) { +void kb_set_LEDs(unsigned char status) { i86_kb_set_LEDs(status); } diff --git a/SysCore/hal/irq/irq.h b/SysCore/hal/irq/irq.h index a2bb50c..af8efd4 100644 --- a/SysCore/hal/irq/irq.h +++ b/SysCore/hal/irq/irq.h @@ -1,6 +1,8 @@ #ifndef __IRQ_H #define __IRQ_H +#include + /* These are own ISRs that point to our special IRQ handler * instead of the regular 'fault_handler' function */ diff --git a/SysCore/hal/isrs/BSOD.c b/SysCore/hal/isrs/BSOD.c index b3a2638..f8636ab 100644 --- a/SysCore/hal/isrs/BSOD.c +++ b/SysCore/hal/isrs/BSOD.c @@ -36,10 +36,10 @@ char *exception_messages[] = { }; -void _STOP_ERROR_SCREEN (ISR_stack_regs *r) -{ - set_default_colors (0x01, 0x0F); clrscr(); - puts (" Blue Screen Of Death\n"); +//void _STOP_ERROR_SCREEN (ISR_stack_regs *r) +//{ + //set_default_colors (0x01, 0x0F); clrscr(); + /*puts_pos (0, 0, " Blue Screen Of Death\n"); int i; for (i = 79; i>=0; i--) putc('='); puts_pos_font (15, 2, "A fatal error has occured, CTA OS has been halted.", 0x01, 0x0C); puts_pos_font (10, 4, "gs", 0x01, 0x0B); put_hex_pos(15, 4, r->gs); @@ -67,8 +67,8 @@ void _STOP_ERROR_SCREEN (ISR_stack_regs *r) puts_pos_font (10, 20, "useresp", 0x01, 0x0B); put_hex_pos(17, 20, r->useresp); puts_pos_font (10, 21, "ss", 0x01, 0x0B); put_hex_pos(17, 21, r->ss); - puts_pos_font (29, 24, "!!! System Halted !!!", 0x01, 0x0C); -} + puts_pos_font (29, 24, "!!! System Halted !!!", 0x01, 0x0C);*/ +//} /*void _STOP_ERROR_SCREEN (ISR_stack_regs *r) { @@ -76,4 +76,9 @@ void _STOP_ERROR_SCREEN (ISR_stack_regs *r) puts_pos(50, 24, exception_messages[r->int_no]); puts_pos_font (5, 24, "!!! System Halted !!!", 0x01, 0x0C); -}*/ \ No newline at end of file +}*/ + +void _STOP_ERROR_SCREEN (ISR_stack_regs *r) +{ + cprintf ("%#0C** Fatal Error: "); cprintf("%#0E %s \n\r", exception_messages[r->int_no]); +} \ No newline at end of file diff --git a/SysCore/hal/keyboard/keyboard.h b/SysCore/hal/keyboard/keyboard.h index 465d7f6..cd07aa5 100644 --- a/SysCore/hal/keyboard/keyboard.h +++ b/SysCore/hal/keyboard/keyboard.h @@ -6,128 +6,130 @@ #define KB_KEY_LCTRL 0x90 // 1001 0000 #define KB_KEY_RCTRL 0xA0 // 1010 0000 #define KB_KEY_FSHIFT 0xC0 // 1100 0000 -extern volatile byte kb_modifier_status; +extern volatile unsigned char kb_modifier_status; #define KB_PREFIX_GRAY 0x01 // Gray #define KB_PREFIX_BREAK 0x02 // Break code #define KB_PREFIX_PAUSE 0x04 // Pause/break key -#define KB_PREFIX_PAUSE1 0x08 // Recieved first byte from pause/break -extern volatile byte kb_prefix; +#define KB_PREFIX_PAUSE1 0x08 // Recieved first unsigned char from pause/break +extern volatile unsigned char kb_prefix; #define KB_KEY_SCROLL 0xF1 // 1111 0001 #define KB_KEY_NUM 0xF2 // 1111 0010 #define KB_KEY_CAPS 0xF4 // 1111 0100 -extern volatile byte kb_lights_status; +extern volatile unsigned char kb_lights_status; -extern byte kb_scancode_set; -#define KB_KEY_PAUSE 0x00 -#define KB_KEY_F9 0x01 -#define KB_KEY_F7 0x02 -#define KB_KEY_F5 0X03 -#define KB_KEY_F3 0x04 -#define KB_KEY_F1 0x05 -#define KB_KEY_F2 0x06 -#define KB_KEY_F12 0x07 -#define KB_KEY_PRINTSCRN 0x08 -#define KB_KEY_F10 0x09 -#define KB_KEY_F8 0x0A -#define KB_KEY_F6 0x0B -#define KB_KEY_F4 0x0C -#define KB_KEY_TAB 0x0D -#define KB_KEY_TILDA 0x0E -#define KB_KEY_Q 0x15 -#define KB_KEY_1 0x16 -#define KB_KEY_Z 0x1A -#define KB_KEY_S 0x1B -#define KB_KEY_A 0x1C -#define KB_KEY_W 0x1D -#define KB_KEY_2 0x1E -#define KB_KEY_LWIN 0x1F -#define KB_KEY_C 0x21 -#define KB_KEY_X 0x22 -#define KB_KEY_D 0x23 -#define KB_KEY_E 0x24 -#define KB_KEY_4 0x25 -#define KB_KEY_3 0x26 -#define KB_KEY_RWIN 0x27 -#define KB_KEY_SPACE 0x29 -#define KB_KEY_V 0x2A -#define KB_KEY_F 0x2B -#define KB_KEY_T 0x2C -#define KB_KEY_R 0x2D -#define KB_KEY_5 0x2E -#define KB_KEY_MENU 0x2F -#define KB_KEY_N 0x31 -#define KB_KEY_B 0x32 -#define KB_KEY_H 0x33 -#define KB_KEY_G 0x34 -#define KB_KEY_Y 0x35 -#define KB_KEY_6 0x36 -#define KB_KEY_M 0x3A -#define KB_KEY_J 0x3B -#define KB_KEY_U 0x3C -#define KB_KEY_7 0x3D -#define KB_KEY_8 0x3E -#define KB_KEY_COMMA 0x41 -#define KB_KEY_K 0x42 -#define KB_KEY_I 0x43 -#define KB_KEY_O 0x44 -#define KB_KEY_0 0x45 -#define KB_KEY_9 0x46 -#define KB_KEY_PERIOD 0x49 -#define KB_KEY_SLASH 0x4A -#define KB_KEY_L 0x4B -#define KB_KEY_SEMICOLON 0x4C -#define KB_KEY_P 0x4D -#define KB_KEY_DASH 0x4E -#define KB_KEY_APOSTROPHE 0x52 -#define KB_KEY_LBRACKET 0x54 -#define KB_KEY_EQUAL 0x55 -#define KB_KEY_NUMPAD_ENTER 0x59 -#define KB_KEY_ENTER 0x5A -#define KB_KEY_RBRACKET 0x5B -#define KB_KEY_BACKSLASH 0x5D -#define KB_KEY_END 0x5E -#define KB_KEY_LEFT 0x5F -#define KB_KEY_HOME 0x60 -#define KB_KEY_INSERT 0x61 -#define KB_KEY_DELETE 0x62 -#define KB_KEY_DOWN 0x63 -#define KB_KEY_RIGHT 0x64 -#define KB_KEY_UP 0x65 -#define KB_KEY_BACKSPACE 0x66 -#define KB_KEY_PGDOWN 0x67 -#define KB_KEY_PGUP 0x68 -#define KB_KEY_NUMPAD_1 0x69 -#define KB_KEY_NUMPAD_SLASH 0x6A -#define KB_KEY_NUMPAD_4 0x6B -#define KB_KEY_NUMPAD_7 0x6C -#define KB_KEY_NUMPAD_0 0x70 -#define KB_KEY_NUMPAD_COLON 0x71 -#define KB_KEY_NUMPAD_2 0x72 -#define KB_KEY_NUMPAD_5 0x73 -#define KB_KEY_NUMPAD_6 0x74 -#define KB_KEY_NUMPAD_8 0x75 -#define KB_KEY_ESC 0x76 -#define KB_KEY_F11 0x78 -#define KB_KEY_NUMPAD_PLUS 0x79 -#define KB_KEY_NUMPAD_3 0x7A -#define KB_KEY_NUMPAD_MINUS 0x7B -#define KB_KEY_NUMPAD_ASTERISK 0x7C -#define KB_KEY_NUMPAD_9 0x7D +extern unsigned char kb_scancode_set; +enum KB_KEYS { + KB_KEY_PAUSE = 0x00 + KB_KEY_F9 = 0x01 + KB_KEY_F7 = 0x02 + KB_KEY_F5 = 0X03 + KB_KEY_F3 = 0x04 + KB_KEY_F1 = 0x05 + KB_KEY_F2 = 0x06 + KB_KEY_F12 = 0x07 + KB_KEY_PRINTSCRN = 0x08 + KB_KEY_F10 = 0x09 + KB_KEY_F8 = 0x0A + KB_KEY_F6 = 0x0B + KB_KEY_F4 = 0x0C + KB_KEY_TAB = 0x0D + KB_KEY_TILDA = 0x0E + KB_KEY_Q = 0x15 + KB_KEY_1 = 0x16 + KB_KEY_Z = 0x1A + KB_KEY_S = 0x1B + KB_KEY_A = 0x1C + KB_KEY_W = 0x1D + KB_KEY_2 = 0x1E + KB_KEY_LWIN = 0x1F + KB_KEY_C = 0x21 + KB_KEY_X = 0x22 + KB_KEY_D = 0x23 + KB_KEY_E = 0x24 + KB_KEY_4 = 0x25 + KB_KEY_3 = 0x26 + KB_KEY_RWIN = 0x27 + KB_KEY_SPACE = 0x29 + KB_KEY_V = 0x2A + KB_KEY_F = 0x2B + KB_KEY_T = 0x2C + KB_KEY_R = 0x2D + KB_KEY_5 = 0x2E + KB_KEY_MENU = 0x2F + KB_KEY_N = 0x31 + KB_KEY_B = 0x32 + KB_KEY_H = 0x33 + KB_KEY_G = 0x34 + KB_KEY_Y = 0x35 + KB_KEY_6 = 0x36 + KB_KEY_M = 0x3A + KB_KEY_J = 0x3B + KB_KEY_U = 0x3C + KB_KEY_7 = 0x3D + KB_KEY_8 = 0x3E + KB_KEY_COMMA = 0x41 + KB_KEY_K = 0x42 + KB_KEY_I = 0x43 + KB_KEY_O = 0x44 + KB_KEY_0 = 0x45 + KB_KEY_9 = 0x46 + KB_KEY_PERIOD = 0x49 + KB_KEY_SLASH = 0x4A + KB_KEY_L = 0x4B + KB_KEY_SEMICOLON = 0x4C + KB_KEY_P = 0x4D + KB_KEY_DASH = 0x4E + KB_KEY_APOSTROPHE = 0x52 + KB_KEY_LBRACKET = 0x54 + KB_KEY_EQUAL = 0x55 + KB_KEY_NUMPAD_ENTER = 0x59 + KB_KEY_ENTER = 0x5A + KB_KEY_RBRACKET = 0x5B + KB_KEY_BACKSLASH = 0x5D + KB_KEY_END = 0x5E + KB_KEY_LEFT = 0x5F + KB_KEY_HOME = 0x60 + KB_KEY_INSERT = 0x61 + KB_KEY_DELETE = 0x62 + KB_KEY_DOWN = 0x63 + KB_KEY_RIGHT = 0x64 + KB_KEY_UP = 0x65 + KB_KEY_BACKSPACE = 0x66 + KB_KEY_PGDOWN = 0x67 + KB_KEY_PGUP = 0x68 + KB_KEY_NUMPAD_1 = 0x69 + KB_KEY_NUMPAD_SLASH = 0x6A + KB_KEY_NUMPAD_4 = 0x6B + KB_KEY_NUMPAD_7 = 0x6C + KB_KEY_NUMPAD_0 = 0x70 + KB_KEY_NUMPAD_COLON = 0x71 + KB_KEY_NUMPAD_2 = 0x72 + KB_KEY_NUMPAD_5 = 0x73 + KB_KEY_NUMPAD_6 = 0x74 + KB_KEY_NUMPAD_8 = 0x75 + KB_KEY_ESC = 0x76 + KB_KEY_F11 = 0x78 + KB_KEY_NUMPAD_PLUS = 0x79 + KB_KEY_NUMPAD_3 = 0x7A + KB_KEY_NUMPAD_MINUS = 0x7B + KB_KEY_NUMPAD_ASTERISK = 0x7C + KB_KEY_NUMPAD_9 = 0x7D +}; typedef struct { - byte status; - byte lights; - byte scancode; - byte character; + unsigned char status; + unsigned char lights; + unsigned char scancode; + unsigned char character; } kb_key; extern char getch(); extern kb_key get_key(); -extern scancode_to_ascii(byte scancode); -extern byte get_key_status(byte scancode); +extern scancode_to_ascii(unsigned char scancode); +extern unsigned char get_key_status(unsigned char scancode); extern void kb_set_repeat(float rate, int delay); -extern void kb_set_LEDs(byte status); \ No newline at end of file +extern void kb_set_LEDs(unsigned char status); \ No newline at end of file diff --git a/SysCore/hal/keyboard/keyus.c b/SysCore/hal/keyboard/keyus.c index e5313e7..9db6a73 100644 --- a/SysCore/hal/keyboard/keyus.c +++ b/SysCore/hal/keyboard/keyus.c @@ -28,18 +28,18 @@ const char kbdus_map_shift[] = { }; -volatile byte kb_array[16]; -volatile byte kb_newdata; -volatile byte kb_modifier_status; -volatile byte kb_prefix; -volatile byte kb_lights_status; -byte kb_scancode_set; +volatile unsigned char kb_array[16]; +volatile unsigned char kb_newdata; +volatile unsigned char kb_modifier_status; +volatile unsigned char kb_prefix; +volatile unsigned char kb_lights_status; +unsigned char kb_scancode_set; -void i86_kb_set_key(byte scancode, byte val) +void i86_kb_set_key(unsigned char scancode, unsigned char val) { - byte pos = scancode/8; - byte offset = scancode%8; + unsigned char pos = scancode/8; + unsigned char offset = scancode%8; if (val) { kb_array[pos] |= 1<3 || delay>31) return; - byte out = rate<<5 | delay; + unsigned char out = rate<<5 | delay; while ((inportb(0x64)&2) != 0); outportb(0x60, 0xF3); while ((inportb(0x64)&2) != 0); @@ -231,7 +230,7 @@ void i86_kb_set_repeat(byte rate, byte delay) |(reserved) | lock | lock | lock | +-----------+-------+-------+--------+ ***************************************/ -void i86_kb_set_LEDs(byte status) +void i86_kb_set_LEDs(unsigned char status) { while ((inportb (0x64)&2)!=0); outportb (0x60, 0xED); @@ -248,7 +247,7 @@ void i86_kb_set_LEDs(byte status) 2 Set to scancode set 2 3 Set to scancode set 3 ***************************************/ -void i86_kb_set_scancodeset(byte set) +void i86_kb_set_scancodeset(unsigned char set) { if (set>3) return; @@ -261,7 +260,7 @@ void i86_kb_set_scancodeset(byte set) kb_scancode_set = set; } -byte i86_kb_get_scancodeset() { +unsigned char i86_kb_get_scancodeset() { return kb_scancode_set; } @@ -298,7 +297,7 @@ int i86_kb_install_parttwo() int ret = 0; // Wait for BAT test results - byte temp; + unsigned char temp; do temp = inportb(0x60); while (temp!=0xAA && temp!=0xFC); @@ -311,13 +310,13 @@ int i86_kb_install_parttwo() i86_kb_set_scancodeset(2); // Set new scancode set i86_kb_waitin(); - outportb(0x64, 0x20); // Get "Command byte" + outportb(0x64, 0x20); // Get "Command unsigned char" do { temp = inportb(0x60); } while (temp==0xFA || temp==0xAA); temp &= 0xFF - (1<<6); // Set bit6 to 0: disable conversion - i86_kb_waitin(); outportb(0x64, 0x60); // Function to write cmd byte + i86_kb_waitin(); outportb(0x64, 0x60); // Function to write cmd unsigned char i86_kb_waitin(); outportb(0x60, temp); // Send it memset((void*)kb_array, 0, 16); diff --git a/SysCore/hal/keyboard/keyus.h b/SysCore/hal/keyboard/keyus.h index 6b608c7..9d832a5 100644 --- a/SysCore/hal/keyboard/keyus.h +++ b/SysCore/hal/keyboard/keyus.h @@ -4,22 +4,22 @@ extern const char kbdus_map[0x80]; extern const char kbdus_map_shift[0x80]; -extern volatile byte kb_modifier_status; -extern volatile byte kb_prefix; -extern volatile byte kb_lights_status; -extern byte kb_scancode_set; +extern volatile unsigned char kb_modifier_status; +extern volatile unsigned char kb_prefix; +extern volatile unsigned char kb_lights_status; +extern unsigned char kb_scancode_set; -extern void i86_kb_set_key(byte scancode, byte val); -extern void i86_kb_set_LEDs(byte status); -extern void i86_kb_set_repeat(byte rate, byte delay); -extern void i86_kb_set_scancodeset(byte set); -extern byte i86_kb_get_key(byte scancode); +extern void i86_kb_set_key(unsigned char scancode, unsigned char val); +extern void i86_kb_set_LEDs(unsigned char status); +extern void i86_kb_set_repeat(unsigned char rate, unsigned char delay); +extern void i86_kb_set_scancodeset(unsigned char set); +extern unsigned char i86_kb_get_key(unsigned char scancode); extern void i86_kb_handler(ISR_stack_regs *r); extern kb_key getkey(); -extern void i86_kb_set_repeat(byte rate, byte delay); -extern void i86_kb_set_LEDs(byte status); -extern void i86_kb_set_scancodeset(byte set); -extern byte i86_kb_get_scancodeset(); +extern void i86_kb_set_repeat(unsigned char rate, unsigned char delay); +extern void i86_kb_set_LEDs(unsigned char status); +extern void i86_kb_set_scancodeset(unsigned char set); +extern unsigned char i86_kb_get_scancodeset(); extern void i86_kb_waitin(); extern void i86_kb_waitout(); extern void i86_kb_install_partone(); diff --git a/SysCore/hal/makeall.bat b/SysCore/hal/makeall.bat index f34925b..e69a0c4 100644 --- a/SysCore/hal/makeall.bat +++ b/SysCore/hal/makeall.bat @@ -30,13 +30,31 @@ goto cmos :cpu cd cpu - @echo * Compiling Central Processing Unit... + @echo * Compiling Central Processing Unit (CPU)... del %objpath%\cpu.o %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/cpu.o cpu.c if not exist %objpath%\cpu.o goto error cd.. + +:dma + cd dma + @echo * Compiling Direct Memory Access Controller (DMAC)... + del %objpath%\dma.o + %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/dma.o dma.c + if not exist %objpath%\dma.o goto error + cd.. + + +:floppy + cd floppy + @echo * Compiling Floppy Driver... + del %objpath%\floppy.o + %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/floppy.o floppy.c + if not exist %objpath%\floppy.o goto error + cd.. + :gdt cd gdt @echo * Compiling Global Descriptor Table... diff --git a/SysCore/hal/pit/pit.c b/SysCore/hal/pit/pit.c index 5e24e22..078efc1 100644 --- a/SysCore/hal/pit/pit.c +++ b/SysCore/hal/pit/pit.c @@ -50,6 +50,11 @@ void i86_pit_install(int freq) } +TIME i86_pit_get_time() +{ + return _internal_clock; +} + unsigned char i86_pit_is_initialized() { return _pit_init; diff --git a/SysCore/hal/pit/pit.h b/SysCore/hal/pit/pit.h index 93c3d28..5e38463 100644 --- a/SysCore/hal/pit/pit.h +++ b/SysCore/hal/pit/pit.h @@ -2,7 +2,7 @@ #define __PIT_H #include -extern volatile unsigned int _pit_ticks; +extern volatile unsigned int _pit_ticks; extern volatile unsigned int _pit_frequency; extern volatile TIME _internal_clock; diff --git a/SysCore/include/bootinfo.h b/SysCore/include/bootinfo.h index 5b0599c..3215d82 100644 --- a/SysCore/include/bootinfo.h +++ b/SysCore/include/bootinfo.h @@ -6,32 +6,185 @@ #include -//! multiboot info structure passed from boot loader +/**The structure used by the VESA Controller Info table.*/ +struct _VESA_CONTROLLER_INFO { + /** Vesa signature, should be "VESA". */ + unsigned char Signature[4]; + /** Version number, example: 0x0300 for VBE 3.0. */ + uint16_t Version; + /** FAR pointer to OEM string. (seg:offset). */ + uint16_t OEMString[2]; + /** Capabilities, taken as 4 bytes. */ + uint32_t Capabilities; + /** Video modes. FAR pointer (seg:offset). */ + uint16_t VideoModes[2]; + /** Total memory as number of 64k blocks. */ + uint16_t TotalMemory; +} __attribute__((packed)); + +enum _VESA_MODE_ATTRIBUTES { + /** The mode is supported by the present hardware configuration. */ + IsSupported = 0x01, + /** Optional information is available (must be = 1 for VBE v1.2+) */ + OptionalInformation = 0x02, + /** BIOS output is supported. */ + BiosOutput = 0x04, + /** Set if color, clear if monochrome. */ + IsColor = 0x08, + /** Set if graphic mode, clear if text mode. */ + IsGraphic = 0x10, + /** (VBE v2.0+) mode is not VGA compatible. */ + VGACompatible = 0x20, + /** (VBE v2.0+) Bank switched mode not supported. */ + BankSwitchedNotSupported = 0x40, + /** (VBE v2.0+) Linear framebuffer mode supported. */ + LinearFramebufferSupported = 0x80, + /** (VBE v3.0) Interlaced mode available. */ + InterlacedAvailable = 0x100, + /** (VBE/AF v1.0P) Application must call EnableDirrectAccess before calling bank-switching functions. */ + EnableDirectAccess = 0x100, + /** (VBE v3.0) Hardware supports triple buffering. */ + TripleBufferingSupported = 0x200, + /** (VBE v3.0) Hardware supports stereoscopic display. */ + StereoscopicSupported = 0x400, + /** (VBE v3.0) Dual display start address support. */ + DualDisplayStartAddress = 0x800 +} VESAModeAttributeMasks; + +enum _VESA_MODE_WINDOW_ATTRIBUTES { + /** Window exists. */ + Exists = 0x1, + /** Window is readable. */ + Readable = 0x2, + /** Window is writable. */ + Writable = 0x4 +} VESAModeWindowAttributeMasks; + +enum _VESA_MODE_MEMORY_MODELS { + /** Text */ + Text = 0x00, + /** CGA graphics*/ + CGA = 0x01, + /** HGC graphics*/ + HGC = 0x02, + /** 16-color EGA grahpics*/ + EGA = 0x03, + /** packed pixel graphics*/ + PackedPixel = 0x04, + /** "sequ 256 (non chain 4) grahpics*/ + Sequ256 = 0x05, + /** Direct color (HiColor, 24bit TrueColor)*/ + DirectColor = 0x06, + /** YUV (luminance-chrominance, also called YIQ)*/ + YUV = 0x07 +} VESAModeMemoryModels; + +struct _VESA_MODE_INFO { + /** Mode attributes, defined in VESAModeAttributeMasks. */ + uint16_t Attributes; + /** Window attributes (window A or B), defined in VESAModeWindowAttributeMasks. */ + uint8_t WindowAttributesA, WindowAttributesB; + /** Window granularity in KB. */ + uint16_t WindowGranularity; + /** Start segment of window A (0x0000 if not supported).*/ + uint16_t WindowStartSegmentA; + /** Start segment of window B (0x0000 if not supported).*/ + uint16_t WindowStartSegmentB; + /** FAR window positioning function (equivalent to AX = 0x4F05. */ + uint32_t WindowPositioningFunction; + /** Bytes per scanline.*/ + uint16_t BytesPerScanline; + /** Width in pixels (graphics) or characters (text).*/ + uint16_t Width; + /** Height in pixels (graphics) or characters (text).*/ + uint16_t Height; + /** Width of character cell in pixels. */ + uint8_t CharacterWidth; + /** Height of character cell in pixels. */ + uint8_t CharacterHeight; + /** Number of memory planes. */ + uint8_t MemoryPlanes; + /** Number of bits per pixel. */ + uint8_t Bpp; + /** Number of banks.*/ + uint8_t Banks; + /** Memory model type, defined in VESAModeMemoryModels.*/ + uint8_t MemoryModelType; + /** Size of bank in KB. */ + uint8_t BankSize; + /** Number of image pages minus one, that will fit in video RAM.*/ + uint8_t ImagePages; + /** Reserved, 0x00 for VBE 1.0 to 2.0, 0x01 for VBE 3.0.*/ + uint8_t Reserved_0; + + /** (VESA v1.2+) Self explanatory.*/ + uint8_t RedMaskSize, RedFieldPosition; + uint8_t GreenMaskSize, GreenFieldPosition; + uint8_t BlueMaskSize, BlueFieldPosition; + uint8_t ReservedMaskSize, ReservedFieldPosition; + /** (VESA v1.2+) Direct Color Mode info\n + Bit 0: color ramp is programmable\n + Bit 1: bytes in reserved field may be used by application.*/ + uint8_t DirectColorModeInfo; + /** (VESA v2.0+) Physical address of linear video buffer.*/ + void* LinearVideoBuffer; + /** (VESA v2.0+) Pointer to start of offscreen memory.*/ + void* OffscreenMemory; + /** (VESA v2.0+) KB of offscreen memory.*/ + uint16_t OffscreenMemorySize; + + /** (VESA v3.0) Bytes per scanline in linear modes.*/ + uint16_t BytesPerScanlineLinear; + /** (VESA v3.0) Number of images minus one for banked video modes.*/ + uint8_t ImagesBankedMode; + /** (VESA v3.0) Number of images minus one for linear video modes.*/ + uint8_t ImagesLinearMode; + /** (VESA v3.0) LINEAR MODES ONLY\n + * \DirectColorMaskSize: size of direct color mask (in bits).\n + * \BitPosition: bit position of mask LSB (e.g. shift count)*/ + uint8_t RedDirectColorMaskSize, RedBitPosition; + uint8_t GreenDirectColorMaskSize, GreenBitPosition; + uint8_t BlueDirectColorMaskSize, BlueBitPosition; + uint8_t ReservedDirectColorMaskSize, ReservedBitPosition; + /** (VESA v3.0) Maximum pixel clock for graphics video mode, in Hz*/ + uint32_t MaxPixelClock; +} __attribute__ ((packed)); + +/**The structure passed by the bootloader. */ typedef struct { + /** How much memory is installed on the system (in KB). */ + uint64_t Memory; + /** Boot device. */ + uint32_t BootDevice; + /** Pointer to a char[] string containing kernel parameters. */ + unsigned char* CommandLine; + /** Number of other modules loaded by the bootloader. */ + uint32_t ModulesCount; + /** Pointer to where other modules were loaded. */ + void* ModulesAddress; + /** Size of memory map. */ + uint32_t MemoryMapLength; + /** Pointer to memory map. */ + void* MemoryMapAddress; + /** Drives info length. */ + uint32_t DrivesLength; + /** Pointer to drives info. */ + void* DrivesAddress; + /** BIOS ROM configuration table. */ + uint32_t ConfigurationTable; + /** Name of bootloader, should be "CTA" (0 ended string). */ + unsigned char BootloaderName[4]; + /** APM Table. */ + uint32_t APMTable; + /** VGA current video mode information. */ + uint8_t VGACurrentVideoMode; + uint8_t VGACurrentVideoModeColumns; + uint8_t VGACurrentVideoPage; + /** VESA video mode(s) information. */ + struct _VESA_CONTROLLER_INFO* VESAControllerInformation; + - uint32_t m_flags; - uint32_t m_memoryLo; - uint32_t m_memoryHi; - uint32_t m_bootDevice; - uint32_t m_cmdLine; - uint32_t m_modsCount; - uint32_t m_modsAddr; - uint32_t m_syms0; - uint32_t m_syms1; - uint32_t m_syms2; - uint32_t m_mmap_length; - uint32_t m_mmap_addr; - uint32_t m_drives_length; - uint32_t m_drives_addr; - uint32_t m_config_table; - uint32_t m_bootloader_name; - uint32_t m_apm_table; - uint32_t m_vbe_control_info; - uint32_t m_vbe_mode_info; - uint16_t m_vbe_mode; - uint32_t m_vbe_interface_addr; - uint16_t m_vbe_interface_len; } multiboot_info ; diff --git a/SysCore/include/conio.h b/SysCore/include/conio.h index 24d36ab..a80343d 100644 --- a/SysCore/include/conio.h +++ b/SysCore/include/conio.h @@ -1,30 +1,104 @@ #ifndef __CONIO_H #define __CONIO_H -#define _ATTRIB 0x0F -extern unsigned char default_background, default_foreground; -extern char hex[16]; +#include +//#define _ATTRIB 0x0F -extern void itoa (int value, char *string, unsigned int radix); -extern int printf(const char* str, ...); -extern int abs(int x); -extern void graphics_init(); -extern void text_mode_cursor(int x, int y); -extern void set_default_colors(unsigned char back, unsigned char fore); +typedef struct { + /** Console window width. */ + unsigned width; + /** Console window height. */ + unsigned height; + /** Default colors (can be changed later with ConsoleSetDefaultColors() routine)*/ + unsigned char defcolors; + /** Pointer to a routine to set the blinking cursor position.\n + Parameters are as following: (int x, int y), where x, y is a 2D position on the screen. */ + void (*cursor)(int, int); + /** Pointer to a routine to put a character in a specified position.\n + Parameters are as following: (int x, int y, unsigned char c),\n + * where: x, y = 2D position on the screen\n + * c = ascii character*/ + void (*putc)(int, int, unsigned char); + /** Pointer to a routine to return a character in a specified position.\n + Parameters are as following: (int x, int y), where x, y is a 2D position on the screen. */ + unsigned char (*getc)(int, int); + /** Pointer to a routine to set the colors for the character in the specified position\n + Parameters are as following: (int x, int y, unsigned char color),\n + * where: x, y = 2D position on the screen\n + * color = index in 16 color palette for background (high nibble) and foreground (low nibble)*/ + void (*putcolor)(int, int, unsigned char); + /** Pointer to a routine to return the colors for the character in the specified position\n + Parameters are as following: (int x, int y, unsigned char c),\n + * where: x, y = 2D position on the screen*/ + unsigned char (*getcolor)(int, int); +} ConsoleScreen; + + +typedef struct { + /**Integer coordonates*/ + int X, Y; +} Point; + +typedef struct { + /**Unsigned integer coordonates.*/ + unsigned X, Y; +} UPoint; + +enum COLORS { + BLACK = 0x0, + BLUE = 0x1, + GREEN = 0x2, + CYAN = 0x3, + RED = 0x4, + MAGENTA = 0x5, + BROWN = 0x6, + LIGHTGRAY = 0x7, + DARKGRAY = 0x8, + LIGHTBLUE = 0x9, + LIGHTGREEN = 0xA, + LIGHTCYAN = 0xB, + LIGHTRED = 0xC, + LIGHTMAGENTA = 0xD, + YELLOW = 0xE, + WHITE = 0xF, + BLINK = 0x80 +}; + +enum CURSORSHAPE { + _NOCURSOR = 0x0, + _SOLIDCURSOR = 0x1, + _NORMALCURSOR = 0x2 +}; + +/***/ +//extern char* cgets(char* string); + + +extern void ConsoleInstall(ConsoleScreen screen); +extern void ConsoleUpdateCursor(UPoint position, unsigned char type); +extern void ConsoleScroll(unsigned lines); + + +/** Clears to end of line in text window\n\n + Declaration: void clreol(void);\n\n + Remarks:\n +clreol clears all characters from the cursor position to the end of the line + within the current text window, without moving the cursor.\n\n + Return Value: None*/ +extern void clreol(); extern void clrscr(); -extern void scroll(int n); -extern void prev_line(); -extern void next_line(); -extern void putc_pos_font(int x, int y, char c, unsigned char back, unsigned char fore); -extern void putc_pos(int x, int y, char c); -extern void putc_font(char c, unsigned char back, unsigned char fore); -extern void putc(char c); -extern void puts_pos_font(int x, int y, const char *str, unsigned char back, unsigned char fore); -extern void puts_pos(int x, int y, const char *str); -extern void puts(const char *str); -extern void puts_font(const char *str, unsigned char back, unsigned char fore); -extern void put_hex(unsigned int alpha); -extern void put_hex_pos(int x, int y, unsigned int alpha); -extern void put_bin (int x, int y, unsigned char xz); - +extern int gettext (int left, int top, int right, int bottom, unsigned char* dest); +extern void gotoxy (int x, int y); +extern int cprintf(const char* str, ...); +extern int cputs(const char* str); +extern int cgets(char* string, int maxlen); +extern int getch(); +extern int getche(); +extern void movetext(int left, int top, int right, int bottom, int destleft, int desttop); +extern int putch(const char c); +extern int puttext(int left, int top, int right, int bottom, unsigned char* src); +extern void _setcursortype (int cursor); +extern int wherex(); +extern int wherey(); + #endif \ No newline at end of file diff --git a/SysCore/include/ctype.h b/SysCore/include/ctype.h index 23beb48..3881116 100644 --- a/SysCore/include/ctype.h +++ b/SysCore/include/ctype.h @@ -1,55 +1,31 @@ #ifndef __CTYPE_H #define __CTYPE_H -/****************************** - * ctype.h * - * - character macros * - ******************************/ +extern unsigned char _ctype[]; -#ifdef _MSC_VER -// Get rid of conversion warnings -#pragma warning (disable:4244) -#endif +#define _CTYPE_ISCONTROL 0x01 // 0000 0001 +#define _CTYPE_ISSPACE 0x02 // 0000 0010 +#define _CTYPE_ISBLANK 0x04 // 0000 0100 etc. +#define _CTYPE_ISPUNCT 0x08 +#define _CTYPE_ISDIGIT 0x10 +#define _CTYPE_ISHEX 0x20 +#define _CTYPE_ISUPPER 0x40 +#define _CTYPE_ISLOWER 0x80 -#ifdef __cplusplus -extern "C" -{ -#endif +#define isalnum(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT)) +#define isalpha(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER)) +#define isblank(c) (_ctype[(int)c+1] & (_CTYPE_ISBLANK)) +#define iscntrl(c) (_ctype[(int)c+1] & (_CTYPE_ISCONTROL)) +#define isdigit(c) (_ctype[(int)c+1] & (_CTYPE_ISDIGIT)) +#define isgraph(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT | _CTYPE_ISPUNCT)) +#define islower(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER)) +#define isprint(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT | _CTYPE_ISPUNCT | _CTYPE_ISBLANK)) +#define ispunct(c) (_ctype[(int)c+1] & (_CTYPE_ISPUNCT)) +#define isspace(c) (_ctype[(int)c+1] & (_CTYPE_ISSPACE)) +#define isupper(c) (_ctype[(int)c+1] & (_CTYPE_ISUPPER)) +#define isxdigit(c) (_ctype[(int)c+1] & (_CTYPE_ISHEX)) -extern char _ctype[]; +extern int toupper(int c); +extern int tolower(int c); -/* Constants */ - -#define CT_UP 0x01 /* upper case */ -#define CT_LOW 0x02 /* lower case */ -#define CT_DIG 0x04 /* digit */ -#define CT_CTL 0x08 /* control */ -#define CT_PUN 0x10 /* punctuation */ -#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */ -#define CT_HEX 0x40 /* hex digit */ -#define CT_SP 0x80 /* hard space (0x20) */ - -/* Basic macros */ - -#define isalnum(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG)) -#define isalpha(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW)) -#define iscntrl(c) ((_ctype + 1)[(unsigned)(c)] & (CT_CTL)) -#define isdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG)) -#define isgraph(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG)) -#define islower(c) ((_ctype + 1)[(unsigned)(c)] & (CT_LOW)) -#define isprint(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP)) -#define ispunct(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN)) -#define isspace(c) ((_ctype + 1)[(unsigned)(c)] & (CT_WHT)) -#define isupper(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP)) -#define isxdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX)) -#define isascii(c) ((unsigned)(c) <= 0x7F) -#define toascii(c) ((unsigned)(c) & 0x7F) -#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c) -#define toupper(c) (islower(c) ? c + 'A' - 'a' : c) - -#ifdef __cplusplus -} -#endif - - -#endif +#endif \ No newline at end of file diff --git a/SysCore/include/hal.h b/SysCore/include/hal.h index 60ac986..4d08980 100644 --- a/SysCore/include/hal.h +++ b/SysCore/include/hal.h @@ -3,14 +3,15 @@ #include #include +//#include <..\hal\floppy\floppy.h> #define far #define near #define i86_start_interrupts() __asm__ __volatile__ ("sti"); #define i86_clear_interrupts() __asm__ __volatile__ ("cli"); -extern volatile TIME _internal_clock; - +extern TIME i86_pit_get_time() ; +extern unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA); // initialize hardware abstraction layer extern void i86_hal_initialize (); @@ -23,10 +24,10 @@ extern int i86_hal_shutdown (); //! output sound to speaker extern void sound (unsigned frequency); -//! read byte from device using port mapped io +//! read unsigned char from device using port mapped io //extern unsigned char inportb (unsigned short _port); -//! write byte to device through port mapped io +//! write unsigned char to device through port mapped io //extern void outportb (unsigned short _port, unsigned char _data); //! sets new interrupt vector @@ -44,6 +45,7 @@ extern void reboot(); /********************************************************************** * KEYBOARD STUFF * **********************************************************************/ + #define KB_KEY_LSHIFT 0x81 // 1000 0001 #define KB_KEY_RSHIFT 0X82 // 1000 0010 #define KB_KEY_LALT 0X84 // 1000 0100 @@ -51,130 +53,132 @@ extern void reboot(); #define KB_KEY_LCTRL 0x90 // 1001 0000 #define KB_KEY_RCTRL 0xA0 // 1010 0000 #define KB_KEY_FSHIFT 0xC0 // 1100 0000 -extern volatile byte kb_modifier_status; +extern volatile unsigned char kb_modifier_status; #define KB_PREFIX_GRAY 0x01 // Gray #define KB_PREFIX_BREAK 0x02 // Break code #define KB_PREFIX_PAUSE 0x04 // Pause/break key -#define KB_PREFIX_PAUSE1 0x08 // Recieved first byte from pause/break -extern volatile byte kb_prefix; +#define KB_PREFIX_PAUSE1 0x08 // Recieved first unsigned char from pause/break +extern volatile unsigned char kb_prefix; #define KB_KEY_SCROLL 0xF1 // 1111 0001 #define KB_KEY_NUM 0xF2 // 1111 0010 #define KB_KEY_CAPS 0xF4 // 1111 0100 -extern volatile byte kb_lights_status; +extern volatile unsigned char kb_lights_status; -extern byte kb_scancode_set; -#define KB_KEY_PAUSE 0x00 -#define KB_KEY_F9 0x01 -#define KB_KEY_F7 0x02 -#define KB_KEY_F5 0X03 -#define KB_KEY_F3 0x04 -#define KB_KEY_F1 0x05 -#define KB_KEY_F2 0x06 -#define KB_KEY_F12 0x07 -#define KB_KEY_PRINTSCRN 0x08 -#define KB_KEY_F10 0x09 -#define KB_KEY_F8 0x0A -#define KB_KEY_F6 0x0B -#define KB_KEY_F4 0x0C -#define KB_KEY_TAB 0x0D -#define KB_KEY_TILDA 0x0E -#define KB_KEY_Q 0x15 -#define KB_KEY_1 0x16 -#define KB_KEY_Z 0x1A -#define KB_KEY_S 0x1B -#define KB_KEY_A 0x1C -#define KB_KEY_W 0x1D -#define KB_KEY_2 0x1E -#define KB_KEY_LWIN 0x1F -#define KB_KEY_C 0x21 -#define KB_KEY_X 0x22 -#define KB_KEY_D 0x23 -#define KB_KEY_E 0x24 -#define KB_KEY_4 0x25 -#define KB_KEY_3 0x26 -#define KB_KEY_RWIN 0x27 -#define KB_KEY_SPACE 0x29 -#define KB_KEY_V 0x2A -#define KB_KEY_F 0x2B -#define KB_KEY_T 0x2C -#define KB_KEY_R 0x2D -#define KB_KEY_5 0x2E -#define KB_KEY_MENU 0x2F -#define KB_KEY_N 0x31 -#define KB_KEY_B 0x32 -#define KB_KEY_H 0x33 -#define KB_KEY_G 0x34 -#define KB_KEY_Y 0x35 -#define KB_KEY_6 0x36 -#define KB_KEY_M 0x3A -#define KB_KEY_J 0x3B -#define KB_KEY_U 0x3C -#define KB_KEY_7 0x3D -#define KB_KEY_8 0x3E -#define KB_KEY_COMMA 0x41 -#define KB_KEY_K 0x42 -#define KB_KEY_I 0x43 -#define KB_KEY_O 0x44 -#define KB_KEY_0 0x45 -#define KB_KEY_9 0x46 -#define KB_KEY_PERIOD 0x49 -#define KB_KEY_SLASH 0x4A -#define KB_KEY_L 0x4B -#define KB_KEY_SEMICOLON 0x4C -#define KB_KEY_P 0x4D -#define KB_KEY_DASH 0x4E -#define KB_KEY_APOSTROPHE 0x52 -#define KB_KEY_LBRACKET 0x54 -#define KB_KEY_EQUAL 0x55 -#define KB_KEY_NUMPAD_ENTER 0x59 -#define KB_KEY_ENTER 0x5A -#define KB_KEY_RBRACKET 0x5B -#define KB_KEY_BACKSLASH 0x5D -#define KB_KEY_END 0x5E -#define KB_KEY_LEFT 0x5F -#define KB_KEY_HOME 0x60 -#define KB_KEY_INSERT 0x61 -#define KB_KEY_DELETE 0x62 -#define KB_KEY_DOWN 0x63 -#define KB_KEY_RIGHT 0x64 -#define KB_KEY_UP 0x65 -#define KB_KEY_BACKSPACE 0x66 -#define KB_KEY_PGDOWN 0x67 -#define KB_KEY_PGUP 0x68 -#define KB_KEY_NUMPAD_1 0x69 -#define KB_KEY_NUMPAD_SLASH 0x6A -#define KB_KEY_NUMPAD_4 0x6B -#define KB_KEY_NUMPAD_7 0x6C -#define KB_KEY_NUMPAD_0 0x70 -#define KB_KEY_NUMPAD_COLON 0x71 -#define KB_KEY_NUMPAD_2 0x72 -#define KB_KEY_NUMPAD_5 0x73 -#define KB_KEY_NUMPAD_6 0x74 -#define KB_KEY_NUMPAD_8 0x75 -#define KB_KEY_ESC 0x76 -#define KB_KEY_F11 0x78 -#define KB_KEY_NUMPAD_PLUS 0x79 -#define KB_KEY_NUMPAD_3 0x7A -#define KB_KEY_NUMPAD_MINUS 0x7B -#define KB_KEY_NUMPAD_ASTERISK 0x7C -#define KB_KEY_NUMPAD_9 0x7D +extern unsigned char kb_scancode_set; +enum KB_KEYS { + KB_KEY_PAUSE = 0x00, + KB_KEY_F9 = 0x01, + KB_KEY_F7 = 0x02, + KB_KEY_F5 = 0X03, + KB_KEY_F3 = 0x04, + KB_KEY_F1 = 0x05, + KB_KEY_F2 = 0x06, + KB_KEY_F12 = 0x07, + KB_KEY_PRINTSCRN = 0x08, + KB_KEY_F10 = 0x09, + KB_KEY_F8 = 0x0A, + KB_KEY_F6 = 0x0B, + KB_KEY_F4 = 0x0C, + KB_KEY_TAB = 0x0D, + KB_KEY_TILDA = 0x0E, + KB_KEY_Q = 0x15, + KB_KEY_1 = 0x16, + KB_KEY_Z = 0x1A, + KB_KEY_S = 0x1B, + KB_KEY_A = 0x1C, + KB_KEY_W = 0x1D, + KB_KEY_2 = 0x1E, + KB_KEY_LWIN = 0x1F, + KB_KEY_C = 0x21, + KB_KEY_X = 0x22, + KB_KEY_D = 0x23, + KB_KEY_E = 0x24, + KB_KEY_4 = 0x25, + KB_KEY_3 = 0x26, + KB_KEY_RWIN = 0x27, + KB_KEY_SPACE = 0x29, + KB_KEY_V = 0x2A, + KB_KEY_F = 0x2B, + KB_KEY_T = 0x2C, + KB_KEY_R = 0x2D, + KB_KEY_5 = 0x2E, + KB_KEY_MENU = 0x2F, + KB_KEY_N = 0x31, + KB_KEY_B = 0x32, + KB_KEY_H = 0x33, + KB_KEY_G = 0x34, + KB_KEY_Y = 0x35, + KB_KEY_6 = 0x36, + KB_KEY_M = 0x3A, + KB_KEY_J = 0x3B, + KB_KEY_U = 0x3C, + KB_KEY_7 = 0x3D, + KB_KEY_8 = 0x3E, + KB_KEY_COMMA = 0x41, + KB_KEY_K = 0x42, + KB_KEY_I = 0x43, + KB_KEY_O = 0x44, + KB_KEY_0 = 0x45, + KB_KEY_9 = 0x46, + KB_KEY_PERIOD = 0x49, + KB_KEY_SLASH = 0x4A, + KB_KEY_L = 0x4B, + KB_KEY_SEMICOLON = 0x4C, + KB_KEY_P = 0x4D, + KB_KEY_DASH = 0x4E, + KB_KEY_APOSTROPHE = 0x52, + KB_KEY_LBRACKET = 0x54, + KB_KEY_EQUAL = 0x55, + KB_KEY_NUMPAD_ENTER = 0x59, + KB_KEY_ENTER = 0x5A, + KB_KEY_RBRACKET = 0x5B, + KB_KEY_BACKSLASH = 0x5D, + KB_KEY_END = 0x5E, + KB_KEY_LEFT = 0x5F, + KB_KEY_HOME = 0x60, + KB_KEY_INSERT = 0x61, + KB_KEY_DELETE = 0x62, + KB_KEY_DOWN = 0x63, + KB_KEY_RIGHT = 0x64, + KB_KEY_UP = 0x65, + KB_KEY_BACKSPACE = 0x66, + KB_KEY_PGDOWN = 0x67, + KB_KEY_PGUP = 0x68, + KB_KEY_NUMPAD_1 = 0x69, + KB_KEY_NUMPAD_SLASH = 0x6A, + KB_KEY_NUMPAD_4 = 0x6B, + KB_KEY_NUMPAD_7 = 0x6C, + KB_KEY_NUMPAD_0 = 0x70, + KB_KEY_NUMPAD_COLON = 0x71, + KB_KEY_NUMPAD_2 = 0x72, + KB_KEY_NUMPAD_5 = 0x73, + KB_KEY_NUMPAD_6 = 0x74, + KB_KEY_NUMPAD_8 = 0x75, + KB_KEY_ESC = 0x76, + KB_KEY_F11 = 0x78, + KB_KEY_NUMPAD_PLUS = 0x79, + KB_KEY_NUMPAD_3 = 0x7A, + KB_KEY_NUMPAD_MINUS = 0x7B, + KB_KEY_NUMPAD_ASTERISK = 0x7C, + KB_KEY_NUMPAD_9 = 0x7D +}; typedef struct { - byte status; - byte lights; - byte scancode; - byte character; + unsigned char status; + unsigned char lights; + unsigned char scancode; + unsigned char character; } kb_key; -extern char getch(); +//extern char getch(); extern kb_key getkey(); -extern char scancode_to_ascii(byte scancode, byte status); -extern byte get_key_status(byte scancode); +extern char scancode_to_ascii(unsigned char scancode, unsigned char status); +extern unsigned char get_key_status(unsigned char scancode); extern void kb_set_repeat(float rate, int delay); -extern void kb_set_LEDs(byte status); +extern void kb_set_LEDs(unsigned char status); #endif \ No newline at end of file diff --git a/SysCore/include/stdlib.h b/SysCore/include/stdlib.h new file mode 100644 index 0000000..9558dd0 --- /dev/null +++ b/SysCore/include/stdlib.h @@ -0,0 +1,93 @@ +#ifndef __STDLIB_H__ +#define __STDLIB_H__ + +/** Returns the absolute value of an integer.*/ +#define abs(x) (x>0) ? (x) : (x*-1) +/** Returns the absolute value of a long variable.*/ +#define labs(x) (x>0) ? (x) : (x*-1) +/** Returns the maximum of two numbers.*/ +#define max(a, b) (a > b) ? a : b +/** Returns the minimum of two numbers.*/ +#define min(a, b) (a < b) ? a : b +#define NULL 0 + +/** div_t is a structure of integers used by div()\n + Notes:\n + - quot = quotient;\n + - rem = remainder;\n */ +typedef struct { + /** Quotient */ + long quot; + /** Remainder */ + long rem; +} div_t; + +/** ldiv_t is a structure of integers used by ldiv()\n + Notes:\n + - quot = quotient;\n + - rem = remainder;\n */ +typedef struct { + /** Quotient*/ + long quot; + /** Remainder*/ + long rem; +} ldiv_t; + + +// TODO: extern long double _atold (const char* string); +// TODO: extern double atof (const char* string); // TODO: initialize FPU + +/** Convert ASCII string to INT */ +extern int atoi (const char* string); + +/** Convert ASCII string to LONG */ +extern long atol (const char* string); + +/** Convert ASCII string in hexadecimal to unsigned integer.*/ +extern unsigned int atox (const char* string); + +/** Peform a binary search\n + Notes:\n + - const void* key = A pointer to the element to look for\n + - const void* base = A pointer to the first element of the table\n + - unsigned nelem = The number of elements in the table\n + - unsigned width = The size of one element of the table\n + - int *fcmp = A user defined comparison routine\n */ +extern void* bsearch (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)); + +/**Divides two integers and returns both the quotient and the remainder as a div_t structure.*/ +extern div_t div (int numerator, int denominator); + +/** Convert SIGNED INT to ASCII string */ +extern void itoa (signed int value, char *string, int radix); + +/**Divides two longs and returns both the quotient and the remainder as a ldiv_t structure.*/ +extern ldiv_t ldiv (long numerator, long denominator); + +/**Does a linear search for *key in a table\n + Notes:\n + - const void* key = A pointer to the element to look for\n + - const void* base = A pointer to the first element of the table\n + - unsigned nelem = The number of elements in the table\n + - unsigned width = The size of one element of the table\n + - int *fcmp = A user defined comparison routine\n */ +void* lfind (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)); + +/** Convert SIGNED LONG to ASCII string */ +extern void ltoa (signed long value, char *string, int radix); + +/** Sorts an array using an optimized quick sort algorithm.\n + Notes:\n + - void base = A pointer to the first element of the table\n + - unsigned *nelem = The number of elements in the table\n + - unsigned width = The size of one element of the table\n + - int *fcmp = A user defined comparison routine\n */ +void qsort (void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)); + +/** Convert UNSIGNED INT to ASCII string */ +extern void uitoa (unsigned int value, char *string, int radix); + +/** Convert UNSIGNED LONG to ASCII string */ +extern void ultoa (unsigned long value, char *string, int radix); + +#endif \ No newline at end of file diff --git a/SysCore/include/time.h b/SysCore/include/time.h index 33eecaa..a93d099 100644 --- a/SysCore/include/time.h +++ b/SysCore/include/time.h @@ -1,21 +1,19 @@ #ifndef __TIME_C #define __TIME_C -extern const char* clock_months[13]; -extern const char* clock_weekdays[8]; -extern byte clock_months_len[13]; +extern const char* clock_month[13]; +extern const char* clock_weekday[8]; +extern unsigned char clock_month_len[13]; typedef struct { - byte seconds; - byte minutes; - byte hours; - byte weekday; - byte day; - byte month; - byte year; - byte century; - byte am_pm; - + unsigned char second; + unsigned char minute; + unsigned char hour; + unsigned char weekday; + unsigned char day; + unsigned char month; + unsigned char year; + unsigned char century; } TIME; extern void _CLOCK_INC(TIME *tim); diff --git a/SysCore/lib/compile.bat b/SysCore/lib/compile.bat index 91ab1d4..a5f09bb 100644 --- a/SysCore/lib/compile.bat +++ b/SysCore/lib/compile.bat @@ -11,7 +11,9 @@ set incpath=../include del %objpath%\system.o del %objpath%\string.o del %objpath%\conio.o +del %objpath%\stdlib.o del %objpath%\time.o +del %objpath%\ctype.o goto build :error @@ -30,6 +32,13 @@ goto build @echo * Compiling CONIO.C ... %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/conio.o conio.c + @echo * Compiling CTYPE.C ... + %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/ctype.o ctype.c + + + @echo * Compiling STDLIB.C ... + %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/stdlib.o stdlib.c + @echo * Compiling TIME.C ... %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/time.o time.c @@ -37,4 +46,6 @@ goto build if not exist %objpath%\system.o goto error if not exist %objpath%\string.o goto error if not exist %objpath%\conio.o goto error + if not exist %objpath%\ctype.o goto error + if not exist %objpath%\stdlib.o goto error if not exist %objpath%\time.o goto error diff --git a/SysCore/lib/conio.c b/SysCore/lib/conio.c index 0864238..c799dd0 100644 --- a/SysCore/lib/conio.c +++ b/SysCore/lib/conio.c @@ -1,34 +1,530 @@ #include -#include -#include -#include #include +#include +#include +#include +#include +#include "../memory/mmngr_ph.h" -byte default_background, default_foreground; +unsigned char ColorDefault; +unsigned char ConsoleScreenInstalled = 0; +/*char hex[] = "0123456789ABCDEF"; */ -char hex[] = "0123456789ABCDEF"; -const static char base_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; +/* External routines the user must specify */ +void (*_console_cursor)(int x, int y); +void (*_console_putc)(int x, int y, unsigned char c); +unsigned char (*_console_getc) (int x, int y); +void (*_console_putcolor)(int x, int y, unsigned char color); +unsigned char (*_console_getcolor)(int x, int y); -int abs(int x) +/* Other external routines */ +extern void *memset(void *dest, char val, int count); + +/* Important variables */ +UPoint ScreenSize, Cursor; + +void ConsoleInstall(ConsoleScreen screen) { - return (x>0) ? (x) : (x*-1); + _console_cursor = screen.cursor; + _console_putc = screen.putc; + _console_getc = screen.getc; + + _console_putcolor = screen.putcolor; + _console_getcolor = screen.getcolor; + + ScreenSize.X = screen.width; + ScreenSize.Y = screen.height; + + ColorDefault = screen.defcolors; + + Cursor.X = 0; Cursor.Y = 0; + ConsoleUpdateCursor (Cursor, _NORMALCURSOR); + + ConsoleScreenInstalled = 1; + } +unsigned char _cuc_ex_type; +UPoint _cuc_ex_pos; +void ConsoleUpdateCursor(UPoint position, unsigned char type) +{ + if (_cuc_ex_type == _SOLIDCURSOR) + (*_console_putcolor) ( + _cuc_ex_pos.X, + _cuc_ex_pos.Y, + 0xFF - (*_console_getcolor)(_cuc_ex_pos.X, _cuc_ex_pos.Y) + ); + if (_cuc_ex_type == _NORMALCURSOR && type != _NORMALCURSOR) + (*_console_cursor)(ScreenSize.X, ScreenSize.Y); + + switch (type) { + case _NORMALCURSOR: + (*_console_cursor)(position.X, position.Y); + break; + case _SOLIDCURSOR: + (*_console_putcolor) ( + position.X, position.Y, + 0xFF - (*_console_getcolor)(position.X, position.Y) + ); break; + case _NOCURSOR: + (*_console_cursor)(ScreenSize.X, ScreenSize.Y); break; + } + + _cuc_ex_type = type; + _cuc_ex_pos.X = position.X; + _cuc_ex_pos.Y = position.Y; +} + + +void ConsoleScroll(unsigned lines) +{ + movetext(0, (int)lines, ScreenSize.X, ScreenSize.Y, 0, 0); +} + + +void ConsoleSetDefaultColors (unsigned char background, unsigned char foreground) +{ + ColorDefault = (foreground & 0xF) | (background<<4); +} + + +void ConsoleSetCursorPosition (Point rel, unsigned char display) +{ + Point abs = { (int)(Cursor.X) + rel.X, + (int)(Cursor.Y) + rel.Y }; + + while (abs.X < 0) { abs.X += (int)ScreenSize.X; abs.Y--; } + while (abs.X >= (int)ScreenSize.X) { abs.X -= (int)ScreenSize.X; abs.Y++; } + if (abs.Y < 0) abs.Y = 0; + + if (abs.Y >= (int)ScreenSize.Y) { + ConsoleScroll((unsigned)abs.Y - ScreenSize.Y + 1); + abs.Y = (int)ScreenSize.Y - 1; + } + + Cursor.X = (unsigned)abs.X; + Cursor.Y = (unsigned)abs.Y; + if (display) ConsoleUpdateCursor(Cursor, _cuc_ex_type); + +} + +/**Inline function to return the index of next word\n + Parameters:\n + - const char* string = string to check for words\n + - int len = length of string\n + - int current = current cursor position\n + - int plus = direction (0:back, 1:foward)\n*/ +inline int __cgets__skip_word(const char* string, int len, int current, int plus) +{ + int tmp = current; + + if (!plus) { + --tmp; + while ((isspace((unsigned char)string[tmp]) || ispunct((unsigned char)string[tmp])) && tmp > 0) --tmp; + while (isalnum((unsigned char)string[tmp]) && tmp > 0) --tmp; + } + + else { + ++tmp; + while (isalnum((unsigned char)string[tmp]) && tmp < len) ++tmp; + while ((isspace((unsigned char)string[tmp]) || ispunct((unsigned char)string[tmp])) && tmp < len) ++tmp; + } + + if (tmp != 0 && plus==0) tmp++; + return tmp; +} + +/**Macro which defines the INSERT key behaviour (overwrite/insert mode)*/ +#define __cgets__key_insert() OverWrite = 1 - OverWrite +/**Macro which defines the ENTER key behaviour*/ +#define __cgets__key_enter() { ConsoleSetCursorPosition((Point){Len, 0}, 1); return Len; } + +/**Move the cursor to the left/right\n + Parameters:\n + - const char* string = the character string to work with\n + - int direction = direction to go (0: backward, 1:foward)\n + - int len = length of string\n + - int* cursor = pointer to cursor integer\n + - int word = move one word (1) or just one character(0)\n */ +inline void __cgets__move_cursor(const char* string, int direction, int len, int* cursor, int word) +{ + int dtmp = (direction) ? 1 : -1; + if ((*cursor <= 0 && direction == 0) || (*cursor >= len && direction == 1)) return; + + // Skip one word (e.g. CTRL is pressed) + if (word) { + int tmp = __cgets__skip_word(string, len, *cursor+dtmp, direction); + *cursor = tmp; + } + else { + *cursor += dtmp; + } +} + +/**Deletes the substring between index_start and index_end-1, also updates string length\n + Parameters:\n + - char* string = the character string to work with\n + - int index_start = where to start\n + - int index_end = where to stop\n + - int* len = pointer to length of string\n*/ +inline void __cgets__delete (char* string, int index_start, int index_end, int* len) +{ + for (; index_end <= *len+1; index_start++, index_end++) + string[index_start] = string[index_end]; + + *len = strlen(string); +} + +/**Inserts a char in position of index, also updates string length\n + Parameters:\n + - char* string = the character string to work with\n + - int index = where to insert\n + - char c = characer to insert\n + - int* len = pointer to length of string\n*/ +inline void __cgets__insert (char* string, int index, char c, int* len) +{ + *len = *len+1; + int i; + + for (i = *len-1; i > index; i--) + string[i] = string[i-1]; + string[index] = c; + + string[*len] = 0; +} + +int cgets(char* string, int maxlen) +{ + unsigned char OverWrite = 0; + memset ((void*)string, 0, maxlen); + + int Len = 0, CurPos = 0; + kb_key Key; + UPoint CursorSave; + + while (Len < maxlen) + { + // Display string on the screen + CursorSave = Cursor; + ConsoleUpdateCursor(Cursor, _NOCURSOR); + cputs(string); clreol(); + // Display cursor in right position + Cursor = CursorSave; + ConsoleSetCursorPosition((Point){CurPos, 0}, 0); + ConsoleUpdateCursor(Cursor, (OverWrite) ? _SOLIDCURSOR : _NORMALCURSOR); + // Restore cursor + Cursor = CursorSave; + + // Get key and process + Key = getkey(); + + switch (Key.scancode) { + // Switch overwrite/insert + case KB_KEY_INSERT: __cgets__key_insert(); break; + + // Finish writing (return) + case KB_KEY_ENTER: __cgets__key_enter(); break; + case KB_KEY_NUMPAD_ENTER: __cgets__key_enter(); break; + + // Left + case KB_KEY_LEFT: + __cgets__move_cursor(string, 0, Len, &CurPos, ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL))); + break; + + // Right + case KB_KEY_RIGHT: + __cgets__move_cursor(string, 1, Len, &CurPos, ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL))); + break; + + case KB_KEY_HOME: + CurPos = 0; + break; + + case KB_KEY_END: + CurPos = Len; + break; + + case KB_KEY_BACKSPACE: + if (CurPos > 0) { + int tmp; + if ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL)) + tmp = __cgets__skip_word(string, Len, CurPos, 0); + else tmp = CurPos-1; + + __cgets__delete(string, tmp, CurPos, &Len); + CurPos = tmp; + + }; + break; + + // Delete + case KB_KEY_DELETE: + if (CurPos < Len) { + int tmp; + // If CTRL is pressed, foward one word + if ((Key.status & KB_KEY_LCTRL) || (Key.status & KB_KEY_RCTRL)) + tmp = __cgets__skip_word(string, Len, CurPos, 1); + else tmp = CurPos+1; + + __cgets__delete(string, CurPos, tmp, &Len); + + + } + break; + + // Text character + default: + if (isprint(Key.character)) { + // fix CAPS bug + if ((Key.lights & KB_KEY_CAPS) && islower((unsigned char)Key.character)) + Key.character = toupper(Key.character); + + // Cursor is at the end of the string + if (CurPos == Len) { + Len++; string[Len-1] = Key.character; + string[Len] = 0; + } + + // Cursor is not at the end in OverWrite mode + else if (OverWrite) string[CurPos] = Key.character; + + // Cursor is not at the end in Insert mode + else __cgets__insert(string, CurPos, Key.character, &Len); + + // Increase cursor position + CurPos++; + } + break; + } + + } + + __cgets__key_enter(); +} + + +void clreol() +{ + int counter = Cursor.X; + while (counter < ScreenSize.X) { + (*_console_putc)(counter, Cursor.Y, 0); + ++counter; + } +} + + +void clrscr() +{ + for (Cursor.Y = 0; Cursor.Y < ScreenSize.Y; Cursor.Y++) + for (Cursor.X = 0; Cursor.X < ScreenSize.X; Cursor.X++) { + _console_putc(Cursor.X, Cursor.Y, 0); + _console_putcolor(Cursor.X, Cursor.Y, ColorDefault); + } + Cursor.X = 0; Cursor.Y = 0; +} + + +void getpass (char* string) +{} + + +int gettext (int left, int top, int right, int bottom, unsigned char* dest) +{ + if (left < 0 || top < 0 || (unsigned)right > ScreenSize.X || (unsigned)bottom > ScreenSize.Y) + return 0; + + int i, j; + + for (i = top; i < bottom; i++) + for (j = left; j < right; j++) { + *dest++ = (*_console_getc)(j, i); + *dest++ = (*_console_getcolor)(j, i); + } + return 1; +} + + +void gotoxy (int x, int y) +{ + Cursor.X = x; Cursor.Y = y; + ConsoleUpdateCursor(Cursor, _cuc_ex_type); +} + +int cputs(const char* str) +{ + while (*str != 0) { + putch(*str); str++; + } + return (int)*str; +} + + +int getch() +{ + kb_key k; + k = getkey(); + + if ((k.lights & KB_KEY_CAPS) && k.character >= 'a' && k.character <= 'z') + return (int)(k.character - 'a' + 'A'); + + return k.character; +} + + +int getche() +{ + int ret = getch(); + putch((char)ret); + return ret; +} + + +/*TODO: kbhit()*/ +void movetext(int left, int top, int right, int bottom, int destleft, int desttop) +{ + int destright = destleft + right - left; + int destbottom = desttop + bottom - top; + // Sanity check + if (left < 0 || top < 0 || (unsigned)right > ScreenSize.X || + (unsigned)bottom > ScreenSize.Y || destleft < 0 || desttop < 0) + return; + + // Allocate memory + int needed_mem = ((right-left) * (bottom - top) * 2) / pmmngr_get_block_size(); + unsigned char* map = (unsigned char*) pmmngr_alloc_blocks(needed_mem); + + // Save box in a buffer + gettext(left, top, right, bottom, map); + + // Empty box + int i, j; + for (i = top; i < bottom; i++) + for (j = left; j < right; j++) { + (*_console_putc)(j, i, 0); + (*_console_putcolor)(j, i, ColorDefault); + } + // Put new text + puttext(destleft, desttop, destright, destbottom, map); + + // Free used memory + pmmngr_free_blocks((unsigned)map, needed_mem * pmmngr_get_block_size()); +} + +int putch(const char c) +{ + switch(c) + { + case '\n': ConsoleSetCursorPosition((Point){0, 1}, 0); + break; + + case '\r': Cursor.X = 0; + break; + + case '\t': ConsoleSetCursorPosition((Point){6 - (Cursor.X % 6), 0}, 0); + break; + + case '\b': ConsoleSetCursorPosition((Point){-1, 0}, 0); + (*_console_putc)(Cursor.X, Cursor.Y, 0); + break; + + default: + (*_console_putc)(Cursor.X, Cursor.Y, c); + (*_console_putcolor)(Cursor.X, Cursor.Y, ColorDefault); + ConsoleSetCursorPosition((Point){1,0}, 0); + break; + } + + return c; +} + +int puttext(int left, int top, int right, int bottom, unsigned char* src) +{ + if (left < 0 || top < 0 || (unsigned)right > ScreenSize.X || (unsigned)bottom > ScreenSize.Y) + return 0; + int i,j; + for (i = top; i < bottom; i++) + for (j = left; j < right; j++) { + (*_console_putc)(j, i, *src++); + (*_console_putcolor)(j, i, *src++); + } + return 1; +} + +void _setcursortype (int cursor) +{ + ConsoleUpdateCursor(Cursor, cursor); +} + +int wherex() { return (int)Cursor.X; }; +int wherey() { return (int)Cursor.Y; }; + + +int cprintf(const char* str, ...) +{ + if (!ConsoleScreenInstalled) return -1; + if (!str || !*str) return 0; + + va_list args; + va_start (args, str); + unsigned i, len = strlen(str); + unsigned char temp_col = ColorDefault; + + for (i = 0; i < len; i++) + switch (str[i]) { + case '%': + switch (str[i+1]) { + // Character + case 'c': {char c = va_arg (args, char); + putch(c); i++; break;} + // String + case 's': {int* c = (int*) va_arg (args, char*); + cputs((const char*)c); i++; break;} + // Integers + case 'd': + case 'i': {int c = va_arg(args, int); + char temp[32]; + itoa(c, temp, 10); + cputs(temp); + i++; break;} + // Integers - hex + case 'X': + case 'x': {int c = va_arg(args, int); + char temp[32]; + uitoa(c, temp, 16); + cputs(temp); + i++; break;} + + // Integers - unsigned + case 'u': { int c = va_arg(args, unsigned int); + char temp[32]; + uitoa(c, temp, 10); + cputs(temp); + i++; break; + } + + case '#': { char temp[] = {str[i+2], str[i+3], 0}; + ColorDefault = (unsigned char) atox(temp); + i+=3; + break; } + + + default: va_end(args); return 1; + }; + break; + default: putch(str[i]); break; + } + + va_end(args); + ColorDefault = temp_col; + return i; +} + +/* void graphics_init() { - // Detect if color/monochrome screen - char c = (*(volatile unsigned short*)0x410)&0x30; - if (c==0x30) TextVideoRam = (byte *)0xb0000; - else TextVideoRam = (byte *)0xb8000; - - // Reset cursor, use 80x25 text video mode - current_mode_width = 80; - current_mode_height = 25; - cursor_x = cursor_y = 0; } - // Change cursor position void text_mode_cursor(int x, int y) { @@ -41,17 +537,17 @@ void text_mode_cursor(int x, int y) } // Set the default colors; max is 0x0F -void set_default_colors(byte back, byte fore) +void set_default_colors(unsigned char back, unsigned char fore) { - if (back < 0x10) default_background = back; - if (fore < 0x10) default_foreground = fore; + if (back < 0x10) ColorDefaultBack = back; + if (fore < 0x10) ColorDefaultFore = fore; } // Clear screen, and set font to default font void clrscr() { - byte font = default_foreground | (default_background<<4); + unsigned char font = ColorDefaultFore | (ColorDefaultBack<<4); int i = 0; for (i = 0; i < current_mode_width*current_mode_height; i++) { TextVideoRam[2*i] = 0; @@ -66,7 +562,7 @@ void scroll(int n) TextVideoRam+(current_mode_width*n*2), 2*current_mode_width*(current_mode_height - n)); - byte blank = default_foreground | (default_background<<4); + unsigned char blank = ColorDefaultFore | (ColorDefaultBack<<4); int i; for (i = current_mode_width*(current_mode_height-n); @@ -95,7 +591,7 @@ void next_line() // Put character on screen in specified position; can use different font colors -void putc_pos_font(int x, int y, char c, byte back, byte fore) +void putc_pos_font(int x, int y, char c, unsigned char back, unsigned char fore) { TextVideoRam[2*(y*current_mode_width+x)] = c; TextVideoRam[2*(y*current_mode_width+x)+1] = fore|(back<<4); @@ -106,7 +602,7 @@ void putc_pos(int x, int y, char c) TextVideoRam[2*(y*current_mode_width+x)] = c; } // Put character on screen in the current cursor position; different font colors -void putc_font(char c, byte back, byte fore) +void putc_font(char c, unsigned char back, unsigned char fore) { if (cursor_x >= current_mode_width) next_line(); @@ -126,50 +622,11 @@ void putc(char c) cursor_x++; } -// Unsigned INT to ASCII -void uitoa (unsigned int value, char *string, int radix) -{ - if (radix == 1 || radix>36) return; - - // Calculate how much space needed for number - int len, temp = abs(value); - for (len = 0; temp > 0; len++) temp/=radix; - if (len == 0) len = 1; - - string[len] = 0; - for (len--; len >=0; len-- ) { - string[len] = base_chars[value%radix]; - value/=radix; - } -} - -// Signed INT to ASCII -void itoa (int value, char *string, unsigned int radix) -{ - if (radix < 2 || radix>36) return; - - // Calculate how much space needed for number - int len, temp = abs(value); - for (len = 0; temp > 0; len++) temp/=radix; - if (len == 0) len = 1; - - //Add a space for '-' - if (value<0) { - len++; string[0] = '-'; - value = abs(value); - } - - string[len] = 0; - for (len--; len >0; len-- ) { - string[len] = base_chars[value%radix]; - value/=radix; - } -} // Put string on screen in specified position; can use different font colors -void puts_pos_font(int x, int y, const char *str, byte back, byte fore) +void puts_pos_font(int x, int y, const char *str, unsigned char back, unsigned char fore) { int i; for (i = 0; str[i] != 0; i++) @@ -191,7 +648,7 @@ void puts(const char *str) putc(str[i]); } -void puts_font(const char *str, byte back, byte fore) +void puts_font(const char *str, unsigned char back, unsigned char fore) { int i; for (i = 0; str[i] != 0; i++) @@ -221,7 +678,7 @@ void put_hex_pos(int x, int y, unsigned int alpha) puts_pos(x,y,nr); } -void put_bin (int x, int y, byte xz) +void put_bin (int x, int y, unsigned char xz) { int i; char arr[9] = {0,0,0,0,0,0,0,0,0}; @@ -232,53 +689,6 @@ void put_bin (int x, int y, byte xz) } -int printf(const char* str, ...) -{ - if (!str) return 0; - - va_list args; - va_start (args, str); - size_t i, len = strlen(str); - for (i = 0; i < len; i++) - switch (str[i]) { - case '%': - switch (str[i+1]) { - // Character - case 'c': {char c = va_arg (args, char); - putc(c); i++; break;} - // String - case 's': {int* c = (int*) va_arg (args, char*); - puts((const char*)c); i++; break;} - // Integers - case 'd': - case 'i': {int c = va_arg(args, int); - char temp[32]; - itoa(c, temp, 10); - puts(temp); - i++; break;} - // Integers - hex - case 'X': - case 'x': {int c = va_arg(args, int); - char temp[32]; - uitoa(c, temp, 16); - puts(temp); - i++; break;} - - // Integers - unsigned - case 'u': { int c = va_arg(args, unsigned int); - char temp[32]; - uitoa(c, temp, 10); - puts(temp); - i++; break; - } - - default: va_end(args); return 1; - }; - break; - default: putc(str[i]); break; - } - - va_end(args); - return i; -} + +*/ \ No newline at end of file diff --git a/SysCore/lib/ctype.c b/SysCore/lib/ctype.c new file mode 100644 index 0000000..b83de4c --- /dev/null +++ b/SysCore/lib/ctype.c @@ -0,0 +1,146 @@ +#include + +unsigned char _ctype[256] = +{ + 0, // -1 EOF + _CTYPE_ISCONTROL, // 00 (NUL) + _CTYPE_ISCONTROL, // 01 (SOH) + _CTYPE_ISCONTROL, // 02 (STX) + _CTYPE_ISCONTROL, // 03 (ETX) + _CTYPE_ISCONTROL, // 04 (EOT) + _CTYPE_ISCONTROL, // 05 (ENQ) + _CTYPE_ISCONTROL, // 06 (ACK) + _CTYPE_ISCONTROL, // 07 (BEL) + _CTYPE_ISCONTROL, // 08 (BS) + _CTYPE_ISSPACE+_CTYPE_ISCONTROL, // 09 (HT) + _CTYPE_ISSPACE+_CTYPE_ISCONTROL, // 0A (LF) + _CTYPE_ISSPACE+_CTYPE_ISCONTROL, // 0B (VT) + _CTYPE_ISSPACE+_CTYPE_ISCONTROL, // 0C (FF) + _CTYPE_ISSPACE+_CTYPE_ISCONTROL, // 0D (CR) + _CTYPE_ISCONTROL, // 0E (SI) + _CTYPE_ISCONTROL, // 0F (SO) + _CTYPE_ISCONTROL, // 10 (DLE) + _CTYPE_ISCONTROL, // 11 (DC1) + _CTYPE_ISCONTROL, // 12 (DC2) + _CTYPE_ISCONTROL, // 13 (DC3) + _CTYPE_ISCONTROL, // 14 (DC4) + _CTYPE_ISCONTROL, // 15 (NAK) + _CTYPE_ISCONTROL, // 16 (SYN) + _CTYPE_ISCONTROL, // 17 (ETB) + _CTYPE_ISCONTROL, // 18 (CAN) + _CTYPE_ISCONTROL, // 19 (EM) + _CTYPE_ISCONTROL, // 1A (SUB) + _CTYPE_ISCONTROL, // 1B (ESC) + _CTYPE_ISCONTROL, // 1C (FS) + _CTYPE_ISCONTROL, // 1D (GS) + _CTYPE_ISCONTROL, // 1E (RS) + _CTYPE_ISCONTROL, // 1F (US) + _CTYPE_ISSPACE+_CTYPE_ISBLANK, // 20 SPACE + _CTYPE_ISPUNCT, // 21 ! + _CTYPE_ISPUNCT, // 22 " + _CTYPE_ISPUNCT, // 23 # + _CTYPE_ISPUNCT, // 24 $ + _CTYPE_ISPUNCT, // 25 % + _CTYPE_ISPUNCT, // 26 & + _CTYPE_ISPUNCT, // 27 ' + _CTYPE_ISPUNCT, // 28 ( + _CTYPE_ISPUNCT, // 29 ) + _CTYPE_ISPUNCT, // 2A * + _CTYPE_ISPUNCT, // 2B + + _CTYPE_ISPUNCT, // 2C , + _CTYPE_ISPUNCT, // 2D - + _CTYPE_ISPUNCT, // 2E . + _CTYPE_ISPUNCT, // 2F / + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 30 0 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 31 1 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 32 2 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 33 3 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 34 4 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 35 5 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 36 6 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 37 7 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 38 8 + _CTYPE_ISDIGIT+_CTYPE_ISHEX, // 39 9 + _CTYPE_ISPUNCT, // 3A : + _CTYPE_ISPUNCT, // 3B ; + _CTYPE_ISPUNCT, // 3C < + _CTYPE_ISPUNCT, // 3D = + _CTYPE_ISPUNCT, // 3E > + _CTYPE_ISPUNCT, // 3F ? + _CTYPE_ISPUNCT, // 40 @ + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 41 A + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 42 B + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 43 C + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 44 D + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 45 E + _CTYPE_ISUPPER+_CTYPE_ISHEX, // 46 F + _CTYPE_ISUPPER, // 47 G + _CTYPE_ISUPPER, // 48 H + _CTYPE_ISUPPER, // 49 I + _CTYPE_ISUPPER, // 4A J + _CTYPE_ISUPPER, // 4B K + _CTYPE_ISUPPER, // 4C L + _CTYPE_ISUPPER, // 4D M + _CTYPE_ISUPPER, // 4E N + _CTYPE_ISUPPER, // 4F O + _CTYPE_ISUPPER, // 50 P + _CTYPE_ISUPPER, // 51 Q + _CTYPE_ISUPPER, // 52 R + _CTYPE_ISUPPER, // 53 S + _CTYPE_ISUPPER, // 54 T + _CTYPE_ISUPPER, // 55 U + _CTYPE_ISUPPER, // 56 V + _CTYPE_ISUPPER, // 57 W + _CTYPE_ISUPPER, // 58 X + _CTYPE_ISUPPER, // 59 Y + _CTYPE_ISUPPER, // 5A Z + _CTYPE_ISPUNCT, // 5B [ + _CTYPE_ISPUNCT, // 5C backslash + _CTYPE_ISPUNCT, // 5D ] + _CTYPE_ISPUNCT, // 5E ^ + _CTYPE_ISPUNCT, // 5F _ + _CTYPE_ISPUNCT, // 60 ` + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 61 a + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 62 b + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 63 c + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 64 d + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 65 e + _CTYPE_ISLOWER+_CTYPE_ISHEX, // 66 f + _CTYPE_ISLOWER, // 67 g + _CTYPE_ISLOWER, // 68 h + _CTYPE_ISLOWER, // 69 i + _CTYPE_ISLOWER, // 6A j + _CTYPE_ISLOWER, // 6B k + _CTYPE_ISLOWER, // 6C l + _CTYPE_ISLOWER, // 6D m + _CTYPE_ISLOWER, // 6E n + _CTYPE_ISLOWER, // 6F o + _CTYPE_ISLOWER, // 70 p + _CTYPE_ISLOWER, // 71 q + _CTYPE_ISLOWER, // 72 r + _CTYPE_ISLOWER, // 73 s + _CTYPE_ISLOWER, // 74 t + _CTYPE_ISLOWER, // 75 u + _CTYPE_ISLOWER, // 76 v + _CTYPE_ISLOWER, // 77 w + _CTYPE_ISLOWER, // 78 x + _CTYPE_ISLOWER, // 79 y + _CTYPE_ISLOWER, // 7A z + _CTYPE_ISPUNCT, // 7B { + _CTYPE_ISPUNCT, // 7C + + _CTYPE_ISPUNCT, // 7D } + _CTYPE_ISPUNCT, // 7E ~ + _CTYPE_ISCONTROL, // 7F (DEL) + // and the rest are 0... +}; + + +int toupper(int c) +{ + return ((islower(c)) ? (c-'a'+'A') : c); +} + +int tolower(int c) +{ + return((isupper(c)) ? (c-'A'+'a') : c); +} \ No newline at end of file diff --git a/SysCore/lib/stdlib.c b/SysCore/lib/stdlib.c new file mode 100644 index 0000000..f4ea5db --- /dev/null +++ b/SysCore/lib/stdlib.c @@ -0,0 +1,286 @@ +#include +#include + +const char base_chars[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + +void uitoa (unsigned int value, char *string, int radix) +{ + if (radix == 1 || radix>36) return; + + // Variables + int len; *string = '0'; + unsigned int temp = value; + + // Calculate string length needed + for (len = 0; temp > 0; len++) temp /= radix; + if (len == 0) len = 2; + + // Last character is NULL + string[len] = 0; + + // Write characters + for (len--; len >=0; len-- ) { + string[len] = base_chars[value%radix]; + value/=radix; + } +} + +void ultoa (unsigned long value, char *string, int radix) +{ + if (radix == 1 || radix>36) return; + + // Variables + int len; *string = '0'; + unsigned long temp = value; + + // Calculate string length needed + for (len = 0; temp > 0; len++) temp /= radix; + if (len == 0) len = 2; + + // Last character is NULL + string[len] = 0; + + // Write characters + for (len--; len >=0; len-- ) { + string[len] = base_chars[value%radix]; + value/=radix; + } +} + +void itoa (signed int value, char *string, int radix) +{ + if (radix == 1 || radix>36) return; + + // Variables + int len = 0; *string = '0'; + unsigned int copy = value; + + // If number is < 0 + if (value < 0) { + if (radix == 10) { + len++; copy = abs(value); + } + else copy = (unsigned) value; // If base is not 10, set high bit + } + + // Calculate string length needed + unsigned int temp = copy; + for (; temp > 0; len++) temp /= radix; + if (len == 0) len = 2; + + // Last character is NULL + string[len] = 0; + + // Write characters + for (len--; len >= 0; len-- ) { + string[len] = base_chars[copy%radix]; + copy/=radix; + } + + // Add minus sign + if (value < 0 && radix == 10) string[0] = '-'; +} + +void ltoa (signed long value, char *string, int radix) +{ + if (radix == 1 || radix>36) return; + + // Variables + int len = 0; *string = '0'; + unsigned long copy = value; + + // If number is < 0 + if (value < 0) { + if (radix == 10) { + len++; copy = abs(value); + } + else copy = (unsigned) value; // If base is not 10, set high bit + } + + // Calculate string length needed + unsigned long temp = copy; + for (; temp > 0; len++) temp /= radix; + if (len == 0) len = 2; + + // Last character is NULL + string[len] = 0; + + // Write characters + for (len--; len >= 0; len-- ) { + string[len] = base_chars[copy%radix]; + copy/=radix; + } + + // Add minus sign + if (value < 0 && radix == 10) string[0] = '-'; +} + +int atoi (const char* string) +{ + int ret = 0; + unsigned char sign = 0; + + for (;!isdigit((unsigned char)*string); string++) { + if (*string == NULL) return 0; + else if (*string == '-' && isdigit(*(string+1))) + sign = 1; + } + + for (;isdigit(*string); string++) + ret = ret*10 + (*string - '0'); + + if (sign) ret*=-1; + + return ret; +} + +long atol (const char* string) +{ + long int ret = 0; + unsigned char sign = 0; + + for (;!isdigit(*string); string++) { + if (*string == NULL) return 0; + else if (*string == '-' && *(string+1) > '0' && *(string+1) < '9') + sign = 1; + } + + for (;isdigit(*string); string++) + ret = ret*10 + (*string - '0'); + + if (sign) ret*=-1; + + return ret; +} + +unsigned int atox (const char* string) +{ + unsigned ret = 0; + unsigned temp; + + for (;!isxdigit(*string); string++) + if (*string == 0) return 0; + + for (;isxdigit(*string); string++) { + if (isdigit(*string)) temp = (unsigned)*string - '0'; + else if (isupper(*string)) temp = 10 + (unsigned)(*string) - 'A'; + else temp = 10 + (unsigned)(*string) - 'a'; + ret = ret*0x10 + temp; + } + return ret; +} + +void* bsearch (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)) +{ + int beg = 0, end = nelem, mid, result; + unsigned addr; + + while (beg != end && beg != end-1) { + mid = (beg + end) / 2; + addr = (unsigned)base + (mid * width); + result = (*fcmp)(key, (void*) addr); + + if (result == 0) return (void*) addr; + else if (result > 0) beg = mid; + else end = mid; + } + return 0; +} + +void* lfind (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)) +{ + int result = 1, i = 0; + + while (result != 0 && i != nelem) { + base = (void*)((unsigned)base + width); + result = (*fcmp)(key, base); + i++; + } + + if (result == 0) return (void*) base; + return 0; +} + +div_t div (int numerator, int denominator) +{ + div_t ret; + ret.quot = numerator / denominator; + ret.rem = numerator % denominator; + return ret; +} + +ldiv_t ldiv (long numerator, long denominator) +{ + ldiv_t ret; + ret.quot = numerator / denominator; + ret.rem = numerator % denominator; + return ret; +} + +inline void __qassign (void *dest, void *source, unsigned width) +{ + unsigned char* dst = (unsigned char*)dest; + unsigned char* src = (unsigned char*)source; + int i; + + for (i = 0; i < width; i++, dst++, src++) + *dst = *src; + +} + +void __qsort(void* base, unsigned width, int (*fcmp)(const void*, const void*), int beg, int end) +{ + unsigned char piv_str[width]; + unsigned char tmp_str[width]; + void* piv = (void*) piv_str; void* tmp = (void*) tmp_str; + + int l,r,p; + + while (beg 0 ) ) r--; + + if (l>r) break; + + __qassign (tmp, (void*) ((unsigned)base + (width * l)), width); + __qassign ((void*) ((unsigned)base + (width * l)), (void*) ((unsigned)base + (width * r)), width); + __qassign ((void*) ((unsigned)base + (width * r)), tmp, width); + //tmp=base[l]; base[l]=base[r]; base[r]=tmp; + + if (p==r) p=l; + + l++; r--; + } + + __qassign((void*) ((unsigned)base + (width * p)), (void*) ((unsigned)base + (width * r)), width); + __qassign((void*) ((unsigned)base + (width * r)), piv, width); + //base[p]=base[r]; base[r]=piv; + r--; + + // Recursion on the shorter side & loop (with new indexes) on the longer + if ((r-beg)<(end-l)) + { + __qsort(base, width, *fcmp, beg, r); + beg=l; + } + else + { + __qsort(base, width, *fcmp, l, end); + end=r; + } + } +} + +void qsort (void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*)) +{ + __qsort(base, width, *fcmp, 0, nelem-1); +} + diff --git a/SysCore/lib/string.c b/SysCore/lib/string.c index 937ec2c..35e2e29 100644 --- a/SysCore/lib/string.c +++ b/SysCore/lib/string.c @@ -1,8 +1,8 @@ #include -size_t strlen (const char *str) +unsigned strlen (const char *str) { - size_t i; + unsigned i; for (i = 0; *str!=0; str++) i++; return i; } diff --git a/SysCore/lib/system.c b/SysCore/lib/system.c index 7b13fee..fbaee98 100644 --- a/SysCore/lib/system.c +++ b/SysCore/lib/system.c @@ -4,7 +4,7 @@ #include -byte *TextVideoRam; +extern unsigned char *TextVideoRam; volatile int cursor_x, cursor_y; int current_mode_width; int current_mode_height; @@ -32,13 +32,13 @@ unsigned short *memsetw(unsigned short *dest, unsigned short val, int count) } -byte inportb (word _port) { - byte rv; +unsigned char inportb (word _port) { + unsigned char rv; __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port)); return rv; } -byte inb (word _port) { - byte rv; +unsigned char inb (word _port) { + unsigned char rv; __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port)); return rv; } \ No newline at end of file diff --git a/SysCore/lib/time.c b/SysCore/lib/time.c index d88c147..50baf6f 100644 --- a/SysCore/lib/time.c +++ b/SysCore/lib/time.c @@ -1,13 +1,13 @@ #include #include -const char* clock_months[] = {0, +const char* clock_month[] = {0, "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; -const char* clock_weekdays[] = {0, +const char* clock_weekday[] = {0, "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; -byte clock_months_len[] = { +unsigned char clock_months_len[] = { 0, 31, // January 28, // February @@ -26,14 +26,14 @@ byte clock_months_len[] = { void _CLOCK_INC(TIME *tim) { // New minute - if (++tim->seconds > 59) { - tim->seconds = 0; + if (++tim->second > 59) { + tim->second = 0; // New hour - if (++tim->minutes > 59) { - tim->minutes = 0; - tim->hours++; - if (tim->hours == 12 && tim->am_pm == 1) { // 11:59pm -> 0:00am - tim->hours = 0; tim->am_pm = 0; + if (++tim->minute > 59) { + tim->minute = 0; + tim->hour++; + if (tim->hour == 24) { // Midnight + tim->hour = 0; // New day tim->weekday = 1+(tim->weekday%7); // Leap years @@ -49,8 +49,6 @@ void _CLOCK_INC(TIME *tim) } } } - else if (tim->hours == 12 && tim->am_pm == 0) tim->am_pm = 1; // 11:59am -> 12:00pm - else if (tim->hours == 13 && tim->am_pm == 1) tim->hours = 1; // 12:59pm -> 1:59pm } } } @@ -69,7 +67,7 @@ void _CLOCK_INC(TIME *tim) { char str[100]; int l = strlen(format), i; - byte special = 0; + unsigned char special = 0; for (i=0; i #include #include +#include "hal/floppy/floppy.h" #include #include #include "memory/mmngr_ph.h" #include "memory/mmngr_vi.h" -#include "shell/shell.c" +#include "video/vga03h.h" -//! format of a memory region +#include + +// format of a memory region typedef struct { - - uint32_t startLo; - uint32_t startHi; - uint32_t sizeLo; - uint32_t sizeHi; - uint32_t type; - uint32_t acpi_3_0; + unsigned startLo; + unsigned startHi; + unsigned sizeLo; + unsigned sizeHi; + unsigned type; + unsigned acpi_3_0; } memory_region ; -//! different memory regions (in memory_region.type) -char* strMemoryTypes[] = { +// different memory regions (in memory_region.type) +/*char* strMemoryTypes[] = { "", "Available", //memory_region.type==0 "Reserved", //memory_region.type==1 "ACPI Reclaim", //memory_region.type==2 "ACPI NVS Memory" //memory_region.type==3 -}; +};*/ -extern dword _code; -extern dword _data; -extern dword _bss; -extern dword _end; +extern void _code, _data, _bss, _end; void k_init(multiboot_info* bootinfo) { - // Start by zero-ing the bss - memset(&_bss, 0, &_end - &_bss); - - // Initialize HAL - i86_hal_initialize(); - - // Initialize Graphics - graphics_init(); - - // cleanup the console screen - set_default_colors (0x07, 0x04); - clrscr(); - - // Start memory manager - uint32_t memSize = 1024 + bootinfo->m_memoryLo + bootinfo->m_memoryHi*64; - memory_region* memMap = (memory_region*)0x1000; - pmmngr_init (memSize, (uint32_t)&_end); - + memset(&_bss, 0, &_end - &_bss); // zero the bss unsigned int i; - for (i=0; (memMap[i].sizeHi != 0 || memMap[i].sizeLo != 0) && i<15; ++i) - if (memMap[i].type==1) pmmngr_init_region (memMap[i].startLo, memMap[i].sizeLo); - - // Protect kernel, bios data area etc - _end += (memSize / 4) * 3; - pmmngr_deinit_region (0x100000, _end - 0x100000); - pmmngr_deinit_region (0x0, 0x500); - pmmngr_deinit_region (0x9FC00, 0x400); - pmmngr_deinit_region (0xA0000, 0x60000); + // Start phyiscal memory manager + unsigned memSize = bootinfo->Memory; - // Start Virtual Memory Manager & Enable paging + memory_region* memMap = bootinfo->MemoryMapAddress; + pmmngr_init (memSize, (unsigned)&_end); + + // Initialize graphics & HAL + //graphics_init(); + i86_hal_initialize(); + + // Initialize memory + for (i=0; (memMap[i].sizeHi != 0 || memMap[i].sizeLo != 0) && i<15; ++i) + if (memMap[i].type==1) + pmmngr_init_region (memMap[i].startLo, memMap[i].sizeLo); + + // Protect kernel, bios data area etc + pmmngr_deinit_region (0x100000, 4096+(unsigned)((&_end) + (memSize / 4)*3) - 0xC0000000); + pmmngr_deinit_region (0x0, 0x500); // IVT, Bios Data Area + + // Initialize virtual mem manager vmmngr_initialize(); } - -void k_main(uint32_t kernel_size, multiboot_info* bootinfo) -{ - k_init(bootinfo); - apps_osver(); - shell(); - for(;;); +extern void shell(); +void k_main(unsigned kernel_size, multiboot_info* bootinfo) +{ + k_init(bootinfo); + vga03h_install(); + + shell(); + for(;;); } \ No newline at end of file diff --git a/SysCore/makeall.bat b/SysCore/makeall.bat index 92e0b25..4811697 100644 --- a/SysCore/makeall.bat +++ b/SysCore/makeall.bat @@ -33,14 +33,24 @@ goto KernelEntry :KernelSTDLIB cd lib - rem call compile.bat + call compile.bat cd.. :KernelMemoryManager cd memory + rem call compile.bat + cd.. + + +:KernelVIDEO + cd video call compile.bat cd.. +:KernelSHELL + cd shell + call compile.bat + cd.. rem here go other sources: rem here go other sources ^ diff --git a/SysCore/makeallh.bat b/SysCore/makeallh.bat index f00da90..642f6f4 100644 --- a/SysCore/makeallh.bat +++ b/SysCore/makeallh.bat @@ -48,6 +48,16 @@ goto KernelEntry call makeall.bat cd.. +:KernelVIDEO + cd video + call compile.bat + cd.. + +:KernelSHELL + cd shell + call compile.bat + cd.. + rem here go other sources: rem here go other sources ^ diff --git a/SysCore/memory/lib/pte.c b/SysCore/memory/lib/pte.c index d51801b..5f8bb35 100644 --- a/SysCore/memory/lib/pte.c +++ b/SysCore/memory/lib/pte.c @@ -22,4 +22,24 @@ void pt_entry_add_attrib (pt_entry* entry, unsigned mask) { unsigned char pt_entry_is_writable (pt_entry entry) { return (entry & _I86_PTE_WRITABLE); -} \ No newline at end of file +} + + +/*#include + +void pt_entry_print(pt_entry entry) +{ + cprintf ("page "); +}*/ \ No newline at end of file diff --git a/SysCore/memory/lib/pte.h b/SysCore/memory/lib/pte.h index a09cc8a..246f007 100644 --- a/SysCore/memory/lib/pte.h +++ b/SysCore/memory/lib/pte.h @@ -24,4 +24,6 @@ extern unsigned pt_entry_get_frame (pt_entry entry); extern unsigned char pt_entry_is_present (pt_entry entry); extern unsigned char pt_entry_is_writable (pt_entry entry); + +extern void pt_entry_print(pt_entry entry); #endif \ No newline at end of file diff --git a/SysCore/memory/mmngr.asm b/SysCore/memory/mmngr.asm index 886c75a..8c4421d 100644 --- a/SysCore/memory/mmngr.asm +++ b/SysCore/memory/mmngr.asm @@ -21,6 +21,7 @@ _read_cr3: global _write_cr3 _write_cr3: + ;xchg bx, bx ; bochs magic breakpoint push ebp mov ebp, esp mov eax, [ebp+8] @@ -34,4 +35,4 @@ _vmmngr_flush_tbl_entry: cli invlpg [eax] sti - retn + retn \ No newline at end of file diff --git a/SysCore/memory/mmngr_ph.c b/SysCore/memory/mmngr_ph.c index 4581cb3..a3374e8 100644 --- a/SysCore/memory/mmngr_ph.c +++ b/SysCore/memory/mmngr_ph.c @@ -1,6 +1,9 @@ -/****************************************************** - * Physical Memory Manager * - ******************************************************/ +/********************************************************************* + * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God * + * * + * Physical Memory Manager * + * ======================= * + ************************************************************ cta os */ // +==============================================+ // | HEADERS | @@ -129,7 +132,7 @@ void mstack_qsort(int beg, int end) /*void print_stack() { int i; - for (i = 0; i < _mmngr_index; i++) printf (" %u", _mmngr_memory_stack[i].low); + for (i = 0; i < _mmngr_index; i++) \n\r (" %u", _mmngr_memory_stack[i].low); } extern char getch();*/ @@ -285,15 +288,15 @@ void* pmmngr_alloc_blocks (unsigned blocks) unsigned prev = _mmngr_memory_stack[i].low | (_mmngr_memory_stack[i].high<<16); --i; // Search consecutive blocks - for (; i >=0; i--) { + for (i = 0; i < _mmngr_index; i++) { temp = _mmngr_memory_stack[i].low | (_mmngr_memory_stack[i].high<<16); - if (temp == prev-1) l++; + if (temp == prev+1) l++; else l = 1; if (l == blocks) { pmmngr_deinit_region (temp * PMMNGR_BLOCK_SIZE, blocks * PMMNGR_BLOCK_SIZE); - return (void*) (temp * PMMNGR_BLOCK_SIZE); + return (void*) ((temp-l+1) * PMMNGR_BLOCK_SIZE); } prev = temp; diff --git a/SysCore/memory/mmngr_vi.c b/SysCore/memory/mmngr_vi.c index c604ac9..21c2363 100644 --- a/SysCore/memory/mmngr_vi.c +++ b/SysCore/memory/mmngr_vi.c @@ -5,16 +5,18 @@ #include "mmngr_ph.h" // +==============================================+ -// | DEFINITIONS | +// | DEFINITIONS & MACROS | // +===================================== cta os =+ #define PAGE_SIZE 4096 #define PTABLE_ADDR_SPACE_SIZE 0x400000 #define DTABLE_ADDR_SPACE_SIZE 0xffffffff +#define PAGE_DIRECTORY_INDEX(x) (((x) >> 22) & 0x3ff) +#define PAGE_TABLE_INDEX(x) (((x) >> 12) & 0x3ff) +#define PAGE_GET_PHYSICAL_ADDRESS(x) (*x & ~0xfff) pdirectory* _current_directory; unsigned _current_page_directory_base_register; extern unsigned char *memset (unsigned char *dest, unsigned char val, int count); -extern char getch(); // +==============================================+ // | PAGE FUNCTIONS | @@ -95,39 +97,88 @@ pdirectory* vmmngr_get_directory() { return _current_directory; } -void vmmngr_initialize() + +unsigned char vmmngr_map_page (unsigned phys, unsigned virt) { - // Allocate default page table - ptable* table = (ptable*) pmmngr_alloc_block(); - if (!table) return; + pdirectory* dir = _current_directory; // get page directory + pd_entry* e = &dir->m_entries [PAGE_DIRECTORY_INDEX (virt)]; // get page table - // Clear page table + if ((*e & _I86_PTE_PRESENT) != _I86_PTE_PRESENT) { + + // Page table not present, allocate it + ptable* table = (ptable *)pmmngr_alloc_block(); + if (!table) return 0; + + // Clear it + vmmngr_ptable_clear(table); + + // Create new entry + pd_entry* entry = &dir->m_entries [PAGE_DIRECTORY_INDEX (virt)]; + + // Map in the table + pd_entry_add_attrib (entry, _I86_PDE_PRESENT); + pd_entry_add_attrib (entry, _I86_PDE_WRITABLE); + pd_entry_set_frame (entry, (unsigned) table); + } + + // get table + ptable* table = (ptable*) PAGE_GET_PHYSICAL_ADDRESS(e); + + // get page + pt_entry* page = &table->m_entries [PAGE_TABLE_INDEX (virt)]; + + pt_entry_set_frame (page, phys); + pt_entry_add_attrib (page, _I86_PTE_PRESENT); + + return 1; +} + +unsigned char vmmngr_initialize() +{ + unsigned int i, virt, frame; + + // Allocate default page & directory table(s) + ptable* table = (ptable*) pmmngr_alloc_block(); + ptable* table2 = (ptable*) pmmngr_alloc_block(); + pdirectory* dir = (pdirectory*) pmmngr_alloc_blocks(3); + + if (!table || !table2 || !dir) return 0; + + // Clear page & directory tables vmmngr_ptable_clear(table); + vmmngr_ptable_clear(table2); + vmmngr_pdirectory_clear(dir); // Identity map the first page table - int i, frame; - for (i = 0, frame = 0; i < 1024; i++, frame += 4096) + virt = 0; frame = 0; + for (i = 0; i < 1024; i++, virt+=4096, frame += 4096) { - // Create a new page - pt_entry page = 0; - pt_entry_add_attrib (&page, _I86_PTE_PRESENT); - pt_entry_set_frame (&page, frame); - - table->m_entries[vmmngr_ptable_virt_to_index(frame)] = page; + pt_entry* page = &table2->m_entries[PAGE_TABLE_INDEX(virt)]; + *page = 0; + pt_entry_add_attrib (page, _I86_PTE_PRESENT); + pt_entry_set_frame (page, frame); } - - // Create default directory table - pdirectory* dir = (pdirectory*) pmmngr_alloc_blocks(3); - if (!dir) return; - - // Clear directory table and set it as current - vmmngr_pdirectory_clear(dir); - - // Get first entry in dir table and set it up to point to our table - pd_entry* entry = vmmngr_pdirectory_lookup_entry(dir, 0); + + // Map 0x100000 to 0xC0000000 + virt = 0xC0000000; frame = 0x100000; + for (i = 0; i < 1024; i++, virt+=4096, frame += 4096) + { + pt_entry* page = &table->m_entries[PAGE_TABLE_INDEX(virt)]; + *page = 0; + pt_entry_add_attrib (page, _I86_PTE_PRESENT); + pt_entry_set_frame (page, frame); + } + + // Get tables in dir table and point them to our tables + pd_entry* entry = &dir->m_entries [PAGE_DIRECTORY_INDEX (0xC0000000)]; pd_entry_add_attrib (entry, _I86_PDE_PRESENT); pd_entry_add_attrib (entry, _I86_PDE_WRITABLE); pd_entry_set_frame (entry, (unsigned) table); + + entry = &dir->m_entries [PAGE_DIRECTORY_INDEX (0x00000000)]; + pd_entry_add_attrib (entry, _I86_PDE_PRESENT); + pd_entry_add_attrib (entry, _I86_PDE_WRITABLE); + pd_entry_set_frame (entry, (unsigned) table2); // Store current PDBR _current_page_directory_base_register = (unsigned) &dir->m_entries; @@ -137,4 +188,6 @@ void vmmngr_initialize() // Enable paging pmmngr_paging_enable (1); + + return 1; } \ No newline at end of file diff --git a/SysCore/memory/mmngr_vi.h b/SysCore/memory/mmngr_vi.h index 0861421..765a336 100644 --- a/SysCore/memory/mmngr_vi.h +++ b/SysCore/memory/mmngr_vi.h @@ -20,6 +20,7 @@ typedef struct { //extern pdirectory* _current_directory; extern void vmmngr_flush_tbl_entry (unsigned addr); -extern void vmmngr_initialize(); +extern unsigned char vmmngr_initialize(); +extern unsigned char vmmngr_map_page(unsigned phys, unsigned virt); #endif \ No newline at end of file diff --git a/SysCore/objects/BSOD.O b/SysCore/objects/BSOD.O index 328c9710e1a836e2be7b682c11d5dd379eb652e3..67ab6f1bc9ee7f9ab117814e63561e2f0f5869f1 100644 GIT binary patch delta 425 zcmX>mHI0YYhmnN=3|JW$cqj5o7&0+1Yyk?)V1^4bC;*vyDTyVC5Fs$x03=y}YECgv z4D*hIDu&Ag4N+A#aMsdNa06<~QE)9P$}h4~013J(s1_@5@iH{Ok;nk4e{uQ$|NqTL zIJ#X_B)T08{+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J2 diff --git a/SysCore/objects/CTYPE.O b/SysCore/objects/CTYPE.O new file mode 100644 index 0000000000000000000000000000000000000000..0d7476ba72db0efbf1c3e1b456a745bafc340c81 GIT binary patch literal 762 zcmeZaWMKdS9wr6`UNDP=QLiMmq6Ex_5C%YM3lRTcgz$k%85Dq6FD0=g5h4U3f$~p~ z`9QV<5bGrs7o!Pda2r7ClJj$OQ}f_fivY!*K<$KU09xMdqQcU!11wR=-26h}Fi7BA z14zK3gt_^E!r=)hfPoPPm_Y!>LC|a*sK5XYpyCN&;D7}{6f6LP1}p$1kM0GyU+Bbe zcXqZ?&~Wz))l@LiGtn~wS<42*pqOW45Qnq$(lT>WfjkiS_n(0woiVwjvLID286pHG zk<$jqU(Ae3KoXQ95CAz{fMl2%88CtXIZZG_)F2FivXIjQ$gRwbf*5MzOY%z#3Q~(e h5+F;M7~t_G_F*$xyb$A?*{Y}2l_|7bJ2gJ87- z+qy!*gC~a`JgG2LWacDh2SG35kR8U@X%q@YPr?Sq?`yg=nX(7(_j~X2`{upy%kP(Q zPGDr84l&kUj|5KA)OoEQTf;Msv3Ce(p&@IB_rj%sqA8dUvddVMZl%))X=p7Am;8xX zOpV*EePC0Ko(L^NKKW=yY%7k4-r~5}70m6nW_%^z(`Bq9;WK>6*Hg=Xu1y>N3cDeE zvnLcvQ$3ueEKZ36Dz;^JS~E93P^bJiQ!FJ(TGlZ>ftTS+aLQl6U%}r}ejh`1K+n;1 zPJcj?s26BDr9Y(Ugr29VGrJ>b9oe0unHH+SY6f}=Lqg_wpNX_IX0BkX+4rq&kI^8z zdt_}-%VTkS%~&?KH|l8Nqt-IS&3UQHRVe(dRbB&5-!yEIA2}2qmZG{58L2PP9!*r9Q-#$wBQoZIiw#&V zj}8xC>ODJp>5 z@+)YEz&my}5vQYBg159b9w*A_zb%5VF51|rM|f$dq#T7j*OQ|tDP_lSuA&U~ru-Su zH!T1rPw$GmYnCUEcsp*_3SSbl+N-ppSLOnAmM`&q)$YAu!8khR-cGM#z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(m{;qSy);jGy=&P6jeea_75&@AbfzEvyUk%#=A%F?@Rc;Uag;#TVv z^uKCh)yk=iEiYSi+uiq}{`MtzUV9y^3S=e+ICT;#y^|*sjrG#()mwt6{F);dmk4>YdU^$6CSx@4BrRn zFDue)o)SHCe^gxuOemWUI6ZKB&!AcE+6kQB zj_>Dmau=Q86p`q&;j>4;s4xV~#{yY?XYjPqzsQjPYJWJ8mDzh*A27d81o^M}UKDuW zi{NPR+a=Fnu6vYcQwnxapG}$=0$RJ0`xm9m|B(%UJl1YQh0bqJK~)N5XfN!urJ$UO za;j&rrd{c?rLv2*v=IJEIt#MsLY~14x5=}~2p1Fb=|W4Yo7~l{o7qCg`c?tlUfo(# z$4XmT>l@ka)tlK8casB;#?7qMy#arz!z%IVvt#3W{2}d%8do#r%bVLZM1`Y911j-} zGTPqWEV3%Mqm7DpIcl3UsH)E0Do_hs>#3%)+U0H~Ahu*kAy%t79iP?8j*ZRPay68zf2^@rQiDy?x~wC>}jL}NI|3{NPj}=M|vIU zuSf$(XOYe$ed~9Ng{2{lMjD5tAQd1LBC*N2lPBSyczmnj6~q+{T+zT44P4Q{6%Aa` bz!eQ#(ZCfAT+zT44P4Q{6%G8qp@IJmWVyy~ diff --git a/SysCore/objects/KEYUS.O b/SysCore/objects/KEYUS.O index 068c97430af23b75988cd6a72394e6abd5302620..93d2898d255b58b9fbd68d2716791f7144fa7cc6 100644 GIT binary patch delta 25 hcmaE%{z84jbPk^8BOK9(C-iPnV_;y|yqLq48vu@Y35);$ delta 25 hcmaE%{z84jbPk>k3eOapk8ngE?k!QJ58cWrgdj}?JJ58Vl2gwb~Q4@&F-R1fT!_ diff --git a/SysCore/objects/MAIN.O b/SysCore/objects/MAIN.O index 6bb3cf0cb85e83b9d85de24d66f1545bec08595d..93f7425c3168f9bfd5a7b2e621ae703203a2e90b 100644 GIT binary patch literal 1172 zcmZ`%O=uHQ5S~q92`IX1)D$Y@(1Qvt#a7XJX(>_=qk(91sQTD;pV@79H=5nVp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xY-xSr#h0iz^P{%9dW*BT zcDK0BS>`HpmEs)jFyXJ3vQigJ>vh;-2DTP%hE)f*M~GjmX}x7y@0iv_)4FC_c1tdH zw`sMQR>ZX4FfG@Cu23hi;c*+jBnRoR)Dh}xbF~{7zAiq!;E$Ds_QIbzKC|S<;*$%= z0iXO@&RTqG0ReaSS#)B-=O_#PKrY<82jniPCulrk8q5dh8kqQyVIToHM0~md%_7;L z%X!3bq3{l2iEx?sHwQs$8mAjvzBqkwFK60$yR;m%-h`=NQEDCu8PK~Xg4cPN2@?qf0^ZvgQdwR0c?|B8Co-usPM*Az=`Ulzz!0CDlb@U&U!Izposw9|000MxK7s%M delta 336 zcmeC;+{4M~!^pw_0u2*6r8yfI85p(zIXfomDzlm}F)$pO80yWqWa2_ayX!#VV+;&k z0gO%^0gMg5tohrHfP@?vfnrQRF{XxJJp8Q-fnr?&91Xu1`CEIy@=QQA91}mpI6542 zU}5YEUAmfB>M;46lIr6A=FfVn(3L*@2iFhy{RH6o_SjSPh8vfY=;}(E-ru z4DLYe2gG4OoB+g`KwL06kx89#@#IdXzl@cW+nKlX8vwOB05LE`fY@QOFN>~FF++TE SPJVKBe0geWc1mJpF#`biEKe{1 diff --git a/SysCore/objects/link.ld b/SysCore/objects/link.ld index 8b991bb..503db94 100644 --- a/SysCore/objects/link.ld +++ b/SysCore/objects/link.ld @@ -6,6 +6,9 @@ INPUT("loader.o", "cmos.o", "conio.o", "cpu.o", + "ctype.o", + "dma.o", + "floppy.o", "gdt.o", "gdt_asm.o", "hal.o", @@ -23,12 +26,15 @@ INPUT("loader.o", "keyus.o", "pic.o", "pit.o", + "shell.o", + "stdlib.o", "string.o", "system.o", - "time.o" + "time.o", + "video/vga03h.o" ) OUTPUT(kernel.bin) -phys = 0x00100000; +phys = 0xC0000000; SECTIONS { .text phys : AT(phys) { diff --git a/SysCore/objects/mmngr_vi.o b/SysCore/objects/mmngr_vi.o index 9a66ec5bcd9f06ad275e9dccbb618e0d70893543..33f9063cfaa18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zH=Z0gh4tTLcW?KJXl1wPWOkt>kjo)e9@P?k=iJ`jUQ` z64!tuz&yJn*b~8C3icKZUki0D_)|cJeS|+9u^;d}`%|z#g7pO(2&O+Oc`hQdzaz$q z(zBv{>B?i>;o8L0l+g#GcFwcpgpndk`|vbZu_dPqO-Bu%)VN}LvgqCN;c0=EoGLm& zmQE&*5PV_G=m@%xv9kd6B33Sv45K`+q3>=0am@`x)VWwGAfi6TN)geUDJAMN6tX#H zIbJnzsyvL8SMXL2-OgsOW|_r5vgNE-1HUT5r|Y4^tX2HIh0>bq-?qylRdgve-bQu4 Zm)J= '0' && str[i] <= '9') digit = str[i] - '0'; - else if (str[i] >= 'A' && str[i] <= 'F') digit = str[i] - 'A' + 10; - else if (str[i] >= 'a' && str[i] <= 'f') digit = str[i] - 'a' + 10; - else break; - - temp = temp*16 + digit; - } - - return temp; -} - -unsigned int atoui(const char* str) -{ - unsigned int temp = 0; - int i; - - for (i = 0; str[i] >= '0' && str[i] <= '9' ; i++) - temp = temp*10 + (str[i] - '0'); - - return temp; -} - - - void apps_osver() { - printf ("CTA 32bit Operating System v0.1"); - printf ("\n(c) CTA 2010\n"); + cprintf ("%#0BC%#0CT%#0AA %#0F32bit Operating System v0.1\n\r"); + cprintf ("(c) CTA 2010\n\r"); } void apps_time() { - printf ("Today is %s, %u of %s, %u%u.\n", clock_weekdays[_internal_clock.weekday], - (unsigned int) _internal_clock.day, clock_months[_internal_clock.month], - (unsigned int) _internal_clock.century, (unsigned int) _internal_clock.year); - - printf ("Now is %u:%u:%u.\n", (unsigned int) _internal_clock.hours, - (unsigned int) _internal_clock.minutes, (unsigned int) _internal_clock.seconds); + TIME _internal_clock = i86_pit_get_time(); + cprintf ("Today is %#0F%s%#07, %#0F%u %#07of %#0F%s%#07, %#0F%u%u%#07.\n\r", clock_weekday[_internal_clock.weekday], + (unsigned) _internal_clock.day, clock_month[_internal_clock.month], + (unsigned) _internal_clock.century, (unsigned) _internal_clock.year); + cprintf ("%#07Now is %#0F%u%#87:%#0F%u%#87:%#0F%u%#07.\n\r", (unsigned) _internal_clock.hour, + (unsigned) _internal_clock.minute, (unsigned) _internal_clock.second); } void apps_place() { - printf ("On your desk, if you didn't notice... \n"); + cprintf ("%#0FOn your desk, %#07if you didn't notice... \n\r"); } void apps_clrscr() @@ -71,66 +42,112 @@ void apps_clrscr() clrscr(); } -void apps_memory(const int pn, const char* param[]) +void apps_dump(const int pn, const char* param[]) { if (pn<3) { - printf ("Correct syntax: memory [start_address] [end_address] (in hex)\n"); + cprintf ("%#0CCorrect syntax: %#07dump %#0F[start_address] %#0F[end_address] %#0C(in hex)\n\r"); return; } - byte *start, *end; - start = (byte *) atox (param[1]); - end = (byte *) atox (param[2]); - byte* count; + unsigned char *start, *end; + start = (unsigned char *) atox (param[1]); + end = (unsigned char *) atox (param[2]); + unsigned char* count; while (start <= end) { - put_hex ((unsigned int) start); puts(": "); + cprintf("%#0D%x%#07: ", (unsigned int) start); for (count = start; count < start+16; count++) { - putc(hex[*count/16]); putc(hex[*count%16]); - putc(' '); + if (*count == 0) cprintf ("%#0800 "); + else cprintf ("%#0F%c%c ", hex(*count/16), hex(*count%16)); } - puts(" "); + + cprintf(" "); for (count = start; count < start+16; count++) { - if (*count < 32) putc('.'); - else putc(*count); + if (*count < 32) cprintf("."); + else cprintf("%#0A%c", *count); } - putc('\n'); + cprintf("\n\r"); start+=16; } - - +} + +int apps_help_sort(const void* a, const void* b) +{ + return strcmp(apps_lst[*(short *)a], apps_lst[*(short *)b]); } void apps_help(const int pn, const char* param[]) { + short arr[apps_count]; int i; - puts ("\n"); + + for (i = 0; i < apps_count; i++) + arr[i] = i; + + qsort((void*)arr, apps_count, sizeof(short), apps_help_sort); + if (pn==1) { - puts("[BeTA]\n"); - puts("Available commands:"); - for (i = 1; i < apps_count; i++) { - puts("\n \t "); puts((char*)apps_lst[i]); - } - puts("\n\nUse help [command] for help on individual commands.\n"); + cprintf("%#0BC%#0CT%#0AA %#0FShell %#07commands:\n\r"); + for (i = 1; i < apps_count; i++) + cprintf("%#0F\t%c %s\n\r", 0x7 ,apps_lst[arr[i]]); + + cprintf("\n\rUse help %#0E[command]%#07 for help on individual commands.\n\r"); return; } for (i = 0; strcmp(apps_lst[i], param[1])!=0 && i +#include +#include +#include +#include "../memory/mmngr_ph.h" #include "apps.h" -void get_str(char *str, int len) -{ - kb_key alpha; - - int i; - for (i = 0; i0) { // Only backspace our string - if (--cursor_x < 0) { // Begin of row - 1 = End of previous row - cursor_x = 79; cursor_y--; - } - putc_pos(cursor_x, cursor_y, 0); - str[--i] = 0; - } - i--; break; - - case '\n': str[i]=0; putc('\n'); return; - - default: putc(alpha.character); - str[i] = alpha.character; - str[i+1] = 0; - break; - } - } -} - - void shell() { + apps_osver(); char str[256]; char* param[16]; int i, len, params=0; - //clrscr(); - - - for (;;) { - puts("\n] "); - get_str(str, 256); + cprintf("%#0A\n] "); + cgets(str, 256); + cprintf("\n\r"); - len = strlen(str); + len = strlen(str); - // Ignore spaces in front of command - i=0; params = 0; - while (str[i] == ' ') i++; - param[params] = str+i; params++; i++; // Parameter 0 = app itself + // Ignore spaces in front of command + i=0; params = 0; + while (str[i] == ' ') i++; + param[params] = str+i; params++; i++; // Parameter 0 = app itself - for (; i < len && params<16; i++) { - if (str[i] == ' ') str[i]=0; + for (; i < len && params<16; i++) { + if (str[i] == ' ') str[i]=0; - if (str[i] != 0 && str[i-1]==0) { - param[params] = str+i; params++; - } + if (str[i] != 0 && str[i-1]==0) { + param[params] = str+i; params++; + } } for (i = 0; strcmp(apps_lst[i], param[0])!=0 && i +#include + +RGBColor RGBColors_4bpp[] = {{0, 0, 0}, // 00 Black + {0, 0, 127}, // 01 Dark Blue + {0, 127, 0}, // 02 Dark Green + {0, 127, 127}, // 03 Dark Cyan + {127, 0, 0}, // 04 Dark Red + {127, 0, 127}, // 05 Dark Magenta + {127, 127, 0}, // 06 Dark Yellow + {192, 192, 192},// 07 Light Gray + {127, 127, 127},// 08 Dark Gray + {0, 0, 255}, // 09 Blue + {0, 255, 0}, // 10 Green + {0, 255, 255}, // 11 Cyan + {255, 0, 0}, // 12 Red + {255, 0, 255}, // 13 Magenta + {255, 255, 0}, // 14 Yellow + {255, 255, 255} // 15 White +}; + + +RGBColor Convert_1bpp_to_RGB(Color_1Bpp c) +{ + unsigned char t = (c) ? 0xFF : 0x00; + RGBColor temp = {t, t, t}; + return temp; +} + +RGBColor Convert_4bpp_to_RGB(Color_4Bpp c) +{ + return RGBColors_4bpp[c]; +} + +RGBColor Convert_6bpp_to_RGB(Color_6Bpp c) +{ + unsigned char R, G, B; + R = (unsigned char) ((unsigned)((c & 0x30)>>4) * 255 / 3 ); + G = (unsigned char) ((unsigned)((c & 0x0C)>>2) * 255 / 3 ); + B = (unsigned char) ((unsigned) (c & 0x03) * 255 / 3 ); + RGBColor ret = {R, G, B}; + return ret; +} + +RGBColor Convert_8bpp_to_RGB(Color_8Bpp c) +{ + unsigned char R, G, B; + R = (unsigned char) ((unsigned)((c & 0xE0)>>5) * 255 / 7 ); + G = (unsigned char) ((unsigned)((c & 0x1C)>>2) * 255 / 7 ); + B = (unsigned char) ((unsigned) (c & 0x03) * 255 / 3 ); + RGBColor ret = {R, G, B}; + return ret; +} + +RGBColor Convert_15bpp_to_RGB(Color_15Bpp c) +{ + unsigned char R, G, B; + R = (unsigned char) ((unsigned)((c & 0x7C00)>>10) * 255 / 31 ); + G = (unsigned char) ((unsigned)((c & 0x03E0)>>5) * 255 / 31 ); + B = (unsigned char) ((unsigned) (c & 0x001F) * 255 / 31 ); + RGBColor ret = {R, G, B}; + return ret; +} + +RGBColor Convert_16bpp_to_RGB(Color_16Bpp c) +{ + unsigned char R, G, B; + R = (unsigned char) ((unsigned)((c & 0xF800)>>11) * 255 / 31 ); + G = (unsigned char) ((unsigned)((c & 0x07E0)>>5) * 255 / 63 ); + B = (unsigned char) ((unsigned) (c & 0x001F) * 255 / 31 ); + RGBColor ret = {R, G, B}; + return ret; +} + +RGBColor Convert_18bpp_to_RGB(Color_18Bpp c) +{ + unsigned char R, G, B; + R = (unsigned char) ((unsigned)(c.R) * 255 / 0x3F ); + G = (unsigned char) ((unsigned)(c.G) * 255 / 0x3F); + B = (unsigned char) ((unsigned)(c.B) * 255 / 0x3F); + RGBColor ret = {R, G, B}; + return ret; +} + +RGBColor Convert_24bpp_to_RGB(Color_24Bpp c) +{ + return c; +} + + +Color_1Bpp Convert_RGB_to_1bpp(RGBColor c) +{ + if (((unsigned)c.R + (unsigned)c.G + (unsigned)c.B) / 3 >= 128) return 1; + return 0; +} + +Color_4Bpp Convert_RGB_to_4bpp(RGBColor c) +{ + int i; int minim = 0xFFFF; int index = 0; + int R, G, B; + + for (i = 0; i < 16; i++) + { + R = (int)(c.R) - (int)(RGBColors_4bpp[i].R); + G = (int)(c.G) - (int)(RGBColors_4bpp[i].G); + B = (int)(c.B) - (int)(RGBColors_4bpp[i].B); + + R = abs(R) + abs(G) + abs(B); + if (R <= minim) { + minim = R; index = i; + } + } + + return index; +} + +Color_6Bpp Convert_RGB_to_6bpp(RGBColor c) +{ + Color_6Bpp temp = 0; unsigned tmp; + tmp = (unsigned)(c.R) * 3 / 255; temp |= (tmp & 0x03) << 4; + tmp = (unsigned)(c.G) * 3 / 255; temp |= (tmp & 0x03) << 2; + tmp = (unsigned)(c.B) * 3 / 255; temp |= (tmp & 0x03); + return temp; +} + +Color_8Bpp Convert_RGB_to_8bpp(RGBColor c) +{ + Color_8Bpp temp = 0; unsigned tmp; + tmp = (unsigned)(c.R) * 7 / 255; temp |= (tmp & 0x07) << 5; + tmp = (unsigned)(c.G) * 7 / 255; temp |= (tmp & 0x07) << 2; + tmp = (unsigned)(c.B) * 3 / 255; temp |= (tmp & 0x03); + return temp; +} + +Color_15Bpp Convert_RGB_to_15bpp(RGBColor c) +{ + Color_15Bpp temp = 0; unsigned tmp; + tmp = (unsigned)(c.R) * 0x1F / 255; temp |= (tmp & 0x1F) << 10; + tmp = (unsigned)(c.G) * 0x1F / 255; temp |= (tmp & 0x1F) << 5; + tmp = (unsigned)(c.B) * 0x1F / 255; temp |= (tmp & 0x1F); + return temp; +} + +Color_16Bpp Convert_RGB_to_16bpp(RGBColor c) +{ + Color_16Bpp temp = 0; unsigned tmp; + tmp = (unsigned)(c.R) * 0x1F / 255; temp |= (tmp & 0x1F) << 11; + tmp = (unsigned)(c.G) * 0x3F / 255; temp |= (tmp & 0x3F) << 5; + tmp = (unsigned)(c.B) * 0x1F / 255; temp |= (tmp & 0x1F); + return temp; +} + +Color_18Bpp Convert_RGB_to_18bpp(RGBColor c) +{ + Color_18Bpp temp; unsigned tmp; + tmp = (unsigned)(c.R) * 0x3F / 255; temp.R = (unsigned char)tmp; + tmp = (unsigned)(c.G) * 0x3F / 255; temp.G = (unsigned char)tmp; + tmp = (unsigned)(c.B) * 0x3F / 255; temp.B = (unsigned char)tmp; + return temp; +} + +Color_24Bpp Convert_RGB_to_24bpp(RGBColor c) +{ + return c; +} diff --git a/SysCore/video/color/color.h b/SysCore/video/color/color.h new file mode 100644 index 0000000..f879fe3 --- /dev/null +++ b/SysCore/video/color/color.h @@ -0,0 +1,66 @@ +#ifndef __COLOR__H__ +#define __COLOR__H__ + +/**RGB color structure.*/ +typedef struct { + unsigned char R,G,B; +} RGBColor; + +/**\Monochrome (black and white)*/ +typedef bool Color_1Bpp; + +/**CGA 2 bits per pixel indexed color.\n\n\Notes: Cannot be converted to/from RGB.*/ +typedef unsigned char Color_2Bpp; + +/**16 color VGA. + * \n\n\Format: Uses 1-1-1 bit format, highest bit is intensity. + * \n\n\Notes: Unused bits are ignored (should be 0).*/ +typedef unsigned char Color_4Bpp; + +/**64 color EGA. + * \n\n\Format: Uses 2-2-2 bit format. + * \n\n\Notes: High 2 bits are ignored (should be 0).*/ +typedef unsigned char Color_6Bpp; + +/**256 color VGA. + * \n\n\Format: Uses 3-3-2 bit format + * \n\n\Notes: The palette must be changed before usable.*/ +typedef unsigned char Color_8Bpp; + +/**SVGA Highcolor palette. + * \n\n\Format: Uses 5-5-5 bit format. + * \n\n\Notes: Unused high bit is ignored (should be 0).*/ +typedef unsigned short Color_15Bpp; + +/**SVGA Highcolor palette. + * \n\n\Format: Uses 5-6-5 bit format.*/ +typedef unsigned short Color_16Bpp; + +/**VGA 18-bit RGB + * \n\n\Format: Uses the RGBColor structure, with the R, G and B components. + * \n\n\Notes: High 2 bits of each component are ignored, should be 0.*/ +typedef RGBColor Color_18Bpp; + +/**24-bit Truecolor + * \n\n\Format: Uses the RGBColor structure, with the R, G and B components.*/ +typedef RGBColor Color_24Bpp; + +/**Few functions to convert values from one format to another.*/ +extern RGBColor Convert_1bpp_to_RGB(Color_1Bpp c); +extern RGBColor Convert_4bpp_to_RGB(Color_4Bpp c); +extern RGBColor Convert_6bpp_to_RGB(Color_6Bpp c); +extern RGBColor Convert_8bpp_to_RGB(Color_8Bpp c); +extern RGBColor Convert_15bpp_to_RGB(Color_15Bpp c); +extern RGBColor Convert_16bpp_to_RGB(Color_16Bpp c); +extern RGBColor Convert_18bpp_to_RGB(Color_18Bpp c); +extern RGBColor Convert_24bpp_to_RGB(Color_24Bpp c); +extern Color_1Bpp Convert_RGB_to_1bpp(RGBColor c); +extern Color_4Bpp Convert_RGB_to_4bpp(RGBColor c); +extern Color_6Bpp Convert_RGB_to_6bpp(RGBColor c); +extern Color_8Bpp Convert_RGB_to_8bpp(RGBColor c); +extern Color_15Bpp Convert_RGB_to_15bpp(RGBColor c); +extern Color_16Bpp Convert_RGB_to_16bpp(RGBColor c); +extern Color_18Bpp Convert_RGB_to_18bpp(RGBColor c); +extern Color_24Bpp Convert_RGB_to_24bpp(RGBColor c); + +#endif \ No newline at end of file diff --git a/SysCore/video/compile.bat b/SysCore/video/compile.bat new file mode 100644 index 0000000..4de8cc5 --- /dev/null +++ b/SysCore/video/compile.bat @@ -0,0 +1,26 @@ +@echo off + +rem NASM and DJGPP executable paths: +set nasm_path=C:\nasm +set djgpp_path=C:\DJGPP\bin +set objpath=..\objects +set incpath=../include + +@echo Building Video Drivers... + +del %objpath%\video\vga03h.o + +goto build +:error + @echo. + @echo There have been build errors. Building halted. + @pause + exit + +:build + @echo * Compiling Text Mode 0x03 video driver ... + %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/video/vga03h.o vga03h.c + + +:check + if not exist %objpath%\video\vga03h.o goto error diff --git a/SysCore/video/vga.h b/SysCore/video/vga.h new file mode 100644 index 0000000..451a85a --- /dev/null +++ b/SysCore/video/vga.h @@ -0,0 +1,37 @@ +#ifndef __VGA__H__ +#define __VGA__H__ + +typedef struct { + enum MODE_TYPES { + TextMode = 0, + GraphicsMode = 1 + }; + /**Defines the mode returned by BIOS int 0x10, ah = 0xF*/ + unsigned char Mode; + /**Text mode or Graphic mode (defined in MODE_TYPES enumeration)*/ + unsigned char ModeType; + + /**Screen size (characters in text modes, pixels in graphic modes)*/ + unsigned Width, Height; + + /**Bits per pixel*/ + unsigned bpp; + + /**Pointer to a function that sets the cursor position*/ + void (*SetCursor) (int wherex, int wherey); + /**Pointer to a function that prints an ascii character in a specified position*/ + void (*PutChar) (int wherex, int wherey, unsigned char character); + /**Pointer to a function that returns the ascii character in the specified position*/ + unsigned char (*GetChar) (int wherex, int wherey); + + /**Pointer to a function which plots a pixel on the screen. Should be set NULL in text modes. + \nColor is a void pointer, to ensure compatibility with different colors.*/ + void (*PutPixel) (int wherex, int wherey, void* color); + + /**Pointer to a function which returns the color of a pixel on the screen. Should be set NULL in text modes. + \nReturn is a void pointer, to ensure compatibility with different colors.*/ + void* (*GetPixel) (int wherex, int wherey); + +} VideoMode; + +#endif \ No newline at end of file diff --git a/SysCore/video/vga03h.c b/SysCore/video/vga03h.c new file mode 100644 index 0000000..f7917cf --- /dev/null +++ b/SysCore/video/vga03h.c @@ -0,0 +1,30 @@ +//#include "vga.h" +#include +#include + +unsigned char* TextVideoRam = (unsigned char*)0xB8000; + +void vga03h_cursor(int x, int y) +{ + unsigned temp = y*80 + x; + + outportb (0x3D4, 14); + outportb (0x3D5, temp >> 8); + outportb (0x3D4, 15); + outportb (0x3D5, temp); +} + +void vga03h_putc (int x, int y, unsigned char c) { TextVideoRam[2*(y*80+x)] = c; } +unsigned char vga03h_getc (int x, int y) { return TextVideoRam[2*(y*80+x)]; } +void vga03h_putcolor (int x, int y, unsigned char c) { TextVideoRam[2*(y*80+x)+1] = c; } +unsigned char vga03h_getcolor (int x, int y) { return TextVideoRam[2*(y*80+x)+1]; } + +void vga03h_install() +{ + ConsoleScreen screen = { + 80, 25, 0x07, vga03h_cursor, vga03h_putc, vga03h_getc, + vga03h_putcolor, vga03h_getcolor}; + + ConsoleInstall (screen); + clrscr(); +} \ No newline at end of file diff --git a/SysCore/video/vga03h.h b/SysCore/video/vga03h.h new file mode 100644 index 0000000..c9a91b0 --- /dev/null +++ b/SysCore/video/vga03h.h @@ -0,0 +1,7 @@ +#ifndef __DEFAULT__TEXT__MODE__H__ +#define __DEFAULT__TEXT__MODE__H__ + +void vga03h_install(); + + +#endif \ No newline at end of file