diff --git a/#RESOURCES/Text Mode Color Table.png b/#RESOURCES/Text Mode Color Table.png
deleted file mode 100644
index 9d9f3bc..0000000
Binary files a/#RESOURCES/Text Mode Color Table.png and /dev/null differ
diff --git a/#RESOURCES/kb.txt b/#RESOURCES/kb.txt
deleted file mode 100644
index 3ed4e31..0000000
--- a/#RESOURCES/kb.txt
+++ /dev/null
@@ -1,635 +0,0 @@
-================================================================
-IBM PC KEYBOARD INFORMATION FOR SOFTWARE DEVELOPERS
-================================================================
-Your host: Chris Giese
-http://www.execpc.com/~geezer/os
-
-Distribute freely. Last revised on Jan 3, 2002
-Sources:
- PORTS.A of Ralf Brown's interrupt list collection
- repairfaq.org keyboard FAQ(doesn't appear to exsist)
- Linux source code
-Test hardware:
- New Samsung KB3T001SAXAA 104-key keyboard
- Old Maxi 2186035-00-21 101-key keyboard
-
-NO WARRANTY. NO GUARANTEE. I have tried to make this information
-accurate. I don't know if I succeeded. Corrections or additional
-information would be welcome.
-
-This is a plain-text document. If you use a word-processor to view
-it, use a fixed-pitch font (like Courier) so columnar data and
-ASCII art lines up properly.
-
-Lessons learned:
-- Both the 8048 MCU in the keyboard and the 8042 controller
- on the motherboard accept command bytes.
-- There is a bit (KCC) in the poorly-named "Command Byte" which
- seems to enable AT-to-XT scancode conversion (scancode set 2
- to scancode set 1). After booting DOS, my keyboard uses
- scancode set 2 with this conversion bit turned on. If I turn
- the bit off and switch to scancode set 1, operation remains
- the same.
-- Scancode set 3 is probably the most elegant, in that it returns
- a one-byte make code for _every_ key. Unfortunately, not all
- keyboards support it.
-- The scancodes of some keys depend on the internal num lock state
- of the keyboard.
-
-================================================================
-KEYBOARD I/O REGISTERS ON THE PC
-================================================================
-60h data
-64h command (write)
-64h Status (read)
-
-Bits in Status register (names from Linux source)
- b7 PERR parity error in data received from keyboard
- b6 GTO receive timeout
- b5 transmit timeout (or PS/2 mouse?)
- b4 keyboard is locked
- b3 0=60h was the port last accessed, 1=61h was last (?)
- b2 System Flag status: 0=power-up/reset, 1=selftest OK (?)
- b1 IBF input buffer full (data from host to keyboard)
- b0 OBF output buffer full (data from keyboard to host)
-
-Bits in Output Port of 8042 chip (Table P0383 in PORTS.A)
-The Output Port is written by controller command D1h,
-and read by controller command D0h
- b7 keyboard data output
- b6 keyboard clock output
- b5 input buffer NOT full
- b4 output buffer NOT empty
- b3 (varies)
- b2 (varies)
- b1 A20 gate
- b0 system reset (THIS BIT SHOULD ALWAYS BE SET TO 1)
-
-Bits in Input Port of 8042 chip
-The Input Port is read by controller command C0h
- b7 keyboard NOT locked
- b6-b0 (varies)
-
-Bits in "Command Byte" (confusing name; from Table P0404 in PORTS.A)
-The "Command Byte" is written by controller command 60h
-and read by controller command 20h
-(names from Linux source)
- b7 (reserved)
- b6 KCC convert set 2 scancodes to set 1 ("IBM PC compatibility mode")
- b5 DMS disables PS/2 mouse when set
- b4 disables keyboard when set
- b3 ignore keyboard lock switch when set
- b2 SYS System Flag (same as b2 in Status register, it seems)
- b1 enables IRQ12 from PS/2 mouse when set
- b0 EKI enables IRQ1 on keyboard output buffer full
-
-Result Byte for interface self-tests (Table P0406 in PORTS.A)
-Returned by controller commands A9h or ABh
- 0 no error
- 1 clock line stuck low
- 2 clock line stuck high
- 3 data line stuck low
- 4 data line stuck high
-
-================================================================
-CONTROLLER COMMANDS (from Table P0401 of PORTS.A)
-================================================================
-Before writing each byte of these commands to port 64h,
-poll the status register (port 60h) until bit b1=0.
-
-20h-2Fh reads byte with address=lower 5 bits of command
- The byte at address 0 is the "Command Byte".
-60h-7Fh nn writes byte nn to address=lower 5 bits of command
- The byte at address 0 is the "Command Byte".
-A7h disables PS/2 mouse port (MCA only?)
-A8h enables PS/2 mouse port (MCA only?)
-A9h self-test mouse interface, returns Result Byte (see above)
-AAh self-test controller; returns 55h if success, FCh if failure
-ABh self-test keyboard interface, returns Result Byte (see above)
-ADh disables keyboard (sets b4 of "Command Byte")
-AEh enables keyboard (clears b4 of "Command Byte")
-C0h reads Input Port
-D0h reads Output Port
-D1h nn writes Output Port
- Important: bit 0 (system reset) should always be set here,
- as the system may hang constantly. To reset the PC, pulse
- b0 of the Output Port with command FEh instead.
-DDh disable A20 (Not all systems support this byte)
-DFh enable A20 (Not all systems support this byte)
-E0h read test inputs. return value=
- b1 kbd data
- b0 kbd clock
-EDh nn write LEDs. nn=
- b2 Caps Lock
- b1 Num Lock
- b0 Scroll Lock
-F0h-FFh pulse bit(s) of Output Port low for 6 microseconds.
- If b0-b3 of the command is low, the corresponding bit
- in the Output Port will be pulsed low. b0=system reset,
- and should ALWAYS be PULSED low, never set low constantly.
-
-================================================================
-KEYBOARD COMMANDS (from Table P0386 of PORTS.A)
-================================================================
-Before writing each byte of these commands to port 60h,
-poll the status register (port 60h) until bit b1=0.
-Unless otherwise noted: each command responds with FAh (ACKnowledge)
-or FEh (Resend) after receiving each byte of the command.
-
-EDh nn write LEDs, as above
-EEh echo, keyboard responds with EEh
-EFh no-operation (reserved)
-F0h nn selects scancode set nn=1-3 or 0 to return current set
-F2h read ID. Keyboard responds with ACK (FAh) and two optional
- ID bytes:
- (none) AT keyboard
- 83h ABh (?)
- ABh 41h MF2, translation mode
- ABh 83h MF2, pass-through mode
-F3h nn set typematic (auto-repeat) rate/delay. nn=
- b7 unused
- b6..5 Repeat delay (00=250 msec ... 11=1000msec)
- b4..0 Repeat rate (00000=30 Hz ... 11111=2 Hz).
-F4h clears output buffer, enables keyboard
-F5h disables keyboard, resets to defaults
-F6h sets keyboard defaults
-
-F7h make all keys typematic (auto-repeat) [*]
-F8h make all keys make-break [*]
-F9h make all keys make-only [*]
-FAh make all keys typematic and make-break [*]
-FBh nn make one key typematic [*]
-FCh nn make one key make-break [*]
-FDh nn make one key make-only [*]
- [*] these commands may work only for
- scancode set 3; I'm not sure.
-FEh resend previous scan code
-FFh reset keyboard CPU, do power-on self-test, return
- self-test result byte
-
-non-key status bytes
---------------------
-00h Key detection error or buffer full.
-AAh Power-on/reset diagnostics successful.
-E0h (scancode sets 1 and 2) Prefix byte for "gray" keys
- (keys not on original 83-/84-key keyboard)
-EEh Sent in response to ECHO command.
-F0h (scancode sets 2 and 3) Prefix byte for break codes.
-FAh ACKknowledge; response to most commands.
-FCh Diagnostics failed (MF keyboard).
-FDh Diagnostics failed (AT keyboard).
- The keyboard stops scanning and waits for next command
- after returning code FCh or FDh
-FEh Last command was invalid or had parity error; resend it.
-FFh Key detection error or buffer full.
-
-====================================================================
-SCANCODES FOR SCANCODE SET 1 (XT)
-====================================================================
-US 104-key keyboard, set 1 scancodes
-
-
-"Make" code is generated when key is pressed.
-"Break" code is generated when key is released.
-Hex value of make code for each key is shown.
-
-Most keys:
- one-byte make code = nn
- one-byte repeat code = nn
- one-byte break code = 80h + nn
-
-"Gray" keys (not on original 84-key keyboard):
- two-byte make code = E0nn
- two-byte repeat code = E0nn
- two-byte break code = E0 followed by 80h + nn
-
-"Gray" keys noted by [1] are NumLock-sensitive.
-When the keyboard's internal NumLock is active:
- four-byte make code = E02AE0nn
- two-byte repeat code = E0nn
- four-byte break code = E0 followed by 80h + nn followed by E0AA
-
- ____ ___________________ ___________________ ___________________
-| | | | | | | | | | | | | | | | |
-|Esc | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10 |F11 |F12 |
-| | | | | | | | | | | | | | | | |
-| 01| | 3B| 3C| 3D| 3E| | 3F| 40| 41| 42| | 43| 44| 57| 58|
-|____| |____|____|____|____| |____|____|____|____| |____|____|____|____|
-
- __________________________________________________________________________
-| | | | | | | | | | | | | | | |
-|~ |! |@ |# |$ |% |^ |& |* |( |) |_ |+ || |bksp|
-|` |1 |2 |3 |4 |5 |6 |7 |8 |9 |0 |- |= |\ | |
-| 29| 02| 03| 04| 05| 06| 07| 08| 09| 0A| 0B| 0C| 0D| 2B| 0E|
-|____|____|____|____|____|____|____|____|____|____|____|____|____|____|____|
-| | | | | | | | | | | | | | |
-|Tab |Q |W |E |R |T |Y |U |I |O |P |{ |} | |
-| | | | | | | | | | | |[ |] | |
-| 0F| 10| 11| 12| 13| 14| 15| 16| 17| 18| 19| 1A| 1B| |
-|____|____|____|____|____|____|____|____|____|____|____|____|____| |
-| | | | | | | | | | | | | |
-|Caps|A |S |D |F |G |H |J |K |L |: |" | Enter |
-| | | | | | | | | | |; |' | |
-| 3A| 1E| 1F| 20| 21| 22| 23| 24| 25| 26| 27| 28| 1C|
-|____|____|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | | | | | |
-| L Shift |Z |X |C |V |B |N |M |< |> |? | R Shift |
-| | | | | | | | |, |. |/ | |
-| 2A| 2C| 2D| 2E| 2F| 30| 31| 32| 33| 34| 35| 36|
-|_________|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | |
-|L Ctrl | L win | L Alt | space | R Alt | R win | menu |R Ctrl |
-| |[1] | | | |[1] |[1] | |
-| 1D| E05B| 38| 39| E038| E05C| E05D| E01D|
-|_______|_______|_______|__________________|_______|_______|_______|_______|
-
-
-[2] For PrintScreen/SysRq key: make code = E02AE037,
-repeat code = E037, break code = E0B7E0AA
-
-[3] The Pause/Break key does not repeat, and it does not
-generate a break code. Its make code is E11D45E19DC5
-
- ____ ____ ____
-| | | |
-|Prt |Scrl|Paus|
-|Scrn|Lock|Brk |
-| [2]| 46| [3]|
-|____|____|____|
-
- ____ ____ ____ ____ ____ ____ ____
-| | | | | | | | |
-|Ins |Home|PgUp| |Num |/ |* |- |
-|[1] |[1] |[1] | |Lock| | | |
-|E052|E047|E049| | 45|E035| 37| 4A|
-|____|____|____| |____|____|____|____|
-| | | | | | | | |
-|Del |End |PgDn| |7 |8 |9 | |
-|[1] |[1] |[1] | |Home|(U) |PgUp| |
-|E053|E04F|E051| | 47| 48| 49| |
-|____|____|____| |____|____|____| |
- | | | |+ |
- |4 |5 |6 | |
- |(L) | |(R) | |
- | 4B| 4C| 4D| 4E|
- ____ |____|____|____|____|
- | | | | | | |
- |(U) | |1 |2 |3 | |
- |[1] | |End |(D) |PgDn| |
- |E048| | 4F| 50| 51|Ent |
- ____|____|____ |____|____|____| |
-| | | | | | | |
-|(L) |(D) |(R) | |0 |. | |
-|[1] |[1] |[1] | |Ins |Del | |
-|E04B|E050|E04D| | 52| 53|E01C|
-|____|____|____| |_________|____|____|
-
-
-code key code key code key code key
----- --- ---- --- ---- --- ---- ---
-01 Esc 0F Tab 1D L Ctrl 2B \|
-02 1! 10 Q 1E A 2C Z
-03 2" 11 W 1F S 2D X
-04 3# 12 E 20 D 2E C
-05 4$ 13 R 21 F 2F V
-06 5% 14 T 22 G 30 B
-07 6^ 15 Y 23 H 31 N
-08 7& 16 U 24 J 32 M
-09 8* 17 I 25 K 33 ,<
-0A 9( 18 O 26 L 34 .>
-0B 0) 19 P 27 ;: 35 /?
-0C -_ 1A [{ 28 '" 36 R Shift
-0D =+ 1B ]} 29 `~ 37 *
-0E BackSpace 1C Enter 2A L Shift 38 L Alt
-
-code key code key code key code key
----- --- ---- --- ---- --- ---- ---
-39 Space 41 F7 49 PageUp 9 51 PageDown 3
-3A CapsLock 42 F8 4A - 52 Insert 0
-3B F1 43 F9 4B (left) 4 53 Del .
-3C F2 44 F10 4C 5
-3D F3 45 NumLock 4D (right) 6 57 F11
-3E F4 46 ScrollLock 4E + 58 F12
-3F F5 47 Home 7 4F End 1
-40 F6 48 (up) 8 50 (down) 2
-
-
-
-code key
----- ---
-E01C Enter (on numeric keypad)
-E01D R Ctrl
-E02A make code prefix for keyboard internal numlock
-E02AE037 PrintScreen make code
-E035 /
-E037 PrintScreen repeat code
-E038 R Alt
-E047 Home
-E048 (up)
-E049 PageUp
-E04B (left)
-E04D (right)
-E04F End
-E050 (down)
-E051 PageDown
-E052 Insert
-E053 Del
-E05B L Win
-E05C R Win
-E05D Menu
-E0AA break code suffix for keyboard internal numlock
-E0B7E0AA PrintScreen break code
-E11D45E19DC5 Pause
-
-====================================================================
-SCANCODES FOR SCANCODE SET 2 (AT)
-====================================================================
-US 104-key keyboard, set 2 scancodes,
-8042 AT-to-XT scancode translation OFF
-
-"Make" code is generated when key is pressed.
-"Break" code is generated when key is released.
-Hex value of make code for each key is shown.
-
-Most keys:
- one-byte make code = nn
- one-byte repeat code = nn
- two-byte break code = F0nn
-
-"Gray" keys (not on original 84-key keyboard):
- two-byte make code = E0nn
- two-byte repeat code = E0nn
- three-byte break code = E0F0nn
-
-"Gray" keys noted by [1] are NumLock-sensitive.
-When the keyboard's internal NumLock is active:
- four-byte make code = E012E0nn
- two-byte repeat code = E0nn
- six-byte break code = E0F0nnE0F012
-
- ____ ___________________ ___________________ ___________________
-| | | | | | | | | | | | | | | | |
-|Esc | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10 |F11 |F12 |
-| | | | | | | | | | | | | | | | |
-| 76| | 05| 06| 04| 0C| | 03| 0B| 83| 0A| | 01| 09| 78| 07|
-|____| |____|____|____|____| |____|____|____|____| |____|____|____|____|
-
- __________________________________________________________________________
-| | | | | | | | | | | | | | | |
-|~ |! |@ |# |$ |% |^ |& |* |( |) |_ |+ || |bksp|
-|` |1 |2 |3 |4 |5 |6 |7 |8 |9 |0 |- |= |\ | |
-| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5D| 66|
-|____|____|____|____|____|____|____|____|____|____|____|____|____|____|____|
-| | | | | | | | | | | | | | |
-|Tab |Q |W |E |R |T |Y |U |I |O |P |{ |} | |
-| | | | | | | | | | | |[ |] | |
-| 0D| 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| |
-|____|____|____|____|____|____|____|____|____|____|____|____|____| |
-| | | | | | | | | | | | | |
-|Caps|A |S |D |F |G |H |J |K |L |: |" | Enter |
-| | | | | | | | | | |; |' | |
-| 58| 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 5A|
-|____|____|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | | | | | |
-| L Shift |Z |X |C |V |B |N |M |< |> |? | R Shift |
-| | | | | | | | |, |. |/ | |
-| 12| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 59|
-|_________|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | |
-|L Ctrl | L win | L Alt | space | R Alt | R win | menu |R Ctrl |
-| |[1] | | | |[1] |[1] | |
-| 14| E01F| 11| 29| E011| E027| E02F| E014|
-|_______|_______|_______|__________________|_______|_______|_______|_______|
-
-
-[2] For PrintScreen/SysRq key: make code = E012E07C,
-repeat code = E07C, break code = E0F07CE0F012
-
-[3] The Pause/Break key does not repeat, and it does not
-generate a break code. Its make code is E11477E1F014F077
-
- ____ ____ ____
-| | | |
-|Prt |Scrl|Paus|
-|Scrn|Lock|Brk |
-| [2]| 7E| [3]|
-|____|____|____|
-
- ____ ____ ____ ____ ____ ____ ____
-| | | | | | | | |
-|Ins |Home|PgUp| |Num |/ |* |- |
-|[1] |[1] |[1] | |Lock| | | |
-|E070|E06C|E07D| | 77|E04A| 7C| 7B|
-|____|____|____| |____|____|____|____|
-| | | | | | | | |
-|Del |End |PgDn| |7 |8 |9 | |
-|[1] |[1] |[1] | |Home|(U) |PgUp| |
-|E071|E069|E07A| | 6C| 75| 7D| |
-|____|____|____| |____|____|____| |
- | | | |+ |
- |4 |5 |6 | |
- |(L) | |(R) | |
- | 6B| 73| 74| 79|
- ____ |____|____|____|____|
- | | | | | | |
- |(U) | |1 |2 |3 | |
- |[1] | |End |(D) |PgDn| |
- |E075| | 69| 72| 7A|Ent |
- ____|____|____ |____|____|____| |
-| | | | | | | |
-|(L) |(D) |(R) | |0 |. | |
-|[1] |[1] |[1] | |Ins |Del | |
-|E06B|E072|E074| | 70| 71|E05A|
-|____|____|____| |_________|____|____|
-
-
-code key code key code key code key
----- --- ---- --- ---- --- ---- ---
-01 F9 66 BackSpace
- 21 C 41 ,<
-03 F5 22 X 42 K 69 End 1
-04 F3 23 D 43 I
-05 F1 24 E 44 O 6B (left) 4
-06 F2 25 4$ 45 0) 6C Home 7
-07 F12 26 3# 46 9(
- 70 Ins 0
-09 F10 29 Space 49 .> 71 Del .
-0A F8 2A V 4A /? 72 (down) 2
-0B F6 2B F 4B L 73 5
-0C F4 2C T 4C ;: 74 (right) 6
-0D Tab 2D R 4D P 75 (up) 8
-0E `~ 2E 5% 4E -_ 76 Esc
- 77 NumLock
-11 L Alt 31 N 52 '" 78 F11
-12 L Shift 32 B 79 +
- 33 H 54 [{ 7A PageDown 3
-14 L Ctrl 34 G 55 =+ 7B -
-15 Q 35 Y 7C *
-16 1! 36 6^ 58 CapsLock 7D PageUp 9
- 59 R Shift 7E ScrollLock
-1A Z 3A M 5A Enter
-1B S 3B J 5B ]} 83 F7
-1C A 3C U
-1D W 3D 7& 5D \|
-1E 2@ 3E 8*
-
-code key
----- ---
-E011 R Alt
-E012E07C PrintScreen make code
-E014 R Ctrl
-E01F L Win
-E027 R Win
-E02F Menu
-E04A /
-E05A Enter (on numeric keypad)
-E069 End
-E06B Left
-E06C Home
-E070 Ins
-E071 Del
-E072 (down)
-E074 (right)
-E075 (up)
-E07A PageDown
-E07C PrintScreen repeat code
-E07D PageUp
-E0F07CE0F012 PrintScreen break code
-E11477E1F014F077 Pause
-
-====================================================================
-SCANCODES FOR SCANCODE SET 3
-====================================================================
-US 104-key keyboard, set 3 scancodes
-
-
-"Make" code is generated when key is pressed.
-"Break" code is generated when key is released.
-Hex value of make code for each key is shown.
-
-All keys:
- one-byte make code = nn
- one-byte repeat code = nn
- two-byte break code = F0nn
-
-When operating in scancode set 3, the keyboard
-does not maintain an internal NumLock state.
-
-
-
-
-
-
-
-
-
- ____ ___________________ ___________________ ___________________
-| | | | | | | | | | | | | | | | |
-|Esc | |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10 |F11 |F12 |
-| | | | | | | | | | | | | | | | |
-| 08| | 07| 0F| 17| 1F| | 27| 2F| 37| 3F| | 47| 4F| 56| 5E|
-|____| |____|____|____|____| |____|____|____|____| |____|____|____|____|
-
- __________________________________________________________________________
-| | | | | | | | | | | | | | | |
-|~ |! |@ |# |$ |% |^ |& |* |( |) |_ |+ || |bksp|
-|` |1 |2 |3 |4 |5 |6 |7 |8 |9 |0 |- |= |\ | |
-| 0E| 16| 1E| 26| 25| 2E| 36| 3D| 3E| 46| 45| 4E| 55| 5C| 66|
-|____|____|____|____|____|____|____|____|____|____|____|____|____|____|____|
-| | | | | | | | | | | | | | |
-|Tab |Q |W |E |R |T |Y |U |I |O |P |{ |} | |
-| | | | | | | | | | | |[ |] | |
-| 0D| 15| 1D| 24| 2D| 2C| 35| 3C| 43| 44| 4D| 54| 5B| |
-|____|____|____|____|____|____|____|____|____|____|____|____|____| |
-| | | | | | | | | | | | | |
-|Caps|A |S |D |F |G |H |J |K |L |: |" | Enter |
-| | | | | | | | | | |; |' | |
-| 14| 1C| 1B| 23| 2B| 34| 33| 3B| 42| 4B| 4C| 52| 5A|
-|____|____|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | | | | | |
-| L Shift |Z |X |C |V |B |N |M |< |> |? | R Shift |
-| | | | | | | | |, |. |/ | |
-| 12| 1A| 22| 21| 2A| 32| 31| 3A| 41| 49| 4A| 59|
-|_________|____|____|____|____|____|____|____|____|____|____|______________|
-| | | | | | | | |
-|L Ctrl | L win | L Alt | space | R Alt | R win | menu |R Ctrl |
-| | | | | | | | |
-| 11| 8B| 19| 29| 39| 8C| 8D| 58|
-|_______|_______|_______|__________________|_______|_______|_______|_______|
-
-
-
-
-
-
-
-
- ____ ____ ____
-| | | |
-|Prt |Scrl|Paus|
-|Scrn|Lock|Brk |
-| 57| 5F| 62|
-|____|____|____|
-
- ____ ____ ____ ____ ____ ____ ____
-| | | | | | | | |
-|Ins |Home|PgUp| |Num |/ |* |- |
-| | | | |Lock| | | |
-| 67| 6E| 6F| | 76| 77| 7E| 84|
-|____|____|____| |____|____|____|____|
-| | | | | | | | |
-|Del |End |PgDn| |7 |8 |9 | |
-| | | | |Home|(U) |PgUp| |
-| 64| 65| 6D| | 6C| 75| 7D| |
-|____|____|____| |____|____|____| |
- | | | |+ |
- |4 |5 |6 | |
- |(L) | |(R) | |
- | 6B| 73| 74| 7C|
- ____ |____|____|____|____|
- | | | | | | |
- |(U) | |1 |2 |3 | |
- | | |End |(D) |PgDn| |
- | 63| | 69| 72| 7A|Ent |
- ____|____|____ |____|____|____| |
-| | | | | | | |
-|(L) |(D) |(R) | |0 |. | |
-| | | | |Ins |Del | |
-| 61| 60| 6A| | 70| 71| 79|
-|____|____|____| |_________|____|____|
-
-
-code key code key code key code key
----- --- ---- --- ---- --- ---- ---
-07 F1 2A V 4A /? 6B (left) 4
-08 Esc 2B F 4B L 6C Home 7
- 2C T 4C ;: 6D PageDown
-0D Tab 2D R 4D P 6E Home
-0E `~ 2E 5% 4E -_ 6F PageUp
-0F F2 2F F6 4F F10 70 Ins 0
- 71 Del .
-11 L Ctrl 31 N 52 '" 72 (down) 2
-12 L Shift 32 B 73 5
- 33 H 54 [{ 74 (right) 6
-14 CapsLock 34 G 55 =+ 75 (up) 8
-15 Q 35 Y 56 F11 76 NumLock
-16 1! 36 6^ 57 PrintScr 77 /
-17 F3 37 F7 58 R Ctrl
- 59 R Shift 79 Enter (on numeric keypad)
-19 L Alt 39 R Alt 5A Enter 7A PageDown 3
-1A Z 3A M 5B ]}
-1B S 3B J 5C \| 7C +
-1C A 3C U 7D PageUp 9
-1D W 3D 7& 5E F12 7E *
-1E 2@ 3E 8* 5F ScrollLock
-1F F4 3F F8 60 (down) 84 -
- 61 (left)
-21 C 41 ,< 62 Pause 8B L Win
-22 X 42 K 63 (up) 8C R Win
-23 D 43 I 64 Del 8D Menu
-24 E 44 O 65 End
-25 4$ 45 0) 66 BackSpace
-26 3# 46 9( 67 Ins
-27 F5 47 F9
- 69 End 1
-29 Space 49 .> 6A (right)
diff --git a/#RESOURCES/kbgiud11.zip b/#RESOURCES/kbgiud11.zip
deleted file mode 100644
index 92e9ddb..0000000
Binary files a/#RESOURCES/kbgiud11.zip and /dev/null differ
diff --git a/#RESOURCES/vfd21-080206.zip b/#RESOURCES/vfd21-080206.zip
deleted file mode 100644
index 263adf8..0000000
Binary files a/#RESOURCES/vfd21-080206.zip and /dev/null differ
diff --git a/.cproject b/.cproject
new file mode 100644
index 0000000..8d7bfa2
--- /dev/null
+++ b/.cproject
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.directory b/.directory
new file mode 100644
index 0000000..47f8216
--- /dev/null
+++ b/.directory
@@ -0,0 +1,4 @@
+[Dolphin]
+Timestamp=2011,8,29,9,19,19
+Version=2
+ViewMode=2
diff --git a/.project b/.project
new file mode 100644
index 0000000..5d4ed63
--- /dev/null
+++ b/.project
@@ -0,0 +1,78 @@
+
+
+ lux
+
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.genmakebuilder
+ clean,full,incremental,
+
+
+ ?name?
+
+
+
+ org.eclipse.cdt.make.core.append_environment
+ true
+
+
+ org.eclipse.cdt.make.core.autoBuildTarget
+ all
+
+
+ org.eclipse.cdt.make.core.buildArguments
+
+
+
+ org.eclipse.cdt.make.core.buildCommand
+ C:\Dev\lux\scripts\build.bat
+
+
+ org.eclipse.cdt.make.core.cleanBuildTarget
+ clean
+
+
+ org.eclipse.cdt.make.core.contents
+ org.eclipse.cdt.make.core.activeConfigSettings
+
+
+ org.eclipse.cdt.make.core.enableAutoBuild
+ false
+
+
+ org.eclipse.cdt.make.core.enableCleanBuild
+ true
+
+
+ org.eclipse.cdt.make.core.enableFullBuild
+ true
+
+
+ org.eclipse.cdt.make.core.fullBuildTarget
+ all
+
+
+ org.eclipse.cdt.make.core.stopOnError
+ true
+
+
+ org.eclipse.cdt.make.core.useDefaultBuildCmd
+ false
+
+
+
+
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder
+ full,incremental,
+
+
+
+
+
+ org.eclipse.cdt.core.cnature
+ org.eclipse.cdt.managedbuilder.core.managedBuildNature
+ org.eclipse.cdt.managedbuilder.core.ScannerConfigNature
+
+
diff --git a/.settings/org.eclipse.cdt.codan.core.prefs b/.settings/org.eclipse.cdt.codan.core.prefs
new file mode 100644
index 0000000..7031730
--- /dev/null
+++ b/.settings/org.eclipse.cdt.codan.core.prefs
@@ -0,0 +1,66 @@
+#Mon Aug 15 18:15:44 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.cdt.codan.checkers.errnoreturn=Warning
+org.eclipse.cdt.codan.checkers.errnoreturn.params={implicit\=>false}
+org.eclipse.cdt.codan.checkers.errreturnvalue=Error
+org.eclipse.cdt.codan.checkers.errreturnvalue.params={}
+org.eclipse.cdt.codan.checkers.noreturn=Error
+org.eclipse.cdt.codan.checkers.noreturn.params={implicit\=>false}
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation=Error
+org.eclipse.cdt.codan.internal.checkers.AbstractClassCreation.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem=Error
+org.eclipse.cdt.codan.internal.checkers.AmbiguousProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.AssignmentInConditionProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem=Error
+org.eclipse.cdt.codan.internal.checkers.AssignmentToItselfProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.CaseBreakProblem.params={no_break_comment\=>"no break",last_case_param\=>true,empty_case_param\=>false}
+org.eclipse.cdt.codan.internal.checkers.CatchByReference=Warning
+org.eclipse.cdt.codan.internal.checkers.CatchByReference.params={unknown\=>false,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem=Error
+org.eclipse.cdt.codan.internal.checkers.CircularReferenceProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.FieldResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.FunctionResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidArguments=Error
+org.eclipse.cdt.codan.internal.checkers.InvalidArguments.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem=Error
+org.eclipse.cdt.codan.internal.checkers.InvalidTemplateArgumentsProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem=Error
+org.eclipse.cdt.codan.internal.checkers.LabelStatementNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem=Error
+org.eclipse.cdt.codan.internal.checkers.MemberDeclarationNotFoundProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.MethodResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker=-Info
+org.eclipse.cdt.codan.internal.checkers.NamingConventionFunctionChecker.params={pattern\=>"^[a-z]",macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.NonVirtualDestructorProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.OverloadProblem=Error
+org.eclipse.cdt.codan.internal.checkers.OverloadProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem=Error
+org.eclipse.cdt.codan.internal.checkers.RedeclarationProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.RedefinitionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem=-Warning
+org.eclipse.cdt.codan.internal.checkers.ReturnStyleProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem=-Warning
+org.eclipse.cdt.codan.internal.checkers.ScanfFormatStringSecurityProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.StatementHasNoEffectProblem.params={macro\=>true,exceptions\=>()}
+org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.SuggestedParenthesisProblem.params={paramNot\=>false}
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.SuspiciousSemicolonProblem.params={else\=>false,afterelse\=>false}
+org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.TypeResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem.params={}
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem=Warning
+org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem.params={exceptions\=>("@(\#)","$Id")}
+org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem=Error
+org.eclipse.cdt.codan.internal.checkers.VariableResolutionProblem.params={launchModes\=>{RUN_ON_FULL_BUILD\=>false,RUN_ON_INC_BUILD\=>false,RUN_AS_YOU_TYPE\=>true,RUN_ON_DEMAND\=>true}}
diff --git a/.settings/org.eclipse.ltk.core.refactoring.prefs b/.settings/org.eclipse.ltk.core.refactoring.prefs
new file mode 100644
index 0000000..a12030a
--- /dev/null
+++ b/.settings/org.eclipse.ltk.core.refactoring.prefs
@@ -0,0 +1,3 @@
+#Tue Aug 16 15:19:43 EEST 2011
+eclipse.preferences.version=1
+org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
diff --git a/Build/bootload.bin b/Build/bootload.bin
deleted file mode 100644
index a1ea468..0000000
Binary files a/Build/bootload.bin and /dev/null differ
diff --git a/Build/lib-conio.o b/Build/lib-conio.o
deleted file mode 100644
index 8e403c2..0000000
Binary files a/Build/lib-conio.o and /dev/null differ
diff --git a/Build/lib-ctype.o b/Build/lib-ctype.o
deleted file mode 100644
index a09ec32..0000000
Binary files a/Build/lib-ctype.o and /dev/null differ
diff --git a/Build/loader.o b/Build/loader.o
index f9ab807..b125264 100644
Binary files a/Build/loader.o and b/Build/loader.o differ
diff --git a/Build/main.o b/Build/main.o
index 183423c..596f6bd 100644
Binary files a/Build/main.o and b/Build/main.o differ
diff --git a/Build/mmngr-asm.o b/Build/mmngr-asm.o
deleted file mode 100644
index bc7bef7..0000000
Binary files a/Build/mmngr-asm.o and /dev/null differ
diff --git a/Build/mmngr-lib-pde.o b/Build/mmngr-lib-pde.o
deleted file mode 100644
index 22f9618..0000000
Binary files a/Build/mmngr-lib-pde.o and /dev/null differ
diff --git a/Build/mmngr-lib-pte.o b/Build/mmngr-lib-pte.o
deleted file mode 100644
index d516b2f..0000000
Binary files a/Build/mmngr-lib-pte.o and /dev/null differ
diff --git a/Build/mmngr-phys.o b/Build/mmngr-phys.o
deleted file mode 100644
index 0b8d7cb..0000000
Binary files a/Build/mmngr-phys.o and /dev/null differ
diff --git a/Build/mmngr-virt.o b/Build/mmngr-virt.o
deleted file mode 100644
index 134b7d8..0000000
Binary files a/Build/mmngr-virt.o and /dev/null differ
diff --git a/Build/stage2.cta b/Build/stage2.cta
deleted file mode 100644
index 1a688e1..0000000
Binary files a/Build/stage2.cta and /dev/null differ
diff --git a/FONT.TXT b/FONT.TXT
deleted file mode 100644
index 6799ab6..0000000
--- a/FONT.TXT
+++ /dev/null
@@ -1,955 +0,0 @@
-1 8 0 0 0 0 0 0 0 0
-1 8 0 0 0 0 0 0 0 -1
-1 8 0 0 0 0 0 0 0 -2
-1 8 0 0 0 0 0 0 0 -3
-1 8 0 0 0 0 0 0 0 -4
-1 8 0 0 0 0 0 0 0 -5
-1 8 0 0 0 0 0 0 0 -6
-1 8 0 0 0 0 0 0 0 -7
-1 8 0 0 0 0 0 0 0 -8
-1 8 0 0 0 0 0 0 0 -9
-1 8 0 0 0 0 0 0 0 -10
-1 8 0 0 0 0 0 0 0 -11
-1 8 0 0 0 0 0 0 0 -12
-1 8 0 0 0 0 0 0 0 -13
-1 8 0 0 0 0 0 0 0 -14
-1 8 0 0 0 0 0 0 0 -15
-1 8 0 0 0 0 0 0 0 -16
-1 8 0 0 0 0 0 0 0 -17
-1 8 0 0 0 0 0 0 0 -18
-1 8 0 0 0 0 0 0 0 -19
-1 8 0 0 0 0 0 0 0 -20
-1 8 0 0 0 0 0 0 0 -21
-1 8 0 0 0 0 0 0 0 -22
-1 8 0 0 0 0 0 0 0 -23
-1 8 0 0 0 0 0 0 0 -24
-1 8 0 0 0 0 0 0 0 -25
-1 8 0 0 0 0 0 0 0 -26
-1 8 0 0 0 0 0 0 0 -27
-1 8 0 0 0 0 0 0 0 -28
-1 8 0 0 0 0 0 0 0 -29
-1 8 0 0 0 0 0 0 0 -30
-1 8 0 0 0 0 0 0 0 -31
-
-5 8
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-
-1 8
-1 1 1 1 1 0 1 0
-
-3 8
-0 1 0 1
-0 1 0 1
-0 0 0 0
-0 0 0 0
-0 0 0 0
-0 0 0 0
-0 0 0 0
-0 0 0 0
-
-7 8
-0 0 1 0 1 0 0
-0 0 1 0 1 0 0
-1 1 1 1 1 1 1
-0 0 1 0 1 0 0
-1 1 1 1 1 1 1
-0 0 1 0 1 0 0
-0 0 1 0 1 0 0
-0 0 0 0 0 0 0
-
-5 8
-0 0 1 0 0
-0 1 1 1 1
-1 0 1 0 0
-0 1 1 1 0
-0 0 1 0 1
-1 1 1 1 0
-0 0 1 0 0
-0 0 0 0 0
-
-5 8
-0 0 0 0 0
-1 1 0 0 1
-1 1 0 1 0
-0 0 1 0 0
-0 1 0 1 1
-1 0 0 1 1
-0 0 0 0 0
-0 0 0 0 0
-
-6 8
-0 0 1 1 0 0
-0 1 0 1 0 0
-0 0 1 0 0 0
-0 1 0 1 0 0
-1 0 0 0 1 1
-1 0 0 0 1 0
-0 1 1 1 0 1
-0 0 0 0 0 0
-
-1 8
-1 1 0 0 0 0 0 0
-
-3 8
-0 0 1
-0 1 0
-1 0 0
-1 0 0
-1 0 0
-0 1 0
-0 0 1
-0 0 0
-
-3 8
-1 0 0
-0 1 0
-0 0 1
-0 0 1
-0 0 1
-0 1 0
-1 0 0
-0 0 0
-
-7 8
-0 0 0 1 0 0 0
-1 0 0 1 0 0 1
-0 1 0 1 0 1 0
-0 0 1 1 1 0 0
-0 1 0 1 0 1 0
-1 0 0 1 0 0 1
-0 0 0 1 0 0 0
-0 0 0 0 0 0 0
-
-7 8
-0 0 0 1 0 0 0
-0 0 0 1 0 0 0
-0 0 0 1 0 0 0
-1 1 1 1 1 1 1
-0 0 0 1 0 0 0
-0 0 0 1 0 0 0
-0 0 0 1 0 0 0
-0 0 0 0 0 0 0
-
-2 8
-0 0
-0 0
-0 0
-0 0
-1 1
-1 1
-0 1
-1 0
-
-6 8
-0 0 0 0 0 0
-0 0 0 0 0 0
-0 0 0 0 0 0
-1 1 1 1 1 1
-0 0 0 0 0 0
-0 0 0 0 0 0
-0 0 0 0 0 0
-0 0 0 0 0 0
-
-2 8
-0 0
-0 0
-0 0
-0 0
-1 1
-1 1
-0 0
-0 0
-
-7 8
-0 0 0 0 0 0 1
-0 0 0 0 0 1 0
-0 0 0 0 1 0 0
-0 0 0 1 0 0 0
-0 0 1 0 0 0 0
-0 1 0 0 0 0 0
-1 0 0 0 0 0 0
-0 0 0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 0 1 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-3 8
-0 1 0
-1 1 0
-0 1 0
-0 1 0
-0 1 0
-0 1 0
-1 1 1
-0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-0 0 0 0 1
-0 0 0 1 0
-0 0 1 0 0
-0 1 0 0 0
-1 1 1 1 1
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-0 0 0 0 1
-0 0 1 1 0
-0 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-6 8
-0 0 0 1 1 0
-0 0 1 0 1 0
-0 1 0 0 1 0
-1 0 0 0 1 0
-1 1 1 1 1 1
-0 0 0 0 1 0
-0 0 0 0 1 0
-0 0 0 0 0 0
-
-5 8
-1 1 1 1 1
-1 0 0 0 0
-1 0 0 0 0
-1 1 1 1 0
-0 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 0
-1 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 1 1 1 1
-0 0 0 0 1
-0 0 0 1 0
-0 0 1 0 0
-0 1 0 0 0
-0 1 0 0 0
-0 1 0 0 0
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 1
-0 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-2 8
-0 0
-1 1
-1 1
-0 0
-1 1
-1 1
-0 0
-0 0
-
-2 8
-0 0
-1 1
-1 1
-0 0
-1 1
-1 1
-0 1
-1 0
-
-4 8
-0 0 0 1
-0 0 1 0
-0 1 0 0
-1 0 0 0
-0 1 0 0
-0 0 1 0
-0 0 0 1
-0 0 0 0
-
-5 8
-0 0 0 0 0
-0 0 0 0 0
-1 1 1 1 1
-0 0 0 0 0
-1 1 1 1 1
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-
-4 8
-1 0 0 0
-0 1 0 0
-0 0 1 0
-0 0 0 1
-0 0 1 0
-0 1 0 0
-1 0 0 0
-0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-0 0 0 0 1
-0 0 0 1 0
-0 0 1 0 0
-0 0 0 0 0
-0 0 1 0 0
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 1 1 1
-1 0 1 0 1
-1 0 1 1 1
-1 0 0 0 0
-0 1 1 1 1
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 1 1 1 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 0 0 0 0
-
-5 8
-1 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 1 1 1 1
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 1 1 1 1
-1 0 0 0 0
-1 0 0 0 0
-1 1 1 1 0
-1 0 0 0 0
-1 0 0 0 0
-1 1 1 1 1
-0 0 0 0 0
-
-5 8
-1 1 1 1 1
-1 0 0 0 0
-1 0 0 0 0
-1 1 1 1 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 0
-1 0 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 1 1 1 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 0 0 0 0
-
-3 8
-1 1 1
-0 1 0
-0 1 0
-0 1 0
-0 1 0
-0 1 0
-1 1 1
-0 0 0
-
-5 8
-0 0 1 1 1
-0 0 0 1 0
-0 0 0 1 0
-0 0 0 1 0
-0 0 0 1 0
-1 0 0 1 0
-0 1 1 0 0
-0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 1 0
-1 1 1 0 0
-1 0 0 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 0 0 0 0
-
-5 8
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 0
-1 0 0 0 1
-1 1 1 1 1
-0 0 0 0 0
-
-7 8
-1 0 0 0 0 0 1
-1 1 0 0 0 1 1
-1 0 1 0 1 0 1
-1 0 0 1 0 0 1
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-0 0 0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-1 1 0 0 1
-1 0 1 0 1
-1 0 0 1 1
-1 0 0 0 1
-1 0 0 0 1
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-4 8
-1 1 1 0
-1 0 0 1
-1 0 0 1
-1 1 1 0
-1 0 0 0
-1 0 0 0
-1 0 0 0
-0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 1 1
-
-5 8
-1 1 1 0 0
-1 0 0 1 0
-1 0 0 1 0
-1 1 1 0 0
-1 0 1 0 0
-1 0 0 1 0
-1 0 0 0 1
-0 0 0 0 0
-
-5 8
-0 1 1 1 0
-1 0 0 0 1
-1 0 0 0 0
-0 1 1 1 0
-0 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 1 1 1 1
-0 0 1 0 0
-0 0 1 0 0
-0 0 1 0 0
-0 0 1 0 0
-0 0 1 0 0
-0 0 1 0 0
-0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 0 1 0
-0 0 1 0 0
-0 0 0 0 0
-
-7 8
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-0 1 0 1 0 1 0
-0 1 0 1 0 1 0
-0 0 1 0 1 0 0
-0 0 1 0 1 0 0
-0 0 0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-0 1 0 1 0
-0 0 1 0 0
-0 1 0 1 0
-1 0 0 0 1
-1 0 0 0 1
-0 0 0 0 0
-
-5 8
-1 0 0 0 1
-1 0 0 0 1
-0 1 0 1 0
-0 0 1 0 0
-0 0 1 0 0
-0 0 1 0 0
-0 1 1 1 0
-0 0 0 0 0
-
-5 8
-1 1 1 1 1
-0 0 0 0 1
-0 0 0 1 0
-0 0 1 0 0
-0 1 0 0 0
-1 0 0 0 0
-1 1 1 1 1
-0 0 0 0 0
-
-3 8
-1 1 1
-1 0 0
-1 0 0
-1 0 0
-1 0 0
-1 0 0
-1 1 1
-0 0 0
-
-7 8
-1 0 0 0 0 0 0
-0 1 0 0 0 0 0
-0 0 1 0 0 0 0
-0 0 0 1 0 0 0
-0 0 0 0 1 0 0
-0 0 0 0 0 1 0
-0 0 0 0 0 0 1
-0 0 0 0 0 0 0
-
-3 8
-1 1 1
-0 0 1
-0 0 1
-0 0 1
-0 0 1
-0 0 1
-1 1 1
-0 0 0
-
-5 8
-0 0 1 0 0
-0 1 0 1 0
-1 0 0 0 1
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-
-5 8
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-0 0 0 0 0
-1 1 1 1 1
-
-2 8
-1 0
-0 1
-0 0
-0 0
-0 0
-0 0
-0 0
-0 0
-
-
-6 8
-0 0 0 0 0 0
-0 0 0 0 0 0
-0 1 1 1 0 0
-0 0 0 0 1 0
-0 1 1 1 1 0
-1 0 0 0 1 0
-0 1 1 1 0 1
-0 0 0 0 0 0
-
-4 8
-1 0 0 0
-1 0 0 0
-1 1 1 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-1 1 1 0
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 0
-1 0 0 1
-1 0 0 0
-1 0 0 1
-0 1 1 0
-0 0 0 0
-
-4 8
-0 0 0 1
-0 0 0 1
-0 1 1 1
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 1 1 1
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 0
-1 0 0 1
-1 1 1 1
-1 0 0 0
-0 1 1 1
-0 0 0 0
-
-4
-0 0 1 0
-0 1 0 1
-0 1 0 0
-1 1 1 0
-0 1 0 0
-0 1 0 0
-0 1 0 0
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 0
-1 0 0 1
-1 0 0 1
-0 1 1 1
-0 0 0 1
-1 1 1 1
-
-4 8
-1 0 0 0
-1 0 0 0
-1 1 1 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 0 0 0
-
-1 8
-1 0 1 1 1 1 1 0
-
-3 8
-0 0 1
-0 0 0
-0 0 1
-0 0 1
-0 0 1
-0 0 1
-0 0 1
-1 1 0
-
-4 8
-1 0 0 0
-1 0 0 0
-1 0 0 1
-1 0 1 0
-1 1 0 0
-1 0 1 0
-1 0 0 1
-0 0 0 0
-
-2 8
-1 0
-1 0
-1 0
-1 0
-1 0
-1 0
-1 1
-0 0
-
-7 8
-0 0 0 0 0 0 0
-0 0 0 0 0 0 0
-0 1 1 0 1 1 0
-1 0 0 1 0 0 1
-1 0 0 1 0 0 1
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-0 0 0 0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-1 1 1 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 1 1 0
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-1 1 1 0
-1 0 0 1
-1 0 0 1
-1 1 1 0
-1 0 0 0
-1 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 1
-1 0 0 1
-1 0 0 1
-0 1 1 1
-0 0 0 1
-0 0 0 1
-
-4 8
-0 0 0 0
-0 0 0 0
-1 0 1 1
-1 1 0 0
-1 0 0 0
-1 0 0 0
-1 0 0 0
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-0 1 1 1
-1 0 0 0
-0 1 1 0
-0 0 0 1
-1 1 1 0
-0 0 0 0
-
-4 8
-0 1 0 0
-0 1 0 0
-1 1 1 1
-0 1 0 0
-0 1 0 0
-0 1 0 1
-0 0 1 0
-0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 1 1 0
-0 0 0 0
-
-5 8
-0 0 0 0 0
-0 0 0 0 0
-1 0 0 0 1
-1 0 0 0 1
-1 0 0 0 1
-0 1 0 1 0
-0 0 1 0 0
-0 0 0 0 0
-
-7 8
-0 0 0 0 0 0 0
-0 0 0 0 0 0 0
-1 0 0 0 0 0 1
-1 0 0 0 0 0 1
-1 0 0 1 0 0 1
-0 1 0 1 0 1 0
-0 0 1 0 1 0 0
-0 0 0 0 0 0 0
-
-5 8
-0 0 0 0 0
-0 0 0 0 0
-1 0 0 0 1
-0 1 0 1 0
-0 0 1 0 0
-0 1 0 1 0
-1 0 0 0 1
-0 0 0 0 0
-
-4 8
-0 0 0 0
-0 0 0 0
-1 0 0 1
-1 0 0 1
-1 0 0 1
-0 1 1 1
-0 0 0 1
-1 1 1 1
-
-4 8
-0 0 0 0
-0 0 0 0
-1 1 1 1
-0 0 0 1
-0 1 1 0
-1 0 0 0
-1 1 1 1
-0 0 0 0
-
-3 8
-0 0 1
-0 1 0
-0 1 0
-1 0 0
-0 1 0
-0 1 0
-0 0 1
-0 0 0
-
-1 8
-1 1 1 1 1 1 1 0
-
-3 8
-1 0 0
-0 1 0
-0 1 0
-0 0 1
-0 1 0
-0 1 0
-1 0 0
-0 0 0
-
-7 8
-0 0 0 0 0 0 0
-0 0 0 0 0 0 0
-0 1 1 0 0 0 0
-1 0 0 1 0 0 1
-0 0 0 0 1 1 0
-0 0 0 0 0 0 0
-0 0 0 0 0 0 0
-0 0 0 0 0 0 0
diff --git a/Kernel/debug/commands.c b/Kernel/debug/commands.c
new file mode 100644
index 0000000..06ea81d
--- /dev/null
+++ b/Kernel/debug/commands.c
@@ -0,0 +1,255 @@
+#include
+#include
+#include
+#include
+#include "../hal/mouse/mouse.h"
+#include "../drivers/floppy/floppy.h"
+
+string ConsoleCommands[] =
+{
+ "osver",
+ "time",
+ "cls",
+ "help",
+ "dump",
+ "mem",
+ "crash",
+ "mouse",
+ "read",
+ "reboot",
+ "restart",
+};
+
+int32 ConsoleCommandsCount = 11;
+
+/*****************************************
+ * osver - get os info *
+ *****************************************/
+void CommandOsver()
+{
+ ConsoleWrite ("%#%s%# 32bit operating system\n", Color(0,ColorYellow), OS_STRING, Color(0,ColorLightGray));
+
+ int32 i = 0;
+ for (i = 0; i < 30; i++)
+ ConsoleWrite ("%#%c", ColorDarkGray, 205);
+
+ ConsoleWrite ("\n%#OS version: %#%s\n", ColorDarkGray, ColorLightGray, OS_VERSION);
+ ConsoleWrite ("%#Build: %#%s ", ColorDarkGray, ColorLightGray, OS_BUILD);
+ ConsoleWrite ("%#built on %#%s %#at %#%s\n", ColorDarkGray, ColorLightGray, OS_BUILD_DATE, ColorDarkGray, ColorLightGray, OS_BUILD_TIME);
+ ConsoleWrite ("%#(c) Copyright %#CTA Systems Inc.\n", ColorDarkGray ,ColorLightGray);
+}
+
+
+/*****************************************
+ * time - get date and time *
+ *****************************************/
+void CommandTime()
+{
+ const char* Months[] = {
+ "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ };
+
+ const char* Weekdays[] = {
+ "", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+ };
+
+
+ Time time = TimeConvertToTime(TimeGetInternalTime());
+
+ ConsoleWrite ("Current time: ");
+ ConsoleWrite ("%#%d:%d%d:%d%d.%d%d%d\n", Color(0,ColorLightGreen) ,(int)time.Hour,
+ time.Minute/10, time.Minute%10, time.Second/10, time.Second%10, time.Milisecond/100, (time.Milisecond/10)%10, time.Milisecond%10);
+
+ ConsoleWrite ("Date: %#%s, %s %d, %d\n", Color(0,ColorLightGreen), Weekdays[time.WeekDay],
+ Months[time.Month], time.Day, time.Year);
+
+}
+
+
+/*****************************************
+ * help - help provider *
+ *****************************************/
+void CommandHelp(string params[], int32 count)
+{
+ if (count <= 1)
+ {
+ ConsoleWrite ("Available commands:\n");
+
+ int i;
+ for (i = 0; i < ConsoleCommandsCount; i++)
+ ConsoleWrite(" > %#%s\n", Color(0,ColorWhite), ConsoleCommands[i]);
+
+ return;
+ }
+
+ ConsoleWrite("%#! Help for %s command is not implemented yet.\n", Color(0,ColorLightRed), params[1]);
+}
+
+
+/*****************************************
+ * dump - dumps memory content *
+ *****************************************/
+inline char hex (int32 digit)
+{
+ return (digit < 10) ? (digit + '0') : (digit - 10 + 'A');
+}
+
+void CommandDump (string argv[], int32 argc)
+{
+ unsigned pause = 1, i = 0;
+
+ // Verify correct number of arguments
+ if (argc < 3) {
+ ConsoleWrite("%#! Correct syntax: %#dump %#[start_address] [end_address]\n",
+ ColorLightRed, ColorWhite, ColorLightGray);
+ ConsoleWrite("%#Start %#and %#end %#addresses are in hex.\n",
+ ColorLightGray, ColorDarkGray, ColorLightGray, ColorDarkGray);
+ return;
+ }
+
+ // Disable pause
+ if (argc==4 && strcmp(argv[3], "!p") == 0)
+ pause = 0;
+
+ // Dump memory
+ unsigned char *start, *end;
+ start = (unsigned char *) ConvertStringToIntHex(argv[1]);
+ end = (unsigned char *) ConvertStringToIntHex(argv[2]);
+ unsigned char* count;
+
+ while (start <= end) {
+ // Write address
+ ConsoleWrite("%#%x%#: ", Color(0,ColorLightMagenta), (unsigned int)start, Color(0,ColorLightGray));
+
+ // Write hex data
+ for (count = start; count < start+16; count++) {
+ if (*count == 0) ConsoleWrite ("%#00 ", Color(0,ColorDarkGray));
+ else ConsoleWrite ("%#%c%c ", Color(0,ColorWhite), hex(*count/16), hex(*count%16));
+ }
+
+ // Write ASCII data
+ ConsoleWrite(" ");
+ for (count = start; count < start+16; count++) {
+ if (*count < 32) ConsoleWrite(".");
+ else ConsoleWrite("%#%c", Color(0,ColorLightGreen), *count);
+ }
+
+ // New line
+ ConsoleWrite("\n\r");
+ start+=16; i++;
+
+ // Pause
+ if ((i%22 == 0) && (pause==1)) {
+ ConsoleWrite("\n\r%#Press %#any key %#to continue scrolling, %#Esc %#to exit.",
+ 0x8, 0x7, 0x8, 0x7, 0x8);
+ Key k = ReadKey();
+ if (k.Scancode == KeyboardKeyEscape) return;
+ ConsoleWrite("\n\n\r");
+ }
+ }
+}
+
+
+#define _CommandMemTotalRows 10
+void _CommandMemPrintMemmap()
+{
+ uint8 color = Color(ColorGreen, ColorRed);
+ uint32 total = MemoryGetFramesTotal();
+
+ char c = ' ';
+
+ // Print memory map
+ int32 i, old = 0, n = 0, blocks, used;
+ for (i = 0; i < 80; i++)
+ ConsoleWrite("%#%c", ColorLightGray, 220);
+
+ for (i = 1; i <= 80*_CommandMemTotalRows; i++, old++)
+ {
+ n = (total * i) / (80 * _CommandMemTotalRows);
+
+ blocks = n - old;
+ used = 0;
+ for (; old < n; old++)
+ used += (MemPhGetFrame(old) != 0);
+
+ if (used <= blocks / 5) c = ' ';
+ else if (used > 4 * blocks / 5) c = 219;
+ else if (used <= 2 * blocks / 5) c = 176;
+ else if (used <= 3 * blocks / 5) c = 177;
+ else c = 178;
+
+ ConsoleWrite("%#%c", color, c);
+ }
+
+ for (i = 0; i < 80; i++)
+ ConsoleWrite("%#%c", ColorDarkGray, 223);
+}
+
+void CommandMem (string argv[], int32 argc)
+{
+ if (argc < 2)
+ {
+ ConsoleWrite ("Physical memory map:\n");
+
+ _CommandMemPrintMemmap();
+
+ ConsoleWrite ("Free space: %#%ukb (%u frames)\n", ColorLightMagenta, MemoryGetFree(), MemoryGetFramesFree());
+ ConsoleWrite ("Used space: %#%ukb (%u frames)\n\n", ColorLightMagenta, MemoryGetUsed(), MemoryGetFramesUsed());
+ ConsoleWrite ("Total space: %#%ukb (%u frames)\n", ColorLightMagenta, MemoryGetTotal(), MemoryGetFramesTotal());
+
+ return;
+ }
+
+ if (strcmp(argv[1], "alloc") == 0)
+ {
+ uint32 addr = 0;
+ if (argc < 3) addr = (uint32)kmalloc(0x4);
+ else addr = (uint32)kmalloc(ConvertStringToUInt(argv[2]));
+
+ ConsoleWrite("Returned address: %#0x%x\n", ColorWhite, addr);
+ }
+
+ else if (strcmp(argv[1], "free") == 0)
+ {
+ if (argc < 3) {
+ ConsoleWrite ("%#! Missing parameter: address to free.", ColorRed);
+ return;
+ }
+
+ kfree((void*)ConvertStringToIntHex(argv[2]));
+ ConsoleWrite("Done.\n");
+ }
+
+ else ConsoleWrite("%#! Invalid command. Available commands are: alloc, free.", ColorLightRed);
+}
+
+void CommandCrash()
+{
+ int a = 10, b = 0;
+ ConsoleWrite ("%d", a/b);
+}
+
+void CommandMouse()
+{
+ MouseState s = MouseGetState();
+ ConsoleWrite("X=%d Y=%d Buttons=", s.Position.X, s.Position.Y);
+
+ if (!s.Buttons) ConsoleWrite("");
+ if (s.Buttons & 1) ConsoleWrite("");
+ if (s.Buttons & 2) ConsoleWrite("");
+ if (s.Buttons & 4) ConsoleWrite("");
+
+ ConsoleWrite("\n");
+}
+
+void CommandRead(string argv[], int32 argc)
+{
+ if (argc < 2)
+ {
+ ConsoleWrite("%#! Missing parameter - sector!\n", ColorLightRed);
+ return;
+ }
+
+ uint32 sector = ConvertStringToUInt(argv[1]);
+ ConsoleWrite("Returned value: 0x%x\n", FloppyRead(0, sector));
+}
diff --git a/Kernel/debug/commands.c~ b/Kernel/debug/commands.c~
new file mode 100644
index 0000000..3c95cd3
--- /dev/null
+++ b/Kernel/debug/commands.c~
@@ -0,0 +1,255 @@
+#include
+#include
+#include
+#include
+#include "../hal/mouse/mouse.h"
+#include "../drivers/floppy/floppy.h"
+
+string ConsoleCommands[] =
+{
+ "osver",
+ "time",
+ "cls",
+ "help",
+ "dump",
+ "mem",
+ "crash",
+ "mouse",
+ "read",
+ "reboot",
+ "restart",
+};
+
+int32 ConsoleCommandsCount = 11;
+
+/*****************************************
+ * osver - get os info *
+ *****************************************/
+void CommandOsver()
+{
+ ConsoleWrite ("%#%s%# 32bit operating system\n", Color(0,ColorYellow), OS_STRING, Color(0,ColorLightGray));
+
+ int32 i = 0;
+ for (i = 0; i < 30; i++)
+ ConsoleWrite ("%#%c", ColorDarkGray, 205);
+
+ ConsoleWrite ("\n%#OS version: %#%s\n", ColorDarkGray, ColorLightGray, OS_VERSION);
+ ConsoleWrite ("%#Build: %#%s ", ColorDarkGray, ColorLightGray, OS_BUILD);
+ ConsoleWrite ("%#built on %#%s %#at %#%s\n", ColorDarkGray, ColorLightGray, OS_BUILD_DATE, ColorDarkGray, ColorLightGray, OS_BUILD_TIME);
+ ConsoleWrite ("%#(c) Copyright %#CTA Systems Inc.\n", ColorDarkGray ,ColorLightGray);
+}
+
+
+/*****************************************
+ * time - get date and time *
+ *****************************************/
+void CommandTime()
+{
+ const char* Months[] = {
+ "", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
+ };
+
+ const char* Weekdays[] = {
+ "", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"
+ };
+
+
+ Time time = TimeConvertToTime(TimeGetInternalTime());
+
+ ConsoleWrite ("Current time: ");
+ ConsoleWrite ("%#%d:%d%d:%d%d.%d%d%d\n", Color(0,ColorLightGreen) ,(int)time.Hour,
+ time.Minute/10, time.Minute%10, time.Second/10, time.Second%10, time.Milisecond/100, (time.Milisecond/10)%10, time.Milisecond%10);
+
+ ConsoleWrite ("Date: %#%s, %s %d, %d\n", Color(0,ColorLightGreen), Weekdays[time.WeekDay],
+ Months[time.Month], time.Day, time.Year);
+
+}
+
+
+/*****************************************
+ * help - help provider *
+ *****************************************/
+void CommandHelp(string params[], int32 count)
+{
+ if (count <= 1)
+ {
+ ConsoleWrite ("Available commands:\n");
+
+ int i;
+ for (i = 0; i < ConsoleCommandsCount; i++)
+ ConsoleWrite(" > %#%s\n", Color(0,ColorWhite), ConsoleCommands[i]);
+
+ return;
+ }
+
+ ConsoleWrite("%#! Help for %s command is not implemented yet.\n", Color(0,ColorLightRed), params[1]);
+}
+
+
+/*****************************************
+ * dump - dumps memory content *
+ *****************************************/
+inline char hex (int32 digit)
+{
+ return (digit < 10) ? (digit + '0') : (digit - 10 + 'A');
+}
+
+void CommandDump (string argv[], int32 argc)
+{
+ unsigned pause = 1, i = 0;
+
+ // Verify correct number of arguments
+ if (argc < 3) {
+ ConsoleWrite("%#! Correct syntax: %#dump %#[start_address] [end_address]\n",
+ ColorLightRed, ColorWhite, ColorLightGray);
+ ConsoleWrite("%#Start %#and %#end %#addresses are in hex.\n",
+ ColorLightGray, ColorDarkGray, ColorLightGray, ColorDarkGray);
+ return;
+ }
+
+ // Disable pause
+ if (argc==4 && strcmp(argv[3], "!p") == 0)
+ pause = 0;
+
+ // Dump memory
+ unsigned char *start, *end;
+ start = (unsigned char *) ConvertStringToIntHex(argv[1]);
+ end = (unsigned char *) ConvertStringToIntHex(argv[2]);
+ unsigned char* count;
+
+ while (start <= end) {
+ // Write address
+ ConsoleWrite("%#%x%#: ", Color(0,ColorLightMagenta), (unsigned int)start, Color(0,ColorLightGray));
+
+ // Write hex data
+ for (count = start; count < start+16; count++) {
+ if (*count == 0) ConsoleWrite ("%#00 ", Color(0,ColorDarkGray));
+ else ConsoleWrite ("%#%c%c ", Color(0,ColorWhite), hex(*count/16), hex(*count%16));
+ }
+
+ // Write ASCII data
+ ConsoleWrite(" ");
+ for (count = start; count < start+16; count++) {
+ if (*count < 32) ConsoleWrite(".");
+ else ConsoleWrite("%#%c", Color(0,ColorLightGreen), *count);
+ }
+
+ // New line
+ ConsoleWrite("\n\r");
+ start+=16; i++;
+
+ // Pause
+ if ((i%22 == 0) && (pause==1)) {
+ ConsoleWrite("\n\r%#Press %#any key %#to continue scrolling, %#Esc %#to exit.",
+ 0x8, 0x7, 0x8, 0x7, 0x8);
+ Key k = ReadKey();
+ if (k.Scancode == KeyboardKeyEscape) return;
+ ConsoleWrite("\n\n\r");
+ }
+ }
+}
+
+
+#define _CommandMemTotalRows 10
+void _CommandMemPrintMemmap()
+{
+ uint8 color = Color(ColorGreen, ColorRed);
+ uint32 total = MemoryGetFramesTotal();
+
+ char c = ' ';
+
+ // Print memory map
+ int32 i, old = 0, n = 0, blocks, used;
+ for (i = 0; i < 80; i++)
+ ConsoleWrite("%#%c", ColorLightGray, 220);
+
+ for (i = 1; i <= 80*_CommandMemTotalRows; i++, old++)
+ {
+ n = (total * i) / (80 * _CommandMemTotalRows);
+
+ blocks = n - old;
+ used = 0;
+ for (; old < n; old++)
+ used += (MemPhGetFrame(old) != 0);
+
+ if (used <= blocks / 5) c = ' ';
+ else if (used > 4 * blocks / 5) c = 219;
+ else if (used <= 2 * blocks / 5) c = 176;
+ else if (used <= 3 * blocks / 5) c = 177;
+ else c = 178;
+
+ ConsoleWrite("%#%c", color, c);
+ }
+
+ for (i = 0; i < 80; i++)
+ ConsoleWrite("%#%c", ColorDarkGray, 223);
+}
+
+void CommandMem (string argv[], int32 argc)
+{
+ if (argc < 2)
+ {
+ ConsoleWrite ("Memory map:\n");
+
+ _CommandMemPrintMemmap();
+
+ ConsoleWrite ("Free space: %#%ukb (%u frames)\n", ColorLightMagenta, MemoryGetFree(), MemoryGetFramesFree());
+ ConsoleWrite ("Used space: %#%ukb (%u frames)\n\n", ColorLightMagenta, MemoryGetUsed(), MemoryGetFramesUsed());
+ ConsoleWrite ("Total space: %#%ukb (%u frames)\n", ColorLightMagenta, MemoryGetTotal(), MemoryGetFramesTotal());
+
+ return;
+ }
+
+ if (strcmp(argv[1], "alloc") == 0)
+ {
+ uint32 addr = 0;
+ if (argc < 3) addr = (uint32)kmalloc(0x4);
+ else addr = (uint32)kmalloc(ConvertStringToUInt(argv[2]));
+
+ ConsoleWrite("Returned address: %#0x%x\n", ColorWhite, addr);
+ }
+
+ else if (strcmp(argv[1], "free") == 0)
+ {
+ if (argc < 3) {
+ ConsoleWrite ("%#! Missing parameter: address to free.", ColorRed);
+ return;
+ }
+
+ kfree((void*)ConvertStringToIntHex(argv[2]));
+ ConsoleWrite("Done.\n");
+ }
+
+ else ConsoleWrite("%#! Invalid command. Available commands are: alloc, free.", ColorLightRed);
+}
+
+void CommandCrash()
+{
+ int a = 10, b = 0;
+ ConsoleWrite ("%d", a/b);
+}
+
+void CommandMouse()
+{
+ MouseState s = MouseGetState();
+ ConsoleWrite("X=%d Y=%d Buttons=", s.Position.X, s.Position.Y);
+
+ if (!s.Buttons) ConsoleWrite("");
+ if (s.Buttons & 1) ConsoleWrite("");
+ if (s.Buttons & 2) ConsoleWrite("");
+ if (s.Buttons & 4) ConsoleWrite("");
+
+ ConsoleWrite("\n");
+}
+
+void CommandRead(string argv[], int32 argc)
+{
+ if (argc < 2)
+ {
+ ConsoleWrite("%#! Missing parameter - sector!\n", ColorLightRed);
+ return;
+ }
+
+ uint32 sector = ConvertStringToUInt(argv[1]);
+ ConsoleWrite("Returned value: 0x%x\n", FloppyRead(0, sector));
+}
diff --git a/Kernel/debug/console-base.c b/Kernel/debug/console-base.c
new file mode 100644
index 0000000..1eee06a
--- /dev/null
+++ b/Kernel/debug/console-base.c
@@ -0,0 +1,131 @@
+#include
+#include
+#include
+
+uint8* VideoPtr = (uint8*) 0xb8000;
+
+Point ConsoleCursor = {0, 0};
+UPoint ConsoleSize = {80, 25};
+
+uint8 ConsoleDefaultColor = CONSOLE_DEFAULT_COLOR;
+
+/**************************************
+ * Basic console operations *
+ **************************************/
+void ConsoleClear()
+{
+ uint32 temp;
+
+ for (temp = 0; temp < ConsoleSize.X * ConsoleSize.Y; temp++)
+ {
+ VideoPtr[2 * temp] = 0;
+ VideoPtr[2 * temp + 1] = ConsoleDefaultColor;
+ }
+
+ ConsoleCursor.X = ConsoleCursor.Y = 0;
+ ConsoleCursorUpdateHardware();
+}
+
+void ConsoleScroll (uint32 lines)
+{
+ // Sanity check, don't scroll too much
+ if (lines > ConsoleSize.Y) lines = ConsoleSize.Y;
+
+ uint32 x, y;
+ for (y = 0; y < ConsoleSize.Y - lines; y++)
+ for (x = 0; x < 2*ConsoleSize.X; x++)
+ VideoPtr[y * ConsoleSize.X * 2 + x] = VideoPtr[(y+lines)*ConsoleSize.X*2 + x];
+
+ for (y = ConsoleSize.Y - lines; y < ConsoleSize.Y; y++)
+ for (x = 0; x < ConsoleSize.X; x++)
+ {
+ VideoPtr[2 * (y * ConsoleSize.X + x)] = 0;
+ VideoPtr[2 * (y * ConsoleSize.X + x) + 1] = ConsoleDefaultColor;
+ }
+
+ ConsoleCursor.Y -= lines;
+}
+
+
+/**************************************
+ * Cursor position *
+ **************************************/
+Point ConsoleGetCursor()
+{
+ return ConsoleCursor;
+}
+
+extern void ConsoleSetCursor(Point p)
+{
+ ConsoleCursor = p;
+}
+
+void ConsoleCursorIncreasePos (int32 delta)
+{
+ // Increase X, Y positions
+ ConsoleCursor.Y += delta / ConsoleSize.X;
+ ConsoleCursor.X += delta % ConsoleSize.X;
+
+ // Next line if X > Screen width
+ while (ConsoleCursor.X >= (int32)ConsoleSize.X)
+ {
+ ConsoleCursor.Y++;
+ ConsoleCursor.X -= ConsoleSize.X;
+ }
+
+ // Previous line if X < 0
+ while (ConsoleCursor.X < 0)
+ {
+ ConsoleCursor.Y--;
+ ConsoleCursor.X += ConsoleSize.X;
+ }
+
+ // Scroll if Y > Screen height
+ if (ConsoleCursor.Y >= (int32)ConsoleSize.Y)
+ ConsoleScroll(1);
+}
+
+void ConsoleCursorNewline()
+{
+ ConsoleCursor.X = 0;
+
+ if (++ConsoleCursor.Y >= (int32)ConsoleSize.Y)
+ ConsoleScroll(1);
+}
+
+void ConsoleCursorUpdateHardware()
+{
+ uint16 temp = (uint16) (ConsoleCursor.Y * ConsoleSize.X + ConsoleCursor.X);
+ uint16* port = (uint16*) 0x463 ;
+
+ outportb(*port, 14);
+ outportb(*port + 1, (temp >> 8) & 0xff);
+ outportb(*port, 15);
+ outportb(*port + 1, temp & 0xff);
+}
+
+uint8 Color (uint8 back, uint8 fore)
+{
+ return ((back<<4) | fore);
+}
+
+void ConsoleSetDefaultColor(uint8 color)
+{
+ ConsoleDefaultColor = color;
+}
+
+uint8 ConsoleGetDefaultColor ()
+{
+ return ConsoleDefaultColor;
+}
+
+UPoint ConsoleGetSize()
+{
+ return ConsoleSize;
+}
+
+void ConsoleCursorGoto(Point p)
+{
+ if (p.X >= 0 && p.X < (int32)ConsoleSize.X) ConsoleCursor.X = p.X;
+ if (p.Y >= 0 && p.Y < (int32)ConsoleSize.Y) ConsoleCursor.Y = p.Y;
+}
diff --git a/Kernel/debug/console-in.c b/Kernel/debug/console-in.c
new file mode 100644
index 0000000..d997ec7
--- /dev/null
+++ b/Kernel/debug/console-in.c
@@ -0,0 +1,162 @@
+#include
+#include
+#include
+#include "../hal/keyboard/keyboard.h"
+
+// extern uint8* VideoPtr;
+extern UPoint ConsoleCursor;
+// extern UPoint ConsoleSize;
+// extern uint8 ConsoleDefaultColor;
+
+extern void _write_char (char c);
+extern void _write_string (string s);
+
+int _next_word_index (string s, int32 direction, int32 current, int32 len)
+{
+ int32 tmp = current;
+
+ if (direction < 0) {
+ --tmp;
+ while ((isspace((unsigned char)s[tmp]) || ispunct((unsigned char)s[tmp])) && tmp > 0) --tmp;
+ while (isalnum((unsigned char)s[tmp]) && tmp > 0) --tmp;
+
+ if (tmp != 0) tmp++;
+ }
+
+ else {
+ ++tmp;
+ while (isalnum((unsigned char)s[tmp]) && tmp < len) ++tmp;
+ while ((isspace((unsigned char)s[tmp]) || ispunct((unsigned char)s[tmp])) && tmp < len) ++tmp;
+ }
+
+ return tmp;
+}
+
+void _string_crop (string s, int32 start, int32 end, int32* len)
+{
+ int32 i;
+ for (i = end; i < *len; i++)
+ s[i-(end-start)] = s[i];
+
+ *len = *len - (end - start);
+ s[*len] = 0;
+}
+
+void _string_insert (string s, char what, int32 position, int32* len)
+{
+ int32 i;
+ for (i = *len; i > position; i--)
+ s[i] = s[i-1];
+
+ s[position] = what;
+ *len = *len + 1;
+
+ s[*len] = 0;
+}
+
+void ConsoleReadString (string s, int32 buffer_size, char end_char)
+{
+ Key key;
+ int32 cursor=0, length = 0, old_length = 0;
+ UPoint cursor_original = ConsoleCursor;
+
+ s[0] = 0;
+
+ do {
+ // Read a key from keyboard
+ key = ReadKey();
+
+ // Process scancode
+ switch (key.Scancode)
+ {
+ // Left arrow
+ case KeyboardKeyLeft:
+ if (cursor > 0)
+ {
+ if (KeyboardGetKeyStatus(KeyboardKeyRightCtrl) || KeyboardGetKeyStatus(KeyboardKeyLeftCtrl))
+ cursor = _next_word_index(s, -1, cursor, length);
+ else --cursor;
+ }
+ break;
+
+ // Right arrow
+ case KeyboardKeyRight:
+ if (cursor < length)
+ {
+ if (KeyboardGetKeyStatus(KeyboardKeyRightCtrl) || KeyboardGetKeyStatus(KeyboardKeyLeftCtrl))
+ cursor = _next_word_index(s, 1, cursor, length);
+ else ++cursor;
+ }
+ break;
+
+ // Delete key
+ case KeyboardKeyDelete:
+ {
+ if (cursor == length) break;
+
+ int32 start_d = cursor, end_d;
+ if (KeyboardGetKeyStatus(KeyboardKeyRightCtrl) || KeyboardGetKeyStatus(KeyboardKeyLeftCtrl))
+ end_d = _next_word_index(s, 1, cursor, length);
+ else end_d = cursor + 1;
+
+ _string_crop(s, start_d, end_d, &length);
+
+ break;
+ }
+
+ // Backspace key
+ case KeyboardKeyBackspace:
+ {
+ if (cursor == 0) break;
+
+ int32 end = cursor;
+ if (KeyboardGetKeyStatus(KeyboardKeyRightCtrl) || KeyboardGetKeyStatus(KeyboardKeyLeftCtrl))
+ cursor = _next_word_index(s, -1, cursor, length);
+ else cursor --;
+
+ _string_crop(s, cursor, end, &length);
+
+ break;
+ }
+
+ // Home key
+ case KeyboardKeyHome:
+ cursor = 0; break;
+
+ // End key
+ case KeyboardKeyEnd:
+ cursor = length; break;
+
+ // Rest of keys
+ default:
+ // Ignore non-character keys
+ if (key.Character == 0 || iscntrl(key.Character)) break;
+
+ _string_insert(s, key.Character, cursor, &length);
+ ++cursor;
+
+ break;
+ }
+
+ // Redraw string
+ ConsoleCursor = cursor_original;
+
+ // Remove old string if still there
+ int32 i;
+ if (old_length > length)
+ for (i = 0; i < old_length; i++)
+ _write_char(' ');
+
+ old_length = length;
+ ConsoleCursor = cursor_original;
+ _write_string(s);
+
+ ConsoleCursor = cursor_original;
+ ConsoleCursorIncreasePos(cursor);
+ ConsoleCursorUpdateHardware();
+
+ } while (key.Character != end_char && length < buffer_size);
+
+ ConsoleWriteChar('\n');
+}
+
diff --git a/Kernel/debug/console-out.c b/Kernel/debug/console-out.c
new file mode 100644
index 0000000..94de0a2
--- /dev/null
+++ b/Kernel/debug/console-out.c
@@ -0,0 +1,155 @@
+#include
+#include
+#include
+#include
+
+extern uint8* VideoPtr;
+
+extern UPoint ConsoleCursor;
+extern UPoint ConsoleSize;
+
+extern uint8 ConsoleDefaultColor;
+
+/**************************************
+ * Write operations*
+ **************************************/
+void _write_char(char c)
+{
+ switch (c)
+ {
+ case '\n':
+ ConsoleCursorNewline(); break;
+
+ case '\r':
+ ConsoleCursor.X = 0; break;
+
+ case '\t':
+ ConsoleCursorIncreasePos(6 - ConsoleCursor.X % 6); break;
+
+ case '\b':
+ ConsoleCursorIncreasePos(-1);
+ VideoPtr[2 * (ConsoleCursor.Y * ConsoleSize.X + ConsoleCursor.X)] = 0;
+ break;
+
+ default:
+ VideoPtr[2 * (ConsoleCursor.Y * ConsoleSize.X + ConsoleCursor.X)] = c;
+ VideoPtr[2 * (ConsoleCursor.Y * ConsoleSize.X + ConsoleCursor.X) + 1] = ConsoleDefaultColor;
+
+ ConsoleCursorIncreasePos(1);
+ break;
+ }
+}
+
+void _write_string (string s)
+{
+ int32 len = strlen(s), i;
+
+ for (i = 0; i < len; i++)
+ _write_char(s[i]);
+}
+
+
+void ConsoleWriteChar (char c)
+{
+ _write_char(c);
+ ConsoleCursorUpdateHardware();
+}
+
+void ConsoleWriteString (string s)
+{
+ _write_string(s);
+ ConsoleCursorUpdateHardware();
+}
+
+int32 ConsoleWrite (string format, ...)
+{
+ if (!format || !*format) return 0;
+
+ va_list args;
+ va_start (args, format);
+ uint32 i, len = strlen(format);
+
+ uint8 temp_color = ConsoleDefaultColor;
+
+ for (i = 0; i < len; i++)
+ if (format[i] != '%') _write_char(format[i]);
+ else
+ {
+ ++i;
+ switch (format[i]) {
+ // Character
+ case 'c': {
+ char c = va_arg (args, char);
+ _write_char(c);
+ break;
+ }
+
+ // String
+ case 's': {
+ int32* c = (int32*) va_arg (args, string);
+ _write_string((string)c);
+ break;
+ }
+
+ // Integers
+ case 'd':
+ case 'i': {
+ int32 c = va_arg(args, int32); char temp[32];
+ ConvertIntToString(temp, c, 10);
+ _write_string(temp);
+ break;
+ }
+
+ // Integers - hex
+ case 'X':
+ case 'x': {
+ int32 c = va_arg(args, int32); char temp[32];
+ ConvertUIntToString(temp, c, 16);
+ _write_string(temp);
+ break;
+ }
+
+ // Integers - unsigned
+ case 'u': {
+ int32 c = va_arg(args, uint32); char temp[32];
+ ConvertUIntToString (temp, c, 10);
+ _write_string(temp);
+ break;
+ }
+
+ // Colors
+ case '#': {
+ uint8 c = va_arg(args, uint8);
+ ConsoleDefaultColor = c;
+ break; }
+
+ default: va_end(args); return 1;
+ };
+ }
+
+ va_end(args);
+
+ ConsoleDefaultColor = temp_color;
+ ConsoleCursorUpdateHardware();
+ return i;
+}
+
+void ConsoleSetChar(Point pos, char c)
+{
+ VideoPtr[2 * (pos.Y * ConsoleSize.X + pos.X)] = c;
+}
+
+void ConsoleSetColor(Point pos, uint8 color)
+{
+ VideoPtr[2 * (pos.Y * ConsoleSize.X + pos.X) + 1] = color;
+}
+
+char ConsoleGetChar(Point pos)
+{
+ return (char)VideoPtr[2 * (pos.Y * ConsoleSize.X + pos.X)];
+}
+
+uint8 ConsoleGetColor (Point pos)
+{
+ return VideoPtr[2 * (pos.Y * ConsoleSize.X + pos.X) + 1];
+}
diff --git a/Kernel/debug/console.c b/Kernel/debug/console.c
new file mode 100644
index 0000000..b98ba17
--- /dev/null
+++ b/Kernel/debug/console.c
@@ -0,0 +1,93 @@
+#include
+#include
+#include
+#include "commands.c"
+
+void _process_command (string params[16], int32 count);
+void _command_does_not_exist(string command);
+
+void ConsoleMain()
+{
+ char buffer[512];
+ string params[CONSOLE_MAX_PARAMS];
+
+ CommandOsver();
+
+ for (;;)
+ {
+ // Read a string
+ ConsoleWrite("\n%#] ", Color(ColorBlack, ColorYellow));
+ ConsoleReadString(buffer, 512, '\n');
+
+ // Split buffer in params
+ params[0] = buffer;
+
+ int32 i=0, len = strlen(buffer), param_count = 0;
+
+ while (i < len && param_count < CONSOLE_MAX_PARAMS)
+ {
+ // Skip spaces before
+ while (i < len && isspace(buffer[i])) buffer[i++] = 0;
+ if (i == len) break;
+
+ params[param_count++] = &buffer[i];
+
+ // Skip non-spaces
+ while (i < len && !isspace(buffer[i])) i++;
+ }
+
+ // Send command to processing
+ _process_command(params, param_count);
+ }
+
+}
+
+void _process_command (string params[CONSOLE_MAX_PARAMS], int32 count)
+{
+ int32 Cmd = -1;
+
+ if (count == 0)
+ {
+ ConsoleWrite ("%#! You must enter a command!\n", Color(0, ColorLightRed));
+ return;
+ }
+
+ // Lookup command in list
+ int32 i;
+ for (i = 0; i < ConsoleCommandsCount && Cmd == -1; i++)
+ if (strcmp(params[0], ConsoleCommands[i]) == 0) Cmd = i;
+
+ switch (Cmd)
+ {
+ case -1: _command_does_not_exist(params[0]); break;
+ case 0: CommandOsver(); break;
+ case 1: CommandTime(); break;
+ case 2: ConsoleClear(); break;
+ case 3: CommandHelp(params, count); break;
+ case 4: CommandDump (params, count); break;
+ case 5: CommandMem(params, count); break;
+ case 6: CommandCrash(); break;
+ case 7: CommandMouse(); break;
+ case 8: CommandRead(params, count); break;
+ case 9:
+ case 10: SystemReboot(); break;
+
+ default: ConsoleWrite ("%#! Command %#%s%# was not implemented (yet)!\n",
+ Color(0,ColorLightRed), Color(0,ColorWhite), params[0], Color(0,ColorLightRed)); break;
+ }
+
+
+}
+
+void _command_does_not_exist(string command)
+{
+ if (strlen(command) > 20)
+ {
+ command[18] = command[19] = command[20] = '.';
+ command[21] = null;
+ }
+
+ ConsoleWrite ("%#! Command %#%s%# does not exist!\n",
+ Color(0,ColorLightRed), Color(0,ColorWhite), command, Color(0,ColorLightRed));
+
+}
diff --git a/Kernel/drivers/cmos/cmos.c b/Kernel/drivers/cmos/cmos.c
new file mode 100644
index 0000000..0a0a7bc
--- /dev/null
+++ b/Kernel/drivers/cmos/cmos.c
@@ -0,0 +1,63 @@
+#include
+#include
+#include "cmos.h"
+
+uint8 CmosRead (uint8 address)
+{
+ outportb(0x70, address); iowait();
+ return inportb(0x71);
+}
+
+void CmosWrite (uint8 address, uint8 val)
+{
+ outportb(0x70, address); iowait();
+ outportb(0x71, val);
+}
+
+void CmosSetRTC (const Time* time)
+{
+ unsigned char BCD = ((CmosRead(0x0b)&4)==0) ? 1 : 0;
+ unsigned char ampm = ((CmosRead(0x0b)&2)==0) ? 1 : 0;
+
+ uint8 year = time->Year % 100;
+ uint8 century = time->Year / 100;
+
+ CmosWrite (0, (BCD) ? (time->Second%10) | (time->Second/10*16) : time->Second); // Seconds
+ CmosWrite (2, (BCD) ? (time->Minute%10) | (time->Minute/10*16) : time->Minute); // Minutes
+
+ if (ampm && time->Hour > 12) // Hours
+ CmosWrite (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
+ CmosWrite (4, (BCD) ? 0x92 : 0x8C);
+
+ else CmosWrite (4, (BCD) ? (time->Hour%10) | (time->Hour/10*16) : time->Hour); // 24h / AM
+
+ CmosWrite (7, (BCD) ? (time->Day%10) | (time->Day/10*16) : time->Day); // Day
+ CmosWrite (8, (BCD) ? (time->Month%10) | (time->Month/10*16) : time->Month); // Month
+ CmosWrite (9, (BCD) ? (year%10) | (year/10*16) : year); // Year
+ CmosWrite (0x32, (BCD) ? (century%10) | (century/10*16) : century); // Century
+}
+
+void CmosGetRTC(Time* tim)
+{
+ unsigned char BCD = ((CmosRead(0x0b)&4)==0) ? 1 : 0;
+ unsigned char am_pm = ((CmosRead(0x0b)&2)==0) ? 1 : 0;
+
+ tim->Second = (BCD) ? (CmosRead(0x00)%16) + 10*(CmosRead(0x00)/16): CmosRead(0x00);
+ tim->Minute = (BCD) ? (CmosRead(0x02)%16) + 10*(CmosRead(0x02)/16): CmosRead(0x02);
+
+ // Time is PM
+ if (am_pm && (CmosRead(0x04)&80)) {
+ tim->Hour = (BCD) ? ((CmosRead(0x04)-0x80)%16) + 10*((CmosRead(0x04)-0x80)/16): CmosRead(0x04)-0x80;
+ tim->Hour += 12;
+ }
+ // 24Hour format, or AM
+ else tim->Hour = (BCD) ? (CmosRead(0x04)%16) + 10*(CmosRead(0x04)/16): CmosRead(0x04);
+
+ tim->WeekDay = (BCD) ? (CmosRead(0x06)%16) + 10*(CmosRead(0x06)/16): CmosRead(0x06);
+ tim->Day = (BCD) ? (CmosRead(0x07)%16) + 10*(CmosRead(0x07)/16): CmosRead(0x07);
+ tim->Month = (BCD) ? (CmosRead(0x08)%16) + 10*(CmosRead(0x08)/16): CmosRead(0x08);
+ tim->Year = (BCD) ? (CmosRead(0x09)%16) + 10*(CmosRead(0x09)/16): CmosRead(0x09);
+ tim->Year += 100 * ((BCD) ? (CmosRead(0x32)%16) + 10*(CmosRead(0x32)/16): CmosRead(0x32));
+}
diff --git a/Kernel/drivers/cmos/cmos.h b/Kernel/drivers/cmos/cmos.h
new file mode 100644
index 0000000..f6f2685
--- /dev/null
+++ b/Kernel/drivers/cmos/cmos.h
@@ -0,0 +1,12 @@
+#ifndef __CMOS__H
+#define __CMOS__H
+
+#include
+#include
+
+extern uint8 CmosRead (uint8 address);
+extern void CmosWrite (uint8 address, uint8 val);
+extern void CmosSetRTC (const Time* time);
+extern void CmosGetRTC(Time* tim);
+
+#endif
\ No newline at end of file
diff --git a/Kernel/drivers/dma/dma.c b/Kernel/drivers/dma/dma.c
new file mode 100644
index 0000000..0c389eb
--- /dev/null
+++ b/Kernel/drivers/dma/dma.c
@@ -0,0 +1,111 @@
+/*
+ * dma.c
+ *
+ * Created on: Aug 20, 2011
+ * Author: Tiberiu
+ */
+
+#include
+#include "dma.h"
+
+void DmaSetAddress (uint8 channel, uint8 low, uint8 high)
+{
+ uint16 port = 0;
+
+ switch (channel)
+ {
+ case 0: port = DmaRegisterChannel0Address; break;
+ case 1: port = DmaRegisterChannel1Address; break;
+ case 2: port = DmaRegisterChannel2Address; break;
+ case 3: port = DmaRegisterChannel3Address; break;
+ case 4: port = DmaRegisterChannel4Address; break;
+ case 5: port = DmaRegisterChannel5Address; break;
+ case 6: port = DmaRegisterChannel6Address; break;
+ case 7: port = DmaRegisterChannel7Address; break;
+ default: return;
+ }
+
+ outportb(port, low); iowait();
+ outportb(port, high);
+}
+
+void DmaSetCount (uint8 channel, uint8 low, uint8 high)
+{
+ uint16 port = 0;
+
+ switch (channel)
+ {
+ case 0: port = DmaRegisterChannel0Count; break;
+ case 1: port = DmaRegisterChannel1Count; break;
+ case 2: port = DmaRegisterChannel2Count; break;
+ case 3: port = DmaRegisterChannel3Count; break;
+ case 4: port = DmaRegisterChannel4Count; break;
+ case 5: port = DmaRegisterChannel5Count; break;
+ case 6: port = DmaRegisterChannel6Count; break;
+ case 7: port = DmaRegisterChannel7Count; break;
+ default: return;
+ }
+
+ outportb(port, low); iowait();
+ outportb(port, high);
+}
+
+void DmaSetExternalPageRegisters (uint8 channel, uint8 val)
+{
+ uint16 port = 0;
+
+ switch (channel)
+ {
+ case 1: port = DmaRegisterChannel1PageAddress; break;
+ case 2: port = DmaRegisterChannel2PageAddress; break;
+ case 3: port = DmaRegisterChannel3PageAddress; break;
+ case 5: port = DmaRegisterChannel5PageAddress; break;
+ case 6: port = DmaRegisterChannel6PageAddress; break;
+ case 7: port = DmaRegisterChannel7PageAddress; break;
+ default: return;
+ }
+
+ outportb(port, val);
+}
+
+void DmaResetFlipFlop (uint8 channel)
+{
+ uint16 port = (channel < 4) ? DmaRegisterFlipFlopReset : 2*DmaRegisterFlipFlopReset+0xC0;
+ outportb(port, 0);
+}
+
+void DmaReset ()
+{
+ outportb(DmaRegisterMasterReset, 0);
+}
+
+void DmaUnmaskAll()
+{
+ outportb(DmaRegisterMaskReset, 0);
+}
+
+void DmaMaskChannel(uint8 channel)
+{
+ if (channel >= 8) return;
+ uint16 port = (channel < 4) ? (DmaRegisterSingleChannelMask) : (2*DmaRegisterSingleChannelMask + 0xC0);
+
+ outportb(port, channel%4 | 4);
+}
+
+void DmaUnmaskChannel (uint8 channel)
+{
+ if (channel >= 8) return;
+ uint16 port = (channel < 4) ? (DmaRegisterSingleChannelMask) : (2*DmaRegisterSingleChannelMask + 0xC0);
+
+ outportb(port, channel%4);
+}
+
+void DmaSetMode (uint8 channel, uint8 mode)
+{
+ if (channel >= 8) return;
+ uint16 port = (channel < 4) ? (DmaRegisterMode) : (2*DmaRegisterMode + 0xC0);
+
+ DmaMaskChannel(channel);
+ outportb(port, (channel%4) | mode );
+ DmaUnmaskAll();
+}
diff --git a/Kernel/drivers/dma/dma.h b/Kernel/drivers/dma/dma.h
new file mode 100644
index 0000000..f4840de
--- /dev/null
+++ b/Kernel/drivers/dma/dma.h
@@ -0,0 +1,80 @@
+/*
+ * dma.h
+ *
+ * Created on: Aug 20, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef DMA_H_
+#define DMA_H_
+
+#include
+
+enum DmaRegisters
+{
+ DmaRegisterStatus = 0x08,
+ DmaRegisterCommand = 0x08,
+ DmaRegisterRequest = 0x09,
+ DmaRegisterSingleChannelMask = 0x0A,
+ DmaRegisterMode = 0x0B,
+ DmaRegisterFlipFlopReset = 0x0C,
+ DmaRegisterIntermediate = 0x0D,
+ DmaRegisterMasterReset = 0x0D,
+ DmaRegisterMaskReset = 0x0E,
+ DmaRegisterMultichannelMask = 0x0F,
+
+ DmaRegisterChannel0Address = 0x00,
+ DmaRegisterChannel1Address = 0x02,
+ DmaRegisterChannel2Address = 0x04,
+ DmaRegisterChannel3Address = 0x06,
+ DmaRegisterChannel4Address = 0xC0,
+ DmaRegisterChannel5Address = 0xC4,
+ DmaRegisterChannel6Address = 0xC8,
+ DmaRegisterChannel7Address = 0xCC,
+
+ DmaRegisterChannel0Count = 0x01,
+ DmaRegisterChannel1Count = 0x03,
+ DmaRegisterChannel2Count = 0x05,
+ DmaRegisterChannel3Count = 0x07,
+ DmaRegisterChannel4Count = 0xC2,
+ DmaRegisterChannel5Count = 0xC6,
+ DmaRegisterChannel6Count = 0xCA,
+ DmaRegisterChannel7Count = 0xCE,
+
+ DmaRegisterChannel1PageAddress = 0x83,
+ DmaRegisterChannel2PageAddress = 0x81,
+ DmaRegisterChannel3PageAddress = 0x82,
+ DmaRegisterChannel5PageAddress = 0x8B,
+ DmaRegisterChannel6PageAddress = 0x89,
+ DmaRegisterChannel7PageAddress = 0x8A
+};
+
+enum DmaModes
+{
+ DmaModeChannelMask = 0x3,
+
+ DmaModeSelfTest = 0,
+ DmaModeWrite = 0x8,
+ DmaModeRead = 0x4,
+ DmaModeAutoReinit = 0x10,
+ DmaModeDown = 0x20,
+
+ DmaModeTransferOnDemand = 0,
+ DmaModeTransferSingleDma = 0x40,
+ DmaModeTransferBlockDma = 0x80,
+ DmaModeTransferCascade = 0xC0
+};
+
+extern void DmaSetAddress (uint8 channel, uint8 low, uint8 high);
+extern void DmaSetCount (uint8 channel, uint8 low, uint8 high);
+extern void DmaSetExternalPageRegisters (uint8 channel, uint8 val);
+extern void DmaSetMode (uint8 channel, uint8 mode);
+
+extern void DmaResetFlipFlop (uint8 channel);
+extern void DmaReset ();
+
+extern void DmaMaskChannel(uint8 channel);
+extern void DmaUnmaskChannel (uint8 channel);
+extern void DmaUnmaskAll ();
+
+#endif /* DMA_H_ */
diff --git a/Kernel/drivers/drivers.c b/Kernel/drivers/drivers.c
new file mode 100644
index 0000000..2f03bae
--- /dev/null
+++ b/Kernel/drivers/drivers.c
@@ -0,0 +1,34 @@
+#include "drivers.h"
+#include "cmos/cmos.h"
+#include "pit/pit.h"
+#include "floppy/floppy.h"
+#include "time.h"
+#include "../hal/cpu/irq.h"
+#include
+
+void DriversInstall_Clock()
+{
+ // Set up PIT
+ PitSetFrequency(PIT_FREQUENCY);
+
+ // Update internal clock
+ Time time;
+ CmosGetRTC(&time);
+
+ TimeSetInternalTime(TimeConvertToTimeSystem(time));
+
+ Log("%#[Drivers] %#Read RTC time: ", ColorWhite, ColorLightGray);
+ Log("%#%u/%u/%u %u:%u:%u.%u\n", ColorLightCyan, time.Month, time.Day,
+ time.Year, time.Hour, time.Minute, time.Second, time.Milisecond);
+}
+
+
+void DriversInstall()
+{
+ // Install clock
+ DriversInstall_Clock();
+
+ // Install fdc
+ IrqInstallHandler(6, FloppyIrqHandler);
+ FloppyInitialize();
+}
diff --git a/Kernel/drivers/drivers.h b/Kernel/drivers/drivers.h
new file mode 100644
index 0000000..0037418
--- /dev/null
+++ b/Kernel/drivers/drivers.h
@@ -0,0 +1,6 @@
+#ifndef __DRIVERS__H
+#define __DRIVERS__H
+
+extern void DriversInstall();
+
+#endif
diff --git a/Kernel/drivers/floppy/floppy.c b/Kernel/drivers/floppy/floppy.c
new file mode 100644
index 0000000..caa5999
--- /dev/null
+++ b/Kernel/drivers/floppy/floppy.c
@@ -0,0 +1,384 @@
+/*
+ * floppy.c
+ *
+ * Created on: Aug 20, 2011
+ * Author: Tiberiu
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "floppy.h"
+#include "../dma/dma.h"
+#include "../cmos/cmos.h"
+
+FloppyType fdTypes[] = {
+/* Sectors
+ * | Sectors per track
+ * | | Heads
+ * | | | Tracks
+ * | | | | Gap1
+ * | | | | | Data rate
+ * | | | | | | Spec1
+ * | | | | | | | SRT HLT HUT Motor Spinup time
+ * | | | | | | | | | | | Motor Spindown time
+ * | | | | | | | | | | | | Interrupt timeout
+ * | | | | | | | | | | | | | Disk type name string*/
+ { 0, 0,0, 0,0x00,0x00,0x00,0x00,0x00,0x00, 0, 0, 0, "none"},
+ { 720, 9,2,40,0x2A,0x01,0xDF,0x0C,0x04,0x00,1000,1000,3000, "5.25\" 360k"},
+ { 2400,15,2,80,0x1B,0x00,0xDF,0x0A,0x08,0x00, 400,1000,3000, "5.25\" 1.2M"},
+ { 1440, 9,2,80,0x2A,0x02,0xDF,0x0F,0x04,0x00,1000,1000,3000, "3.5\" 720k"},
+ { 2880,18,2,80,0x1B,0x00,0xCF,0x0C,0x08,0x00, 400,1000,3000, "3.5\" 1.44M"},
+ //{ 2880,18,2,80,0x1B,0x00,0xCF,0x0C,0x08,0x00,2000,3000,3000, "3.5\" 1.44M"},
+ { 5760,36,2,80,0x1B,0x03,0xAF,0x0A,0x0F,0x00, 400,1000,3000, "3.5\" 2.88M AMI BIOS"},
+ { 5760,36,2,80,0x1B,0x03,0xAF,0x0A,0x0F,0x00, 400,1000,3000, "3.5\" 2.88M"},
+};
+
+int8 fd0, fd1;
+
+/**************************************
+ * IRQ handler etc *
+ **************************************/
+volatile uint8 FloppyIrqFired;
+void FloppyIrqHandler(_RegsStack32* UNUSED(r))
+{
+ FloppyIrqFired = 1;
+}
+
+void FloppyWaitIrq()
+{
+ TimerStart(fdTypes[4].InterruptTimeout);
+
+ while (!FloppyIrqFired && !TimerIsDone());
+
+ if (!FloppyIrqFired) {
+ Error("%#[Floppy] %#Irq timeout [%ums] !\n", ColorBrown, ColorLightRed, fdTypes[4].InterruptTimeout);
+ }
+}
+
+
+/**************************************
+ * Installation *
+ **************************************/
+void FloppyInitialize()
+{
+ // Detect drives
+ uint8 fd = CmosRead(0x10);
+ fd0 = fd >> 4;
+ fd1 = fd & 0xf;
+
+ if (fd0 > 6) fd0 = 0;
+ if (fd1 > 6) fd1 = 0;
+
+ if (!fd0 && !fd1) {
+ Error("%#[Floppy] %#No supported floppy drives found.", ColorBrown, ColorLightRed);
+ outportb(FloppyRegisterDigitalOutput, 0);
+ return;
+ }
+
+ Log("%#[Floppy] %#Detected floppy drives:", ColorBrown, ColorLightGray);
+ if (fd0) Log(" %#fd0=%#%s", ColorLightCyan, Color(ColorCyan, ColorWhite), fdTypes[fd0].Name);
+ if (fd1) Log(" %#fd1=%#%s", ColorLightCyan, Color(ColorCyan, ColorWhite), fdTypes[fd1].Name);
+ Log("\n");
+
+
+ // Reset floppy controller
+ FloppyReset();
+
+ // Configure and lock
+ FloppyConfigure();
+ FloppySendCommand(FloppyCommandLock | 0x80);
+ FloppyReadData();
+
+ // Enable perpendicular mode for 3.5" ED floppies
+ if (fd0 > 4)
+ {
+ FloppySendCommand(FloppyCommandPerpendicularMode);
+ FloppySendCommand(1);
+ }
+ if (fd1 > 4)
+ {
+ FloppySendCommand(FloppyCommandPerpendicularMode);
+ FloppySendCommand(2);
+ }
+
+ // Initialize DMA
+ FloppyInitDma();
+}
+
+void FloppyInitDma()
+{
+ DmaMaskChannel(2);
+ DmaResetFlipFlop(2);
+ DmaSetAddress(2, 0, 0x10);
+ DmaResetFlipFlop(2);
+ DmaSetCount(2, 0xff, 0x23);
+ DmaSetExternalPageRegisters(2,0);
+ DmaUnmaskChannel(2);
+}
+
+
+/**************************************
+ * Controller reset *
+ **************************************/
+void FloppyReset()
+{
+ FloppyIrqFired = 0; int32 i = 0;
+
+ Log("%#[Floppy] %#Resetting...\n", ColorBrown, ColorLightGray);
+
+ // Clear reset bit from DOR
+ outportb(FloppyRegisterDigitalOutput, 0);
+ for (i = 0; i < 1000; i++);
+ outportb(FloppyRegisterDigitalOutput, 4|8);
+
+ // Wait for IRQ6
+ FloppyWaitIrq(fd0);
+
+ // Recalibrate every drive
+ if (fd0)
+ {
+ FloppyMotor(0,1);
+ FloppySelectDrive(0);
+ FloppyRecalibrate(0);
+ FloppyMotor(0,0);
+ }
+
+ if (fd1)
+ {
+ FloppyMotor(1,1);
+ FloppySelectDrive(1);
+ FloppyRecalibrate(1);
+ FloppyMotor(1,0);
+ }
+
+}
+
+/**************************************
+ * Configure floppy controller *
+ **************************************/
+void FloppyConfigure()
+{
+ FloppySendCommand(FloppyCommandConfigure);
+ FloppySendCommand(0);
+ FloppySendCommand(1<<6 | 7);
+ FloppySendCommand(0);
+}
+
+/**************************************
+ * Base commands *
+ **************************************/
+void FloppySendCommand (uint8 command)
+{
+ int32 t;
+ for (t = 0; t < 5000 && ((inportb(FloppyRegisterMainStatus) & FloppyMsrRQM) == 0); t++) ;
+
+ outportb (FloppyRegisterFIFO, command);
+
+}
+
+uint8 FloppyReadData ()
+{
+ int32 t;
+ for (t = 0; t < 5000 && ((inportb(FloppyRegisterMainStatus) & FloppyMsrRQM) == 0); t++) ;
+
+ return inportb (FloppyRegisterFIFO);
+}
+
+/**************************************
+ * Sense interrupt *
+ **************************************/
+void FloppySenseInterrupt(uint8 *st0, uint8 *cyl)
+{
+ FloppySendCommand(FloppyCommandSenseInterrupt);
+ *st0 = FloppyReadData();
+ *cyl = FloppyReadData();
+}
+
+/**************************************
+ * Specify *
+ **************************************/
+void FloppySpecify (uint8 fd)
+{
+ FloppySendCommand(FloppyCommandSpecify);
+ FloppySendCommand((fdTypes[fd].SRT << 4) | fdTypes[fd].HUT);
+ FloppySendCommand(fdTypes[fd].HLT << 1);
+}
+
+/**************************************
+ * Motor on/off *
+ **************************************/
+void FloppyMotor (uint8 fd_number, uint8 status)
+{
+ if (fd_number >= 2) return;
+
+ uint8 fd = (fd_number == 0) ? fd0 : fd1;
+ uint8 temp = inportb(FloppyRegisterDigitalOutput);
+
+ // Turn motor on/off
+ if (status) temp |= 0x1<<(4+fd_number);
+ else temp &= ~(0x1<<(4+fd_number));
+ outportb(FloppyRegisterDigitalOutput, temp);
+
+ // Wait for spinup/spindown
+ if (status) TimerStart(fdTypes[fd].Spinup);
+ else TimerStart(fdTypes[fd].Spindown);
+
+ Log("%#[Floppy] %#Waiting for motor...\n", ColorBrown, ColorLightGray);
+ while (!TimerIsDone());
+}
+
+/**************************************
+ * Select drive *
+ **************************************/
+void FloppySelectDrive(uint8 number)
+{
+ if (number >= 2) return;
+ uint8 fd = (number == 0) ? fd0 : fd1;
+
+ // Set CCR
+ outportb(FloppyRegisterConfigurationControl, fdTypes[fd].DataRate);
+
+ // Specify
+ FloppySpecify(fd);
+
+ // Select drive
+ uint8 dor = inportb(FloppyRegisterDigitalOutput);
+ dor = (dor & ~0xFF) | number;
+}
+
+/**************************************
+ * RECALIBRATE *
+ * motor must be on, drive selected *
+ **************************************/
+void FloppyRecalibrate(uint8 fd_number)
+{
+ if (fd_number >= 2) return;
+
+ uint8 st0, cyl, timeout = 10;
+ do {
+ Log("%#[Floppy] %#Recalibrating: attempt %u/10\n", ColorBrown, ColorLightGray, 11-timeout);
+ FloppyIrqFired = 0;
+ FloppySendCommand(FloppyCommandRecalibrate);
+ FloppySendCommand(fd_number);
+ FloppyWaitIrq();
+
+ FloppySenseInterrupt(&st0, &cyl);
+
+ timeout--;
+ } while((st0 & 0x20) == 0 && timeout > 0);
+}
+
+/**************************************
+ * SEEK *
+ * motor must be on, drive selected *
+ **************************************/
+void FloppySeek(uint8 fd_number, uint8 cylinder, uint8 head)
+{
+ if (fd_number >= 2) return;
+
+ uint8 st0, cyl, timeout = 10;
+ do {
+ Log("%#[Floppy] %#Seeking: attempt %u/10\n", ColorBrown, ColorLightGray, 11-timeout);
+ FloppyIrqFired = 0;
+ FloppySendCommand(FloppyCommandSeek);
+ FloppySendCommand(head<<2 | fd_number);
+ FloppySendCommand(cylinder);
+ FloppyWaitIrq();
+
+ FloppySenseInterrupt(&st0, &cyl);
+
+ timeout--;
+ } while(cyl != cylinder && timeout > 0);
+
+}
+
+/**************************************
+ * READ/WRITE *
+ * motor must be on, drive selected *
+ **************************************/
+void FloppyRW(uint8 isWrite, uint8 fd_number, uint8 head, uint8 cylinder, uint8 sector)
+{
+ if (fd_number >= 2) return;
+ uint8 fd = (fd_number == 0) ? fd0 : fd1;
+
+ uint8 timeout = 10;
+ uint8 result[7], i, error;
+ do
+ {
+ error = 0;
+ Log("%#[Floppy] %#Read/write operation: attempt %u/10\n", ColorBrown, ColorLightGray, 11-timeout);
+ FloppyIrqFired = 0;
+
+ if (isWrite) FloppySendCommand(FloppyCommandWriteData | FloppyModeMultitrack | FloppyModeMagneticEncoding);
+ else FloppySendCommand(FloppyCommandReadData | FloppyModeMultitrack | FloppyModeMagneticEncoding);
+
+ FloppySendCommand(head<<2 | fd_number);
+ FloppySendCommand(cylinder);
+ FloppySendCommand(head);
+ FloppySendCommand(sector);
+ FloppySendCommand(2);
+ FloppySendCommand(fdTypes[fd].SectorsPerTrack);
+ FloppySendCommand(fdTypes[fd].Gap);
+ FloppySendCommand(0xff);
+
+ FloppyWaitIrq();
+
+ for (i = 0; i < 7; i++)
+ result[i] = FloppyReadData();
+
+ // Disk is write protected, don't try again
+ if (result[1] & 2)
+ {
+ Error("%#[Floppy] %#Error: disk is write protected!\n", ColorBrown, ColorLightRed);
+ return;
+ }
+
+ // Any other error - try again
+ if (result[0] & 0xC8) error = 1;
+ if (result[1] & 0xB5) error = 1;
+ if (result[2] & 0x77) error = 1;
+ if (result[6] & 0x02) error = 1;
+
+ timeout--;
+ } while (timeout > 0 && !error);
+}
+
+uint32 FloppyRead(uint8 drive, uint32 lba)
+{
+ if (drive >= 2) return 0;
+ uint8 fd = (drive == 0) ? fd0 : fd1;
+
+ // Convert LBA to CHS
+ uint32 cyl=0, head=0, sect=1;
+ ConvertLbaToChs(fdTypes[fd].SectorsPerTrack, lba, &cyl, &head, §);
+ Log("%#[Floppy] %#Converted LBA=%u to Cyl=%u Head=%u Sect=%u\n", ColorBrown, ColorLightGray, lba, cyl, head, sect);
+
+ FloppyInitDma();
+
+ // Reset drive if necessary
+ if ((inportb(FloppyRegisterMainStatus) & 0xC0) != 0x80)
+ FloppyReset();
+
+ // Start motor, select drive
+ FloppyMotor(drive, 1);
+ FloppySelectDrive(drive);
+
+ // Seek to correct location
+ FloppySeek(drive, cyl, head);
+
+ // Start DMA read
+ DmaMaskChannel(2);
+ DmaSetMode(2, 0x46);
+ DmaUnmaskChannel(2);
+
+ FloppyRW(0, drive, head, cyl, sect);
+
+ FloppyMotor(drive, 0);
+
+ return 0x1000;
+}
+
+// Log("%#[Drivers] %#Initializing blah blah %d...", ColorWhite, ColorLightGray,PIT_FREQUENCY);
diff --git a/Kernel/drivers/floppy/floppy.h b/Kernel/drivers/floppy/floppy.h
new file mode 100644
index 0000000..1f1e8c7
--- /dev/null
+++ b/Kernel/drivers/floppy/floppy.h
@@ -0,0 +1,86 @@
+/*
+ * floppy.h
+ *
+ * Created on: Aug 20, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef FLOPPY_H_
+#define FLOPPY_H_
+
+#include
+
+enum FloppyRegisters
+{
+ FloppyRegisterStatusA = 0x3F0, // read-only
+ FloppyRegisterStatusB = 0x3F1, // read-only
+ FloppyRegisterDigitalOutput = 0x3F2,
+ FloppyRegisterTapeDrive = 0x3F3,
+ FloppyRegisterMainStatus = 0x3F4, // read-only
+ FloppyRegisterDatarateSelect = 0x3F4, // write-only
+ FloppyRegisterFIFO = 0x3F5,
+ FloppyRegisterDigitalInput = 0x3F7, // read-only
+ FloppyRegisterConfigurationControl = 0x3F7 // write-only
+};
+
+enum FloppyCommands
+{
+ FloppyCommandReadTrack = 2, // generates IRQ6
+ FloppyCommandSpecify = 3, // * set drive parameters
+ FloppyCommandSenseDriveStatus = 4,
+ FloppyCommandWriteData = 5, // * write to the disk
+ FloppyCommandReadData = 6, // * read from the disk
+ FloppyCommandRecalibrate = 7, // * seek to cylinder 0
+ FloppyCommandSenseInterrupt = 8, // * ack IRQ6, get status of last command
+ FloppyCommandWriteDeletedData = 9,
+ FloppyCommandReadID = 10, // generates IRQ6
+ FloppyCommandReadDeletedData = 12,
+ FloppyCommandFormatTrack = 13, // *
+ FloppyCommandSeek = 15, // * seek both heads to cylinder X
+ FloppyCommandVersion = 16, // * used during initialization, once
+ FloppyCommandScanEqual = 17,
+ FloppyCommandPerpendicularMode = 18, // * used during initialization, once, maybe
+ FloppyCommandConfigure = 19, // * set controller parameters
+ FloppyCommandLock = 20, // * protect controller params from a reset
+ FloppyCommandVerify = 22,
+ FloppyCommandScanLowOrEqual = 25,
+ FloppyCommandScanHighOrEqual = 29,
+
+ FloppyModeMultitrack = 0x80,
+ FloppyModeMagneticEncoding = 0x40, // always set for read/write/verify/format
+ FloppyModeSkip = 0x20
+};
+
+enum FloppyMSRMasks
+{
+ FloppyMsrRQM = 0x80,
+ FloppyMsrDIO = 0x40,
+ FloppyMsrNDMA = 0x20,
+ FloppyMsrBusy = 0x10
+};
+
+typedef struct {
+ uint32 Size, SectorsPerTrack, Heads, Tracks;
+ uint8 Gap, DataRate, Spec1, SRT, HLT, HUT;
+ uint32 Spinup, Spindown, InterruptTimeout;
+ string Name;
+} FloppyType;
+
+extern void FloppyInitialize();
+extern void FloppyIrqHandler(_RegsStack32 *r);
+extern void FloppyWaitIrq();
+extern void FloppyInitDma();
+
+extern void FloppyReset();
+extern void FloppyConfigure();
+extern void FloppySendCommand (uint8 command);
+extern uint8 FloppyReadData ();
+extern void FloppySenseInterrupt(uint8 *st0, uint8 *cyl);
+extern void FloppySpecify (uint8 fd);
+extern void FloppyMotor (uint8 fd_number, uint8 status);
+extern void FloppySelectDrive(uint8 number);
+extern void FloppyRecalibrate(uint8 fd_number);
+extern void FloppyRW(uint8 isWrite, uint8 fd_number, uint8 head, uint8 cylinder, uint8 sector);
+extern uint32 FloppyRead(uint8 drive, uint32 lba);
+
+#endif /* FLOPPY_H_ */
diff --git a/Kernel/drivers/pit/pit.c b/Kernel/drivers/pit/pit.c
new file mode 100644
index 0000000..763685a
--- /dev/null
+++ b/Kernel/drivers/pit/pit.c
@@ -0,0 +1,13 @@
+#include
+#include
+#include "pit.h"
+
+void PitSetFrequency(uint32 frequency)
+{
+ uint32 divisor = 1193180 / frequency; // Calculate the divisor
+ outportb(0x43, 0x36); // Set our command byte 0x36
+ outportb(0x40, divisor & 0xff); // Set low byte
+ outportb(0x40, divisor>>8); // Set high byte
+
+ TimeSetInternalFrequency(frequency);
+}
diff --git a/Kernel/drivers/pit/pit.h b/Kernel/drivers/pit/pit.h
new file mode 100644
index 0000000..60cf309
--- /dev/null
+++ b/Kernel/drivers/pit/pit.h
@@ -0,0 +1,7 @@
+#ifndef __PIT__H
+#define __PIT__H
+
+extern void PitSetFrequency(uint32 frequency);
+
+
+#endif
\ No newline at end of file
diff --git a/Kernel/hal/clock/clock.c b/Kernel/hal/clock/clock.c
new file mode 100644
index 0000000..1d59115
--- /dev/null
+++ b/Kernel/hal/clock/clock.c
@@ -0,0 +1,19 @@
+#include
+#include "clock.h"
+
+#define MILISECONDS_IN_DAY 86400000
+
+volatile TimeSystem _internal_time;
+uint32 _internal_frequency_hz;
+
+void TimeHandler(_RegsStack32* UNUSED(r))
+{
+ if (_internal_frequency_hz == 0) return;
+
+ _internal_time.Time += 1000/_internal_frequency_hz;
+ if (_internal_time.Time >= MILISECONDS_IN_DAY)
+ {
+ _internal_time.Date++;
+ _internal_time.Time-=MILISECONDS_IN_DAY;
+ }
+}
diff --git a/Kernel/hal/clock/clock.h b/Kernel/hal/clock/clock.h
new file mode 100644
index 0000000..45eaef0
--- /dev/null
+++ b/Kernel/hal/clock/clock.h
@@ -0,0 +1,9 @@
+#ifndef __CLOCK__H
+#define __CLOCK__H
+
+#include
+
+extern void TimeHandler(_RegsStack32 *r);
+
+
+#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/gdt/gdt.asm b/Kernel/hal/cpu/gdt-asm.asm
similarity index 64%
rename from SysCore/drivers/cpu/gdt/gdt.asm
rename to Kernel/hal/cpu/gdt-asm.asm
index d3ce6f7..a8a1b49 100644
--- a/SysCore/drivers/cpu/gdt/gdt.asm
+++ b/Kernel/hal/cpu/gdt-asm.asm
@@ -1,14 +1,17 @@
+; GLOBAL DESCRIPTOR TABLE
+;
+;
+
bits 32
; !!! GDT !!!
; This will set up our new segment registers. We need to do
; something special in order to set CS. We do what is called a
; far jump. A jump that includes a segment as well as an offset.
-; This is declared in C as 'extern void gdt_flush();'
-global _i86_GdtFlush ; Allows the C code to link to this
-extern _gp ; Says that '_gp' is in another file
-_i86_GdtFlush:
- lgdt [_gp] ; Load the GDT with our '_gp' which is a special pointer
+global GdtFlush ; Allows the C code to link to this
+extern gp ; Says that 'gp' is in another file
+GdtFlush:
+ lgdt [gp] ; Load the GDT with our 'gp' which is a special pointer
mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment
mov ds, ax
mov es, ax
diff --git a/SysCore/drivers/cpu/gdt/gdt.c b/Kernel/hal/cpu/gdt.c
similarity index 81%
rename from SysCore/drivers/cpu/gdt/gdt.c
rename to Kernel/hal/cpu/gdt.c
index dd21fdd..ade2a8b 100644
--- a/SysCore/drivers/cpu/gdt/gdt.c
+++ b/Kernel/hal/cpu/gdt.c
@@ -5,15 +5,13 @@
#define MAX_DESCRIPTORS 5
#include "gdt.h"
-extern void i86_GdtInstall();
-
/* Our GDT, with 3 entries, and finally our special GDT pointer */
struct GdtEntry gdt[MAX_DESCRIPTORS];
struct GdtPointer gp;
/* Setup a descriptor in the Global Descriptor Table */
-void i86_GdtSetGate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran)
+void GdtSetGate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran)
{
/* Sanity check */
if (num >= MAX_DESCRIPTORS) return;
@@ -32,45 +30,45 @@ void i86_GdtSetGate(int num, unsigned long base, unsigned long limit, unsigned c
gdt[num].access = access;
}
-/*struct gdt_entry* i86_GdtGetGate(int num)
+struct GdtEntry* GdtGetGate(int num)
{
if (num>MAX_DESCRIPTORS) return 0;
return &gdt[num];
-}*/
+}
/* Should be called by main. This will setup the special GDT
* pointer, set up the first 3 entries in our GDT, and then
* finally call gdt_flush() in our assembler file in order
* to tell the processor where the new GDT is and update the
* new segment registers */
-void i86_GdtInstall()
+void GdtInstall()
{
/* Setup the GDT pointer and limit */
gp.limit = (sizeof(struct GdtEntry) * 3) - 1;
gp.base = (unsigned int)&gdt;
/* Our NULL descriptor */
- i86_GdtSetGate(0, 0, 0, 0, 0);
+ GdtSetGate(0, 0, 0, 0, 0);
/* The second entry is our Code Segment. The base address
* is 0, the limit is 4GBytes, it uses 4KByte granularity,
* uses 32-bit opcodes, and is a Code Segment descriptor.
* Please check the table above in the tutorial in order
* to see exactly what each value means */
- i86_GdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
+ GdtSetGate(1, 0, 0xFFFFFFFF, 0x9A, 0xCF);
/* The third entry is our Data Segment. It's EXACTLY the
* same as our code segment, but the descriptor type in
* this entry's access byte says it's a Data Segment */
- i86_GdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
+ GdtSetGate(2, 0, 0xFFFFFFFF, 0x92, 0xCF);
/* User mode Code segment*/
- i86_GdtSetGate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
+ GdtSetGate(3, 0, 0xFFFFFFFF, 0xFA, 0xCF);
/* User mode data segment*/
- i86_GdtSetGate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
+ GdtSetGate(4, 0, 0xFFFFFFFF, 0xF2, 0xCF);
/* Flush out the old GDT and install the new changes! */
- i86_GdtFlush();
+ GdtFlush();
}
-
\ No newline at end of file
+
diff --git a/SysCore/drivers/cpu/gdt/gdt.h b/Kernel/hal/cpu/gdt.h
similarity index 81%
rename from SysCore/drivers/cpu/gdt/gdt.h
rename to Kernel/hal/cpu/gdt.h
index 48fecf5..4068792 100644
--- a/SysCore/drivers/cpu/gdt/gdt.h
+++ b/Kernel/hal/cpu/gdt.h
@@ -30,9 +30,9 @@ struct GdtPointer
/* This will be a function in start.asm. We use this to properly
* reload the new segment registers */
-extern void i86_GdtInstall();
-extern void i86_GdtFlush();
-extern void i86_GdtSetGate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
-//extern struct GdtEntry* i86_GdtGetGate(int num);
+extern void GdtInstall();
+extern void GdtFlush();
+extern void GdtSetGate(int num, unsigned long base, unsigned long limit, unsigned char access, unsigned char gran);
+extern struct GdtEntry* GdtGetGate(int num);
#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/idt/idt.asm b/Kernel/hal/cpu/idt-asm.asm
similarity index 51%
rename from SysCore/drivers/cpu/idt/idt.asm
rename to Kernel/hal/cpu/idt-asm.asm
index 1841ef5..c7bbd04 100644
--- a/SysCore/drivers/cpu/idt/idt.asm
+++ b/Kernel/hal/cpu/idt-asm.asm
@@ -2,8 +2,8 @@ bits 32
; !!! IDT !!!
; Loads the IDT defined in '_idtp'
-global _i86_IdtLoad
-extern _idtp
-_i86_IdtLoad:
- lidt [_idtp]
+global IdtLoad
+extern idtp
+IdtLoad:
+ lidt [idtp]
ret
diff --git a/SysCore/drivers/cpu/idt/idt.c b/Kernel/hal/cpu/idt.c
similarity index 83%
rename from SysCore/drivers/cpu/idt/idt.c
rename to Kernel/hal/cpu/idt.c
index 240cd35..106fd45 100644
--- a/SysCore/drivers/cpu/idt/idt.c
+++ b/Kernel/hal/cpu/idt.c
@@ -2,17 +2,17 @@
* idt.h - INTERRUPT DESCRIPTOR TABLE *
* Contains structures and function declarations for IDT *
******************************************************************/
-#include
+#include
#include "idt.h"
-extern void i86_IdtLoad();
+extern void IdtLoad();
/* Declare an IDT of 256 entries. */
struct IdtEntry idt[256];
struct IdtPointer idtp;
/* Use this function to set an entry in the IDT. Alot simpler
* than twiddling with the GDT ;) */
-void i86_IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
+void IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags)
{
/* The interrupt routine's base address */
idt[num].base_lo = (base & 0xFFFF);
@@ -25,13 +25,13 @@ void i86_IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, u
idt[num].flags = flags;
}
-struct IdtEntry* i86_IdtGetGate(unsigned char num)
+struct IdtEntry* IdtGetGate(unsigned char num)
{
return &idt[num];
}
/* Installs the IDT */
-void i86_IdtInstall()
+void IdtInstall()
{
/* Sets the special IDT pointer up, just like in 'gdt.c' */
idtp.limit = (sizeof (struct IdtEntry) * 256) - 1;
@@ -41,5 +41,5 @@ void i86_IdtInstall()
memset (&idt, 0, sizeof(struct IdtEntry) * 256);
/* Points the processor's internal register to the new IDT */
- i86_IdtLoad();
+ IdtLoad();
}
diff --git a/SysCore/drivers/cpu/idt/idt.h b/Kernel/hal/cpu/idt.h
similarity index 76%
rename from SysCore/drivers/cpu/idt/idt.h
rename to Kernel/hal/cpu/idt.h
index 96067ed..dda72b2 100644
--- a/SysCore/drivers/cpu/idt/idt.h
+++ b/Kernel/hal/cpu/idt.h
@@ -24,8 +24,8 @@ struct IdtPointer
/* This exists in 'start.asm', and is used to load our IDT */
-extern void i86_IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
-extern struct IdtEntry* i86_IdtGetGate(unsigned char num);
-extern void i86_IdtInstall();
+extern void IdtSetGate(unsigned char num, unsigned long base, unsigned short sel, unsigned char flags);
+extern struct IdtEntry* IdtGetGate(unsigned char num);
+extern void IdtInstall();
#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/irq/irq.asm b/Kernel/hal/cpu/irq-asm.asm
similarity index 76%
rename from SysCore/drivers/cpu/irq/irq.asm
rename to Kernel/hal/cpu/irq-asm.asm
index b7fe235..b63337e 100644
--- a/SysCore/drivers/cpu/irq/irq.asm
+++ b/Kernel/hal/cpu/irq-asm.asm
@@ -1,25 +1,25 @@
bits 32
; !!! IRQ !!!
-global _i86_irq0
-global _i86_irq1
-global _i86_irq2
-global _i86_irq3
-global _i86_irq4
-global _i86_irq5
-global _i86_irq6
-global _i86_irq7
-global _i86_irq8
-global _i86_irq9
-global _i86_irq10
-global _i86_irq11
-global _i86_irq12
-global _i86_irq13
-global _i86_irq14
-global _i86_irq15
+global Irq_0
+global Irq_1
+global Irq_2
+global Irq_3
+global Irq_4
+global Irq_5
+global Irq_6
+global Irq_7
+global Irq_8
+global Irq_9
+global Irq_10
+global Irq_11
+global Irq_12
+global Irq_13
+global Irq_14
+global Irq_15
; 32: IRQ0
-_i86_irq0:
+Irq_0:
cli
push byte 0
push byte 32; Note that these don't push an error code on the stack:
@@ -27,113 +27,113 @@ _i86_irq0:
jmp irq_common_stub
; 33: IRQ1
-_i86_irq1:
+Irq_1:
cli
push byte 0
push byte 33
jmp irq_common_stub
; 34: IRQ2
-_i86_irq2:
+Irq_2:
cli
push byte 0
push byte 34
jmp irq_common_stub
; 35: IRQ3
-_i86_irq3:
+Irq_3:
cli
push byte 0
push byte 35
jmp irq_common_stub
; 36: IRQ4
-_i86_irq4:
+Irq_4:
cli
push byte 0
push byte 36
jmp irq_common_stub
; 37: IRQ5
-_i86_irq5:
+Irq_5:
cli
push byte 0
push byte 37
jmp irq_common_stub
; 38: IRQ6
-_i86_irq6:
+Irq_6:
cli
push byte 0
push byte 38
jmp irq_common_stub
; 39: IRQ7
-_i86_irq7:
+Irq_7:
cli
push byte 0
push byte 39
jmp irq_common_stub
; 40: IRQ8
-_i86_irq8:
+Irq_8:
cli
push byte 0
push byte 40
jmp irq_common_stub
; 41: IRQ9
-_i86_irq9:
+Irq_9:
cli
push byte 0
push byte 41
jmp irq_common_stub
; 42: IRQ10
-_i86_irq10:
+Irq_10:
cli
push byte 0
push byte 42
jmp irq_common_stub
; 43: IRQ11
-_i86_irq11:
+Irq_11:
cli
push byte 0
push byte 43
jmp irq_common_stub
; 44: IRQ12
-_i86_irq12:
+Irq_12:
cli
push byte 0
push byte 44
jmp irq_common_stub
; 45: IRQ13
-_i86_irq13:
+Irq_13:
cli
push byte 0
push byte 45
jmp irq_common_stub
; 46: IRQ14
-_i86_irq14:
+Irq_14:
cli
push byte 0
push byte 46
jmp irq_common_stub
; 47: IRQ15
-_i86_irq15:
+Irq_15:
cli
push byte 0
push byte 47
jmp irq_common_stub
-extern _i86_IrqHandler
+extern IrqHandler
; This is a stub that we have created for IRQ based ISRs. This calls
-; '_i86_irq_handler' in our C code. We need to create this in an 'irq.c'
+; 'Irq__handler' in our C code. We need to create this in an 'irq.c'
irq_common_stub:
pusha
push ds
@@ -147,7 +147,7 @@ irq_common_stub:
mov gs, ax
mov eax, esp
push eax
- mov eax, _i86_IrqHandler
+ mov eax, IrqHandler
call eax
pop eax
pop gs
diff --git a/Kernel/hal/cpu/irq.c b/Kernel/hal/cpu/irq.c
new file mode 100644
index 0000000..eed2efb
--- /dev/null
+++ b/Kernel/hal/cpu/irq.c
@@ -0,0 +1,91 @@
+#include
+#include "pic.h"
+#include "irq.h"
+#include "idt.h"
+
+/* These are own ISRs that point to our special IRQ handler
+* instead of the regular 'fault_handler' function */
+extern void Irq_0();
+extern void Irq_1();
+extern void Irq_2();
+extern void Irq_3();
+extern void Irq_4();
+extern void Irq_5();
+extern void Irq_6();
+extern void Irq_7();
+extern void Irq_8();
+extern void Irq_9();
+extern void Irq_10();
+extern void Irq_11();
+extern void Irq_12();
+extern void Irq_13();
+extern void Irq_14();
+extern void Irq_15();
+
+/* This array is actually an array of function pointers. We use
+* this to handle custom IRQ handlers for a given IRQ */
+void *IrqRoutines[16] =
+{
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/* This installs a custom IRQ handler for the given IRQ */
+void IrqInstallHandler (int irq, void (*handler)(_RegsStack32 *r))
+{
+ IrqRoutines[irq] = handler;
+}
+
+void IrqUninstallHandler (int irq)
+{
+ IrqRoutines[irq] = 0;
+}
+
+
+
+/* We first remap the interrupt controllers, and then we install
+* the appropriate ISRs to the correct entries in the IDT. This
+* is just like installing the exception handlers */
+void IrqInstall()
+{
+ PicRemap(32,40);
+
+ IdtSetGate(32, (unsigned)Irq_0, 0x08, 0x8E);
+ IdtSetGate(33, (unsigned)Irq_1, 0x08, 0x8E);
+ IdtSetGate(34, (unsigned)Irq_2, 0x08, 0x8E);
+ IdtSetGate(35, (unsigned)Irq_3, 0x08, 0x8E);
+ IdtSetGate(36, (unsigned)Irq_4, 0x08, 0x8E);
+ IdtSetGate(37, (unsigned)Irq_5, 0x08, 0x8E);
+ IdtSetGate(38, (unsigned)Irq_6, 0x08, 0x8E);
+ IdtSetGate(39, (unsigned)Irq_7, 0x08, 0x8E);
+ IdtSetGate(40, (unsigned)Irq_8, 0x08, 0x8E);
+ IdtSetGate(41, (unsigned)Irq_9, 0x08, 0x8E);
+ IdtSetGate(42, (unsigned)Irq_10, 0x08, 0x8E);
+ IdtSetGate(43, (unsigned)Irq_11, 0x08, 0x8E);
+ IdtSetGate(44, (unsigned)Irq_12, 0x08, 0x8E);
+ IdtSetGate(45, (unsigned)Irq_13, 0x08, 0x8E);
+ IdtSetGate(46, (unsigned)Irq_14, 0x08, 0x8E);
+ IdtSetGate(47, (unsigned)Irq_15, 0x08, 0x8E);
+}
+
+// Default IRQ handler, launches other handler if installed.
+// Also sends end-of-interrupt messages to PIC
+void IrqHandler (_RegsStack32 *r)
+{
+ /* This is a blank function pointer */
+ void (*handler)(_RegsStack32 *r);
+
+ /* Find out if we have a custom handler to run for this
+ * IRQ, and then finally, run it */
+ handler = IrqRoutines[r->int_no - 32];
+ if (handler) handler(r);
+
+ /* If the IDT entry that was invoked was greater than 40
+ * (meaning IRQ8 - 15), then we need to send an EOI to
+ * the slave controller */
+ if (r->int_no >=40) outportb(0xA0, 0x20);
+
+ /* In either case, we need to send an EOI to the master
+ * interrupt controller too */
+ outportb(0x20, 0x20);
+}
diff --git a/Kernel/hal/cpu/irq.h b/Kernel/hal/cpu/irq.h
new file mode 100644
index 0000000..70be7ee
--- /dev/null
+++ b/Kernel/hal/cpu/irq.h
@@ -0,0 +1,10 @@
+#ifndef __IRQ_H
+#define __IRQ_H
+
+#include
+
+extern void IrqInstallHandler (int irq, void (*handler)(_RegsStack32 *r));
+extern void IrqUninstallHandler (int irq);
+extern void IrqInstall();
+
+#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/isrs/isrs.asm b/Kernel/hal/cpu/isrs-asm.asm
similarity index 68%
rename from SysCore/drivers/cpu/isrs/isrs.asm
rename to Kernel/hal/cpu/isrs-asm.asm
index d876d89..b96ab5d 100644
--- a/SysCore/drivers/cpu/isrs/isrs.asm
+++ b/Kernel/hal/cpu/isrs-asm.asm
@@ -1,196 +1,196 @@
bits 32
; !!! ISRs !!!
-global _i86_isr0
-global _i86_isr1
-global _i86_isr2
-global _i86_isr3
-global _i86_isr4
-global _i86_isr5
-global _i86_isr6
-global _i86_isr7
-global _i86_isr8
-global _i86_isr9
-global _i86_isr10
-global _i86_isr11
-global _i86_isr12
-global _i86_isr13
-global _i86_isr14
-global _i86_isr15
-global _i86_isr16
-global _i86_isr17
-global _i86_isr18
-global _i86_isr19
-global _i86_isr20
-global _i86_isr21
-global _i86_isr22
-global _i86_isr23
-global _i86_isr24
-global _i86_isr25
-global _i86_isr26
-global _i86_isr27
-global _i86_isr28
-global _i86_isr29
-global _i86_isr30
-global _i86_isr31
+global isr_exception_0
+global isr_exception_1
+global isr_exception_2
+global isr_exception_3
+global isr_exception_4
+global isr_exception_5
+global isr_exception_6
+global isr_exception_7
+global isr_exception_8
+global isr_exception_9
+global isr_exception_10
+global isr_exception_11
+global isr_exception_12
+global isr_exception_13
+global isr_exception_14
+global isr_exception_15
+global isr_exception_16
+global isr_exception_17
+global isr_exception_18
+global isr_exception_19
+global isr_exception_20
+global isr_exception_21
+global isr_exception_22
+global isr_exception_23
+global isr_exception_24
+global isr_exception_25
+global isr_exception_26
+global isr_exception_27
+global isr_exception_28
+global isr_exception_29
+global isr_exception_30
+global isr_exception_31
-_i86_isr0:
+isr_exception_0:
cli
push byte 0; A normal ISR stub that pops a dummy error code to keep a
; uniform stack frame
push byte 0
jmp isr_common_stub
-_i86_isr1:
+isr_exception_1:
cli
push byte 0
push byte 1
jmp isr_common_stub
-_i86_isr2:
+isr_exception_2:
cli
push byte 0
push byte 2
jmp isr_common_stub
-_i86_isr3:
+isr_exception_3:
cli
push byte 0
push byte 3
jmp isr_common_stub
-_i86_isr4:
+isr_exception_4:
cli
push byte 0
push byte 4
jmp isr_common_stub
-_i86_isr5:
+isr_exception_5:
cli
push byte 0
push byte 5
jmp isr_common_stub
-_i86_isr6:
+isr_exception_6:
cli
push byte 0
push byte 6
jmp isr_common_stub
-_i86_isr7:
+isr_exception_7:
cli
push byte 0
push byte 7
jmp isr_common_stub
-_i86_isr8:
+isr_exception_8:
cli
push byte 8
jmp isr_common_stub
-_i86_isr9:
+isr_exception_9:
cli
push byte 0
push byte 9
jmp isr_common_stub
-_i86_isr10:
+isr_exception_10:
cli
push byte 10
jmp isr_common_stub
-_i86_isr11:
+isr_exception_11:
cli
push byte 11
jmp isr_common_stub
-_i86_isr12:
+isr_exception_12:
cli
push byte 12
jmp isr_common_stub
-_i86_isr13:
+isr_exception_13:
cli
push byte 13
jmp isr_common_stub
-_i86_isr14:
+isr_exception_14:
cli
push byte 14
jmp isr_common_stub
-_i86_isr15:
+isr_exception_15:
cli
push byte 0
push byte 15
jmp isr_common_stub
-_i86_isr16:
+isr_exception_16:
cli
push byte 0
push byte 16
jmp isr_common_stub
-_i86_isr17:
+isr_exception_17:
cli
push byte 0
push byte 17
jmp isr_common_stub
-_i86_isr18:
+isr_exception_18:
cli
push byte 0
push byte 18
jmp isr_common_stub
-_i86_isr19:
+isr_exception_19:
cli
push byte 0
push byte 19
jmp isr_common_stub
-_i86_isr20:
+isr_exception_20:
cli
push byte 0
push byte 20
jmp isr_common_stub
-_i86_isr21:
+isr_exception_21:
cli
push byte 0
push byte 21
jmp isr_common_stub
-_i86_isr22:
+isr_exception_22:
cli
push byte 0
push byte 22
jmp isr_common_stub
-_i86_isr23:
+isr_exception_23:
cli
push byte 0
push byte 23
jmp isr_common_stub
-_i86_isr24:
+isr_exception_24:
cli
push byte 0
push byte 24
jmp isr_common_stub
-_i86_isr25:
+isr_exception_25:
cli
push byte 0
push byte 25
jmp isr_common_stub
-_i86_isr26:
+isr_exception_26:
cli
push byte 0
push byte 26
jmp isr_common_stub
-_i86_isr27:
+isr_exception_27:
cli
push byte 0
push byte 27
jmp isr_common_stub
-_i86_isr28:
+isr_exception_28:
cli
push byte 0
push byte 28
jmp isr_common_stub
-_i86_isr29:
+isr_exception_29:
cli
push byte 0
push byte 29
jmp isr_common_stub
-_i86_isr30:
+isr_exception_30:
cli
push byte 0
push byte 30
jmp isr_common_stub
-_i86_isr31:
+isr_exception_31:
cli
push byte 0
push byte 31
jmp isr_common_stub
-extern _i86_FaultHandler
+extern IsrsFaultHandler
isr_common_stub:
pusha
@@ -205,7 +205,7 @@ isr_common_stub:
mov gs, ax
mov eax, esp ; Push us the stack
push eax
- mov eax, _i86_FaultHandler
+ mov eax, IsrsFaultHandler
call eax ; A special call, preserves the 'eip' register
pop eax
pop gs
diff --git a/Kernel/hal/cpu/isrs.c b/Kernel/hal/cpu/isrs.c
new file mode 100644
index 0000000..78f0cf0
--- /dev/null
+++ b/Kernel/hal/cpu/isrs.c
@@ -0,0 +1,114 @@
+#include
+
+#include "isrs.h"
+#include "idt.h"
+
+// Assembly coded
+extern void isr_exception_0();
+extern void isr_exception_1();
+extern void isr_exception_2();
+extern void isr_exception_3();
+extern void isr_exception_4();
+extern void isr_exception_5();
+extern void isr_exception_6();
+extern void isr_exception_7();
+extern void isr_exception_8();
+extern void isr_exception_9();
+extern void isr_exception_10();
+extern void isr_exception_11();
+extern void isr_exception_12();
+extern void isr_exception_13();
+extern void isr_exception_14();
+extern void isr_exception_15();
+extern void isr_exception_16();
+extern void isr_exception_17();
+extern void isr_exception_18();
+extern void isr_exception_19();
+extern void isr_exception_20();
+extern void isr_exception_21();
+extern void isr_exception_22();
+extern void isr_exception_23();
+extern void isr_exception_24();
+extern void isr_exception_25();
+extern void isr_exception_26();
+extern void isr_exception_27();
+extern void isr_exception_28();
+extern void isr_exception_29();
+extern void isr_exception_30();
+extern void isr_exception_31();
+
+
+void* IdtFaultHandlers[32] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
+ };
+
+void IsrsInstall()
+{
+ IdtSetGate(0, (unsigned)isr_exception_0, 0x08, 0x8E);
+ IdtSetGate(1, (unsigned)isr_exception_1, 0x08, 0x8E);
+ IdtSetGate(2, (unsigned)isr_exception_2, 0x08, 0x8E);
+ IdtSetGate(3, (unsigned)isr_exception_3, 0x08, 0x8E);
+ IdtSetGate(4, (unsigned)isr_exception_4, 0x08, 0x8E);
+ IdtSetGate(5, (unsigned)isr_exception_5, 0x08, 0x8E);
+ IdtSetGate(6, (unsigned)isr_exception_6, 0x08, 0x8E);
+ IdtSetGate(7, (unsigned)isr_exception_7, 0x08, 0x8E);
+ IdtSetGate(8, (unsigned)isr_exception_8, 0x08, 0x8E);
+ IdtSetGate(9, (unsigned)isr_exception_9, 0x08, 0x8E);
+ IdtSetGate(10, (unsigned)isr_exception_10, 0x08, 0x8E);
+ IdtSetGate(11, (unsigned)isr_exception_11, 0x08, 0x8E);
+ IdtSetGate(12, (unsigned)isr_exception_12, 0x08, 0x8E);
+ IdtSetGate(13, (unsigned)isr_exception_13, 0x08, 0x8E);
+ IdtSetGate(14, (unsigned)isr_exception_14, 0x08, 0x8E);
+ IdtSetGate(15, (unsigned)isr_exception_15, 0x08, 0x8E);
+ IdtSetGate(16, (unsigned)isr_exception_16, 0x08, 0x8E);
+ IdtSetGate(17, (unsigned)isr_exception_17, 0x08, 0x8E);
+ IdtSetGate(18, (unsigned)isr_exception_18, 0x08, 0x8E);
+ IdtSetGate(19, (unsigned)isr_exception_19, 0x08, 0x8E);
+ IdtSetGate(20, (unsigned)isr_exception_20, 0x08, 0x8E);
+ IdtSetGate(21, (unsigned)isr_exception_21, 0x08, 0x8E);
+ IdtSetGate(22, (unsigned)isr_exception_22, 0x08, 0x8E);
+ IdtSetGate(23, (unsigned)isr_exception_23, 0x08, 0x8E);
+ IdtSetGate(24, (unsigned)isr_exception_24, 0x08, 0x8E);
+ IdtSetGate(25, (unsigned)isr_exception_25, 0x08, 0x8E);
+ IdtSetGate(26, (unsigned)isr_exception_26, 0x08, 0x8E);
+ IdtSetGate(27, (unsigned)isr_exception_27, 0x08, 0x8E);
+ IdtSetGate(28, (unsigned)isr_exception_28, 0x08, 0x8E);
+ IdtSetGate(29, (unsigned)isr_exception_29, 0x08, 0x8E);
+ IdtSetGate(30, (unsigned)isr_exception_30, 0x08, 0x8E);
+ IdtSetGate(31, (unsigned)isr_exception_31, 0x08, 0x8E);
+}
+
+
+void IsrsInstallHandler(int interr, void (*function)(_RegsStack32 *r))
+{
+ if (interr < 32) IdtFaultHandlers[interr] = function;
+}
+
+
+void IsrsUninstallHandler(int interr)
+{
+ if (interr < 32) IdtFaultHandlers[interr] = 0;
+}
+
+
+extern void CrashMessage(_RegsStack32 *r);
+// Default fault handler; calls other handlers, or displays error message.
+void IsrsFaultHandler(_RegsStack32 *r)
+{
+ /* Is this a fault whose number is from 0 to 31? */
+ if (r->int_no < 32)
+ {
+ void (*func)(_RegsStack32 *r);
+ func = IdtFaultHandlers[r->int_no];
+
+ // Halt system if unhandled
+ if (!func) {
+ CrashMessage(r);
+ asm ("cli");
+ asm ("hlt");
+ }
+
+ else (*func)(r);
+ }
+}
diff --git a/Kernel/hal/cpu/isrs.h b/Kernel/hal/cpu/isrs.h
new file mode 100644
index 0000000..257a0fd
--- /dev/null
+++ b/Kernel/hal/cpu/isrs.h
@@ -0,0 +1,10 @@
+#ifndef __ISRS_H_
+#define __ISRS_H_
+
+#include
+
+extern void IsrsInstall();
+extern void IsrsInstallHandler(int interr, void (*function)(_RegsStack32 *r));
+extern void IsrsUninstallHandler(int interr);
+
+#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/irq/pic.c b/Kernel/hal/cpu/pic.c
similarity index 86%
rename from SysCore/drivers/cpu/irq/pic.c
rename to Kernel/hal/cpu/pic.c
index 4800b51..63a961b 100644
--- a/SysCore/drivers/cpu/irq/pic.c
+++ b/Kernel/hal/cpu/pic.c
@@ -1,7 +1,7 @@
-#include
+#include
#include "pic.h"
-void i86_PicRemap(int pic1, int pic2)
+void PicRemap(int pic1, int pic2)
{
// Send ICW1
outportb(0x20, 0x11);
diff --git a/Kernel/hal/cpu/pic.h b/Kernel/hal/cpu/pic.h
new file mode 100644
index 0000000..e464fcc
--- /dev/null
+++ b/Kernel/hal/cpu/pic.h
@@ -0,0 +1,6 @@
+#ifndef _PIC_H
+#define _PIC_H
+
+extern void PicRemap(int pic1, int pic2);
+
+#endif
\ No newline at end of file
diff --git a/Kernel/hal/crash.c b/Kernel/hal/crash.c
new file mode 100644
index 0000000..fcaa4a0
--- /dev/null
+++ b/Kernel/hal/crash.c
@@ -0,0 +1,96 @@
+/*
+ * crash.c
+ *
+ * Created on: Aug 19, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+string errorCodes[] =
+{
+ "Division by zero", //0
+ "Debugger", //1
+ "Non maskable interrupt", //2
+ "Breakpoint", //3
+ "Overflow", //4
+ "Bounds", //5
+ "Invalid opcode", //6
+ "Coprocessor not available", //7
+ "Double fault", //8
+ "Coprocessor segment overrun",//9
+ "Invalid task state segment", //A
+ "Segment not present", //B
+ "Stack fault", //C
+ "General protection fault", //D
+ "Page fault", //E
+ "", //F
+ "Math fault", //10
+ "Alignment check", //11
+ "Machine check", //12
+ "SIMD floating-point exception" //13
+};
+
+void CrashMessage(_RegsStack32 *r)
+{
+ ConsoleSetDefaultColor(ColorLightRed);
+ ConsoleWrite("\n"); uint32 i;
+ for (i = 0; i < 80; i++) ConsoleWrite("%c", 205);
+
+ ConsoleWrite("%#\t\t\t\tSomething went terribly wrong :(\n\n", ColorWhite);
+ ConsoleWrite("There was an unhandled exception: ");
+
+ if (r->int_no < 20)
+ ConsoleWrite("%#%s (INT%u)", ColorWhite, errorCodes[r->int_no], r->int_no);
+ else ConsoleWrite("%#INT%u", ColorWhite, r->int_no);
+
+ ConsoleWrite("\nTo protect your computer, it had to be halted.\n\n");
+ ConsoleWrite("Here, this might help find the problem:\n");
+
+ Point a = {4, -1}, b = {22, -1}, c = {40, -1}, d = {58, -1};
+
+ ConsoleSetDefaultColor(ColorWhite);
+ ConsoleCursorGoto(a); ConsoleWrite("eax=0x%x", r->eax);
+ ConsoleCursorGoto(b); ConsoleWrite("ebx=0x%x", r->ebx);
+ ConsoleCursorGoto(c); ConsoleWrite("ecx=0x%x", r->ecx);
+ ConsoleCursorGoto(d); ConsoleWrite("edx=0x%x\n", r->edx);
+
+ ConsoleCursorGoto(a); ConsoleWrite("edi=0x%x", r->edi);
+ ConsoleCursorGoto(b); ConsoleWrite("esi=0x%x", r->esi);
+ ConsoleCursorGoto(c); ConsoleWrite("ebp=0x%x", r->ebp);
+ ConsoleCursorGoto(d); ConsoleWrite("esp=0x%x\n", r->esp);
+
+ ConsoleCursorGoto(a); ConsoleWrite("gs=0x%x", r->gs);
+ ConsoleCursorGoto(b); ConsoleWrite("fs=0x%x", r->fs);
+ ConsoleCursorGoto(c); ConsoleWrite("es=0x%x", r->es);
+ ConsoleCursorGoto(d); ConsoleWrite("ds=0x%x\n", r->ds);
+
+ ConsoleCursorGoto(a); ConsoleWrite("eip=0x%x", r->eip);
+ ConsoleCursorGoto(b); ConsoleWrite("cs=0x%x", r->cs);
+ ConsoleCursorGoto(c); ConsoleWrite("eflags=0x%x", r->eflags);
+ ConsoleCursorGoto(d); ConsoleWrite("useresp=0x%x\n", r->useresp);
+
+ ConsoleCursorGoto(a); ConsoleWrite("gs=0x%x", r->ss);
+ ConsoleCursorGoto(b); ConsoleWrite("fs=0x%x", r->int_no);
+ ConsoleCursorGoto(c); ConsoleWrite("err_code=0x%x", r->err_code);
+
+ // Useful info about page fault
+ if (r->int_no == 0xE)
+ {
+ uint32 faulting_address;
+ asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
+
+ ConsoleCursorGoto(d); ConsoleWrite("address=0x%x\n", faulting_address);
+ ConsoleCursorGoto(a); ConsoleWrite("reason: ");
+
+ if (!(r->err_code & 1)) ConsoleWrite("%#PAGE_NOT_PRESENT; ", ColorLightGray);
+ if (r->err_code & 2) ConsoleWrite("%#WRITE_OPERATION; ", ColorLightGray);
+ if (r->err_code & 4) ConsoleWrite("%#CPU_IN_USER_MODE; ", ColorLightGray);
+ if (r->err_code & 8) ConsoleWrite("%#CPU_RESERVED_PAGE_ENTRY_OVERWRITTEN; ", ColorLightGray);
+ if (r->err_code & 0x10) ConsoleWrite("%#INSTRUCTION_FETCH; ", ColorLightGray);
+ }
+
+ ConsoleSetDefaultColor(ColorLightRed);
+ ConsoleWrite("\n");
+ for (i = 0; i < 80; i++) ConsoleWrite("%c", 205);
+}
diff --git a/Kernel/hal/crash.c~ b/Kernel/hal/crash.c~
new file mode 100644
index 0000000..e6044d0
--- /dev/null
+++ b/Kernel/hal/crash.c~
@@ -0,0 +1,97 @@
+/*
+ * crash.c
+ *
+ * Created on: Aug 19, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+string errorCodes[] =
+{
+ "Division by zero", //0
+ "Debugger", //1
+ "Non maskable interrupt", //2
+ "Breakpoint", //3
+ "Overflow", //4
+ "Bounds", //5
+ "Invalid opcode", //6
+ "Coprocessor not available", //7
+ "Double fault", //8
+ "Coprocessor segment overrun",//9
+ "Invalid task state segment", //A
+ "Segment not present", //B
+ "Stack fault", //C
+ "General protection fault", //D
+ "Page fault", //E
+ "", //F
+ "Math fault", //10
+ "Alignment check", //11
+ "Machine check", //12
+ "SIMD floating-point exception" //13
+};
+
+void CrashMessage(_RegsStack32 *r)
+{
+ ConsoleSetDefaultColor(ColorLightRed);
+
+ ConsoleWrite("\n"); uint32 i;
+ for (i = 0; i < 80; i++) ConsoleWrite("%c", 205);
+
+ ConsoleWrite("%#\t\t\t\tSomething went terribly wrong :(\n\n", ColorWhite);
+ ConsoleWrite("There was an unhandled exception: ");
+
+ if (r->int_no < 20)
+ ConsoleWrite("%#%s (INT%u)", ColorWhite, errorCodes[r->int_no], r->int_no);
+ else ConsoleWrite("%#INT%u", ColorWhite, r->int_no);
+
+ ConsoleWrite("\nTo protect your computer, it had to be halted.\n\n");
+ ConsoleWrite("Here, this might help find the problem:\n");
+
+ Point a = {4, -1}, b = {22, -1}, c = {40, -1}, d = {58, -1};
+
+ ConsoleSetDefaultColor(ColorWhite);
+ ConsoleCursorGoto(a); ConsoleWrite("eax=0x%x", r->eax);
+ ConsoleCursorGoto(b); ConsoleWrite("ebx=0x%x", r->ebx);
+ ConsoleCursorGoto(c); ConsoleWrite("ecx=0x%x", r->ecx);
+ ConsoleCursorGoto(d); ConsoleWrite("edx=0x%x\n", r->edx);
+
+ ConsoleCursorGoto(a); ConsoleWrite("edi=0x%x", r->edi);
+ ConsoleCursorGoto(b); ConsoleWrite("esi=0x%x", r->esi);
+ ConsoleCursorGoto(c); ConsoleWrite("ebp=0x%x", r->ebp);
+ ConsoleCursorGoto(d); ConsoleWrite("esp=0x%x\n", r->esp);
+
+ ConsoleCursorGoto(a); ConsoleWrite("gs=0x%x", r->gs);
+ ConsoleCursorGoto(b); ConsoleWrite("fs=0x%x", r->fs);
+ ConsoleCursorGoto(c); ConsoleWrite("es=0x%x", r->es);
+ ConsoleCursorGoto(d); ConsoleWrite("ds=0x%x\n", r->ds);
+
+ ConsoleCursorGoto(a); ConsoleWrite("eip=0x%x", r->eip);
+ ConsoleCursorGoto(b); ConsoleWrite("cs=0x%x", r->cs);
+ ConsoleCursorGoto(c); ConsoleWrite("eflags=0x%x", r->eflags);
+ ConsoleCursorGoto(d); ConsoleWrite("useresp=0x%x\n", r->useresp);
+
+ ConsoleCursorGoto(a); ConsoleWrite("gs=0x%x", r->ss);
+ ConsoleCursorGoto(b); ConsoleWrite("fs=0x%x", r->int_no);
+ ConsoleCursorGoto(c); ConsoleWrite("err_code=0x%x", r->err_code);
+
+ // Useful info about page fault
+ if (r->int_no == 0xE)
+ {
+ uint32 faulting_address;
+ asm volatile("mov %%cr2, %0" : "=r" (faulting_address));
+
+ ConsoleCursorGoto(d); ConsoleWrite("address=0x%x\n", faulting_address);
+ ConsoleCursorGoto(a); ConsoleWrite("reason: ");
+
+ if (!(r->err_code & 1)) ConsoleWrite("%#PAGE_NOT_PRESENT; ", ColorLightGray);
+ if (r->err_code & 2) ConsoleWrite("%#WRITE_OPERATION; ", ColorLightGray);
+ if (r->err_code & 4) ConsoleWrite("%#CPU_IN_USER_MODE; ", ColorLightGray);
+ if (r->err_code & 8) ConsoleWrite("%#CPU_RESERVED_PAGE_ENTRY_OVERWRITTEN; ", ColorLightGray);
+ if (r->err_code & 0x10) ConsoleWrite("%#INSTRUCTION_FETCH; ", ColorLightGray);
+ }
+
+ ConsoleSetDefaultColor(ColorLightRed);
+ ConsoleWrite("\n");
+ for (i = 0; i < 80; i++) ConsoleWrite("%c", 205);
+}
diff --git a/Kernel/hal/hal.c b/Kernel/hal/hal.c
new file mode 100644
index 0000000..db51fe8
--- /dev/null
+++ b/Kernel/hal/hal.c
@@ -0,0 +1,35 @@
+// HARDWARE ABSTRACTION LAYER
+#include "cpu/gdt.h"
+#include "cpu/idt.h"
+#include "cpu/isrs.h"
+#include "cpu/irq.h"
+
+#include "clock/clock.h"
+#include "keyboard/keyboard.h"
+#include "mouse/mouse.h"
+
+#include
+
+void HalInitialize()
+{
+ // Initialize cpu
+ GdtInstall(); Log("%#[HAL] %#Installed GDT\n", ColorYellow, ColorLightGreen);
+ IdtInstall(); Log("%#[HAL] %#Installed IDT\n", ColorYellow, ColorLightGreen);
+ IsrsInstall(); Log("%#[HAL] %#Installed ISRs\n", ColorYellow, ColorLightGreen);
+ IrqInstall(); Log("%#[HAL] %#Installed IRQs\n", ColorYellow, ColorLightGreen);
+
+ // Start interrupts
+ asm volatile ("sti");
+ Log("%#[HAL] %#Interrupts are started...\n", ColorYellow, ColorLightMagenta);
+
+ // Install keyboard
+ IrqInstallHandler(0, TimeHandler);
+ IrqInstallHandler(1, KeyboardHandler);
+ IrqInstallHandler(12, MouseHandler);
+
+ KeyboardInstallA(); Log("%#[HAL] %#Installing keyboard... %#[1/2] ", ColorYellow, ColorLightGray, ColorLightGreen);
+ KeyboardInstallB(); Log("%#[2/2]\n", ColorLightGreen);
+
+ // Install mouse driver
+ MouseInstall(); Log("%#[HAL] %#Installed mouse driver\n", ColorYellow, ColorLightGreen);
+}
diff --git a/Kernel/hal/hal.h b/Kernel/hal/hal.h
new file mode 100644
index 0000000..081bb2d
--- /dev/null
+++ b/Kernel/hal/hal.h
@@ -0,0 +1,6 @@
+#ifndef __HAL__H
+#define __HAL__H
+
+extern void HalInitialize();
+
+#endif
\ No newline at end of file
diff --git a/Kernel/hal/keyboard/keyboard.c b/Kernel/hal/keyboard/keyboard.c
new file mode 100644
index 0000000..64980e7
--- /dev/null
+++ b/Kernel/hal/keyboard/keyboard.c
@@ -0,0 +1,327 @@
+#include
+#include "keyboard.h"
+
+#define KeybCmdWriteLED 0xed
+#define KeybCmdEcho 0xee
+#define KeybCmdSetScancodeSet 0xf0
+#define KeybCmdGetID 0xf2
+#define KeybCmdSetRepeatDelay 0xf3
+#define KeybCmdEnable 0xf4
+#define KeybCmdSetDefaultDisable 0xf5
+#define KeybCmdSetDefault 0xf6
+#define KeybCmdResend 0xfe
+#define KeybCmdReset 0xff
+
+volatile uint8 KeyState[16];
+volatile uint8 KeyboardLastStatus;
+volatile uint8 KeyboardLastScancode;
+
+uint8 KeyboardScancodeSet = 2;
+
+// Byte map:
+// 0 If set, next code is break
+// 1 'Gray' key
+// 2 'Weird' key (Pause/Break)
+// 3 Scroll
+// 4 Num
+// 5 Caps
+// 6 If set, LEDs changed
+uint8 KeyboardModifiers;
+
+const char KeyboardMap[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '`', 0,
+ 0, 0, 0, 0, 0, 'q', '1', 0, 0, 0, 'z', 's', 'a', 'w', '2', 0,
+ 0, 'c', 'x', 'd', 'e', '4', '3', 0, 0, ' ', 'v', 'f', 't', 'r', '5', 0,
+ 0, 'n', 'b', 'h', 'g', 'y', '6', 0, 0, 0, 'm', 'j', 'u', '7', '8', 0,
+ 0, ',', 'k', 'i', 'o', '0', '9', 0, 0, '.', '/', 'l', ';', 'p', '-', 0,
+ 0, 0, '\'', 0, '[', '=', 0, 0, 0, 0, '\n', ']', 0, '\\', 0, 0,
+ 0, 0, 0, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', '\n', 0, 0,
+ '0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
+ };
+
+const char KeyboardMapShift[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '~', 0,
+ 0, 0, 0, 0, 0, 'Q', '!', 0, 0, 0, 'Z', 'S', 'A', 'W', '@', 0,
+ 0, 'C', 'X', 'D', 'E', '$', '#', 0, 0, ' ', 'V', 'F', 'T', 'R', '%', 0,
+ 0, 'N', 'B', 'H', 'G', 'Y', '^', 0, 0, 0, 'M', 'J', 'U', '&', '*', 0,
+ 0, '<', 'K', 'I', 'O', ')', '(', 0, 0, '>', '?', 'L', ':', 'P', '_', 0,
+ 0, 0, '\"', 0, '{', '+', 0, 0, 0, 0, '\n', '}', 0, '|', 0, 0,
+ 0, 0, 0, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', '\n', 0, 0,
+ '0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
+ };
+
+
+void KeyboardSetKeyStatus (uint8 scancode, uint8 status)
+{
+ int32 index = scancode>>3, pos = scancode & 0x7;
+
+ if (status) KeyState[index] |= 1<>3, pos = scancode & 0x7;
+
+ return KeyState[index] & (1< 0);
+ status |= (num > 0) << 1;
+ status |= (caps > 0) << 2;
+
+ KeyboardWaitOutport();
+ outportb (0x60, KeybCmdWriteLED);
+
+ KeyboardWaitOutport();
+ outportb (0x60, status);
+}
+
+
+/***************************************
+ * Set repeat rate/delay *
+ ***************************************
+ Values for inter-character delay (bits 4-0)
+ (characters per second; default is 10.9)
+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
+ ----+----+----+----+----+----+----+----+----
+ 0 |30.0|26.7|24.0|21.8|20.0|18.5|17.1|16.0
+ 8 |15.0|13.3|12.0|10.9|10.0|9.2 |8.6 |8.0
+ 16 |7.5 |6.7 |6.0 |5.5 |5.0 |4.6 |4.3 |4.0
+ 24 |3.7 |3.3 |3.0 |2.7 |2.5 |2.3 |2.1 |2.0
+
+ Values for delay:
+ (miliseconds; default is 500)
+ 0 | 1 | 2 | 3
+ -----+-----+-----+-----
+ 250 | 500 | 750 | 1000
+
+ ***************************************/
+void KeyboardSetRepeatRate(uint8 rate, uint8 delay)
+{
+ if (rate>3 || delay>31) return;
+
+ uint8 out = rate<<5 | delay;
+
+ KeyboardWaitOutport();
+ outportb(0x60, KeybCmdSetRepeatDelay);
+
+ KeyboardWaitOutport();
+ outportb(0x60, out);
+}
+
+/***************************************
+ * Set scancode set *
+ ***************************************
+ 1 Set to scancode set 1
+ 2 Set to scancode set 2
+ 3 Set to scancode set 3
+ ***************************************/
+void KeyboardSetScancodeSet(uint8 set)
+{
+ if (set>3 || set <= 0) return;
+
+ KeyboardWaitOutport();
+ outportb (0x60, KeybCmdSetScancodeSet);
+
+ KeyboardWaitOutport();
+ outportb (0x60, set);
+
+ KeyboardScancodeSet = set;
+}
+
+
+void KeyboardWaitOutport()
+{
+ int fail_safe=200000;
+ while ((inportb(0x64)&2)!=0 && fail_safe>0) fail_safe--;
+}
+
+void KeyboardWaitInport()
+{
+ int fail_safe=200000;
+ while ((inportb(0x64)&1)==0 && fail_safe>0) fail_safe--;
+}
+
+
+void KeyboardInstallA()
+{
+ KeyboardWaitOutport();
+ outportb(0x60, KeybCmdReset); // Reset kb
+
+ // Initialize variables
+ KeyboardLastStatus = 0;
+ KeyboardModifiers = 0;
+
+ int32 i;
+ for (i = 0; i < 16; i++)
+ KeyState[i] = 0;
+}
+
+
+void KeyboardInstallB()
+{
+ // Wait for BAT test results
+ KeyboardWaitInport();
+
+ unsigned char temp;
+ do temp = inportb(0x60);
+ while (temp!=0xAA && temp!=0xFC);
+
+ // Error
+ if (temp == 0xFC) return;
+
+ // Set new repeat rate
+ KeyboardSetRepeatRate(1, 11);
+
+ // Set scancode set 2
+ KeyboardSetScancodeSet(2); // Set new scancode set
+
+ KeyboardWaitOutport();
+ outportb(0x64, 0x20); // Get "Command unsigned char"
+
+ do { temp = inportb(0x60);
+ } while (temp==0xFA || temp==0xAA);
+
+ temp &= ~(1<<6); // Unset bit6: disable conversion
+ KeyboardWaitOutport();
+ outportb(0x64, 0x60); // Function to write cmd unsigned char
+
+ KeyboardWaitOutport();
+ outportb(0x60, temp); // Send it
+}
diff --git a/Kernel/hal/keyboard/keyboard.h b/Kernel/hal/keyboard/keyboard.h
new file mode 100644
index 0000000..7d3805f
--- /dev/null
+++ b/Kernel/hal/keyboard/keyboard.h
@@ -0,0 +1,52 @@
+#ifndef __KEYBOARD__H
+#define __KEYBOARD__H
+
+#include
+
+extern const char KeyboardMap[0x80];
+extern const char KeyboardMapShift[0x80];
+extern volatile uint8 KeyboardLastStatus;
+extern volatile uint8 KeyboardLastScancode;
+
+extern void KeyboardSetKeyStatus (uint8 scancode, uint8 status);
+extern uint8 KeyboardGetKeyStatus (uint8 scancode);
+extern void KeyboardHandler (_RegsStack32 *r);
+extern void KeyboardSetLEDs (uint8 scroll, uint8 num, uint8 caps);
+/***************************************
+ * Set repeat rate/delay *
+ ***************************************
+ Values for inter-character delay (bits 4-0)
+ (characters per second; default is 10.9)
+ | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
+ ----+----+----+----+----+----+----+----+----
+ 0 |30.0|26.7|24.0|21.8|20.0|18.5|17.1|16.0
+ 8 |15.0|13.3|12.0|10.9|10.0|9.2 |8.6 |8.0
+ 16 |7.5 |6.7 |6.0 |5.5 |5.0 |4.6 |4.3 |4.0
+ 24 |3.7 |3.3 |3.0 |2.7 |2.5 |2.3 |2.1 |2.0
+
+ Values for delay:
+ (miliseconds; default is 500)
+ 0 | 1 | 2 | 3
+ -----+-----+-----+-----
+ 250 | 500 | 750 | 1000
+
+ ***************************************/
+extern void KeyboardSetRepeatRate(uint8 rate, uint8 delay);
+
+/***************************************
+ * Set scancode set *
+ ***************************************
+ 1 Set to scancode set 1
+ 2 Set to scancode set 2
+ 3 Set to scancode set 3
+ ***************************************/
+extern void KeyboardSetScancodeSet(uint8 set);
+
+extern void KeyboardWaitOutport();
+extern void KeyboardWaitInport();
+
+extern void KeyboardInstallA();
+extern void KeyboardInstallB();
+
+#endif
+
diff --git a/Kernel/hal/mouse/mouse.c b/Kernel/hal/mouse/mouse.c
new file mode 100644
index 0000000..c5f4070
--- /dev/null
+++ b/Kernel/hal/mouse/mouse.c
@@ -0,0 +1,116 @@
+#include
+#include
+#include "mouse.h"
+#include "../keyboard/keyboard.h"
+
+uint8 MouseCycle = 0;
+uint8 MouseCycleExpected = 3;
+uint8 Packets[4];
+
+Point MousePosition = {0,0};
+Point MouseMinimumPosition = {0,0}, MouseMaximumPosition = {80, 25};
+Point Prev = {0,0};
+
+#define SpeedLimit 0x8
+
+// IRQ12
+void MouseHandler (_RegsStack32* UNUSED(r))
+{
+ uint8 data = inportb(0x60);
+ Point delta;
+
+ if (MouseCycle == 0 && (data == 0 || data == 0xFA || data == 0xFF || data == 0xAA)) return;
+ Packets[MouseCycle++] = data;
+
+ // Cycle ended
+ if (MouseCycle >= MouseCycleExpected)
+ {
+ MouseCycle = 0;
+ if (Packets[0] & 0xC0) return; // Discard packet
+
+ // Update X position
+ if (Packets[0] & 0x10) delta.X = (int32) (Packets[1] | 0xFFFFFF00);
+ else delta.X = (int32) Packets[1];
+
+ // Update Y position
+ if (Packets[0] & 0x20) delta.Y = -1 * (int32) (Packets[2] | 0xFFFFFF00);
+ else delta.Y = -1 * (int32)Packets[2];
+
+ if (delta.X >= SpeedLimit) delta.X = SpeedLimit;
+ if (delta.X <= -SpeedLimit) delta.X = -SpeedLimit;
+ if (delta.Y >= SpeedLimit) delta.Y = SpeedLimit;
+ if (delta.Y <= -SpeedLimit) delta.Y = -SpeedLimit;
+
+ MousePosition.X += delta.X;
+ MousePosition.Y += delta.Y;
+
+ // Check limits
+ if (MousePosition.X < MouseMinimumPosition.X) MousePosition.X = MouseMinimumPosition.X;
+ if (MousePosition.Y < MouseMinimumPosition.Y) MousePosition.Y = MouseMinimumPosition.Y;
+ if (MousePosition.X >= MouseMaximumPosition.X) MousePosition.X = MouseMaximumPosition.X - 1;
+ if (MousePosition.Y >= MouseMaximumPosition.Y) MousePosition.Y = MouseMaximumPosition.Y - 1;
+
+ /* TESTING ONLY */
+ ConsoleSetColor(Prev, 0xFF - ConsoleGetColor(Prev));
+ ConsoleSetColor(MousePosition, 0xFF - ConsoleGetColor(MousePosition));
+ Prev = MousePosition;
+
+ }
+}
+
+void MouseSendCommand(uint8 command)
+{
+ KeyboardWaitOutport();
+ outportb(0x64, 0xD4);
+ KeyboardWaitOutport();
+ outportb(0x60, command);
+}
+
+uint8 MouseReadData ()
+{
+ KeyboardWaitInport();
+ return inportb(0x60);
+}
+
+void MouseInstall()
+{
+ KeyboardWaitOutport();
+ outportb(0x64, 0xA8);
+
+ // Enable interrupts
+ KeyboardWaitOutport();
+ outportb(0x64, 0x20);
+
+ KeyboardWaitInport();
+ uint8 temp = inportb(0x60) | 2;
+ temp &= ~0x20;
+
+ KeyboardWaitOutport();
+ outportb(0x64, 0x60);
+
+ KeyboardWaitOutport();
+ outportb(0x60, temp);
+
+ // Reset mouse, and enable it
+ MouseSendCommand(MouseCommandReset);
+ MouseReadData(); MouseReadData();
+
+ MouseSendCommand(MouseCommandSetDefaults);
+ MouseReadData(); // Read ack
+
+ MouseSendCommand(MouseCommandEnableDataReporting);
+ MouseReadData(); // Read ack
+
+}
+
+void MouseSetLimits (Point min_pos, Point max_pos)
+{
+ MouseMinimumPosition = min_pos;
+ MouseMaximumPosition = max_pos;
+}
+
+MouseState MouseGetState()
+{
+ MouseState ret = { Packets[0] & 0x7, MousePosition};
+ return ret;
+}
diff --git a/Kernel/hal/mouse/mouse.h b/Kernel/hal/mouse/mouse.h
new file mode 100644
index 0000000..b71114b
--- /dev/null
+++ b/Kernel/hal/mouse/mouse.h
@@ -0,0 +1,36 @@
+#ifndef __MOUSE__H
+#define __MOUSE__H
+
+#include
+
+typedef struct
+{
+ uint8 Buttons;
+ Point Position;
+} MouseState;
+
+enum MouseCommands
+{
+ MouseCommandReset = 0xFF,
+ MouseCommandResend = 0xFE,
+ MouseCommandSetDefaults = 0xF6,
+ MouseCommandDisableDataReporting = 0xF5,
+ MouseCommandEnableDataReporting = 0xF4,
+ MouseCommandSetSampleRate = 0xF3,
+ MouseCommandGetDeviceID = 0xF2,
+ MouseCommandSetRemoteMode = 0xF0,
+ MouseCommandSetWrapMode = 0xEE,
+ MouseCommandReadData = 0xEB,
+ MouseCommandSetStreamMode = 0xEA,
+ MouseCommandStatusRequest = 0xE9,
+ MouseCommandSetResolution = 0xE8,
+ MouseCommandSetScaling_2_1 = 0xE7,
+ MouseCommandSetScaling_1_1 = 0xE6
+};
+
+extern void MouseInstall();
+extern void MouseHandler (_RegsStack32 *r);
+extern void MouseSetLimits (Point min_pos, Point max_pos);
+extern MouseState MouseGetState();
+
+#endif
diff --git a/Kernel/hal/sysinfo.c b/Kernel/hal/sysinfo.c
new file mode 100644
index 0000000..8529f4c
--- /dev/null
+++ b/Kernel/hal/sysinfo.c
@@ -0,0 +1,27 @@
+/*
+ * sysinfo.c
+ *
+ * Provides information about system, and useful utilities
+ *
+ * Created on: Aug 17, 2011
+ * Author: Tiberiu
+ */
+
+#include
+#include
+#include
+#include
+
+#include <../drivers/cmos/cmos.h>
+
+#include "keyboard/keyboard.h"
+void SystemReboot()
+{
+ Log("Rebooting system...\n");
+
+ KeyboardWaitOutport();
+ outportb (0x64, 0xFE);
+
+ asm("cli");
+ asm("hlt");
+}
diff --git a/Kernel/hal/vfs.c b/Kernel/hal/vfs.c
new file mode 100644
index 0000000..23000df
--- /dev/null
+++ b/Kernel/hal/vfs.c
@@ -0,0 +1,40 @@
+#include
+#include
+
+#define MAX_FS_COUNT 64
+
+uint32 FsRead(FsNode *node, uint32 offset, uint32 size, uint8 *buffer)
+{
+ if (node->Read != NULL) return node->Read(node, offset, size, buffer);
+ return NULL;
+}
+
+uint32 FsWrite(FsNode *node, uint32 offset, uint32 size, uint8 *buffer)
+{
+ if (node->Write != NULL) return node->Write(node, offset, size, buffer);
+ return NULL;
+}
+
+void FsOpen(FsNode *node, uint8 read, uint8 write)
+{
+ if (node->Open != NULL) return node->Open(node, read, write);
+}
+
+void FsClose(FsNode *node)
+{
+ if (node->Close != NULL) return node->Close();
+}
+
+DirectoryEntry *FsReadDir(FsNode *node, uint32 index)
+{
+ if (node->ReadDir != NULL && (node->Flags&7) == FsDirectory)
+ return node->ReadDir(node, index);
+ return NULL;
+}
+
+FsNode *FsFindDir(FsNode *node, char *name)
+{
+ if (node->FindDir != NULL && (node->Flags&7) == FsDirectory)
+ return node->FindDir(node, name);
+ return NULL;
+}
diff --git a/SysCore/include/ctype.h b/Kernel/include/ctype.h
similarity index 98%
rename from SysCore/include/ctype.h
rename to Kernel/include/ctype.h
index 3881116..ac70a3c 100644
--- a/SysCore/include/ctype.h
+++ b/Kernel/include/ctype.h
@@ -1,5 +1,5 @@
#ifndef __CTYPE_H
-#define __CTYPE_H
+#define __CTYPE_H
extern unsigned char _ctype[];
diff --git a/Kernel/include/debugio.h b/Kernel/include/debugio.h
new file mode 100644
index 0000000..54c6518
--- /dev/null
+++ b/Kernel/include/debugio.h
@@ -0,0 +1,88 @@
+#ifndef __DEBUGIO__H
+#define __DEBUGIO__H
+
+#include
+#include
+#include
+
+enum Colors
+{
+ ColorBlack = 0x0,
+ ColorBlue = 0x1,
+ ColorGreen = 0x2,
+ ColorCyan = 0x3,
+ ColorRed = 0x4,
+ ColorMagenta = 0x5,
+ ColorBrown = 0x6,
+ ColorLightGray = 0x7,
+ ColorDarkGray = 0x8,
+ ColorLightBlue = 0x9,
+ ColorLightGreen = 0xA,
+ ColorLightCyan = 0xB,
+ ColorLightRed = 0xC,
+ ColorLightMagenta = 0xD,
+ ColorYellow = 0xE,
+ ColorWhite = 0xF
+};
+
+extern uint8 Color (uint8 back, uint8 fore);
+
+// Cursor position
+extern Point ConsoleGetCursor();
+extern void ConsoleSetCursor(Point p);
+extern void ConsoleCursorGoto(Point p);
+
+extern void ConsoleCursorIncreasePos (int32 delta);
+extern void ConsoleCursorNewline();
+extern void ConsoleCursorUpdateHardware();
+
+// Get/set properties
+extern void ConsoleSetDefaultColor(uint8 color);
+extern uint8 ConsoleGetDefaultColor ();
+extern UPoint ConsoleGetSize();
+
+extern void ConsoleSetChar(Point pos, char c);
+extern void ConsoleSetColor(Point pos, uint8 color);
+extern char ConsoleGetChar(Point pos);
+extern uint8 ConsoleGetColor (Point pos);
+
+
+// Basic console operations
+extern void ConsoleClear();
+extern void ConsoleScroll (uint32 lines);
+
+// Console write operations
+extern void ConsoleWriteChar (char c);
+extern void ConsoleWriteString (string s);
+extern int32 ConsoleWrite (string format, ...);
+
+// Console read operations
+extern void ConsoleReadString (string s, int32 buffer_size, char end_char);
+
+// Console main loop
+extern void ConsoleMain();
+
+// Debug print
+#if VERBOSE_MODE==1
+#define Log(...) ConsoleWrite(__VA_ARGS__)
+#else
+#define Log(...)
+#endif
+
+// Error print
+#if VERBOSE_ERROR==1
+#define Error(...) ConsoleWrite(__VA_ARGS__)
+#else
+#define Error(...)
+#endif
+
+// Panic
+#if VERBOSE_PANIC==1
+#define Panic(...) { ConsoleWrite("%#[PANIC] KERNEL PANIC: ", ColorLightRed); \
+ ConsoleWrite(__VA_ARGS__); \
+ asm volatile ("cli\nhlt"); }
+#else
+#define Panic(...)
+#endif
+
+#endif
diff --git a/Kernel/include/fileio.h b/Kernel/include/fileio.h
new file mode 100644
index 0000000..0858ea9
--- /dev/null
+++ b/Kernel/include/fileio.h
@@ -0,0 +1,70 @@
+/*
+ * fileio.h
+ *
+ * Created on: Aug 23, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef FILEIO_H_
+#define FILEIO_H_
+
+#include
+
+enum FsFlags
+{
+ FsFile = 0x1,
+ FsDirectory = 0x2,
+ FsCharDevice = 0x3,
+ FsBlockDevice = 0x4,
+ FsPipe = 0x5,
+ FsSymbolLink = 0x6,
+ FsMountPoint = 0x8
+};
+
+typedef uint32 (*ReadRoutine)(struct _FsNode*, uint32, uint32, uint8*);
+typedef uint32 (*WriteRoutine)(struct _FsNode*, uint32, uint32, uint8*);
+typedef void (*OpenRoutine)(struct _FsNode*);
+typedef void (*CloseRoutine)(struct _FsNode*);
+typedef struct _DirectoryEntry (*ReadDirRoutine)(struct _FsNode*,uint32);
+typedef struct _FsNode* (*FindDirRoutine)(struct _FsNode*,char *name);
+
+typedef struct _FsNode
+{
+ char Name[128]; // The filename.
+ uint32 Permissions; // The permissions mask.
+ uint32 UserId; // The owning user.
+ uint32 GroupId; // The owning group.
+ uint32 Flags; // Includes the node type. See enum above.
+ uint32 INode; // This is device-specific - provides a way for a filesystem to identify files.
+ uint32 Length; // Size of the file, in bytes.
+ uint32 Implementation; // An implementation-defined number.
+ ReadRoutine Read;
+ WriteRoutine Write;
+ OpenRoutine Open;
+ CloseRoutine Close;
+ ReadDirRoutine ReadDir;
+ FindDirRoutine FindDir;
+ struct _FsNode *Ptr; // Used by mountpoints and symlinks.
+} FsNode;
+
+
+typedef struct _DirectoryEntry
+{
+ char Name[128];
+ uint32 INode;
+} DirectoryEntry;
+
+
+extern uint32 FsRead(FsNode *node, uint32 offset, uint32 size, uint8 *buffer);
+extern uint32 FsWrite(FsNode *node, uint32 offset, uint32 size, uint8 *buffer);
+extern void FsOpen(FsNode *node, uint8 read, uint8 write);
+extern void FsClose(FsNode *node);
+extern DirectoryEntry *FsReadDir(FsNode *node, uint32 index);
+extern FsNode *FsFindDir(FsNode *node, char *name);
+
+#ifdef NEVER
+void VfsRegisterFilesys();
+void VfsMount();
+#endif
+
+#endif /* FILEIO_H_ */
diff --git a/Kernel/include/memory-add.h b/Kernel/include/memory-add.h
new file mode 100644
index 0000000..e423cff
--- /dev/null
+++ b/Kernel/include/memory-add.h
@@ -0,0 +1,97 @@
+/*
+ * memory-add.h
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef MEMORY_ADD_H_
+#define MEMORY_ADD_H_
+
+#include
+#include
+#include
+
+/***************************************************
+ * Paging *
+ ***************************************************/
+typedef uint32 Page;
+
+enum PageFlags
+{
+ PagePresent = 0x1,
+ PageWriteable = 0x2,
+ PageUser = 0x4,
+ PageWriteThough = 0x8,
+ PageNotCacheable = 0x10,
+ PageAccessed = 0x20,
+ PageDirty = 0x40,
+ PagePAT = 0x80,
+ PageCpuGlobal = 0x100,
+ PageLvl4Global = 0x200,
+ PageFrame = 0xFFFFF000
+};
+
+
+
+typedef struct {
+ Page Pages[1024];
+} PageTable;
+
+typedef struct {
+ PageTable* Tables[1024];
+ uint32 TablesPhysical[1024];
+ uint32 PhysicalAddr;
+} PageDirectory;
+
+extern PageDirectory* CurrentDirectory;
+extern PageDirectory* KernelDirectory;
+
+extern void PagingInitialize(uint32 SystemMemory);
+extern void PagingSwitchPageDirectory (PageDirectory* dir);
+extern Page* PagingGetPage(uint32 addr, uint8 make, PageDirectory* dir);
+
+
+/***************************************************
+ * Physical memory manager *
+ ***************************************************/
+extern uint32 TotalFrames;
+extern uint32 TotalMemory;
+extern uint32 UsedFrames;
+
+void MemPhInitialize(uint32 SystemMemoryKb);
+extern void MemPhSetFrame (uint32 frame, uint8 value);
+uint32 MemPhGetFrame (uint32 frame);
+uint32 MemPhFindFreeFrame();
+void MemPhAllocFrame(Page* page, uint8 isKernel, uint8 isWriteable);
+void MemPhFreeFrame(Page* page);
+void MemPhReserveFrames (uint32 address, uint32 length);
+
+
+/***************************************************
+ * Memory heap *
+ ***************************************************/
+typedef struct
+{
+ OrderedArray Index;
+ uint32 StartAddress, EndAddress, MaxAddress;
+ // bit 0: supervisor-only bit 1: read-only
+ uint8 Flags;
+} MemHeap;
+
+extern MemHeap* KernelHeap;
+
+extern uint32 MemHeapFindSmallestHole (uint32 size, uint8 page_align, MemHeap* heap);
+extern int32 MemHeapCompare (uint32 a, uint32 b);
+extern MemHeap* MemHeapCreate(uint32 start, uint32 end, uint32 max, uint8 flags);
+extern void MemHeapExpand(uint32 newsz, MemHeap* heap, PageDirectory* pd);
+extern uint32 MemHeapContract(uint32 newsz, MemHeap* heap, PageDirectory* pd);
+extern uint32 MemHeapAlloc (uint32 size, uint8 isPageAligned, MemHeap* heap, PageDirectory* pd);
+extern void MemHeapFree (uint32 address, MemHeap* heap, PageDirectory* pd);
+
+
+#define LogMem(...) { Log("%#[Mem] ", ColorLightCyan); Log(__VA_ARGS__); }
+#define ErrorMem(...) { Error("%#[Mem] ", ColorLightCyan); Error(__VA_ARGS__); }
+
+
+#endif /* MEMORY_ADD_H_ */
diff --git a/Kernel/include/memory-add.h~ b/Kernel/include/memory-add.h~
new file mode 100644
index 0000000..acd3a39
--- /dev/null
+++ b/Kernel/include/memory-add.h~
@@ -0,0 +1,96 @@
+/*
+ * memory-add.h
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef MEMORY_ADD_H_
+#define MEMORY_ADD_H_
+
+#include
+#include
+#include
+
+/***************************************************
+ * Paging *
+ ***************************************************/
+typedef uint32 Page;
+
+enum PageFlags
+{
+ PagePresent = 0x1,
+ PageWriteable = 0x2,
+ PageUser = 0x4,
+ PageWriteThough = 0x8,
+ PageNotCacheable = 0x10,
+ PageAccessed = 0x20,
+ PageDirty = 0x40,
+ PagePAT = 0x80,
+ PageCpuGlobal = 0x100,
+ PageLvl4Global = 0x200,
+ PageFrame = 0xFFFFF000
+};
+
+
+
+typedef struct {
+ Page Pages[1024];
+} PageTable;
+
+typedef struct {
+ PageTable* Tables[1024];
+ uint32 TablesPhysical[1024];
+ uint32 PhysicalAddr;
+} PageDirectory;
+
+extern PageDirectory* CurrentDirectory;
+extern PageDirectory* KernelDirectory;
+
+extern void PagingInitialize(uint32 SystemMemory);
+extern void PagingSwitchPageDirectory (PageDirectory* dir);
+extern Page* PagingGetPage(uint32 addr, uint8 make, PageDirectory* dir);
+
+
+/***************************************************
+ * Physical memory manager *
+ ***************************************************/
+extern uint32 TotalFrames;
+extern uint32 TotalMemory;
+
+void MemPhInitialize(uint32 SystemMemoryKb);
+extern void MemPhSetFrame (uint32 frame, uint8 value);
+uint32 MemPhGetFrame (uint32 frame);
+uint32 MemPhFindFreeFrame();
+void MemPhAllocFrame(Page* page, uint8 isKernel, uint8 isWriteable);
+void MemPhFreeFrame(Page* page);
+void MemPhReserveFrames (uint32 address, uint32 length);
+
+
+/***************************************************
+ * Memory heap *
+ ***************************************************/
+typedef struct
+{
+ OrderedArray Index;
+ uint32 StartAddress, EndAddress, MaxAddress;
+ // bit 0: supervisor-only bit 1: read-only
+ uint8 Flags;
+} MemHeap;
+
+extern MemHeap* KernelHeap;
+
+extern uint32 MemHeapFindSmallestHole (uint32 size, uint8 page_align, MemHeap* heap);
+extern int32 MemHeapCompare (uint32 a, uint32 b);
+extern MemHeap* MemHeapCreate(uint32 start, uint32 end, uint32 max, uint8 flags);
+extern void MemHeapExpand(uint32 newsz, MemHeap* heap, PageDirectory* pd);
+extern uint32 MemHeapContract(uint32 newsz, MemHeap* heap, PageDirectory* pd);
+extern uint32 MemHeapAlloc (uint32 size, uint8 isPageAligned, MemHeap* heap, PageDirectory* pd);
+extern void MemHeapFree (uint32 address, MemHeap* heap, PageDirectory* pd);
+
+
+#define LogMem(...) { Log("%#[Mem] ", ColorLightCyan); Log(__VA_ARGS__); }
+#define ErrorMem(...) { Error("%#[Mem] ", ColorLightCyan); Error(__VA_ARGS__); }
+
+
+#endif /* MEMORY_ADD_H_ */
diff --git a/Kernel/include/memory.h b/Kernel/include/memory.h
new file mode 100644
index 0000000..0630375
--- /dev/null
+++ b/Kernel/include/memory.h
@@ -0,0 +1,29 @@
+#ifndef __MEMORY__H
+#define __MEMORY__H
+
+#include
+#include
+#include
+
+/***************************************************
+ * Basic memory operations: alloc, free *
+ ***************************************************/
+extern void* kmalloc (uint32 size);
+extern void* kmalloc_a (uint32 size);
+extern void* kmalloc_p (uint32 size, uint32* phys);
+extern void* kmalloc_ap (uint32 size, uint32* phys);
+extern void kfree (void* addr);
+
+extern void MemoryTempInitialize (uint32 kernel_end);
+extern void MemoryInitialize (MultibootInfo* info);
+
+extern uint32 MemoryGetTotal();
+extern uint32 MemoryGetFree(); // Returns total free physical memory in kilobytes
+extern uint32 MemoryGetUsed(); // Total used physical memory in kbytes
+extern uint32 MemoryGetFrameSize(); // Same as above functions, but in frames
+extern uint32 MemoryGetFramesTotal();
+extern uint32 MemoryGetFramesUsed();
+extern uint32 MemoryGetFramesFree();
+
+
+#endif
diff --git a/Kernel/include/memory.h~ b/Kernel/include/memory.h~
new file mode 100644
index 0000000..35992b7
--- /dev/null
+++ b/Kernel/include/memory.h~
@@ -0,0 +1,29 @@
+#ifndef __MEMORY__H
+#define __MEMORY__H
+
+#include
+#include
+#include
+
+/***************************************************
+ * Basic memory operations: alloc, free *
+ ***************************************************/
+extern void* kmalloc (uint32 size);
+extern void* kmalloc_a (uint32 size);
+extern void* kmalloc_p (uint32 size, uint32* phys);
+extern void* kmalloc_ap (uint32 size, uint32* phys);
+extern void kfree (void* addr);
+
+extern void MemoryTempInitialize (uint32 kernel_end);
+extern void MemoryInitialize (MultibootInfo* info);
+
+extern uint32 MemoryGetTotal();
+extern uint32 MemoryGetFree(); // Returns total free physical memory in bytes
+extern uint32 MemoryGetUsed(); // Total used physical memory in bytes
+extern uint32 MemoryGetFrameSize(); // Same as above functions, but in frames
+extern uint32 MemoryGetFramesTotal();
+extern uint32 MemoryGetFramesUsed();
+extern uint32 MemoryGetFramesFree();
+
+
+#endif
diff --git a/Kernel/include/multiboot.h b/Kernel/include/multiboot.h
new file mode 100644
index 0000000..51a5589
--- /dev/null
+++ b/Kernel/include/multiboot.h
@@ -0,0 +1,119 @@
+/*
+ * multiboot.h
+ *
+ * Created on: Aug 17, 2011
+ * Author: Tiberiu
+*/
+
+#ifndef MULTIBOOT_H_
+#define MULTIBOOT_H_
+
+#include
+
+// Flags to be set in the 'flags' member of the multiboot info structure.
+#define MultibootInfo_MEMORY 0x00000001 // is there basic lower/upper memory information?
+#define MultibootInfo_BOOTDEV 0x00000002 // is there a boot device set?
+#define MultibootInfo_CMDLINE 0x00000004 // is the command-line defined?
+#define MultibootInfo_MODS 0x00000008 // are there modules to do something with?
+
+// These next two are mutually exclusive
+#define MultibootInfo_AOUT_SYMS 0x00000010 // is there a symbol table loaded?
+#define MultibootInfo_ELF_SHDR 0X00000020 // is there an ELF section header table?
+
+
+#define MultibootInfo_MEM_MAP 0x00000040 // is there a full memory map?
+#define MultibootInfo_DRIVE_INFO 0x00000080 // Is there drive info?
+#define MultibootInfo_CONFIG_TABLE 0x00000100 // Is there a config table?
+#define MultibootInfo_BOOT_LOADER_NAME 0x00000200 // Is there a boot loader name?
+#define MultibootInfo_APM_TABLE 0x00000400 // Is there a APM table?
+#define MultibootInfo_VIDEO_INFO 0x00000800 // Is there video information?
+
+
+// The symbol table for a.out.
+typedef struct
+{
+ uint32 TableSize;
+ uint32 StrSize;
+ uint32 Address;
+ uint32 Reserved;
+} MultibootAoutSymbolTable;
+
+
+// The section header table for ELF.
+typedef struct
+{
+ uint32 Number;
+ uint32 Size;
+ uint32 Address;
+ uint32 Shndx;
+} MultibootElfSectionHeaderTable;
+
+
+typedef struct
+{
+ uint32 Flags; // Multiboot info version number
+
+ uint32 MemoryLower; // Available memory from BIOS
+ uint32 MemoryUpper;
+
+ uint32 BootDevice; // "root" partition
+
+ uint32 CommandLine; // Kernel command line
+
+ uint32 ModulesCount; // Boot-Module list
+ uint32 ModulesAddress;
+
+ union
+ {
+ MultibootAoutSymbolTable AoutSymbols;
+ MultibootElfSectionHeaderTable ElfSectionHeaderTable;
+ } Symbols;
+
+ uint32 MemoryMapLength; // Memory Mapping buffer
+ uint32 MemoryMapAddress;
+
+ uint32 DrivesLength; // Drive Info buffer
+ uint32 DrivesAddress;
+
+ uint32 ConfigurationTable; // ROM configuration table
+
+ uint32 BootLoaderName; // Boot Loader Name
+
+ uint32 ApmTable; // APM table
+
+ uint32 VbeControlInfo; // Video
+ uint32 VbeModeInfo;
+ uint16 VbeMode;
+ uint16 VbeInterfaceSegment;
+ uint16 VbeInterfaceOffset;
+ uint16 VbeInterfaceLength;
+} MultibootInfo;
+
+
+typedef struct
+{
+ uint32 Size;
+ uint64 Address;
+ uint64 Length;
+
+ #define MULTIBOOT_MEMORY_AVAILABLE 1
+ #define MULTIBOOT_MEMORY_RESERVED 2
+
+ uint32 Type;
+} __attribute__((packed)) MultibootMemoryMapEntry;
+
+typedef struct
+{
+ // the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive
+ uint32 ModuleStart;
+ uint32 ModuleEnd;
+
+ // Module command line
+ uint32 CommandLine;
+
+ // padding to take it to 16 bytes (must be zero)
+ uint32 _Padding;
+} MultibootModule;
+
+
+#endif
diff --git a/Kernel/include/settings.h b/Kernel/include/settings.h
new file mode 100644
index 0000000..4c0382a
--- /dev/null
+++ b/Kernel/include/settings.h
@@ -0,0 +1,38 @@
+/*
+ * settings.h
+ *
+ * Created on: Aug 16, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef SETTINGS_H_
+#define SETTINGS_H_
+
+// OS info
+#define OS_STRING "lux"
+#define OS_VERSION "0.1 [pre-Alpha]"
+#define OS_BUILD_DATE __DATE__
+#define OS_BUILD_TIME __TIME__
+
+#include
+
+// Logger
+#define VERBOSE_MODE 1
+#define VERBOSE_ERROR 1
+#define VERBOSE_PANIC 1
+
+
+// Clock
+#define PIT_FREQUENCY 100
+
+// Console
+#define CONSOLE_MAX_PARAMS 32
+#define CONSOLE_DEFAULT_COLOR 0x7
+
+// Memory manager
+#define KERNEL_HEAP_START 0xC0000000
+#define KERNEL_HEAP_INITIAL_SIZE 0x100000
+#define KERNEL_HEAP_END (KERNEL_HEAP_START + KERNEL_HEAP_INITIAL_SIZE)
+
+
+#endif /* SETTINGS_H_ */
diff --git a/Kernel/include/settings.h~ b/Kernel/include/settings.h~
new file mode 100644
index 0000000..30491f7
--- /dev/null
+++ b/Kernel/include/settings.h~
@@ -0,0 +1,37 @@
+/*
+ * settings.h
+ *
+ * Created on: Aug 16, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef SETTINGS_H_
+#define SETTINGS_H_
+
+// OS info
+#define OS_STRING "lux"
+#define OS_VERSION "0.1 [pre-Alpha]"
+#define OS_BUILD_DATE __DATE__
+#define OS_BUILD_TIME __TIME__
+
+#include
+
+// Logger
+#define VERBOSE_MODE 1
+#define VERBOSE_ERROR 1
+#define VERBOSE_PANIC 1
+
+
+// Clock
+#define PIT_FREQUENCY 100
+
+// Console
+#define CONSOLE_MAX_PARAMS 32
+#define CONSOLE_DEFAULT_COLOR 0x7
+
+// Memory manager
+#define KERNEL_HEAP_START 0xC0000000
+#define KERNEL_HEAP_END 0xCFFFF000
+#define KERNEL_HEAP_INITIAL_SIZE 0x100000
+
+#endif /* SETTINGS_H_ */
diff --git a/SysCore/include/stdarg.h b/Kernel/include/stdarg.h
similarity index 72%
rename from SysCore/include/stdarg.h
rename to Kernel/include/stdarg.h
index 257f25b..4e3b41c 100644
--- a/SysCore/include/stdarg.h
+++ b/Kernel/include/stdarg.h
@@ -1,17 +1,9 @@
-#ifndef __STDARG_H
-#define __STDARG_H
+#ifndef __STDARG__H
+#define __STDARG__H
-
-/******************************
- * [filename] *
- * - [description] *
- ******************************/
-
-// INTERFACE REQUIRED HEADERS
#include
-// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
#ifdef __cplusplus
extern "C"
{
diff --git a/Kernel/include/stdio.h b/Kernel/include/stdio.h
new file mode 100644
index 0000000..59a37dc
--- /dev/null
+++ b/Kernel/include/stdio.h
@@ -0,0 +1,29 @@
+#ifndef __STDIO__H
+#define __STDIO__H
+
+#include
+
+#define inb(port) inportb(port)
+#define outb(port) outportb(port)
+
+extern uint8 inportb (uint16 _port);
+
+static inline void outportb (uint16 _port, uint8 _data) {
+ asm volatile ("outb %1, %0" : : "dN" (_port), "a" (_data));
+}
+
+static inline void iowait() {
+ asm volatile ("outb %al, $0x80");
+}
+
+static inline void MagicBreakpoint()
+{
+ asm volatile ("xchg %bx, %bx");
+}
+
+extern void SystemReboot();
+
+extern Key ReadKey();
+extern KeyEvent ReadKeyEvent();
+
+#endif
diff --git a/Kernel/include/stdlib.h b/Kernel/include/stdlib.h
new file mode 100644
index 0000000..4239b52
--- /dev/null
+++ b/Kernel/include/stdlib.h
@@ -0,0 +1,69 @@
+#ifndef __STDLIB__H
+#define __STDLIB__H
+
+#include
+
+#define IsDigit(c) (c >= '0' && c <= '9')
+#define IsHexDigit(c) ( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') )
+#define IsUpper(c) (c >= 'A' && c <= 'Z')
+#define IsLower(c) (c >= 'a' && c <= 'z')
+
+#define IsAlpha(c) (IsLower(c) || IsUpper(c))
+#define IsAlphaNum(c) (IsAlpha(c) || IsDigit(c))
+
+#define ToLower(c) ((IsUpper(c)) ? (c - 'A' + 'a') : c)
+#define ToUpper(c) ((IsLower(c)) ? (c - 'a' + 'A') : c)
+
+#define Max(a,b) ((a > b) ? (a) : (b))
+#define Min(a,b) ((a < b) ? (a) : (b))
+#define Abs(a) ((a < 0) ? (a * -1) : (a))
+
+/***************************************************
+ * String operations: len, cmp, cpy *
+ ***************************************************/
+extern uint32 strlen (string s);
+extern int32 strcmp (string a, string b);
+extern string strcpy (string s1, const string s2);
+
+/***************************************************
+ * Number operations: len *
+ ***************************************************/
+extern uint32 numlen (int32 number, int32 base);
+extern uint32 unumlen (uint32 number, int32 base);
+
+/***************************************************
+ * Memory operations: cpy, cmp, set *
+ ***************************************************/
+void* memcpy (void *dest, const void *src, uint32 count);
+int32 memcmp (const void *s1, const void *s2, uint32 count);
+void* memset (void *dest, uint8 val, uint32 count);
+
+/***************************************************
+ * Conversion operations: num-str/str-num *
+ ***************************************************/
+extern int32 ConvertIntToString (string buffer, int32 number, int32 base);
+extern uint32 ConvertUIntToString (string buffer, uint32 number, int32 base);
+extern int32 ConvertStringToInt (string buffer);
+extern uint32 ConvertStringToUInt (string buffer);
+extern uint32 ConvertStringToIntHex (string buffer);
+
+/***************************************************
+ * Ordered array implementation *
+ ***************************************************/
+typedef int (*ComparePredicate) (uint32, uint32);
+typedef struct {
+ uint32* Data;
+ uint32 Size;
+ uint32 SizeLimit;
+ ComparePredicate Compare;
+} OrderedArray;
+
+extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
+extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
+extern void OrderedArrayDispose (OrderedArray* arr);
+extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
+extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
+extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
+extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
+
+#endif
diff --git a/Kernel/include/stdlib.h~ b/Kernel/include/stdlib.h~
new file mode 100644
index 0000000..7b0451a
--- /dev/null
+++ b/Kernel/include/stdlib.h~
@@ -0,0 +1,69 @@
+#ifndef __STDLIB__H
+#define __STDLIB__H
+
+#include
+
+#define IsDigit(c) (c >= '0' && c <= '9')
+#define IsHexDigit(c) ( (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') )
+#define IsUpper(c) (c >= 'A' && c <= 'Z')
+#define IsLower(c) (c >= 'a' && c <= 'z')
+
+#define IsAlpha(c) (IsLower(c) || IsUpper(c))
+#define IsAlphaNum(c) (IsAlpha(c) || IsDigit(c))
+
+#define ToLower(c) ((IsUpper(c)) ? (c - 'A' + 'a') : c)
+#define ToUpper(c) ((IsLower(c)) ? (c - 'a' + 'A') : c)
+
+#define Max(a,b) ((a > b) ? (a) : (b))
+#define Min(a,b) ((a < b) ? (a) : (b))
+#define Abs(a) ((a < 0) ? (a * -1) : (a))
+
+/***************************************************
+ * String operations: len, cmp, cpy *
+ ***************************************************/
+extern uint32 strlen (string s);
+extern int32 strcmp (string a, string b);
+extern string strcpy (string s1, const string s2);
+
+/***************************************************
+ * Number operations: len *
+ ***************************************************/
+extern uint32 numlen (int32 number, int32 base);
+extern uint32 unumlen (uint32 number, int32 base);
+
+/***************************************************
+ * Memory operations: cpy, cmp, set *
+ ***************************************************/
+void* memcpy (void *dest, const void *src, uint32 count);
+int32 memcmp (const void *s1, const void *s2, uint32 count);
+void* memset (void *dest, uint8 val, uint32 count);
+
+/***************************************************
+ * Conversion operations: num-str/str-num *
+ ***************************************************/
+extern int32 ConvertIntToString (string buffer, int32 number, int32 base);
+extern uint32 ConvertUIntToString (string buffer, uint32 number, int32 base);
+extern int32 ConvertStringToInt (string buffer);
+extern uint32 ConvertStringToUInt (string buffer);
+extern uint32 ConvertStringToIntHex (string buffer);
+
+/***************************************************
+ * Ordered array implementation *
+ ***************************************************/
+typedef int (*ComparePredicate) (uint32, uint32);
+typedef struct {
+ uint32* Data;
+ uint32 Size;
+ uint32 SizeLimit;
+ ComparePredicate Compare;
+} OrderedArray;
+
+extern OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p);
+extern OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p);
+extern void OrderedArrayDispose (OrderedArray* arr);
+extern uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate);
+extern void OrderedArrayInsert (uint32 item, OrderedArray* arr);
+extern uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr);
+extern void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr);
+
+#endif
diff --git a/Kernel/include/storage.h b/Kernel/include/storage.h
new file mode 100644
index 0000000..dde42b1
--- /dev/null
+++ b/Kernel/include/storage.h
@@ -0,0 +1,65 @@
+/*
+ * storage.h
+ *
+ * Created on: Aug 23, 2011
+ * Author: Tiberiu
+ */
+
+#ifndef STORAGE_H_
+#define STORAGE_H_
+
+#include
+
+// Storage device
+typedef struct {
+
+ char MountPointName[32];// E.g. "fd0"; you should avoid spaces, or special chars, or otherwise get weird paths like "Mom's floppy\virus.exe"
+ uint32 DeviceID; // Autocompleted by VFS
+
+ uint32 BlockSize; // E.g. sector size
+ uint32 BlockCount; // How many blocks are loaded in memory per read
+
+ /********************************************************
+ * READ DATA *
+ * Params: *
+ * > offset: read starting from block ~ *
+ * Returns: address to data, NULL for error *
+ ********************************************************/
+ uint32 (*ReadData) (uint32 offset);
+
+ /********************************************************
+ * WRITE DATA *
+ * Params: *
+ * > offset: write starting from block ~ *
+ * > address: where to write from *
+ * Returns: NULL for error *
+ ********************************************************/
+ uint32 (*WriteData) (uint32 offset, uint32 address);
+
+ uint32 FileSystemID; // Autocompleted by 'mount'... at least should be
+
+} StorageDevice;
+
+
+typedef struct {
+ uint32 FileSystemID; // Autocompleted by VFS
+
+ /********************************************************
+ * DETECT IF THIS IS THE FS ON STORAGE DEVICE *
+ * Params: *
+ * > *s: Pointer to device info & routines *
+ * Returns: positive if match, NULL otherwise *
+ ********************************************************/
+ uint32 (*Detect) (StorageDevice *s);
+
+ uint32 (*Open) (StorageDevice *s, string path);
+ uint32 (*CreateNode) (StorageDevice *s, string path);
+ uint32 (*DeleteNode) (StorageDevice *s, string path);
+
+} FileSystem;
+
+
+
+extern void ConvertLbaToChs(uint32 SectorsPerTrack, uint32 lba, uint32 *cyl, uint32 *head, uint32 *sector);
+
+#endif /* STORAGE_H_ */
diff --git a/Kernel/include/time.h b/Kernel/include/time.h
new file mode 100644
index 0000000..2bdc562
--- /dev/null
+++ b/Kernel/include/time.h
@@ -0,0 +1,37 @@
+#ifndef __TIME__H
+#define __TIME__H
+
+#include
+
+// User friendly time structure
+struct _Time
+{
+ int32 Year;
+ uint8 Month, WeekDay, Day; // Day starts monday
+ uint8 Hour, Minute, Second;
+ uint16 Milisecond;
+} __attribute__((packed));
+
+// System time structure
+struct _TimeSystem {
+ uint32 Date, Time;
+} __attribute__((packed));
+
+typedef struct _Time Time;
+typedef struct _TimeSystem TimeSystem;
+
+
+extern TimeSystem TimeConvertToTimeSystem (Time t);
+extern Time TimeConvertToTime (TimeSystem InternalTime);
+extern uint16 TimeCalculateWeekday (Time t);
+
+extern TimeSystem TimeGetInternalTime();
+extern uint32 TimeGetInternalFrequency ();
+
+extern void TimeSetInternalTime(TimeSystem t);
+extern void TimeSetInternalFrequency (uint32 f);
+
+extern void TimerStart (uint32 ms);
+extern uint8 TimerIsDone ();
+
+#endif
diff --git a/Kernel/include/types.h b/Kernel/include/types.h
new file mode 100644
index 0000000..1860f54
--- /dev/null
+++ b/Kernel/include/types.h
@@ -0,0 +1,267 @@
+#ifndef __TYPES__H
+#define __TYPES__H
+
+// Get rid of annoying unused params warnings
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+/****************************************
+ * NULL constant *
+ ****************************************/
+#define null 0
+#define NULL 0
+
+/****************************************
+ * Int definitions *
+ ****************************************/
+typedef signed char int8;
+typedef unsigned char uint8;
+typedef short int16;
+typedef unsigned short uint16;
+typedef int int32;
+typedef unsigned uint32;
+typedef long long int64;
+typedef unsigned long long uint64;
+
+
+/****************************************
+ * Limits definitions *
+ ****************************************/
+#define INT8_MIN (-128)
+#define INT16_MIN (-32768)
+#define INT32_MIN (-2147483647 - 1)
+#define INT64_MIN (-9223372036854775807LL - 1)
+
+#define INT8_MAX 127
+#define INT16_MAX 32767
+#define INT32_MAX 2147483647
+#define INT64_MAX 9223372036854775807LL
+
+#define UINT8_MAX 0xff /* 255U */
+#define UINT16_MAX 0xffff /* 65535U */
+#define UINT32_MAX 0xffffffff /* 4294967295U */
+#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
+
+
+/****************************************
+ * Registers *
+ ****************************************/
+// 32 bit registers
+typedef struct {
+ uint32 eax, ebx, ecx, edx, esi, edi, ebp, esp, eflags;
+ uint8 cflag;
+} _R32BIT;
+
+// 16 bit registers
+typedef struct {
+ uint16 ax, bx, cx, dx, si, di, bp, sp, es, cs, ss, ds, flags;
+ uint8 cflag;
+} _R16BIT ;
+
+// 16 bit registers expressed in 32 bit registers
+typedef struct {
+ uint16 ax, axh, bx, bxh, cx, cxh, dx, dxh;
+ uint16 si, di, bp, sp, es, cs, ss, ds, flags;
+ uint8 cflags;
+} _R16BIT32 ;
+
+// 8 bit registers
+typedef struct {
+ uint8 al, ah, bl, bh, cl, ch, dl, dh;
+} _R8BIT;
+
+// 8 bit registers expressed in 32 bit registers
+typedef struct {
+ uint8 al, ah; uint16 axh;
+ uint8 bl, bh; uint16 bxh;
+ uint8 cl, ch; uint16 cxh;
+ uint8 dl, dh; uint16 dxh;
+} _R8BIT32;
+
+// 8 and 16 bit registers union
+typedef union {
+ _R16BIT x;
+ _R8BIT h;
+}_INTR16;
+
+// 32 bit, 16 bit and 8 bit registers union
+typedef union {
+ _R32BIT x;
+ _R16BIT32 l;
+ _R8BIT32 h;
+} _INTR32;
+
+/* This defines what the stack looks like after an ISR was running */
+typedef struct
+{
+ uint32 gs, fs, es, ds; /* pushed the segs last */
+ uint32 edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
+ uint32 int_no, err_code; /* our 'push byte #' and ecodes do this */
+ uint32 eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
+} _RegsStack32;
+
+
+/****************************************
+ * Keyboard data types *
+ ****************************************/
+enum KeyboardKeys {
+
+ KeyboardKeyF9 = 0x01,
+ KeyboardKeyF7 = 0x02,
+ KeyboardKeyF5 = 0x03,
+ KeyboardKeyF3 = 0x04,
+ KeyboardKeyF1 = 0x05,
+ KeyboardKeyF2 = 0x06,
+ KeyboardKeyF12 = 0x07,
+ KeyboardKeyMediaNext = 0x08,
+ KeyboardKeyF10 = 0x09,
+ KeyboardKeyF8 = 0x0A,
+ KeyboardKeyF6 = 0x0B,
+ KeyboardKeyF4 = 0x0C,
+ KeyboardKeyTab = 0x0D,
+ KeyboardKeyTilda = 0x0E,
+ KeyboardKeyMediaPrevious = 0x0F,
+ KeyboardKeyMediaStop = 0x10,
+ KeyboardKeyLeftAlt = 0x11,
+ KeyboardKeyLeftShift = 0x12,
+ KeyboardKeyMediaPause = 0x13,
+ KeyboardKeyLeftCtrl = 0x14,
+ KeyboardKeyQ = 0x15,
+ KeyboardKey1 = 0x16,
+ KeyboardKeyMediaVolUp = 0x17,
+ KeyboardKeyMediaVolDown = 0x18,
+ KeyboardKeyMediaSelect = 0x19,
+ KeyboardKeyZ = 0x1A,
+ KeyboardKeyS = 0x1B,
+ KeyboardKeyA = 0x1C,
+ KeyboardKeyW = 0x1D,
+ KeyboardKey2 = 0x1E,
+ KeyboardKeyLeftWin = 0x1F,
+ KeyboardKeyMediaEmail = 0x20,
+ KeyboardKeyC = 0x21,
+ KeyboardKeyX = 0x22,
+ KeyboardKeyD = 0x23,
+ KeyboardKeyE = 0x24,
+ KeyboardKey4 = 0x25,
+ KeyboardKey3 = 0x26,
+ KeyboardKeyRightWin = 0x27,
+ KeyboardKeyMediaCalculator = 0x28,
+ KeyboardKeySpace = 0x29,
+ KeyboardKeyV = 0x2A,
+ KeyboardKeyF = 0x2B,
+ KeyboardKeyT = 0x2C,
+ KeyboardKeyR = 0x2D,
+ KeyboardKey5 = 0x2E,
+ KeyboardKeyMenu = 0x2F,
+ KeyboardKeyMediaComputer = 0x30,
+ KeyboardKeyN = 0x31,
+ KeyboardKeyB = 0x32,
+ KeyboardKeyH = 0x33,
+ KeyboardKeyG = 0x34,
+ KeyboardKeyY = 0x35,
+ KeyboardKey6 = 0x36,
+ KeyboardKeyPower = 0x37,
+ KeyboardKeyMediaWebSearch = 0x38,
+ KeyboardKeyMediaWebHome = 0x39,
+ KeyboardKeyM = 0x3A,
+ KeyboardKeyJ = 0x3B,
+ KeyboardKeyU = 0x3C,
+ KeyboardKey7 = 0x3D,
+ KeyboardKey8 = 0x3E,
+ KeyboardKeySleep = 0x3F,
+ KeyboardKeyWake = 0x40,
+ KeyboardKeyComma = 0x41,
+ KeyboardKeyK = 0x42,
+ KeyboardKeyI = 0x43,
+ KeyboardKeyO = 0x44,
+ KeyboardKey0 = 0x45,
+ KeyboardKey9 = 0x46,
+ KeyboardKeyMediaWebBack = 0x47,
+ KeyboardKeyMediaWebForward = 0x48,
+ KeyboardKeyPeriod = 0x49,
+ KeyboardKeySlash = 0x4A,
+ KeyboardKeyL = 0x4B,
+ KeyboardKeySemicolon = 0x4C,
+ KeyboardKeyP = 0x4D,
+ KeyboardKeyDash = 0x4E,
+ KeyboardKeyMediaWebStop = 0x4F,
+ KeyboardKeyMediaWebRefresh = 0x50,
+ KeyboardKeyMediaWebFavorites = 0x51,
+ KeyboardKeyApostrophe = 0x52,
+ KeyboardKeyRightAlt = 0x53,
+ KeyboardKeyLeftBracket = 0x54,
+ KeyboardKeyEqual = 0x55,
+ KeyboardKeyPrintScreen = 0x56,
+ KeyboardKeyPause = 0x57,
+ KeyboardKeyCapsLock = 0x58,
+ KeyboardKeyRightShift = 0x59,
+ KeyboardKeyReturn = 0x5A,
+ KeyboardKeyRightBracket = 0x5B,
+ KeyboardKeyRightCtrl = 0x5C,
+ KeyboardKeyBackSlash = 0x5D,
+ KeyboardKeyInsert = 0x5E,
+ KeyboardKeyDelete = 0x5F,
+ KeyboardKeyHome = 0x60,
+ KeyboardKeyEnd = 0x61,
+ KeyboardKeyPageUp = 0x62,
+ KeyboardKeyPageDown = 0x63,
+ KeyboardKeyLeft = 0x64,
+ KeyboardKeyDown = 0x65,
+ KeyboardKeyBackspace = 0x66,
+ KeyboardKeyRight = 0x67,
+ KeyboardKeyUp = 0x68,
+ KeyboardKeyNumpad1 = 0x69,
+ KeyboardKeyNumpadSlash = 0x6A,
+ KeyboardKeyNumpad4 = 0x6B,
+ KeyboardKeyNumpad7 = 0x6C,
+ KeyboardKeyNumpadEnter = 0x6D,
+ KeyboardKeyMediaMute = 0x6E,
+ KeyboardKeyNumpad0 = 0x70,
+ KeyboardKeyNumpadColon = 0x71,
+ KeyboardKeyNumpad2 = 0x72,
+ KeyboardKeyNumpad5 = 0x73,
+ KeyboardKeyNumpad6 = 0x74,
+ KeyboardKeyNumpad8 = 0x75,
+ KeyboardKeyEscape = 0x76,
+ KeyboardKeyNumLock = 0x77,
+ KeyboardKeyF11 = 0x78,
+ KeyboardKeyNumpadPlus = 0x79,
+ KeyboardKeyNumpad3 = 0x7A,
+ KeyboardKeyNumpadMinus = 0x7B,
+ KeyboardKeyNumpadAsterisk = 0x7C,
+ KeyboardKeyNumpad9 = 0x7D,
+ KeyboardKeyScrollLock = 0x7E
+};
+
+typedef struct {
+ char Character;
+ uint8 Scancode;
+} Key;
+
+typedef struct {
+ uint8 Pressed;
+ char Character;
+ uint8 Scancode;
+} KeyEvent;
+
+/****************************************
+ * Other data types *
+ ****************************************/
+typedef struct {
+ int32 X, Y;
+} Point;
+
+typedef struct
+{
+ uint32 X, Y;
+} UPoint;
+
+typedef char* string;
+
+#endif
diff --git a/Kernel/include/va_list.h b/Kernel/include/va_list.h
new file mode 100644
index 0000000..71a45a9
--- /dev/null
+++ b/Kernel/include/va_list.h
@@ -0,0 +1,17 @@
+#ifndef __VA_LIST__H
+#define __VA_LIST__H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/* va list parameter list */
+typedef unsigned char *va_list;
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/Kernel/include/version.h b/Kernel/include/version.h
new file mode 100644
index 0000000..e987952
--- /dev/null
+++ b/Kernel/include/version.h
@@ -0,0 +1 @@
+#define OS_BUILD "0.1.0.450"
diff --git a/Kernel/include/version.h~ b/Kernel/include/version.h~
new file mode 100644
index 0000000..2c68073
--- /dev/null
+++ b/Kernel/include/version.h~
@@ -0,0 +1 @@
+-e #define OS_BUILD "0.1.0.418"
diff --git a/SysCore/lib/ctype.c b/Kernel/library/ctype.c
similarity index 100%
rename from SysCore/lib/ctype.c
rename to Kernel/library/ctype.c
diff --git a/Kernel/library/memory/memory_alloc.c b/Kernel/library/memory/memory_alloc.c
new file mode 100644
index 0000000..f630d70
--- /dev/null
+++ b/Kernel/library/memory/memory_alloc.c
@@ -0,0 +1,84 @@
+/*
+ * memory_alloc.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+extern uint32 mem_kernel_end;
+extern uint8 mem_initialized;
+
+// Used prior to proper initialization
+uint32 _malloc_init1 (uint32 size, uint8 page_aligned)
+{
+ uint32 ret = mem_kernel_end;
+
+ if (page_aligned && (ret & 0xfff)) ret = (ret & 0xfffff000) + 0x1000;
+ mem_kernel_end = size + ret;
+
+ LogMem("%#Allocated %u bytes (%spage aligned) at end of kernel (0x%x).\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret);
+ return (ret);
+}
+
+uint32 _malloc_init2 (uint32 size, uint8 page_aligned, uint32* phys)
+{
+ uint32 ret = MemHeapAlloc(size, page_aligned, KernelHeap, KernelDirectory);
+
+ if (phys)
+ {
+ Page *pg = PagingGetPage(ret, 0, KernelDirectory);
+ *phys = (*pg & PageFrame) + (ret & 0xFFF);
+
+ LogMem("%#Allocated %u bytes (%spage aligned) at address 0x%x (phys=%x).\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret, *phys);
+ }
+
+ else {
+ LogMem("%#Allocated %u bytes (%spage aligned) at address 0x%x.\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret);
+ }
+
+ return ret;
+}
+
+// Allocate 'size' bytes
+void* kmalloc (uint32 size)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) return (void*)_malloc_init1(size, 0);
+
+ return (void*)_malloc_init2(size,0,0);
+}
+
+// Allocate 'size' bytes, page aligned
+void* kmalloc_a(uint32 size)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) return (void*)_malloc_init1(size, 1);
+
+ return (void*)_malloc_init2(size,1,0);
+}
+
+void* kmalloc_p(uint32 size, uint32* phys)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) {
+ *phys = _malloc_init1(size,0);
+ return (void*)(*phys);
+ }
+
+ return (void*)_malloc_init2(size,0,phys);
+}
+
+void* kmalloc_ap(uint32 size, uint32* phys)
+{
+ if (!mem_initialized) return 0;
+
+ uint32 ret;
+ if (mem_initialized == 1) {
+ *phys = ret = _malloc_init1(size,1);
+ }
+
+ else ret = _malloc_init2(size,1,phys);
+ return (void*)ret;
+}
diff --git a/Kernel/library/memory/memory_alloc.c~ b/Kernel/library/memory/memory_alloc.c~
new file mode 100644
index 0000000..3969298
--- /dev/null
+++ b/Kernel/library/memory/memory_alloc.c~
@@ -0,0 +1,87 @@
+/*
+ * memory_alloc.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+extern uint32 mem_kernel_end;
+extern uint8 mem_initialized;
+
+// Used prior to proper initialization
+uint32 _malloc_init1 (uint32 size, uint8 page_aligned)
+{
+ uint32 ret = mem_kernel_end;
+
+ if (page_aligned && (ret & 0xfff)) ret = (ret & 0xfffff000) + 0x1000;
+ mem_kernel_end = size + ret;
+
+ LogMem("%#Allocated %u bytes (%spage aligned) at end of kernel (0x%x).\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret);
+ return (ret);
+}
+
+uint32 _malloc_init2 (uint32 size, uint8 page_aligned, uint32* phys)
+{
+ uint32 ret = MemHeapAlloc(size, page_aligned, KernelHeap, KernelDirectory);
+
+ if (phys)
+ {
+ Page *pg = PagingGetPage(ret, 0, KernelDirectory);
+ *phys = (*pg & PageFrame) + (ret & 0xFFF);
+
+ LogMem("%#Allocated %u bytes (%spage aligned) at address 0x%x (phys=%x).\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret, *phys);
+ }
+
+ else {
+ LogMem("%#Allocated %u bytes (%spage aligned) at address 0x%x.\n", ColorLightMagenta, size, ((page_aligned) ? "" : "not "), ret);
+ }
+
+ return ret;
+}
+
+// Allocate 'size' bytes
+void* kmalloc (uint32 size)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) return (void*)_malloc_init1(size, 0);
+
+ return (void*)_malloc_init2(size,0,0);
+}
+
+// Allocate 'size' bytes, page aligned
+void* kmalloc_a(uint32 size)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) return (void*)_malloc_init1(size, 1);
+
+ return (void*)_malloc_init2(size,1,0);
+}
+
+void* kmalloc_p(uint32 size, uint32* phys)
+{
+ if (!mem_initialized) return 0;
+ if (mem_initialized == 1) {
+ *phys = _malloc_init1(size,0);
+ return (void*)(*phys);
+ }
+
+ return (void*)_malloc_init2(size,0,phys);
+}
+
+void* kmalloc_ap(uint32 size, uint32* phys)
+{
+ if (!mem_initialized) return 0;
+
+ uint32 ret;
+ if (mem_initialized == 1) {
+ *phys = ret = _malloc_init1(size,1);
+ }
+
+ else ret = _malloc_init2(size,1,phys);
+
+ LogMem("%#kmalloc_ap requested, returned 0x%x, phys = 0x%x.\n", ColorMagenta, ret, *phys);
+
+ return (void*)ret;
+}
diff --git a/Kernel/library/memory/memory_free.c b/Kernel/library/memory/memory_free.c
new file mode 100644
index 0000000..a61b9fc
--- /dev/null
+++ b/Kernel/library/memory/memory_free.c
@@ -0,0 +1,20 @@
+/*
+ * memory_free.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+extern uint8 mem_initialized;
+
+void kfree(void* addr)
+{
+ if (mem_initialized < 2) {
+ ErrorMem("%#Tried to free at address 0x%x when memory manager is uninitialized.\n", ColorLightRed, (uint32)addr);
+ return;
+ }
+
+ MemHeapFree((uint32)addr, KernelHeap, KernelDirectory);
+}
diff --git a/Kernel/library/memory/memory_info.c b/Kernel/library/memory/memory_info.c
new file mode 100644
index 0000000..fbcf54a
--- /dev/null
+++ b/Kernel/library/memory/memory_info.c
@@ -0,0 +1,48 @@
+/*
+ * memory_info.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#include
+// MemoryGetFree(), MemoryGetTotal(), MemoryGet blah blah...
+
+// Returns total physical memory in bytes
+uint32 MemoryGetTotal()
+{
+ return (TotalMemory);
+}
+
+// Returns total free physical memory in bytes
+uint32 MemoryGetFree()
+{
+ return (TotalFrames - UsedFrames) * 0x4;
+}
+
+// Total used physical memory in bytes
+uint32 MemoryGetUsed()
+{
+ return UsedFrames * 0x4;
+}
+
+// Same as above functions, but in frames
+uint32 MemoryGetFrameSize()
+{
+ return 0x4;
+}
+
+uint32 MemoryGetFramesTotal()
+{
+ return TotalFrames;
+}
+
+uint32 MemoryGetFramesUsed()
+{
+ return UsedFrames;
+}
+
+uint32 MemoryGetFramesFree()
+{
+ return (TotalFrames - UsedFrames);
+}
\ No newline at end of file
diff --git a/Kernel/library/memory/memory_info.c~ b/Kernel/library/memory/memory_info.c~
new file mode 100644
index 0000000..e035707
--- /dev/null
+++ b/Kernel/library/memory/memory_info.c~
@@ -0,0 +1,48 @@
+/*
+ * memory_info.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+
+#include
+// MemoryGetFree(), MemoryGetTotal(), MemoryGet blah blah...
+
+// Returns total physical memory in bytes
+uint32 MemoryGetTotal()
+{
+ return (TotalMemory);
+}
+
+// Returns total free physical memory in bytes
+uint32 MemoryGetFree()
+{
+ return (TotalFrames - UsedFrames) * 0x4;
+}
+
+// Total used physical memory in bytes
+uint32 MemoryGetUsed()
+{
+ return UsedFrames * 0x4;
+}
+
+// Same as above functions, but in frames
+uint32 MemoryGetFrameSize()
+{
+ return 0x1000;
+}
+
+uint32 MemoryGetFramesTotal()
+{
+ return TotalFrames;
+}
+
+uint32 MemoryGetFramesUsed()
+{
+ return UsedFrames;
+}
+
+uint32 MemoryGetFramesFree()
+{
+ return (TotalFrames - UsedFrames);
+}
\ No newline at end of file
diff --git a/Kernel/library/memory/memory_init.c b/Kernel/library/memory/memory_init.c
new file mode 100644
index 0000000..1fd66dc
--- /dev/null
+++ b/Kernel/library/memory/memory_init.c
@@ -0,0 +1,88 @@
+/*
+ * memory-init.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+#include
+#include
+#include "../../drivers/cmos/cmos.h"
+#include
+
+
+uint32 mem_kernel_end = 0;
+uint8 mem_initialized = 0;
+
+uint32 _memory_get_total_mem(MultibootInfo* info)
+{
+ // Grub was nice enough to give us info
+ if (info->Flags & MultibootInfo_MEMORY) return (1024 + info->MemoryUpper);
+
+ // No? Get info from CMOS
+ uint8 low, high;
+ uint32 total;
+
+ low = CmosRead(0x30);
+ high = CmosRead(0x31);
+ total = (uint32)(low | high<<8) + 1024;
+
+ ErrorMem("%#Missing memory info from bootloader. Reading from CMOS: %ukb\n", ColorLightRed, total);
+
+ return total;
+}
+
+void _memory_reserve_system(MultibootInfo* info)
+{
+ MagicBreakpoint();
+ if ((info->Flags & MultibootInfo_MEM_MAP) != 0)
+ {
+ MultibootMemoryMapEntry* location = (MultibootMemoryMapEntry*)info->MemoryMapAddress;
+
+ while ((uint32)location < (info->MemoryMapAddress + info->MemoryMapLength))
+ {
+ if (location->Type > 1)
+ MemPhReserveFrames((uint32)location->Address, (uint32)location->Length);
+
+ location = (MultibootMemoryMapEntry*) ((uint32)location + location->Size + sizeof(uint32));
+ }
+ }
+
+ else
+ {
+ ErrorMem("%#Missing %#memory map%# info from bootloader.\n", ColorLightRed, ColorWhite, ColorLightRed);
+
+ // Standard memory hole at 15mb
+ MemPhReserveFrames(0x00F00000, 0x00100000);
+ }
+
+ // Standard reserved memory areas
+ MemPhReserveFrames(0x0, 0x400 + 256); // Real mode IVT, BDA
+ MemPhReserveFrames(0x1000, 0x2400); // DMA buffer
+ MemPhReserveFrames(0x9FC00, 385*1024); // EBDA, Video memory, ROM area
+}
+
+
+void MemoryInitialize (MultibootInfo* info)
+{
+ uint32 totalSystemMemory = _memory_get_total_mem(info);
+
+ MemPhInitialize(totalSystemMemory);
+ PagingInitialize(0x200000);
+
+ _memory_reserve_system(info);
+
+ KernelHeap = MemHeapCreate(KERNEL_HEAP_START, KERNEL_HEAP_START
+ + KERNEL_HEAP_INITIAL_SIZE, 0xCFFFF000, 3); // is kernel, writeable
+
+ LogMem("Done initializing memory!");
+
+ mem_initialized = 2;
+}
+
+void MemoryTempInitialize (uint32 kernel_end)
+{
+ mem_initialized = 1;
+ mem_kernel_end = kernel_end;
+ LogMem("Initialized temporary memory manager, allocating from %#0x%x.\n", kernel_end);
+}
diff --git a/Kernel/library/memory/memory_init.c~ b/Kernel/library/memory/memory_init.c~
new file mode 100644
index 0000000..0cf2f18
--- /dev/null
+++ b/Kernel/library/memory/memory_init.c~
@@ -0,0 +1,92 @@
+/*
+ * memory-init.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+#include
+#include
+#include "../../drivers/cmos/cmos.h"
+#include
+
+
+uint32 mem_kernel_end = 0;
+uint8 mem_initialized = 0;
+
+uint32 _memory_get_total_mem(MultibootInfo* info)
+{
+ // Grub was nice enough to give us info
+ if (info->Flags & MultibootInfo_MEMORY) return (1024 + info->MemoryUpper);
+
+ // No? Get info from CMOS
+ uint8 low, high;
+ uint32 total;
+
+ low = CmosRead(0x30);
+ high = CmosRead(0x31);
+ total = (uint32)(low | high<<8) + 1024;
+
+ ErrorMem("%#Missing memory info from bootloader. Reading from CMOS: %ukb\n", ColorLightRed, total);
+
+ return total;
+}
+
+void _memory_reserve_system(MultibootInfo* info)
+{
+ MagicBreakpoint();
+ if ((info->Flags & MultibootInfo_MEM_MAP) != 0)
+ {
+ MultibootMemoryMapEntry* location = (MultibootMemoryMapEntry*)info->MemoryMapAddress;
+
+ while ((uint32)location < (info->MemoryMapAddress + info->MemoryMapLength))
+ {
+ if (location->Type > 1)
+ MemPhReserveFrames((uint32)location->Address, (uint32)location->Length);
+
+ location = (MultibootMemoryMapEntry*) ((uint32)location + location->Size + sizeof(uint32));
+ }
+ }
+
+ else
+ {
+ ErrorMem("%#Missing %#memory map%# info from bootloader.\n", ColorLightRed, ColorWhite, ColorLightRed);
+
+ // Standard memory hole at 15mb
+ MemPhReserveFrames(0x00F00000, 0x00100000);
+ }
+
+ // Standard reserved memory areas
+ MemPhReserveFrames(0x0, 0x400 + 256); // Real mode IVT, BDA
+ MemPhReserveFrames(0x1000, 0x2400); // DMA buffer
+ MemPhReserveFrames(0x9FC00, 385*1024); // EBDA, Video memory, ROM area
+}
+
+
+void MemoryInitialize (MultibootInfo* info)
+{
+ uint32 totalSystemMemory = _memory_get_total_mem(info);
+
+ MemPhInitialize(totalSystemMemory);
+ PagingInitialize(0x200000);
+
+ LogMem("Reserving important areas...\n");
+
+ _memory_reserve_system(info);
+
+ LogMem("Allocating kernel heap...\n");
+
+ KernelHeap = MemHeapCreate(KERNEL_HEAP_START, KERNEL_HEAP_START
+ + KERNEL_HEAP_INITIAL_SIZE, 0xCFFFF000, 3); // is kernel, writeable
+
+ LogMem("Done initializing memory!");
+
+ mem_initialized = 2;
+}
+
+void MemoryTempInitialize (uint32 kernel_end)
+{
+ mem_initialized = 1;
+ mem_kernel_end = kernel_end;
+ LogMem("Initialized temporary memory manager, allocating from %#0x%x.\n", kernel_end);
+}
diff --git a/Kernel/library/stdio.c b/Kernel/library/stdio.c
new file mode 100644
index 0000000..2279459
--- /dev/null
+++ b/Kernel/library/stdio.c
@@ -0,0 +1,44 @@
+#include
+#include "../hal/keyboard/keyboard.h"
+
+uint8 inportb (uint16 _port) {
+ uint8 rv;
+ __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
+ return rv;
+}
+
+Key ReadKey()
+{
+ Key key;
+
+ do {
+ KeyboardLastScancode = 0xFF ;
+ while (KeyboardLastScancode == 0xFF) ;
+
+ key.Scancode = KeyboardLastScancode;
+
+ } while (KeyboardLastStatus & 1);
+
+ if (KeyboardGetKeyStatus(KeyboardKeyLeftShift) || KeyboardGetKeyStatus(KeyboardKeyRightShift))
+ key.Character = KeyboardMapShift[key.Scancode];
+ else key.Character = KeyboardMap[key.Scancode];
+
+ return key;
+}
+
+KeyEvent ReadKeyEvent()
+{
+ KeyEvent key;
+
+ KeyboardLastScancode = 0xFF ;
+ while (KeyboardLastScancode == 0xFF) ;
+
+ key.Scancode = KeyboardLastScancode;
+ key.Pressed = 1 - (KeyboardLastStatus & 1);
+
+ if (KeyboardGetKeyStatus(KeyboardKeyLeftShift) || KeyboardGetKeyStatus(KeyboardKeyRightShift))
+ key.Character = KeyboardMapShift[key.Scancode];
+ else key.Character = KeyboardMap[key.Scancode];
+
+ return key;
+}
diff --git a/Kernel/library/stdlib/convert_ops.c b/Kernel/library/stdlib/convert_ops.c
new file mode 100644
index 0000000..2d9c448
--- /dev/null
+++ b/Kernel/library/stdlib/convert_ops.c
@@ -0,0 +1,100 @@
+/*
+ * convert_ops.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+const string _Numbers = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+int32 ConvertIntToString (string buffer, int32 number, int32 base)
+{
+ if (base > 36 || base < 2) return 0;
+
+ int32 len = numlen (number, base), beg = 0, i;
+ uint32 n = (uint32) number;
+
+ // If number is negative and in base 10, we put a '-' in front
+ if (number < 0 && base == 10) buffer[beg++] = '-';
+
+ // Put every digit in string
+ for (i = len-1; i>=beg; i--)
+ {
+ buffer[i] = _Numbers[n % base];
+ n /= base;
+ }
+
+ buffer[len] = 0;
+ return number;
+}
+
+uint32 ConvertUIntToString (string buffer, uint32 number, int32 base)
+{
+ if (base > 36 || base < 2) return 0;
+
+ int32 len = unumlen (number, base), i;
+
+ // Put every digit in string
+ for (i = len-1; i >= 0; i--)
+ {
+ buffer[i] = _Numbers[number % base];
+ number /= base;
+ }
+
+ buffer[len] = 0;
+ return number;
+}
+
+int32 ConvertStringToInt (string buffer)
+{
+ int8 negative = (buffer[0] == '-');
+ int32 pos = (buffer[0] == '-' );
+
+ int32 number = 0;
+
+ while (IsDigit(buffer[pos]))
+ {
+ number = number*10 + (buffer[pos] - '0');
+ pos++;
+ }
+
+ if (negative) return -number;
+ return number;
+}
+
+uint32 ConvertStringToUInt (string buffer)
+{
+ int32 pos = 0;
+ int32 number = 0;
+
+ while (IsDigit(buffer[pos]))
+ {
+ number = number*10 + (buffer[pos] - '0');
+ pos++;
+ }
+
+ return number;
+}
+
+uint32 ConvertStringToIntHex (string buffer)
+{
+ int32 pos = 0;
+ uint32 number = 0;
+
+ // Skip first 2 digits if it is in format 0xXXXX...
+ if (buffer[1] == 'x' || buffer[1] == 'X') pos = 2;
+
+ while (IsHexDigit(buffer[pos]))
+ {
+ number = number*0x10;
+
+ if (IsDigit(buffer[pos])) number += buffer[pos] - '0';
+ else if (buffer[pos] >= 'a' && buffer[pos] <= 'f') number += 10 + buffer[pos] - 'a';
+ else if (buffer[pos] >= 'A' && buffer[pos] <= 'F') number += 10 + buffer[pos] - 'A';
+
+ pos++;
+ }
+
+ return number;
+}
diff --git a/Kernel/library/stdlib/mem_ops.c b/Kernel/library/stdlib/mem_ops.c
new file mode 100644
index 0000000..61bb2c8
--- /dev/null
+++ b/Kernel/library/stdlib/mem_ops.c
@@ -0,0 +1,42 @@
+/*
+ * mem_ops.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+void *memcpy(void *dest, const void *src, uint32 count)
+{
+ uint8* d = (uint8*) dest;
+ const uint8* s = (const uint8*) src;
+
+ while (count-- != 0)
+ *d++ = *s++;
+
+ return dest;
+}
+
+int32 memcmp(const void *s1, const void *s2, uint32 count)
+{
+ const uint8 *us1 = (const uint8*) s1;
+ const uint8 *us2 = (const uint8*) s2;
+
+ while (count-- != 0)
+ {
+ if (*us1 != *us2) return (*us1 < *us2) ? -1 : 1;
+ us1++; us2++;
+ }
+
+ return 0;
+}
+
+
+void *memset(void *dest, uint8 val, uint32 count)
+{
+ uint8 *temp = (uint8 *)dest;
+ while (count-- != 0)
+ *temp++ = val;
+
+ return dest;
+}
diff --git a/Kernel/library/stdlib/num_ops.c b/Kernel/library/stdlib/num_ops.c
new file mode 100644
index 0000000..8ff7752
--- /dev/null
+++ b/Kernel/library/stdlib/num_ops.c
@@ -0,0 +1,39 @@
+/*
+ * num_ops.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+uint32 numlen (int32 number, int32 base)
+{
+ // Sanity check
+ if (base < 2) return 0;
+
+ uint32 len = (number < 0 && base == 10); // add minus sign
+ if (number == 0) return 1;
+
+ while (number) {
+ number /= base;
+ ++len;
+ }
+
+ return len;
+}
+
+uint32 unumlen (uint32 number, int32 base)
+{
+ // Sanity check
+ if (base < 2) return 0;
+
+ uint32 len = 0;
+ if (number == 0) return 1;
+
+ while (number) {
+ number /= base;
+ ++len;
+ }
+
+ return len;
+}
diff --git a/Kernel/library/stdlib/ord_arr.c b/Kernel/library/stdlib/ord_arr.c
new file mode 100644
index 0000000..1c9758b
--- /dev/null
+++ b/Kernel/library/stdlib/ord_arr.c
@@ -0,0 +1,112 @@
+/*
+ * ord-arr.c
+ *
+ * Created on: Aug 25, 2011
+ * Author: Tiberiu
+ */
+
+
+/*
+ * memory.c
+ *
+ * Created on: Aug 24, 2011
+ * Author: Tiberiu
+ */
+
+#include
+#include
+
+int StandardComparePredicate (uint32 a, uint32 b)
+{
+ if (a > b) return 1;
+ else if (a == b) return 0;
+ return -1;
+}
+
+OrderedArray OrderedArrayCreate (uint32 maxSize, ComparePredicate p)
+{
+ OrderedArray ret;
+ ret.Data = (unsigned*) kmalloc(maxSize);
+ memset(ret.Data, 0, maxSize);
+ ret.Size = 0;
+ ret.SizeLimit = maxSize;
+ ret.Compare = (p == 0) ? StandardComparePredicate : p;
+
+ return ret;
+}
+
+OrderedArray OrderedArrayPlace (uint32 addr, uint32 maxSize, ComparePredicate p)
+{
+ OrderedArray ret;
+ ret.Data = (unsigned*)addr;
+ memset(ret.Data, 0, maxSize);
+ ret.Size = 0;
+ ret.SizeLimit = maxSize;
+ ret.Compare = (p == 0) ? StandardComparePredicate : p;
+
+ return ret;
+}
+
+void OrderedArrayDispose (OrderedArray* arr)
+{
+ kfree(arr->Data);
+}
+
+uint32 OrderedArrayBinarySearch (uint32 key, uint32* array, uint32 length, ComparePredicate predicate)
+{
+ if (!predicate) return 0;
+
+ uint32 left = 0, right = length, mid;
+
+ while (left < right)
+ {
+ mid = left + (right-left) / 2;
+
+ int r = (*predicate)(key, array[mid]);
+
+ if (r > 0) left = mid + 1;
+ else if (r < 0) right = mid;
+ else return mid;
+ }
+ mid = left + (right-left) / 2;
+
+ return mid;
+}
+
+uint32 OrderedArraySearch (uint32 key, OrderedArray* arr, ComparePredicate predicate)
+{
+ uint32 r = OrderedArrayBinarySearch(key,arr->Data,arr->Size,predicate);
+
+ if (arr->Data[r] != key) return 0xffffffff;
+ return r;
+}
+
+void OrderedArrayInsert (uint32 item, OrderedArray* arr)
+{
+ if (arr->Size >= arr->SizeLimit) return;
+
+ uint32 location = OrderedArrayBinarySearch(item, arr->Data, arr->Size, arr->Compare);
+
+ uint32 i;
+ for (i = arr->Size; i > location && arr->Size > 0; i--)
+ arr->Data[i] = arr->Data[i-1];
+
+ arr->Data[location] = item;
+ arr->Size++;
+}
+
+uint32 OrderedArrayLookup (uint32 index, OrderedArray* arr)
+{
+ if (index >= arr->Size) return 0;
+ return arr->Data[index];
+}
+
+void OrderedArrayDeleteIndex (uint32 index, OrderedArray* arr)
+{
+ if (index >= arr->Size) return;
+
+ uint32 i;
+ for (i = index + 1; i < arr->Size; i++)
+ arr->Data[i - 1] = arr->Data[i];
+ arr->Size--;
+}
diff --git a/Kernel/library/stdlib/str_ops.c b/Kernel/library/stdlib/str_ops.c
new file mode 100644
index 0000000..e163210
--- /dev/null
+++ b/Kernel/library/stdlib/str_ops.c
@@ -0,0 +1,39 @@
+/*
+ * str_ops.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+uint32 strlen (string s)
+{
+ string end = s;
+ while (*end != '\0')
+ end++;
+
+ return (uint32)(end - s);
+}
+
+int32 strcmp (string a, string b)
+{
+ unsigned char c1, c2;
+
+ while (*a != '\0' && *b != '\0' && *a == *b) {
+ a++; b++;
+ }
+
+ c1 = (*(unsigned char*) a);
+ c2 = (*(unsigned char*) b);
+ return ((c1 < c2) ? -1 : (c1 > c2));
+}
+
+string strcpy (string s1, const string s2)
+{
+ char *dst = s1;
+ const char *src = s2;
+
+ while ((*dst++ = *src++) != '\0') ;
+
+ return s1;
+}
diff --git a/Kernel/library/storage.c b/Kernel/library/storage.c
new file mode 100644
index 0000000..64b66aa
--- /dev/null
+++ b/Kernel/library/storage.c
@@ -0,0 +1,18 @@
+/*
+ * storage.c
+ *
+ * Created on: Aug 23, 2011
+ * Author: Tiberiu
+ */
+
+#include
+
+void ConvertLbaToChs(uint32 SectorsPerTrack, uint32 lba, uint32 *cyl, uint32 *head, uint32 *sector)
+{
+ // Avoid division by 0
+ if (SectorsPerTrack == 0) return;
+
+ *head = (lba % (SectorsPerTrack * 2)) / SectorsPerTrack;
+ *cyl = lba / (SectorsPerTrack * 2);
+ *sector = lba % SectorsPerTrack + 1;
+}
diff --git a/Kernel/library/time.c b/Kernel/library/time.c
new file mode 100644
index 0000000..fa8aa23
--- /dev/null
+++ b/Kernel/library/time.c
@@ -0,0 +1,98 @@
+#include
+extern volatile TimeSystem _internal_time;
+extern uint32 _internal_frequency_hz;
+
+// Length of months (summed)
+const int16 MonthLen[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+
+
+TimeSystem TimeConvertToTimeSystem (Time t)
+{
+ TimeSystem sys = {0,0};
+
+ t.Year--; t.Month--; t.Day--; t.WeekDay--;
+
+ sys.Time = (uint32)(t.Hour * 3600000) + (uint32)(t.Minute * 60000) + (uint32)(t.Second * 1000) + (uint32)t.Milisecond;
+
+ if (t.Year < 0) return sys;
+
+ sys.Date = (uint32)(t.Day) + (uint32)(MonthLen[t.Month])
+ + (uint32)((t.Year/4) * (365*4 + 1)) + (uint32)(t.Year%4 * 365);
+
+ return sys;
+}
+
+Time TimeConvertToTime (TimeSystem InternalTime)
+{
+ Time t;
+ t.Milisecond = InternalTime.Time % 1000;
+ t.Second = (InternalTime.Time / 1000) % 60;
+ t.Minute = (InternalTime.Time / 60000) % 60;
+ t.Hour = (InternalTime.Time / 3600000);
+
+
+ uint32 DayOfYear = (InternalTime.Date % 1461) % 365;
+ t.Year = (InternalTime.Date / 1461)*4 + (InternalTime.Date % 1461)/365 + 1;
+ t.Month = 11;
+ while ((int32)DayOfYear < (MonthLen[t.Month] + (t.Year % 4 == 0 && t.Month>1))) t.Month--;
+ t.WeekDay = InternalTime.Date % 7;
+ t.Day = DayOfYear - MonthLen[t.Month] - (t.Year % 4 == 0 && t.Month>1);
+
+ t.Month++; t.WeekDay++; t.Day++;
+
+ return t;
+}
+
+uint16 TimeCalculateWeekday (Time t)
+{
+ t.Year--;
+ uint32 d = (uint32)(t.Day-1) + (uint32)(MonthLen[t.Month-1]) +
+ + (uint32)((t.Year/4) * (365*4 + 1)) + (uint32)(t.Year%4 * 365);
+
+ return 1 + (d%7);
+}
+
+
+TimeSystem TimeGetInternalTime()
+{
+ return _internal_time;
+}
+
+void TimeSetInternalTime(TimeSystem t)
+{
+ _internal_time = t;
+}
+
+uint32 TimeGetInternalFrequency ()
+{
+ return _internal_frequency_hz;
+}
+
+void TimeSetInternalFrequency (uint32 f)
+{
+ _internal_frequency_hz = f;
+}
+
+
+TimeSystem _timer;
+#define MILISECONDS_IN_DAY 86400000
+
+void TimerStart (uint32 ms)
+{
+ _timer = TimeGetInternalTime();
+ _timer.Time += ms;
+
+ if (_timer.Time >= MILISECONDS_IN_DAY)
+ {
+ _timer.Date++;
+ _timer.Time-=MILISECONDS_IN_DAY;
+ }
+}
+
+uint8 TimerIsDone ()
+{
+ TimeSystem now = TimeGetInternalTime();
+ if (_timer.Date >= now.Date && _timer.Time > now.Time) return 0;
+
+ return 1;
+}
diff --git a/Kernel/loader.asm b/Kernel/loader.asm
new file mode 100644
index 0000000..119b3c7
--- /dev/null
+++ b/Kernel/loader.asm
@@ -0,0 +1,98 @@
+bits 32
+
+global start
+
+; multiboot header
+MODULEALIGN equ 1<<0
+MEMINFO equ 1<<1
+VIDEOINFO equ 1<<2
+FLAGS equ MODULEALIGN | MEMINFO | VIDEOINFO
+MAGIC equ 0x1BADB002
+CHECKSUM equ -(MAGIC + FLAGS)
+
+align 4
+section .__mbHeader
+MultiBootHeader:
+ dd MAGIC
+ dd FLAGS
+ dd CHECKSUM
+
+section .text
+
+STACKSIZE equ 0x4000 ; that's 16k.
+
+start:
+ XCHG BX, BX ; magic breakpoint
+
+ mov ecx, eax
+
+; lgdt [trickgdt]
+; mov ax, 0x10;
+; mov ds, ax
+; mov es, ax
+; mov fs, ax
+; mov gs, ax
+; mov ss, ax
+
+; jmp 0x08:HigherHalf ; NOTE: Must be absolute jump!
+
+HigherHalf:
+
+ ; Verify booted with multiboot compliant bootloader
+ mov esp, stack+STACKSIZE
+
+ cmp ecx, 0x2BADB002
+ jne .bad
+
+ push ebx
+
+ extern k_main
+ call k_main
+
+; Show error message, and halt system
+.bad:
+
+ extern ConsoleClear
+ extern ConsoleWrite
+ extern CommandOsver
+
+ call ConsoleClear
+ call CommandOsver
+
+ mov eax, [ErrorColor]
+ push eax
+ push ErrorString
+ call ConsoleWrite
+
+ cli
+ hlt
+
+
+; some variables
+ErrorString db 0xA, "%#! Fatal error: Not booted with multiboot compliant bootloader (e.g. GRUB).", 0x0
+ErrorColor db 0x0C
+
+
+
+; tells the assembler to include this data in the '.setup' section
+section .setup
+
+trickgdt:
+ dw gdt_end - gdt - 1 ; size of the GDT
+ dd gdt ; linear address of GDT
+
+gdt:
+ dd 0, 0 ; null gate
+ db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40 ; code selector 0x08: base 0x40000000, limit 0xFFFFFFFF, type 0x9A, granularity 0xCF
+ db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40 ; data selector 0x10: base 0x40000000, limit 0xFFFFFFFF, type 0x92, granularity 0xCF
+
+gdt_end:
+
+
+
+
+; stack
+section .bss
+align 32
+stack:
+ resb STACKSIZE ; This reserves 64KBytes of memory here
diff --git a/Kernel/loader.asm~ b/Kernel/loader.asm~
new file mode 100644
index 0000000..68763ef
--- /dev/null
+++ b/Kernel/loader.asm~
@@ -0,0 +1,99 @@
+bits 32
+
+global start
+
+; multiboot header
+MODULEALIGN equ 1<<0
+MEMINFO equ 1<<1
+VIDEOINFO equ 1<<2
+FLAGS equ MODULEALIGN | MEMINFO | VIDEOINFO
+MAGIC equ 0x1BADB002
+CHECKSUM equ -(MAGIC + FLAGS)
+
+
+section .__mbHeader
+align 4
+MultiBootHeader:
+ dd MAGIC
+ dd FLAGS
+ dd CHECKSUM
+
+section .text
+
+STACKSIZE equ 0x4000 ; that's 16k.
+
+start:
+ XCHG BX, BX ; magic breakpoint
+
+ mov ecx, eax
+
+; lgdt [trickgdt]
+; mov ax, 0x10;
+; mov ds, ax
+; mov es, ax
+; mov fs, ax
+; mov gs, ax
+; mov ss, ax
+
+; jmp 0x08:HigherHalf ; NOTE: Must be absolute jump!
+
+HigherHalf:
+
+ ; Verify booted with multiboot compliant bootloader
+ mov esp, stack+STACKSIZE
+
+ cmp ecx, 0x2BADB002
+ jne .bad
+
+ push ebx
+
+ extern k_main
+ call k_main
+
+; Show error message, and halt system
+.bad:
+
+ extern ConsoleClear
+ extern ConsoleWrite
+ extern CommandOsver
+
+ call ConsoleClear
+ call CommandOsver
+
+ mov eax, [ErrorColor]
+ push eax
+ push ErrorString
+ call ConsoleWrite
+
+ cli
+ hlt
+
+
+; some variables
+ErrorString db 0xA, "%#! Fatal error: Not booted with multiboot compliant bootloader (e.g. GRUB).", 0x0
+ErrorColor db 0x0C
+
+
+
+; tells the assembler to include this data in the '.setup' section
+section .setup
+
+trickgdt:
+ dw gdt_end - gdt - 1 ; size of the GDT
+ dd gdt ; linear address of GDT
+
+gdt:
+ dd 0, 0 ; null gate
+ db 0xFF, 0xFF, 0, 0, 0, 10011010b, 11001111b, 0x40 ; code selector 0x08: base 0x40000000, limit 0xFFFFFFFF, type 0x9A, granularity 0xCF
+ db 0xFF, 0xFF, 0, 0, 0, 10010010b, 11001111b, 0x40 ; data selector 0x10: base 0x40000000, limit 0xFFFFFFFF, type 0x92, granularity 0xCF
+
+gdt_end:
+
+
+
+
+; stack
+section .bss
+align 32
+stack:
+ resb STACKSIZE ; This reserves 64KBytes of memory here
diff --git a/Kernel/main.c b/Kernel/main.c
new file mode 100644
index 0000000..b8c764a
--- /dev/null
+++ b/Kernel/main.c
@@ -0,0 +1,27 @@
+#include "hal/hal.h"
+#include "drivers/drivers.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+extern uint32 _end;
+
+void k_main(MultibootInfo* info)
+{
+ uint32 KernelEnd = (uint32)&_end;
+ MemoryTempInitialize(KernelEnd);
+
+ ConsoleClear();
+ HalInitialize();
+ DriversInstall();
+
+ // Set up memory manager
+ MemoryInitialize(info);
+
+ Log("All ready. Starting console...\n\n");
+
+ ConsoleMain();
+}
diff --git a/Kernel/main.c~ b/Kernel/main.c~
new file mode 100644
index 0000000..5d7d17f
--- /dev/null
+++ b/Kernel/main.c~
@@ -0,0 +1,27 @@
+#include "hal/hal.h"
+#include "drivers/drivers.h"
+#include
+#include
+#include
+#include
+#include
+#include
+
+extern uint32 _end;
+
+void k_main(MultibootInfo* info)
+{
+ uint32 KernelEnd = (uint32)&_end;
+ MemoryTempInitialize(KernelEnd);
+
+ ConsoleClear();
+ HalInitialize();
+ DriversInstall();
+
+ // Set up memory manager
+ MemoryInitialize(&info_new);
+
+ Log("All ready. Starting console...\n\n");
+
+ ConsoleMain();
+}
diff --git a/Kernel/memory/mem-heap.c b/Kernel/memory/mem-heap.c
new file mode 100644
index 0000000..eac2d6e
--- /dev/null
+++ b/Kernel/memory/mem-heap.c
@@ -0,0 +1,304 @@
+#include
+#include
+#include
+
+#define MEMHEAP_MAGIC 0x50DBE514
+#define MEMHEAP_INDEX_SIZE 0x20000
+#define MEMHEAP_MINIM_SIZE 0x70000
+
+#define FlagsKernel 1
+#define FlagsWriteable 2
+
+typedef struct
+{
+ uint32 Magic;
+ // bit 0: used bit 1: reserved
+ uint8 Used;
+ uint32 Size;
+} MemHeapHeader;
+
+typedef struct
+{
+ uint32 Magic;
+ MemHeapHeader* Header;
+} MemHeapFooter;
+
+MemHeap* KernelHeap;
+
+uint32 MemHeapFindSmallestHole (uint32 size, uint8 page_align, MemHeap* heap)
+{
+ uint32 i;
+ for (i = 0; i < heap->Index.Size; i++)
+ {
+ MemHeapHeader* head = (MemHeapHeader*) OrderedArrayLookup(i, &heap->Index);
+
+ if (page_align)
+ {
+ uint32 location = (uint32)(head) + sizeof(MemHeapHeader);
+
+ // page align it
+ uint32 offset = 0x1000 - (location & 0xfff);
+ offset &= 0xfff;
+
+ if (head->Size - offset >= size) return i;
+ }
+
+ else if (head->Size >= size) return i;
+ }
+
+ return 0xffffffff;
+}
+
+int32 MemHeapCompare (uint32 a, uint32 b)
+{
+ MemHeapHeader *ha = (MemHeapHeader*)a, *hb = (MemHeapHeader*)b;
+
+ if (ha->Size > hb->Size) return 1;
+ else if (ha->Size == hb->Size) return 0;
+ return -1;
+}
+
+
+inline void MemHeapHeaderSetup (uint32 size, uint8 used, MemHeapHeader* head)
+{
+ head->Magic = MEMHEAP_MAGIC;
+ head->Used = used;
+ head->Size = size;
+}
+
+inline void MemHeapFooterSetup (MemHeapHeader* head, MemHeapFooter* foot)
+{
+ foot->Magic = MEMHEAP_MAGIC;
+ foot->Header = head;
+}
+
+
+MemHeap* MemHeapCreate(uint32 start, uint32 end, uint32 max, uint8 flags)
+{
+ if ((start & 0xfff) || (end & 0xfff)) return NULL;
+
+ MemHeap* heap = (MemHeap*) kmalloc(sizeof(MemHeap));
+ heap->Index = OrderedArrayPlace(start, MEMHEAP_INDEX_SIZE, MemHeapCompare);
+
+ start += sizeof(uint32) * MEMHEAP_INDEX_SIZE;
+
+ if (start & 0xfff) start = (start & 0xFFFFF000) + 0x1000;
+
+ heap->StartAddress = start;
+ heap->EndAddress = end;
+ heap->Flags = flags;
+ heap->MaxAddress = max;
+
+ // One large hole
+ MemHeapHeader* hole = (MemHeapHeader*)start;
+ MemHeapHeaderSetup(end-start, 0, hole);
+ OrderedArrayInsert(start, &heap->Index);
+
+ return heap;
+}
+
+
+void MemHeapExpand(uint32 newsz, MemHeap* heap, PageDirectory* pd)
+{
+ if (newsz <= heap->EndAddress - heap->StartAddress) return;
+
+ if (newsz & 0xfff) newsz = (newsz & 0xfffff000) + 0x1000;
+ if (newsz + heap->StartAddress >= heap->MaxAddress) return;
+
+ uint32 i;
+ for (i = heap->EndAddress - heap->StartAddress; i < heap->StartAddress + newsz; i+=0x1000)
+ MemPhAllocFrame(PagingGetPage(i, 1, pd), heap->Flags & FlagsKernel, heap->Flags & FlagsWriteable);
+
+ heap->EndAddress = heap->StartAddress + newsz;
+}
+
+uint32 MemHeapContract(uint32 newsz, MemHeap* heap, PageDirectory* pd)
+{
+ if (newsz >= heap->EndAddress - heap->StartAddress) return 0;
+
+ if (newsz & 0xfff) newsz = (newsz & 0xfffff000) + 0x1000; // page align
+ newsz = Max(newsz, MEMHEAP_MINIM_SIZE);
+
+ uint32 i;
+ for (i = heap->EndAddress - heap->StartAddress - 0x1000; i > newsz; i-=0x1000)
+ MemPhFreeFrame(PagingGetPage(i, 0, pd));
+
+ heap->EndAddress = heap->StartAddress + newsz;
+ return newsz;
+}
+
+
+uint32 MemHeapAlloc (uint32 size, uint8 isPageAligned, MemHeap* heap, PageDirectory* pd)
+{
+ // Sanity check
+ if (!size || !heap) return 0;
+
+ // Find a good hole
+ uint32 newsize = size + sizeof(MemHeapHeader) + sizeof(MemHeapFooter);
+ uint32 i = MemHeapFindSmallestHole(newsize, isPageAligned, heap);
+
+ // Didn't find? Expand heap
+ if (i == 0xffffffff)
+ {
+ uint32 oldLen = heap->EndAddress - heap->StartAddress;
+ uint32 oldEnd = heap->EndAddress;
+ MemHeapExpand(oldLen + newsize, heap, pd);
+
+ uint32 newLen = heap->EndAddress - heap->StartAddress;
+
+ // Find the last header
+ uint32 i = 0, index = 0, addr = 0;
+ for (; i < heap->Index.Size; i++)
+ {
+ uint32 tmp = OrderedArrayLookup(i, &heap->Index);
+ if (tmp > addr) {
+ addr = tmp; index = i;
+ }
+ }
+
+
+ MemHeapHeader* head; MemHeapFooter* foot;
+
+ if (heap->Index.Size == 0) // No headers? Add one
+ {
+ head = (MemHeapHeader*)oldEnd;
+ MemHeapHeaderSetup(newLen - oldLen, 0, head);
+ OrderedArrayInsert(oldEnd, &heap->Index);
+ }
+
+ else { // Modify last header
+ head = (MemHeapHeader*) OrderedArrayLookup(index, &heap->Index);
+ head->Size = newLen - oldLen;
+ }
+
+ foot = (MemHeapFooter*)((uint32)head + head->Size - sizeof(MemHeapFooter));
+ MemHeapFooterSetup(head, foot);
+
+ // Try again
+ return MemHeapAlloc(size, isPageAligned, heap, pd);
+ }
+
+ // Get info about hole
+ uint32 origAddr = OrderedArrayLookup(i, &heap->Index);
+ MemHeapHeader* origHead =(MemHeapHeader*) origAddr;
+ uint32 origSize = origHead->Size;
+
+ // Should split in two?
+ if (origSize - newsize <= sizeof(MemHeapHeader) + sizeof(MemHeapFooter))
+ {
+ size += origSize - newsize;
+ newsize = origSize;
+ }
+
+ // Should be page aligned
+ if (isPageAligned && (origAddr&0xfffff000))
+ {
+ uint32 newAddr = origAddr + 0x1000 - (origAddr&0xfff) - sizeof(MemHeapHeader);
+ MemHeapHeaderSetup(0x1000 - (origAddr&0xfff) - sizeof(MemHeapHeader), 0, origHead);
+
+ MemHeapFooter* holeFooter = (MemHeapFooter*)(newAddr - sizeof(MemHeapFooter));
+ MemHeapFooterSetup(origHead, holeFooter);
+
+ origAddr = newAddr;
+ origSize -= origHead->Size;
+ }
+
+ else OrderedArrayDeleteIndex(i, &heap->Index);
+
+ // Create the new block
+ MemHeapHeader* bHead = (MemHeapHeader*)origAddr;
+ MemHeapFooter* bFoot = (MemHeapFooter*)(origAddr + sizeof(MemHeapHeader) + size);
+ MemHeapHeaderSetup(newsize, 1, bHead);
+ MemHeapFooterSetup(bHead, bFoot);
+
+ // Create a new hole at the end of current block if necessary
+ if (origSize - newsize > 0)
+ {
+ // header
+ MemHeapHeader* hHead = (MemHeapHeader*)(origAddr + sizeof(MemHeapHeader) +
+ sizeof(MemHeapFooter) + size);
+ MemHeapHeaderSetup(origSize - newsize, 0, hHead);
+
+ // footer
+ MemHeapFooter* hFoot = (MemHeapFooter*)((uint32)hHead + hHead->Size - sizeof(MemHeapFooter));
+ if ((uint32)hFoot < heap->EndAddress) MemHeapFooterSetup(hHead, hFoot);
+
+ // add it to index
+ OrderedArrayInsert((uint32)hHead, &heap->Index);
+ }
+
+ return (uint32)bHead + sizeof(MemHeapHeader);
+}
+
+void MemHeapFree (uint32 address, MemHeap* heap, PageDirectory* pd)
+{
+ // Sanity check
+ if (!address || !heap) return;
+
+ MemHeapHeader* head = (MemHeapHeader*) (address - sizeof(MemHeapHeader));
+ MemHeapFooter* foot = (MemHeapFooter*) ((uint32)head + head->Size - sizeof(MemHeapFooter));
+
+ if (head->Magic != MEMHEAP_MAGIC) return;
+ if (foot->Magic != MEMHEAP_MAGIC) return;
+
+ // Clear used flag
+ head->Used = 0;
+
+ uint8 AddToIndex = 1;
+
+ // Unify left (if possible)
+ MemHeapFooter* testFoot = (MemHeapFooter*) ((uint32)head - sizeof(MemHeapFooter));
+ if (testFoot->Magic == MEMHEAP_MAGIC && testFoot->Header->Used == 0)
+ {
+ uint32 temp = head->Size;
+ head = testFoot->Header;
+ foot->Header = head;
+ head->Size += temp;
+
+ AddToIndex = 0;
+ }
+
+ // Unify right (if possible)
+ MemHeapHeader* testHead = (MemHeapHeader*) ((uint32)foot + sizeof(MemHeapFooter));
+ if ((uint32)testHead < heap->EndAddress && testHead->Magic == MEMHEAP_MAGIC && testHead->Used == 0)
+ {
+ head->Size += testHead->Size;
+ testFoot = (MemHeapFooter*) ((uint32)testHead + testHead->Size - sizeof(MemHeapFooter));
+ foot = testFoot;
+
+ uint32 i;
+ for (i = 0; i < heap->Index.Size &&
+ (uint32)testHead != OrderedArrayLookup(i, &heap->Index); i++) ;
+
+ if (i < heap->Index.Size) OrderedArrayDeleteIndex(i, &heap->Index);
+ }
+
+ // Contract heap (if possible)
+ if ((uint32)foot + sizeof(MemHeapFooter) == heap->EndAddress)
+ {
+ uint32 old = heap->EndAddress - heap->StartAddress;
+ uint32 new = MemHeapContract((uint32)head + head->Size - sizeof(MemHeapFooter), heap,pd);
+
+ // Last block still existent
+ if (head->Size > (old - new))
+ {
+ head->Size -= old - new;
+ foot = (MemHeapFooter*) ((uint32)head + head->Size - sizeof(MemHeapFooter));
+ MemHeapFooterSetup(head, foot);
+ }
+
+ // Nope, not existent
+ else
+ {
+ uint32 i;
+ for (i=0; iIndex.Size && (uint32)testHead != OrderedArrayLookup(i,&heap->Index); i++) ;
+
+ if (i < heap->Index.Size) OrderedArrayDeleteIndex(i,&heap->Index);
+ }
+ }
+
+ // Lastly, insert hole in array
+ if (AddToIndex) OrderedArrayInsert((uint32)head, &heap->Index);
+}
+
+
diff --git a/Kernel/memory/mem-paging.c b/Kernel/memory/mem-paging.c
new file mode 100644
index 0000000..6c4e3d8
--- /dev/null
+++ b/Kernel/memory/mem-paging.c
@@ -0,0 +1,74 @@
+/*
+ * memory-vi.c
+ *
+ * Created on: Aug 23, 2011
+ * Author: Tiberiu
+ */
+#include
+#include
+/*******************************
+ * Data *
+ *******************************/
+PageDirectory* CurrentDirectory;
+PageDirectory* KernelDirectory;
+
+/*******************************
+ * Useful routines *
+ *******************************/
+void PagingInitialize(uint32 kernel_used)
+{
+ LogMem("Virtual memory manager initialization started. End of kernel = 0x%x\n", kernel_used);
+ PageDirectory* kernelPd = (PageDirectory*) kmalloc_a(sizeof(PageDirectory));
+ memset(kernelPd, 0, sizeof(PageDirectory));
+
+ CurrentDirectory = kernelPd;
+ KernelDirectory = kernelPd;
+
+ uint32 i;
+ for (i = 0; i < kernel_used; i+=0x1000)
+ MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 0, 0);
+
+ LogMem("Identity mapped first 0x%x bytes.\n", kernel_used);
+
+ for (i = KERNEL_HEAP_START; i < KERNEL_HEAP_END; i+=0x1000)
+ MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 1, 1);
+
+ LogMem("Mapped kernel space.\n");
+
+ PagingSwitchPageDirectory (kernelPd);
+}
+
+void PagingSwitchPageDirectory (PageDirectory* dir)
+{
+ CurrentDirectory = dir;
+ asm volatile ("mov %0, %%cr3":: "r"(&dir->TablesPhysical));
+
+ uint32 cr0;
+ asm volatile ("mov %%cr0, %0": "=r"(cr0));
+ cr0 |= 0x80000000;
+ asm volatile ("mov %0, %%cr0":: "r"(cr0));
+
+ LogMem("Enabled paging.\n");
+}
+
+Page* PagingGetPage(uint32 addr, uint8 make, PageDirectory* dir)
+{
+ addr >>= 12;
+
+ uint32 tableIndex = addr >> 10;
+
+ if (dir->Tables[tableIndex])
+ return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
+
+ else if (make)
+ {
+ uint32 temp;
+ dir->Tables[tableIndex] = (PageTable*)kmalloc_ap(sizeof(PageTable), &temp);
+ memset (dir->Tables[tableIndex], 0, 0x1000);
+ dir->TablesPhysical[tableIndex] = temp | 0x7;
+ return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
+ }
+
+ else return 0;
+}
+
diff --git a/Kernel/memory/mem-paging.c~ b/Kernel/memory/mem-paging.c~
new file mode 100644
index 0000000..40fbe2d
--- /dev/null
+++ b/Kernel/memory/mem-paging.c~
@@ -0,0 +1,75 @@
+/*
+ * memory-vi.c
+ *
+ * Created on: Aug 23, 2011
+ * Author: Tiberiu
+ */
+#include
+#include
+/*******************************
+ * Data *
+ *******************************/
+PageDirectory* CurrentDirectory;
+PageDirectory* KernelDirectory;
+
+/*******************************
+ * Useful routines *
+ *******************************/
+void PagingInitialize(uint32 kernel_used)
+{
+ LogMem("Virtual memory manager initialization started. End of kernel = 0x%x\n", kernel_used);
+ PageDirectory* kernelPd = (PageDirectory*) kmalloc_a(sizeof(PageDirectory));
+ memset(kernelPd, 0, sizeof(PageDirectory));
+
+ CurrentDirectory = kernelPd;
+ KernelDirectory = kernelPd;
+
+ uint32 i;
+ for (i = 0; i < kernel_used; i+=0x1000)
+ MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 0, 0);
+
+ LogMem("Identity mapped first 0x%x bytes.\n", kernel_used);
+
+ for (i = KERNEL_HEAP_START; i < KERNEL_HEAP_END; i+=0x1000)
+ MemPhAllocFrame(PagingGetPage(i, 1, kernelPd), 1, 1);
+
+ LogMem("Mapped kernel space.\n");
+
+ PagingSwitchPageDirectory (kernelPd);
+}
+
+void PagingSwitchPageDirectory (PageDirectory* dir)
+{
+ CurrentDirectory = dir;
+ asm volatile ("mov %0, %%cr3":: "r"(&dir->TablesPhysical));
+ LogMem("Switched page directory to 0x%x.\n", (uint32)(&dir->TablesPhysical));
+
+ uint32 cr0;
+ asm volatile ("mov %%cr0, %0": "=r"(cr0));
+ cr0 |= 0x80000000;
+ asm volatile ("mov %0, %%cr0":: "r"(cr0));
+
+ LogMem("Enabled paging.\n");
+}
+
+Page* PagingGetPage(uint32 addr, uint8 make, PageDirectory* dir)
+{
+ addr >>= 12;
+
+ uint32 tableIndex = addr >> 10;
+
+ if (dir->Tables[tableIndex])
+ return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
+
+ else if (make)
+ {
+ uint32 temp;
+ dir->Tables[tableIndex] = (PageTable*)kmalloc_ap(sizeof(PageTable), &temp);
+ memset (dir->Tables[tableIndex], 0, 0x1000);
+ dir->TablesPhysical[tableIndex] = temp | 0x7;
+ return &dir->Tables[tableIndex]->Pages[addr&0x3ff];
+ }
+
+ else return 0;
+}
+
diff --git a/Kernel/memory/mem-phys.c b/Kernel/memory/mem-phys.c
new file mode 100644
index 0000000..b19038b
--- /dev/null
+++ b/Kernel/memory/mem-phys.c
@@ -0,0 +1,108 @@
+/*
+ * mem-phys.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+uint32* FrameMap;
+uint32 TotalFrames;
+uint32 TotalMemory;
+uint32 UsedFrames;
+
+inline void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset)
+{
+ *address = (index >> 5);
+ *offset = index & 0x1f;
+}
+
+inline uint32 ConvertFrameToIndex (uint32 address, uint32 offset)
+{
+ return (address<<5) | offset;
+}
+
+void MemPhSetFrame (uint32 frame, uint8 value)
+{
+ uint32 addr, off;
+ ConvertIndexToFrame(frame, &addr, &off);
+
+ if (value) {
+ if ((FrameMap[addr] & (1<> 5; addr++)
+ if (FrameMap[addr] != 0xffffffff)
+ {
+ for (pos = 0; (FrameMap[addr] & (1<> 2;
+ TotalMemory = SystemMemoryKb;
+
+ FrameMap = (uint32*) kmalloc(sizeof(uint32) * (1 + (TotalFrames>>5)));
+ memset(FrameMap, 0, sizeof(uint32) * (1 + (TotalFrames>>5)));
+ LogMem("%#Started physical memory manager ok!, found %ukb\n", ColorLightGreen, SystemMemoryKb);
+}
+
+void MemPhReserveFrames (uint32 address, uint32 length)
+{
+ address >>= 12;
+ length = (length>>12) + ((length & 0xfff) > 0);
+ uint32 end = address + length;
+
+ for (; address < end ; address++)
+ MemPhSetFrame(address, 1);
+}
diff --git a/Kernel/memory/mem-phys.c~ b/Kernel/memory/mem-phys.c~
new file mode 100644
index 0000000..484315b
--- /dev/null
+++ b/Kernel/memory/mem-phys.c~
@@ -0,0 +1,109 @@
+/*
+ * mem-phys.c
+ *
+ * Created on: Aug 27, 2011
+ * Author: Tiberiu
+ */
+#include
+
+uint32* FrameMap;
+uint32 TotalFrames;
+uint32 TotalMemory;
+uint32 UsedFrames;
+
+inline void ConvertIndexToFrame (uint32 index, uint32* address, uint32* offset)
+{
+ *address = (index >> 5);
+ *offset = index & 0x1f;
+}
+
+inline uint32 ConvertFrameToIndex (uint32 address, uint32 offset)
+{
+ return (address<<5) | offset;
+}
+
+void MemPhSetFrame (uint32 frame, uint8 value)
+{
+ uint32 addr, off;
+ ConvertIndexToFrame(frame, &addr, &off);
+
+ if (value) {
+ if ((FrameMap[addr] & (1<> 5; addr++)
+ if (FrameMap[addr] != 0xffffffff)
+ {
+ for (pos = 0; (FrameMap[addr] & (1<> 2;
+ TotalMemory = SystemMemoryKb;
+
+ FrameMap = (uint32*) kmalloc(sizeof(uint32) * (1 + (TotalFrames>>5)));
+ memset(FrameMap, 0, sizeof(uint32) * (1 + (TotalFrames>>5)));
+ LogMem("%#Started physical memory manager ok!, found %ukb\n", ColorLightGreen, SystemMemoryKb);
+}
+
+void MemPhReserveFrames (uint32 address, uint32 length)
+{
+ address >>= 12;
+ length = (length>>12) + ((length & 0xfff) > 0);
+ uint32 end = address + length;
+
+ for (; address < end ; address++)
+ MemPhSetFrame(address, 1);
+}
diff --git a/Makefile b/Makefile
deleted file mode 100644
index e2d3ecd..0000000
--- a/Makefile
+++ /dev/null
@@ -1,270 +0,0 @@
-# User sets these
-CC = gcc
-ASM = nasm
-CURDIR = /media/6C9EE8DF9EE8A336/ctaos
-
-# Other parameters & paths used
-LSCRIPT = SysCore/objects/linker.ld
-OBJ = Build
-
-CCPARAM = -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./SysCore/include -c
-ASMPARAMobj = -f aout
-ASMPARAMbin = -f bin
-
-#.PHONY : FORCE
-#FORCE :#
-# @echo -e "\e[1;4m\e[36mC\e[31mT\e[32mA \e[37mOperating System v0.1\e[0"
-
-# Build final floppy image
-ctaos.img : $(OBJ)bootload.bin $(OBJ)stage2.cta $(OBJ)kernel.bin
- @echo -e "\e[1;32m[ 99%]\e[0m Making floppy image"
- dd bs=512 count=2880 if=/dev/zero of=ctaos.img
- mkfs.msdos ctaos.img
- dd bs=512 count=1 conv=notrunc if=$(OBJ)bootload.bin of=ctaos.img
- sudo mkdir /media/floppy1/
- sudo mount -o loop ctaos.img /media/floppy1/
- sudo cp $(OBJ)stage2.cta /media/floppy1
- sudo cp $(OBJ)kernel.bin /media/floppy1
- sudo umount /media/floppy1/
- sudo rm -r /media/floppy1/
-
-
-# Build Bootloader: Stage 1
-$(OBJ)bootload.bin : SysBoot/stage1/bootload.asm
- echo -e "\e[1;32m[ 4%]\e[0m BOOTLOADER :: stage 1"
- @$(ASM) $(ASMPARAMbin) SysBoot/stage1/bootload.asm -o $(OBJ)bootload.bin
-
-# Build Bootloader: Stage 2
-$(OBJ)stage2.cta : SysBoot/stage2/stage2.asm \
- SysBoot/stage2/a20.inc \
- SysBoot/stage2/bootinfo.inc \
- SysBoot/stage2/common.inc \
- SysBoot/stage2/fat12.inc \
- SysBoot/stage2/floppy16.inc \
- SysBoot/stage2/gdt.inc \
- SysBoot/stage2/getdata.inc \
- SysBoot/stage2/memory.inc \
- SysBoot/stage2/paging.inc \
- SysBoot/stage2/stdio.inc
- @echo -e "\e[1;32m[ 8%]\e[0m BOOTLOADER :: stage 2"
- @$(ASM) $(ASMPARAMbin) -I./SysBoot/stage2/ -o $(OBJ)stage2.cta SysBoot/stage2/stage2.asm
-
-# Build KERNEL:
-$(OBJ)kernel.bin : $(OBJ)/loader.o \
- $(OBJ)/main.o \
- $(OBJ)/lib-conio.o \
- $(OBJ)/lib-ctype.o \
- $(OBJ)/mmngr-asm.o \
- $(OBJ)/mmngr-phys.o \
- $(OBJ)/mmngr-virt.o \
- $(OBJ)/mmngr-lib-pde.o \
- $(OBJ)/mmngr-lib-pte.o \
- $(OBJ)/shell.o \
- $(OBJ)/lib-stdlib.o \
- $(OBJ)/lib-string.o \
- $(OBJ)/lib-system.o \
- $(OBJ)/lib-time.o \
- $(OBJ)/driver-bsod.o \
- $(OBJ)/driver-cpu.o \
- $(OBJ)/driver-dma.o \
- $(OBJ)/driver-drivers.o \
- $(OBJ)/driver-floppy.o \
- $(OBJ)/driver-gdt.o \
- $(OBJ)/driver-gdt-asm.o \
- $(OBJ)/driver-idt.o \
- $(OBJ)/driver-idt-asm.o \
- $(OBJ)/driver-isrs.o \
- $(OBJ)/driver-isrs-asm.o \
- $(OBJ)/driver-irq.o \
- $(OBJ)/driver-irq-asm.o \
- $(OBJ)/driver-keyboard.o \
- $(OBJ)/driver-fat.o \
- $(OBJ)/driver-pic.o \
- $(OBJ)/driver-pit.o \
- $(OBJ)/video-vga03h.o
- ld -T SysCore/link.ld
-
-# ---------- Kernel components ---------- #
-
-# Build assembly sources:
-$(OBJ)/loader.o : SysCore/loader.asm
- @ echo -e "\e[1;33m[ 9%]\e[0m Assembly kernel loader"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/loader.o SysCore/loader.asm
-
-$(OBJ)/driver-gdt-asm.o : SysCore/drivers/cpu/gdt/gdt.asm
- @echo -e "\e[1;33m[ 10%]\e[0m Assembly code for GDT"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-gdt-asm.o SysCore/drivers/cpu/gdt/gdt.asm
-
-$(OBJ)/driver-idt-asm.o : SysCore/drivers/cpu/idt/idt.asm
- @echo -e "\e[1;33m[ 11%]\e[0m Assembly code for IDT"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-idt-asm.o SysCore/drivers/cpu/idt/idt.asm
-
-$(OBJ)/driver-irq-asm.o : SysCore/drivers/cpu/irq/irq.asm
- @echo -e "\e[1;33m[ 12%]\e[0m Assembly code for IRQ"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-irq-asm.o SysCore/drivers/cpu/irq/irq.asm
-
-$(OBJ)/driver-isrs-asm.o : SysCore/drivers/cpu/isrs/isrs.asm
- @echo -e "\e[1;33m[ 13%]\e[0m Assembly code for ISRs"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/driver-isrs-asm.o SysCore/drivers/cpu/isrs/isrs.asm
-
-
-# Build MAIN function
-$(OBJ)/main.o : SysCore/main.c SysCore/include/string.h \
- SysCore/include/system.h SysCore/include/conio.h \
- SysCore/drivers/drivers.h SysCore/include/time.h \
- SysCore/include/bootinfo.h SysCore/memory/mmngr_ph.h \
- SysCore/memory/mmngr_vi.h SysCore/video/vga03h.h
- @echo -e "\e[1;32m[ 14%]\e[0m MAIN C Function"
- @$(CC) $(CCPARAM) -o $(OBJ)/main.o SysCore/main.c
-
-# Build SHELL
-$(OBJ)/shell.o : SysCore/shell/shell.c SysCore/shell/apps.h \
- SysCore/include/system.h SysCore/include/conio.h \
- SysCore/drivers/drivers.h SysCore/include/time.h \
- SysCore/memory/mmngr_ph.h SysCore/drivers/keyboard.h \
- SysCore/drivers/cpu/cpu.h SysCore/include/drivers/floppy.h \
- SysCore/drivers/filesys/fat.h
- @echo -e "\e[1;34m[ 15%]\e[0m Shell"
- @$(CC) $(CCPARAM) -o $(OBJ)/shell.o SysCore/shell/shell.c
-
-# Build LIBRARIES
-$(OBJ)/lib-conio.o : SysCore/lib/conio.c \
- SysCore/include/drivers/keyboard.h SysCore/include/stdarg.h \
- SysCore/include/conio.h SysCore/include/stdlib.h \
- SysCore/include/string.h SysCore/include/ctype.h \
- SysCore/memory/mmngr_ph.h
- @echo -e "\e[1;34m[ 16%]\e[0m Libraries: conio"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-conio.o SysCore/lib/conio.c
-
-$(OBJ)/lib-ctype.o : SysCore/lib/ctype.c SysCore/include/ctype.h
- @echo -e "\e[1;34m[ 17%]\e[0m Libraries: ctype"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-ctype.o SysCore/lib/ctype.c
-
-$(OBJ)/lib-stdlib.o : SysCore/lib/stdlib.c SysCore/include/stdlib.h \
- SysCore/include/ctype.h
- @echo -e "\e[1;34m[ 18%]\e[0m Libraries: stdlib"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-stdlib.o SysCore/lib/stdlib.c
-
-$(OBJ)/lib-string.o : SysCore/lib/string.c SysCore/include/string.h
- @echo -e "\e[1;32m[ 19%]\e[0m Libraries: string"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-string.o SysCore/lib/string.c
-
-$(OBJ)/lib-system.o : SysCore/lib/system.c SysCore/include/system.h
- @echo -e "\e[1;34m[ 20%]\e[0m Libraries: system"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-system.o SysCore/lib/system.c
-
-$(OBJ)/lib-time.o : SysCore/lib/time.c SysCore/include/time.h \
- SysCore/include/system.h
- @echo -e "\e[1;34m[ 21%]\e[0m Libraries: time"
- @$(CC) $(CCPARAM) -o $(OBJ)/lib-time.o SysCore/lib/time.c
-
-
-# Build Memory Manager
-$(OBJ)/mmngr-asm.o : SysCore/memory/mmngr.asm
- @echo -e "\e[1;36m[ 22%]\e[0m Memory manager assembly code"
- @$(ASM) $(ASMPARAMobj) -o $(OBJ)/mmngr-asm.o SysCore/memory/mmngr.asm
-
-$(OBJ)/mmngr-phys.o : SysCore/memory/mmngr_ph.c SysCore/memory/mmngr_ph.h
- @echo -e "\e[1;36m[ 22%]\e[0m Physical memory manager"
- @$(CC) $(CCPARAM) -o $(OBJ)/mmngr-phys.o SysCore/memory/mmngr_ph.c
-
-$(OBJ)/mmngr-virt.o : SysCore/memory/mmngr_vi.c SysCore/memory/mmngr_vi.h \
- SysCore/memory/mmngr_ph.h
- @echo -e "\e[1;36m[ 23%]\e[0m Virtual memory manager"
- @$(CC) $(CCPARAM) -o $(OBJ)/mmngr-virt.o SysCore/memory/mmngr_vi.c
-
-$(OBJ)/mmngr-lib-pde.o : SysCore/memory/lib/pde.c SysCore/memory/lib/pde.h
- @echo -e "\e[1;36m[ 24%]\e[0m Memory manager libraries: PDE"
- @$(CC) $(CCPARAM) -o $(OBJ)/mmngr-lib-pde.o SysCore/memory/lib/pde.c
-
-$(OBJ)/mmngr-lib-pte.o : SysCore/memory/lib/pte.c SysCore/memory/lib/pte.h
- @echo -e "\e[1;36m[ 25%]\e[0m Memory manager libraries: PTE"
- @$(CC) $(CCPARAM) -o $(OBJ)/mmngr-lib-pte.o SysCore/memory/lib/pte.c
-
-
-# Build drivers
-$(OBJ)/driver-drivers.o : SysCore/drivers/drivers.c SysCore/include/system.h \
- SysCore/drivers/cpu/cpu.h SysCore/drivers/clock/clock.h \
- SysCore/drivers/floppy/floppy.h SysCore/include/drivers/keyboard.h
- @echo -e "\e[1;35m[ 26%]\e[0m Driver manager"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-drivers.o SysCore/drivers/drivers.c
-
-$(OBJ)/driver-bsod.o : SysCore/drivers/BSOD.c SysCore/include/system.h \
- SysCore/include/conio.h
- @echo -e "\e[1;35m[ 27%]\e[0m Kernel panic screen"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-bsod.o SysCore/drivers/BSOD.c
-
-$(OBJ)/driver-cpu.o : SysCore/drivers/cpu/cpu.c SysCore/include/system.h \
- SysCore/drivers/cpu/cpu.h SysCore/drivers/cpu/gdt/gdt.h \
- SysCore/drivers/cpu/idt/idt.h SysCore/drivers/cpu/irq/irq.h \
- SysCore/drivers/cpu/isrs/isrs.h
- @echo -e "\e[1;35m[ 28%]\e[0m CPU modules"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-cpu.o SysCore/drivers/cpu/cpu.c
-
-$(OBJ)/driver-gdt.o : SysCore/drivers/cpu/gdt/gdt.c SysCore/drivers/cpu/gdt/gdt.h
- @echo -e "\e[1;35m[ 29%]\e[0m Global descriptor table"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-gdt.o SysCore/drivers/cpu/gdt/gdt.c
-
-$(OBJ)/driver-idt.o : SysCore/drivers/cpu/idt/idt.c SysCore/drivers/cpu/idt/idt.h \
- SysCore/include/system.h
- @echo -e "\e[1;35m[ 30%]\e[0m Interrupt descriptor table"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-idt.o SysCore/drivers/cpu/idt/idt.c
-
-$(OBJ)/driver-isrs.o : SysCore/drivers/cpu/isrs/isrs.c SysCore/drivers/cpu/isrs/isrs.h \
- SysCore/drivers/cpu/idt/idt.h SysCore/include/system.h \
- SysCore/include/conio.h
- @echo -e "\e[1;35m[ 31%]\e[0m Interrupt service routines"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-isrs.o SysCore/drivers/cpu/isrs/isrs.c
-
-
-$(OBJ)/driver-irq.o : SysCore/drivers/cpu/irq/irq.c SysCore/drivers/cpu/irq/irq.h \
- SysCore/include/system.h SysCore/drivers/cpu/idt/idt.h \
- SysCore/drivers/cpu/pic/pic.h
- @echo -e "\e[1;35m[ 32%]\e[0m Interrupt requests"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-irq.o SysCore/drivers/cpu/irq/irq.c
-
-$(OBJ)/driver-pic.o : SysCore/drivers/cpu/irq/pic.c SysCore/drivers/cpu/irq/pic.h \
- SysCore/include/system.h
- @echo -e "\e[1;35m[ 33%]\e[0m Programmable interrupt controller"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-pic.o SysCore/drivers/cpu/irq/pic.c
-
-$(OBJ)/driver-pit.o : SysCore/drivers/clock/pit.c SysCore/drivers/clock/clock.h \
- SysCore/include/system.h SysCore/include/time.h
- @echo -e "\e[1;35m[ 34%]\e[0m Programmable interval timer"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-pit.o SysCore/drivers/clock/pic.c
-
-$(OBJ)/driver-keyboard.o : SysCore/drivers/keyboard/keyboard.c SysCore/include/system.h \
- SysCore/include/drivers/keyboard.h
- @echo -e "\e[1;35m[ 35%]\e[0m Keyboard"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-pic.o SysCore/drivers/cpu/irq/pic.c
-
-$(OBJ)/driver-dma.o : SysCore/drivers/floppy/dma.c SysCore/drivers/floppy/dma.h \
- SysCore/include/system.h
- @echo -e "\e[1;35m[ 36%]\e[0m DMA Controller"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-dma.o SysCore/drivers/floppy/dma.c
-
-$(OBJ)/driver-floppy.o : SysCore/drivers/floppy/floppy.c SysCore/drivers/floppy/dma.h \
- SysCore/include/system.h SysCore/include/time.h \
- SysCore/include/conio.h SysCore/drivers/floppy/storage.h \
- SysCore/drivers/floppy/floppy.h
- @echo -e "\e[1;35m[ 37%]\e[0m FDC Controller"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-floppy.o SysCore/drivers/floppy/floppy.c
-
-# TODO: add SysCore/drivers/filesys/vfs.h
-$(OBJ)/driver-fat.o : SysCore/drivers/filesys/fat.c SysCore/drivers/filesys/fat.h \
- SysCore/drivers/floppy/floppy.h SysCore/include/conio.h
- @echo -e "\e[1;35m[ 38%]\e[0m File system"
- @$(CC) $(CCPARAM) -o $(OBJ)/driver-fat.o SysCore/drivers/floppy/fat.c
-
-# TODO: add vfs.c
-
-# TODO: add colors
-$(OBJ)/video-vga03h.o : SysCore/video/vga03h.c SysCore/include/conio.h \
- SysCore/include/system.h
- @$(CC) $(CCPARAM) -o $(OBJ)/video-vga03h.o SysCore/video/vga03h.c
-
-
-.PHONY : clean
-clean:
- - rm ctaos.img
- rm $(OBJ)*.*
diff --git a/SysBoot/makeall.bat b/SysBoot/makeall.bat
deleted file mode 100644
index 0d28bf6..0000000
--- a/SysBoot/makeall.bat
+++ /dev/null
@@ -1,16 +0,0 @@
-@echo off
-set nasm_path=C:\nasm
-set djgpp_path=C:\DJGPP\bin
-
-@echo ***************** CTA Bootloader *****************
-@echo.
-
-:Stage1
- cd stage1
- call make.bat
- cd..
-
-:Stage2
- cd stage2
- call make.bat
- cd..
\ No newline at end of file
diff --git a/SysBoot/stage1/BOOTLOAD.BIN b/SysBoot/stage1/BOOTLOAD.BIN
deleted file mode 100644
index 0735e88..0000000
Binary files a/SysBoot/stage1/BOOTLOAD.BIN and /dev/null differ
diff --git a/SysBoot/stage1/bootload.asm b/SysBoot/stage1/bootload.asm
deleted file mode 100644
index 9769325..0000000
--- a/SysBoot/stage1/bootload.asm
+++ /dev/null
@@ -1,314 +0,0 @@
-
-;*********************************************
-; Boot1.asm
-; - A Simple Bootloader
-;
-; Operating Systems Development Series
-;*********************************************
-
-bits 16 ; we are in 16 bit real mode
-
-org 0 ; we will set regisers later
-
-start: jmp main ; jump to start of bootloader
-
-;*********************************************
-; BIOS Parameter Block
-;*********************************************
-
-; BPB Begins 3 bytes from start. We do a far jump, which is 3 bytes in size.
-; If you use a short jump, add a "nop" after it to offset the 3rd byte.
-
-bpbOEM db "CTA OS " ; OEM identifier (Cannot exceed 8 bytes!)
-bpbBytesPerSector: DW 512
-bpbSectorsPerCluster: DB 1
-bpbReservedSectors: DW 1
-bpbNumberOfFATs: DB 2
-bpbRootEntries: DW 224
-bpbTotalSectors: DW 2880
-bpbMedia: DB 0xf8 ;; 0xF1
-bpbSectorsPerFAT: DW 9
-bpbSectorsPerTrack: DW 18
-bpbHeadsPerCylinder: DW 2
-bpbHiddenSectors: DD 0
-bpbTotalSectorsBig: DD 0
-bsDriveNumber: DB 0
-bsUnused: DB 0
-bsExtBootSignature: DB 0x29
-bsSerialNumber: DD 0xa0a1a2a3
-bsVolumeLabel: DB "CTA FLOPPY "
-bsFileSystem: DB "FAT12 "
-
-;************************************************;
-; Prints a string
-; DS=>SI: 0 terminated string
-;************************************************;
-Print:
- lodsb ; load next byte from string from SI to AL
- or al, al ; Does AL=0?
- jz PrintDone ; Yep, null terminator found-bail out
- mov ah, 0eh ; Nope-Print the character
- int 10h
- jmp Print ; Repeat until null terminator found
- PrintDone:
- ret ; we are done, so return
-
-;************************************************;
-; Reads a series of sectors
-; CX=>Number of sectors to read
-; AX=>Starting sector
-; ES:BX=>Buffer to read to
-;************************************************;
-
-ReadSectors:
- .MAIN:
- mov di, 0x0005 ; five retries for error
- .SECTORLOOP:
- push ax
- push bx
- push cx
- call LBACHS ; convert starting sector to CHS
- mov ah, 0x02 ; BIOS read sector
- mov al, 0x01 ; read one sector
- mov ch, BYTE [absoluteTrack] ; track
- mov cl, BYTE [absoluteSector] ; sector
- mov dh, BYTE [absoluteHead] ; head
- mov dl, BYTE [bsDriveNumber] ; drive
- int 0x13 ; invoke BIOS
- jnc .SUCCESS ; test for read error
- xor ax, ax ; BIOS reset disk
- int 0x13 ; invoke BIOS
- dec di ; decrement error counter
- pop cx
- pop bx
- pop ax
- jnz .SECTORLOOP ; attempt to read again
- int 0x18
- .SUCCESS:
- mov si, msgProgress
- call Print
- pop cx
- pop bx
- pop ax
- add bx, WORD [bpbBytesPerSector] ; queue next buffer
- inc ax ; queue next sector
- loop .MAIN ; read next sector
- ret
-
-;************************************************;
-; Convert CHS to LBA
-; LBA = (cluster - 2) * sectors per cluster
-;************************************************;
-
-ClusterLBA:
- sub ax, 0x0002 ; zero base cluster number
- xor cx, cx
- mov cl, BYTE [bpbSectorsPerCluster] ; convert byte to word
- mul cx
- add ax, WORD [datasector] ; base data sector
- ret
-
-;************************************************;
-; Convert LBA to CHS
-; AX=>LBA Address to convert
-;
-; absolute sector = (logical sector / sectors per track) + 1
-; absolute head = (logical sector / sectors per track) MOD number of heads
-; absolute track = logical sector / (sectors per track * number of heads)
-;
-;************************************************;
-
-LBACHS:
- xor dx, dx ; prepare dx:ax for operation
- div WORD [bpbSectorsPerTrack] ; calculate
- inc dl ; adjust for sector 0
- mov BYTE [absoluteSector], dl
- xor dx, dx ; prepare dx:ax for operation
- div WORD [bpbHeadsPerCylinder] ; calculate
- mov BYTE [absoluteHead], dl
- mov BYTE [absoluteTrack], al
- ret
-
-;*********************************************
-; Bootloader Entry Point
-;*********************************************
-
-main:
-
- ;----------------------------------------------------
- ; code located at 0000:7C00, adjust segment registers
- ;----------------------------------------------------
-
- cli ; disable interrupts
- mov ax, 0x07C0 ; setup registers to point to our segment
- mov ds, ax
- mov es, ax
- mov fs, ax
- mov gs, ax
-
- ;----------------------------------------------------
- ; create stack
- ;----------------------------------------------------
-
- mov ax, 0x0000 ; set the stack
- mov ss, ax
- mov sp, 0xFFFF
- sti ; restore interrupts
-
- ;----------------------------------------------------
- ; Display loading message
- ;----------------------------------------------------
-
- mov si, msgLoading
- call Print
-
- ;----------------------------------------------------
- ; Load root directory table
- ;----------------------------------------------------
-
- LOAD_ROOT:
-
- ; compute size of root directory and store in "cx"
-
- xor cx, cx
- xor dx, dx
- mov ax, 0x0020 ; 32 byte directory entry
- mul WORD [bpbRootEntries] ; total size of directory
- div WORD [bpbBytesPerSector] ; sectors used by directory
- xchg ax, cx
-
- ; compute location of root directory and store in "ax"
-
- mov al, BYTE [bpbNumberOfFATs] ; number of FATs
- mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
- add ax, WORD [bpbReservedSectors] ; adjust for bootsector
- mov WORD [datasector], ax ; base of root directory
- add WORD [datasector], cx
-
- ; read root directory into memory (7C00:0200)
-
- mov bx, 0x0200 ; copy root dir above bootcode
- call ReadSectors
-
- ;----------------------------------------------------
- ; Find stage 2
- ;----------------------------------------------------
-
- ; browse root directory for binary image
- mov cx, WORD [bpbRootEntries] ; load loop counter
- mov di, 0x0200 ; locate first root entry
- .LOOP:
- push cx
- mov cx, 0x000B ; eleven character name
- mov si, ImageName ; image name to find
- push di
- rep cmpsb ; test for entry match
- pop di
- je LOAD_FAT
- pop cx
- add di, 0x0020 ; queue next directory entry
- loop .LOOP
- jmp FAILURE
-
- ;----------------------------------------------------
- ; Load FAT
- ;----------------------------------------------------
-
- LOAD_FAT:
-
- ; save starting cluster of boot image
-
- mov dx, WORD [di + 0x001A]
- mov WORD [cluster], dx ; file's first cluster
-
- ; compute size of FAT and store in "cx"
-
- xor ax, ax
- mov al, BYTE [bpbNumberOfFATs] ; number of FATs
- mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
- mov cx, ax
-
- ; compute location of FAT and store in "ax"
-
- mov ax, WORD [bpbReservedSectors] ; adjust for bootsector
-
- ; read FAT into memory (7C00:0200)
-
- mov bx, 0x0200 ; copy FAT above bootcode
- call ReadSectors
-
- ; read image file into memory (0050:0000)
-
- mov ax, 0x0050
- mov es, ax ; destination for image
- mov bx, 0x0000 ; destination for image
- push bx
-
- ;----------------------------------------------------
- ; Load Stage 2
- ;----------------------------------------------------
-
- LOAD_IMAGE:
-
- mov ax, WORD [cluster] ; cluster to read
- pop bx ; buffer to read into
- call ClusterLBA ; convert cluster to LBA
- xor cx, cx
- mov cl, BYTE [bpbSectorsPerCluster] ; sectors to read
- call ReadSectors
- push bx
-
- ; compute next cluster
-
- mov ax, WORD [cluster] ; identify current cluster
- mov cx, ax ; copy current cluster
- mov dx, ax ; copy current cluster
- shr dx, 0x0001 ; divide by two
- add cx, dx ; sum for (3/2)
- mov bx, 0x0200 ; location of FAT in memory
- add bx, cx ; index into FAT
- mov dx, WORD [bx] ; read two bytes from FAT
- test ax, 0x0001
- jnz .ODD_CLUSTER
-
- .EVEN_CLUSTER:
-
- and dx, 0000111111111111b ; take low twelve bits
- jmp .DONE
-
- .ODD_CLUSTER:
-
- shr dx, 0x0004 ; take high twelve bits
-
- .DONE:
-
- mov WORD [cluster], dx ; store new cluster
- cmp dx, 0x0FF0 ; test for end of file
- jb LOAD_IMAGE
-
- DONE:
- push WORD 0x0050
- push WORD 0x0000
- retf
-
- FAILURE:
-
- mov si, msgFailure
- call Print
- mov ah, 0x00
- int 0x16 ; await keypress
- int 0x19 ; warm boot computer
-
- absoluteSector db 0x00
- absoluteHead db 0x00
- absoluteTrack db 0x00
-
- datasector dw 0x0000
- cluster dw 0x0000
- ImageName db "STAGE2 CTA"
- msgLoading db 0x0D, "CTA OS v0.1", 0x0A, 0x0D, "(c) CTA 2010", 0x0A, 0x0D, "Loading", 0x00
- msgProgress db ".", 0x00
- msgFailure db 0x0D, 0x0A, "Error: Could not find stage2.bin. Press any key to reboot.", 0x0A, 0x00
-
- TIMES 510-($-$$) db 0
- DW 0xAA55
diff --git a/SysBoot/stage1/make.bat b/SysBoot/stage1/make.bat
deleted file mode 100644
index aa718bf..0000000
--- a/SysBoot/stage1/make.bat
+++ /dev/null
@@ -1,23 +0,0 @@
-@echo off
-set nasm_path=C:\nasm
-set djgpp_path=C:\DJGPP\bin
-
-goto build
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:build
- @echo Compiling stage 1...
- del bootload.bin
- %nasm_path%\nasm.exe -f bin bootload.asm -o bootload.bin
-
-:check
- if not exist bootload.bin goto error
-
-:copy
- @echo Writing stage 1 to floppy boot sector...
- debug bootload.bin <..\..\scripts\stage1d >nul
\ No newline at end of file
diff --git a/SysBoot/stage2/MAKE.BAT b/SysBoot/stage2/MAKE.BAT
deleted file mode 100644
index fc0dc23..0000000
--- a/SysBoot/stage2/MAKE.BAT
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo off
-set nasm_path=C:\nasm
-set djgpp_path=C:\DJGPP\bin
-
-goto build
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:build
-
- @echo Compiling stage 2...
- del stage2.cta
- %nasm_path%\nasm.exe -f bin stage2.asm -o stage2.cta
-
-:test
- if not exist stage2.cta goto error
-
-:copy
- @echo Copying stage 2 to floppy...
- copy stage2.cta A:\stage2.cta >nul
\ No newline at end of file
diff --git a/SysBoot/stage2/STAGE2.CTA b/SysBoot/stage2/STAGE2.CTA
deleted file mode 100644
index 091bc4b..0000000
Binary files a/SysBoot/stage2/STAGE2.CTA and /dev/null differ
diff --git a/SysBoot/stage2/a20.inc b/SysBoot/stage2/a20.inc
deleted file mode 100644
index 2a35227..0000000
--- a/SysBoot/stage2/a20.inc
+++ /dev/null
@@ -1,60 +0,0 @@
-;***** memory.inc ****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Enable A20 address line *
-;* ======================= *
-;* *
-;************************************************************ cta os */
-
-%ifndef __A20_INC_CTA000__
-%define __A20_INC_CTA000__
-
-bits 16 ; real mode 16 bit code
-
-_EnableA20:
-
- cli
-
- call a20wait
- mov al,0xAD
- out 0x64,al
-
- call a20wait
- mov al,0xD0
- out 0x64,al
-
- call a20wait2
- in al,0x60
- push eax
-
- call a20wait
- mov al,0xD1
- out 0x64,al
-
- call a20wait
- pop eax
- or al,2
- out 0x60,al
-
- call a20wait
- mov al,0xAE
- out 0x64,al
-
- call a20wait
- sti
- ret
-
-a20wait:
- in al,0x64
- test al,2
- jnz a20wait
- ret
-
-
-a20wait2:
- in al,0x64
- 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
deleted file mode 100644
index 8bd7f9f..0000000
--- a/SysBoot/stage2/bootinfo.inc
+++ /dev/null
@@ -1,39 +0,0 @@
-;***** bootinfo.inc **************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Multiboot information structure *
-;* =============================== *
-;* *
-;************************************************************ cta os */
-
-%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
-endstruc
-
-
-%endif
diff --git a/SysBoot/stage2/common.inc b/SysBoot/stage2/common.inc
deleted file mode 100644
index aeb3768..0000000
--- a/SysBoot/stage2/common.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-;***** common.inc ****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Common definitions, variables *
-;* ============================= *
-;* *
-;************************************************************ cta os */
-
-%ifndef _COMMON_INC_CTA002__
-%define _COMMON_INC_CTA002__
-
-; where the kernel is to be loaded to in protected mode
-%define IMAGE_PMODE_BASE 0xC0000000
-
-; where the kernel is to be loaded to in real mode
-%define IMAGE_RMODE_BASE 0x3000
-
-; kernel name (Must be 11 bytes)
-ImageName db "KERNEL CTA"
-
-; size of kernel image in bytes
-ImageSize db 0
-
-%endif
diff --git a/SysBoot/stage2/fat12.inc b/SysBoot/stage2/fat12.inc
deleted file mode 100644
index f494a8e..0000000
--- a/SysBoot/stage2/fat12.inc
+++ /dev/null
@@ -1,245 +0,0 @@
-;***** FAT12.inc *****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Fat12 filesystem for 3.5" floppies *
-;* ================================== *
-;* *
-;************************************************************ cta os */
-
-%ifndef __FAT12_INC_CTA003__
-%define __FAT12_INC_CTA003__
-
-bits 16
-
-;%include "Floppy16.inc" ; the erm.. floppy driver
-
-%define ROOT_OFFSET 0x2e00
-%define FAT_SEG 0x2c0
-%define ROOT_SEG 0x2e0
-
-;*******************************************
-; LoadRoot ()
-; - Load Root Directory Table to 0x7e00
-;*******************************************
-
-LoadRoot:
-
- pusha ; store registers
- push es
-
- ; compute size of root directory and store in "cx"
-
- xor cx, cx ; clear registers
- xor dx, dx
- mov ax, 32 ; 32 byte directory entry
- mul WORD [bpbRootEntries] ; total size of directory
- div WORD [bpbBytesPerSector] ; sectors used by directory
- xchg ax, cx ; move into AX
-
- ; compute location of root directory and store in "ax"
-
- mov al, BYTE [bpbNumberOfFATs] ; number of FATs
- mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
- add ax, WORD [bpbReservedSectors]
- mov WORD [datasector], ax ; base of root directory
- add WORD [datasector], cx
-
- ; read root directory into 0x7e00
-
- push word ROOT_SEG
- pop es
- mov bx, 0 ; copy root dir
- call ReadSectors ; read in directory table
- pop es
- popa ; restore registers and return
- ret
-
-;*******************************************
-; LoadFAT ()
-; - Loads FAT table to 0x7c00
-;
-; Parm/ ES:DI => Root Directory Table
-;*******************************************
-
-LoadFAT:
-
- pusha ; store registers
- push es
-
- ; compute size of FAT and store in "cx"
-
- xor ax, ax
- mov al, BYTE [bpbNumberOfFATs] ; number of FATs
- mul WORD [bpbSectorsPerFAT] ; sectors used by FATs
- mov cx, ax
-
- ; compute location of FAT and store in "ax"
-
- mov ax, WORD [bpbReservedSectors]
-
- ; read FAT into memory (Overwrite our bootloader at 0x7c00)
-
- push word FAT_SEG
- pop es
- xor bx, bx
- call ReadSectors
- pop es
- popa ; restore registers and return
- ret
-
-;*******************************************
-; FindFile ()
-; - Search for filename in root table
-;
-; parm/ DS:SI => File name
-; ret/ AX => File index number in directory table. -1 if error
-;*******************************************
-
-FindFile:
-
- push cx ; store registers
- push dx
- push bx
- mov bx, si ; copy filename for later
-
- ; browse root directory for binary image
-
- mov cx, WORD [bpbRootEntries] ; load loop counter
- mov di, ROOT_OFFSET ; locate first root entry at 1 MB mark
- cld ; clear direction flag
-
-.LOOP:
- push cx
- mov cx, 11 ; eleven character name. Image name is in SI
- mov si, bx ; image name is in BX
- push di
- rep cmpsb ; test for entry match
- pop di
- je .Found
- pop cx
- add di, 32 ; queue next directory entry
- loop .LOOP
-
-.NotFound:
- pop bx ; restore registers and return
- pop dx
- pop cx
- mov ax, -1 ; set error code
- ret
-
-.Found:
- pop ax ; return value into AX contains entry of file
- pop bx ; restore registers and return
- pop dx
- pop cx
- ret
-
-;*******************************************
-; LoadFile ()
-; - Load file
-; parm/ ES:SI => File to load
-; parm/ EBX:BP => Buffer to load file to
-; ret/ AX => -1 on error, 0 on success
-;*******************************************
-
-LoadFile:
-
- xor ecx, ecx ; size of file in sectors
- push ecx
-
-.FIND_FILE:
-
- push bx ; BX=>BP points to buffer to write to; store it for later
- push bp
- call FindFile ; find our file. ES:SI contains our filename
- cmp ax, -1
- jne .LOAD_IMAGE_PRE
- pop bp
- pop bx
- pop ecx
- mov ax, -1
- ret
-
-.LOAD_IMAGE_PRE:
-
- sub edi, ROOT_OFFSET
- sub eax, ROOT_OFFSET
-
- ; get starting cluster
-
- push word ROOT_SEG ;root segment loc
- pop es
- mov dx, WORD [es:di + 0x001A] ; DI points to file entry in root directory table. Refrence the table...
- mov WORD [cluster], dx ; file's first cluster
- pop bx ; get location to write to so we dont screw up the stack
- pop es
- push bx ; store location for later again
- push es
- call LoadFAT
-
-.LOAD_IMAGE:
-
- ; load the cluster
-
- mov ax, WORD [cluster] ; cluster to read
- pop es ; bx:bp=es:bx
- pop bx
- call ClusterLBA
- xor cx, cx
- mov cl, BYTE [bpbSectorsPerCluster]
-
- call ReadSectors
-
- pop ecx
- inc ecx
- push ecx
-
- push bx
- push es
-
- mov ax, FAT_SEG ;start reading from fat
- mov es, ax
- xor bx, bx
-
- ; get next cluster
-
- mov ax, WORD [cluster] ; identify current cluster
- mov cx, ax ; copy current cluster
- mov dx, ax ; copy current cluster
- shr dx, 0x0001 ; divide by two
- add cx, dx ; sum for (3/2)
-
- mov bx, 0 ;location of fat in memory
- add bx, cx
- mov dx, WORD [es:bx]
- test ax, 0x0001 ; test for odd or even cluster
- jnz .ODD_CLUSTER
-
-.EVEN_CLUSTER:
-
- and dx, 0000111111111111b ; take low 12 bits
- jmp .DONE
-
-.ODD_CLUSTER:
-
- shr dx, 0x0004 ; take high 12 bits
-
-.DONE:
-
- mov WORD [cluster], dx
- cmp dx, 0x0ff0 ; test for end of file marker
- jb .LOAD_IMAGE
-
-.SUCCESS:
- pop es
- pop bx
- pop ecx
- xor ax, ax
- ret
-
-%endif ;__FAT12_INC_67343546FDCC56AAB872_INCLUDED__
-
-
-
-
-
diff --git a/SysBoot/stage2/floppy16.inc b/SysBoot/stage2/floppy16.inc
deleted file mode 100644
index 3c08ac4..0000000
--- a/SysBoot/stage2/floppy16.inc
+++ /dev/null
@@ -1,120 +0,0 @@
-;***** floppy16.inc **************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Floppy drive interface routines *
-;* =============================== *
-;* *
-;************************************************************ cta os */
-
-%ifndef __FLOPPY16_INC_CTA004__
-%define __FLOPPY16_INC_CTA004__
-
-bits 16
-
-bpbOEM db "CTA OS "
-bpbBytesPerSector: DW 512
-bpbSectorsPerCluster: DB 1
-bpbReservedSectors: DW 1
-bpbNumberOfFATs: DB 2
-bpbRootEntries: DW 224
-bpbTotalSectors: DW 2880
-bpbMedia: DB 0xf0 ;; 0xF1
-bpbSectorsPerFAT: DW 9
-bpbSectorsPerTrack: DW 18
-bpbHeadsPerCylinder: DW 2
-bpbHiddenSectors: DD 0
-bpbTotalSectorsBig: DD 0
-bsDriveNumber: DB 0
-bsUnused: DB 0
-bsExtBootSignature: DB 0x29
-bsSerialNumber: DD 0xa0a1a2a3
-bsVolumeLabel: DB "CTA OS "
-bsFileSystem: DB "FAT12 "
-
-datasector dw 0x0000
-cluster dw 0x0000
-
-absoluteSector db 0x00
-absoluteHead db 0x00
-absoluteTrack db 0x00
-
-;************************************************;
-; Convert CHS to LBA
-; LBA = (cluster - 2) * sectors per cluster
-;************************************************;
-
-ClusterLBA:
- sub ax, 0x0002 ; zero base cluster number
- xor cx, cx
- mov cl, BYTE [bpbSectorsPerCluster] ; convert byte to word
- mul cx
- add ax, WORD [datasector] ; base data sector
- ret
-
-;************************************************;
-; Convert LBA to CHS
-; AX=>LBA Address to convert
-;
-; absolute sector = (logical sector / sectors per track) + 1
-; absolute head = (logical sector / sectors per track) MOD number of heads
-; absolute track = logical sector / (sectors per track * number of heads)
-;
-;************************************************;
-
-LBACHS:
- xor dx, dx ; prepare dx:ax for operation
- div WORD [bpbSectorsPerTrack] ; calculate
- inc dl ; adjust for sector 0
- mov BYTE [absoluteSector], dl
- xor dx, dx ; prepare dx:ax for operation
- div WORD [bpbHeadsPerCylinder] ; calculate
- mov BYTE [absoluteHead], dl
- mov BYTE [absoluteTrack], al
- ret
-
-
-;************************************************;
-; Reads a series of sectors
-; CX=>Number of sectors to read
-; AX=>Starting sector
-; ES:EBX=>Buffer to read to
-;************************************************;
-
-ReadSectors:
- .MAIN:
- mov di, 0x0005 ; five retries for error
- .SECTORLOOP:
- push ax
- push bx
- push cx
- call LBACHS ; convert starting sector to CHS
- mov ah, 0x02 ; BIOS read sector
- mov al, 0x01 ; read one sector
- mov ch, BYTE [absoluteTrack] ; track
- mov cl, BYTE [absoluteSector] ; sector
- mov dh, BYTE [absoluteHead] ; head
- mov dl, BYTE [bsDriveNumber] ; drive
- int 0x13 ; invoke BIOS
- jnc .SUCCESS ; test for read error
- xor ax, ax ; BIOS reset disk
- int 0x13 ; invoke BIOS
- dec di ; decrement error counter
- pop cx
- pop bx
- pop ax
- jnz .SECTORLOOP ; attempt to read again
- int 0x18
- .SUCCESS:
- pop cx
- pop bx
- pop ax
- add bx, WORD [bpbBytesPerSector] ; queue next buffer
- inc ax ; queue next sector
- loop .MAIN ; read next sector
- ret
-
-
-
-
-
-%endif ;__FLOPPY16_INC_67343546FDCC56AAB872_INCLUDED__
diff --git a/SysBoot/stage2/gdt.inc b/SysBoot/stage2/gdt.inc
deleted file mode 100644
index 45b9c7a..0000000
--- a/SysBoot/stage2/gdt.inc
+++ /dev/null
@@ -1,68 +0,0 @@
-;***** gdt.inc *******************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Global Descriptor Table routines *
-;* ===================== *
-;* *
-;************************************************************ cta os */
-
-
-%ifndef __GDT_INC_CTA005__
-%define __GDT_INC_CTA005__
-
-bits 16
-
-;*******************************************
-; InstallGDT()
-; - Install our GDT
-;*******************************************
-
-InstallGDT:
-
- cli ; clear interrupts
- pusha ; save registers
- lgdt [toc] ; load GDT into GDTR
- sti ; enable interrupts
- popa ; restore registers
- ret ; All done!
-
-;*******************************************
-; Global Descriptor Table (GDT)
-;*******************************************
-
-gdt_data:
- dd 0 ; null descriptor
- dd 0
-
-; gdt code: ; code descriptor
- dw 0FFFFh ; limit low
- dw 0 ; base low
- db 0 ; base middle
- db 10011010b ; access
- db 11001111b ; granularity
- db 0 ; base high
-
-; gdt data: ; data descriptor
- dw 0FFFFh ; limit low (Same as code)10:56 AM 7/8/2007
- dw 0 ; base low
- db 0 ; base middle
- db 10010010b ; access
- db 11001111b ; granularity
- db 0 ; base high
-
-end_of_gdt:
-toc:
- dw end_of_gdt - gdt_data - 1 ; limit (Size of GDT)
- dd gdt_data ; base of GDT
-
-; give the descriptor offsets names
-
-%define NULL_DESC 0
-%define CODE_DESC 0x8
-%define DATA_DESC 0x10
-
-%endif ;__GDT_INC_67343546FDCC56AAB872_INCLUDED__
-
-
-
-
diff --git a/SysBoot/stage2/getdata.inc b/SysBoot/stage2/getdata.inc
deleted file mode 100644
index 6a5d44d..0000000
--- a/SysBoot/stage2/getdata.inc
+++ /dev/null
@@ -1,98 +0,0 @@
-
-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
deleted file mode 100644
index eeff590..0000000
--- a/SysBoot/stage2/memory.inc
+++ /dev/null
@@ -1,174 +0,0 @@
-;***** memory.inc ****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Basic memory routines *
-;* ===================== *
-;* *
-;************************************************************ cta os */
-
-%ifndef __MEMORY_INC_CTA006__
-%define __MEMORY_INC_CTA006__
-
-bits 16
-
-;--------------------------------------------
-; Memory map entry structure
-;--------------------------------------------
-
-struc MemoryMapEntry
- .baseAddress resq 1
- .length resq 1
- .type resd 1
- .acpi_null resd 1
-endstruc
-
-;---------------------------------------------
-; Get memory map from bios
-; /in es:di->destination buffer for entries
-; /ret bp=entry count
-;---------------------------------------------
-
-BiosGetMemoryMap:
-
- xor ebx, ebx
- xor bp, bp
- mov edx, 0x0534D4150 ; Place "SMAP" into edx
- mov eax, 0xe820
- 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 + 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
-
-;---------------------------------------------
-; Get memory size for >64M configuations (32 bit)
-; ret\ ax=KB between 1MB and 16MB
-; ret\ bx=number of 64K blocks above 16MB
-; ret\ bx=0 and ax= -1 on error
-;---------------------------------------------
-
-BiosGetMemorySize64MB_32bit:
- push ecx
- push edx
- xor ecx, ecx
- xor edx, edx
- mov eax, 0xe881
- int 0x15
- jc .error
- 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
- pop ecx
- ret
-
-.error:
- mov ax, -1
- mov bx, 0
- pop edx
- pop ecx
- ret
-
-;---------------------------------------------
-; Get memory size for >64M configuations
-; ret\ ax=KB between 1MB and 16MB
-; ret\ bx=number of 64K blocks above 16MB
-; ret\ bx=0 and ax= -1 on error
-;---------------------------------------------
-
-BiosGetMemorySize64MB:
- push ecx
- push edx
- xor ecx, ecx
- xor edx, edx
- mov ax, 0xe801
- 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
-
-.use_ax:
- pop edx ;mem size is in ax and bx already, return it
- pop ecx
- ret
-
-.error:
- mov ax, -1
- mov bx, 0
- pop edx
- pop ecx
- ret
-
-;---------------------------------------------
-; Get amount of contiguous KB from addr 0
-; ret\ ax=KB size from address 0
-;---------------------------------------------
-
-BiosGetMemorySize:
- int 0x12
- ret
-
-;---------------------------------------------
-; Get contiguous exetended memory size
-; ret\ ax=KB size above 1MB; ax= -1 on error
-;---------------------------------------------
-
-BiosGetExtendedMemorySize:
- mov ax, 0x88
- int 0x15
- jc .error
- test ax, ax ; if size=0
- je .error
- cmp ah, 0x86 ;unsupported function
- je .error
- cmp ah, 0x80 ;invalid command
- je .error
- ret
-.error:
- mov ax, -1
- ret
-
-
-%endif
diff --git a/SysBoot/stage2/paging.inc b/SysBoot/stage2/paging.inc
deleted file mode 100644
index d9f4c03..0000000
--- a/SysBoot/stage2/paging.inc
+++ /dev/null
@@ -1,83 +0,0 @@
-;***** 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
deleted file mode 100644
index 97055d0..0000000
--- a/SysBoot/stage2/stage2.asm
+++ /dev/null
@@ -1,264 +0,0 @@
-;***** stage2.asm ****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Stage 2 Bootloader *
-;* ================== *
-;* *
-;************************************************************ cta os */
-bits 16
-
-org 0x500
-
-jmp main ; go to start
-
-;*******************************************************
-; Preprocessor directives
-;*******************************************************
-
-%include "stdio.inc" ; basic i/o routines
-%include "gdt.inc" ; Gdt routines
-%include "a20.inc" ; A20 enabling
-%include "floppy16.inc"
-%include "fat12.inc" ; FAT12 driver. Kinda :)
-%include "common.inc"
-;%include "bootinfo.inc"
-%include "memory.inc"
-%include "getdata.inc"
-
-;*******************************************************
-; Data Section
-;*******************************************************
-
-msgFailure db 0x0D, 0x0A, "FATAL ERROR: Kernel file KERNEL.CTA missing or corrupt. Press Any Key to Reboot.", 0x0D, 0x0A, 0x0A, 0x00
-
-boot_info:
- ; 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:
-
- ;-------------------------------;
- ; Setup segments and stack ;
- ;-------------------------------;
-
- cli ; clear interrupts
- xor ax, ax ; null segments
- mov ds, ax
- mov es, ax
- mov ax, 0x0000 ; stack begins at 0x9000-0xffff
- mov ss, ax
- mov sp, 0xFFFF
- sti ; enable interrupts
-
- call _EnableA20
- call InstallGDT
- sti
-
-
- ;-------------------------------;
- ; Fill in the boot structure ;
- ;-------------------------------;
-; Memory Size
- xor eax, eax
- xor ebx, ebx
- call BiosGetMemorySize64MB
-
- 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 ; address
- xor eax, eax
- mov ax, bp
- 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
- mov dword [ImageSize], ecx
- cmp ax, 0
- je EnterStage3
- mov si, msgFailure
- call Puts16
- mov ah, 0
- int 0x16 ; await keypress
- int 0x19 ; warm boot computer
-
- ;-------------------------------;
- ; Go into pmode ;
- ;-------------------------------;
-
-EnterStage3:
-
- cli ; clear interrupts
- mov eax, cr0 ; set bit 0 in cr0--enter pmode
- or eax, 1
- mov cr0, eax
-
- jmp CODE_DESC:Stage3 ; far jump to fix CS. Remember that the code selector is 0x8!
-
- ; Note: Do NOT re-enable interrupts! Doing so will triple fault!
- ; We will fix this in Stage 3.
-
-;******************************************************
-; ENTRY POINT FOR STAGE 3
-;******************************************************
-
-bits 32
-
-%include "paging.inc"
-
-BadImage db "FATAL ERROR: Kernel file KERNEL.CTA missing or corrupt. Press Any Key to Reboot.", 0
-
-Stage3:
-
- ;-------------------------------;
- ; Set registers ;
- ;-------------------------------;
-
- mov ax, DATA_DESC ; set data segments to data selector (0x10)
- mov ds, ax
- mov ss, ax
- mov es, ax
- mov esp, 90000h ; stack begins from 90000h
-
- call EnablePaging
-
-CopyImage:
- mov eax, dword [ImageSize]
- movzx ebx, word [bpbBytesPerSector]
- mul ebx
- mov ebx, 4
- div ebx
- cld
- mov esi, IMAGE_RMODE_BASE
- mov edi, IMAGE_PMODE_BASE
- mov ecx, eax
- rep movsd ; copy image to its protected mode address
-
- mov eax, 0xC0DEcC7A ; cta bootloader specific
- mov ebx, 0
-
-;edx=8
-
- push dword boot_info
- push dword [ImageSize]
-
- jmp CODE_DESC:IMAGE_PMODE_BASE ; Execute Kernel
- add esp, 4
-
- cli
- hlt
-
-
-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
diff --git a/SysBoot/stage2/stdio.inc b/SysBoot/stage2/stdio.inc
deleted file mode 100644
index b86699f..0000000
--- a/SysBoot/stage2/stdio.inc
+++ /dev/null
@@ -1,296 +0,0 @@
-;***** stdio.inc *****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Standard Input/Output routines *
-;* ============================== *
-;* *
-;************************************************************ cta os */
-
-
-%ifndef __STDIO_INC_CTA008__
-%define __STDIO_INC_CTA008__
-
-
-;==========================================================
-;
-; 16 Bit Real Mode Routines
-;==========================================================
-
-
-;************************************************;
-; Puts16 ()
-; -Prints a null terminated string
-; DS=>SI: 0 terminated string
-;************************************************;
-tmpStr db " ", 0x0D, 0x0A, 0x00
-
-bits 16
-
-Puts16:
- pusha ; save registers
-.Loop1:
- lodsb ; load next byte from string from SI to AL
- or al, al ; Does AL=0?
- jz Puts16Done ; Yep, null terminator found-bail out
- mov ah, 0eh ; Nope-Print the character
- int 10h ; invoke BIOS
- jmp .Loop1 ; Repeat until null terminator found
-Puts16Done:
- popa ; restore registers
- ret ; we are done, so return
-
-
-PutINT:
- pusha ; save registers
-
- mov cx, 0
- .init:
- mov bx, cx
- add bx, tmpStr
- mov [bx], byte ' '
- inc cx
-
- cmp cx, 31
- jne .init
-
-
- mov cx, 31 ; initialize counter
-
- .loop:
- mov dx, 0
- mov bx, 0x0A
- div bx ; ax = ax/10, dx = ax%10
- mov bx, cx
- add bx, tmpStr
- add dl, '0'
- mov [bx], dl
-
- sub cx, 1
-
- cmp ax, 0 ; when done, ax = 0;
- je .done
-
- jmp .loop
-
- .done:
- mov si, tmpStr
- call Puts16
- popa
- ret
-
-;==========================================================
-;
-; 32 Bit Protected Mode Routines
-;==========================================================
-
- ;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)
-
-;_CurX db 0 ; current x/y location
-;_CurY db 0
-
-;**************************************************;
-; Putch32 ()
-; - Prints a character to screen
-; 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
-
- ; 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
-
- ; add the position to draw to the base of vid memory
-
-; 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
-;
- ; print the character
-
-; mov dl, bl ; Get character
-; mov dh, CHAR_ATTRIB ; the character attribute
-; mov word [edi], dx ; write to video display
-;
-; ; go to next location
-
-; 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
-
-;.done:
-; popa
-; ret
-
-;**************************************************;
-; Puts32 ()
-; - Prints a null terminated string
-; parm\ EBX = address of string to print
-;**************************************************;
-
-;Puts32:
-
-; pusha
-; push ebx ; copy the string address
-; pop edi
-
-;.loop:
-
- ;-------------------------------;
- ; Get character ;
- ;-------------------------------;
-
-; 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
-
- ;-------------------------------;
- ; Go to next character ;
- ;-------------------------------;
-
-; inc edi ; go to next character
-; jmp .loop
-
-;.done:
-
- ;-------------------------------;
- ; Update hardware cursor ;
- ;-------------------------------;
-
-; mov bh, byte [_CurY] ; get current position
-; mov bl, byte [_CurX]
-; call MovCur ; update cursor
-
-; popa ; restore registers, and return
-; ret
-
-;**************************************************;
-; MoveCur ()
-; - Update hardware cursor
-; parm/ bh = Y pos
-; parm/ bl = x pos
-;**************************************************;
-
-
-
-;bits 32
-
-;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
-;
- ;--------------------------------------;
- ; 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
-
- ;---------------------------------------;
- ; Set high byte index to VGA register ;
- ;---------------------------------------;
-
-; xor eax, eax
-
-; mov al, 0x0e
-; mov dx, 0x03D4
-; out dx, al
-
-; mov al, bh
-; mov dx, 0x03D5
-; out dx, al ; high byte
-
-; 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
-
-;**************************************************;
-; GotoXY ()
-; - Set current X/Y location
-; parm\ AL=X position
-; parm\ AH=Y position
-;**************************************************;
-
-;bits 32
-
-;GotoXY:
-; pusha
-; mov [_CurX], al
-; mov [_CurY], ah
-; popa
-; ret
-
-
-%endif ;__STDIO_INC_67343546FDCC56AAB872_INCLUDED__
diff --git a/SysCore/compile.bat b/SysCore/compile.bat
deleted file mode 100644
index 8963f0a..0000000
--- a/SysCore/compile.bat
+++ /dev/null
@@ -1,20 +0,0 @@
-@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:\mingw\bin
-
-rem Compile loader
-@echo on
-%nasm_path%\nasm.exe -f aout -o ./objects/%loader_name%.o %loader_name%.asm
-@echo off
-@echo.
-rem Compile main Kernel
-@echo on
-%djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./include -c -o ./objects/main.o main.c
-@echo off
-rem OTHER GCC/NASM SOURCES GO HERE
-
-@pause
diff --git a/SysCore/debug/BIOS-bochs-latest b/SysCore/debug/BIOS-bochs-latest
deleted file mode 100644
index 5e94170..0000000
Binary files a/SysCore/debug/BIOS-bochs-latest and /dev/null differ
diff --git a/SysCore/debug/OSDev.log b/SysCore/debug/OSDev.log
deleted file mode 100644
index da16f8e..0000000
--- a/SysCore/debug/OSDev.log
+++ /dev/null
@@ -1,195 +0,0 @@
-00000000000i[ ] Bochs x86 Emulator 2.4.5
-00000000000i[ ] Build from CVS snapshot, on April 25, 2010
-00000000000i[ ] System configuration
-00000000000i[ ] processors: 1 (cores=1, HT threads=1)
-00000000000i[ ] A20 line support: yes
-00000000000i[ ] CPU configuration
-00000000000i[ ] level: 6
-00000000000i[ ] SMP support: no
-00000000000i[ ] APIC support: yes
-00000000000i[ ] FPU support: yes
-00000000000i[ ] MMX support: yes
-00000000000i[ ] 3dnow! support: no
-00000000000i[ ] SEP support: yes
-00000000000i[ ] SSE support: sse2
-00000000000i[ ] XSAVE support: no
-00000000000i[ ] AES support: no
-00000000000i[ ] MOVBE support: no
-00000000000i[ ] x86-64 support: yes
-00000000000i[ ] 1G paging support: no
-00000000000i[ ] MWAIT support: no
-00000000000i[ ] VMX support: no
-00000000000i[ ] Optimization configuration
-00000000000i[ ] RepeatSpeedups support: yes
-00000000000i[ ] Trace cache support: yes
-00000000000i[ ] Fast function calls: yes
-00000000000i[ ] Devices configuration
-00000000000i[ ] ACPI support: yes
-00000000000i[ ] NE2000 support: yes
-00000000000i[ ] PCI support: yes, enabled=yes
-00000000000i[ ] SB16 support: yes
-00000000000i[ ] USB support: yes
-00000000000i[ ] VGA extension support: vbe cirrus
-00000000000i[MEM0 ] allocated memory at 02720020. after alignment, vector=02721000
-00000000000i[MEM0 ] 32.00MB
-00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
-00000000000i[MEM0 ] rom at 0xe0000/131072 ('BIOS-bochs-latest')
-00000000000i[MEM0 ] rom at 0xc0000/40448 ('VGABIOS-lgpl-latest')
-00000000000i[CMOS ] Using local time for initial clock
-00000000000i[CMOS ] Setting initial clock to: Sun Nov 07 17:10:07 2010 (time0=1289142607)
-00000000000i[DMA ] channel 4 used by cascade
-00000000000i[DMA ] channel 2 used by Floppy Drive
-00000000000i[FDD ] fd0: 'ctaos.img' ro=0, h=2,t=80,spt=18
-00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
-00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
-00000000000i[MEM0 ] Register memory access handlers: 0x000a0000 - 0x000bffff
-00000000000i[WGUI ] Desktop Window dimensions: 1366 x 768
-00000000000i[WGUI ] Number of Mouse Buttons = 5
-00000000000i[WGUI ] IME disabled
-00000000000i[MEM0 ] Register memory access handlers: 0xe0000000 - 0xe0ffffff
-00000000000i[CLVGA] VBE Bochs Display Extension Enabled
-00000000000i[CLVGA] interval=50000
-00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
-00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
-00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
-00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
-00000000000i[ ] init_dev of 'gameport' plugin device by virtual method
-00000000000i[ ] init_dev of 'pci_ide' plugin device by virtual method
-00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
-00000000000i[ ] init_dev of 'acpi' plugin device by virtual method
-00000000000i[PCI ] ACPI Controller present at device 1, function 3
-00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
-00000000000i[IOAP ] initializing I/O APIC
-00000000000i[MEM0 ] Register memory access handlers: 0xfec00000 - 0xfec00fff
-00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
-00000000000i[KBD ] will paste characters every 1000 keyboard ticks
-00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
-00000000000i[HD ] Using boot sequence floppy, none, none
-00000000000i[HD ] Floppy boot signature check is enabled
-00000000000i[ ] init_dev of 'serial' plugin device by virtual method
-00000000000i[SER ] com1 at 0x03f8 irq 4
-00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
-00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
-00000000000i[ ] register state of 'unmapped' plugin device by virtual method
-00000000000i[ ] register state of 'biosdev' plugin device by virtual method
-00000000000i[ ] register state of 'speaker' plugin device by virtual method
-00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method
-00000000000i[ ] register state of 'gameport' plugin device by virtual method
-00000000000i[ ] register state of 'pci_ide' plugin device by virtual method
-00000000000i[ ] register state of 'acpi' plugin device by virtual method
-00000000000i[ ] register state of 'ioapic' plugin device by virtual method
-00000000000i[ ] register state of 'keyboard' plugin device by virtual method
-00000000000i[ ] register state of 'harddrv' plugin device by virtual method
-00000000000i[ ] register state of 'serial' plugin device by virtual method
-00000000000i[ ] register state of 'parallel' plugin device by virtual method
-00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
-00000000000i[CPU0 ] cpu hardware reset
-00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0xfee00000
-00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 756e6547 6c65746e 49656e69
-00000000000i[CPU0 ] CPUID[0x00000001]: 00000f20 00000800 00002000 078bfbff
-00000000000i[CPU0 ] CPUID[0x00000002]: 00410601 00000000 00000000 00000000
-00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
-00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
-00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 00000000 00000000 00000000
-00000000000i[CPU0 ] CPUID[0x80000001]: 00000000 00000000 00000101 2a100800
-00000000000i[CPU0 ] CPUID[0x80000002]: 20202020 20202020 20202020 6e492020
-00000000000i[CPU0 ] CPUID[0x80000003]: 286c6574 50202952 69746e65 52286d75
-00000000000i[CPU0 ] CPUID[0x80000004]: 20342029 20555043 20202020 00202020
-00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
-00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
-00000000000i[CPU0 ] CPUID[0x80000008]: 00003020 00000000 00000000 00000000
-00000000000i[ ] reset of 'unmapped' plugin device by virtual method
-00000000000i[ ] reset of 'biosdev' plugin device by virtual method
-00000000000i[ ] reset of 'speaker' plugin device by virtual method
-00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
-00000000000i[ ] reset of 'gameport' plugin device by virtual method
-00000000000i[ ] reset of 'pci_ide' plugin device by virtual method
-00000000000i[ ] reset of 'acpi' plugin device by virtual method
-00000000000i[ ] reset of 'ioapic' plugin device by virtual method
-00000000000i[ ] reset of 'keyboard' plugin device by virtual method
-00000000000i[ ] reset of 'harddrv' plugin device by virtual method
-00000000000i[ ] reset of 'serial' plugin device by virtual method
-00000000000i[ ] reset of 'parallel' plugin device by virtual method
-00000003305i[BIOS ] $Revision: 1.247 $ $Date: 2010/04/04 19:33:50 $
-00000200000i[WGUI ] dimension update x=720 y=400 fontheight=16 fontwidth=9 bpp=8
-00000318042i[KBD ] reset-disable command received
-00000444800i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert Exp $
-00000444871i[CLVGA] VBE known Display Interface b0c0
-00000444903i[CLVGA] VBE known Display Interface b0c5
-00000447828i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp $
-00000760517i[BIOS ] Starting rombios32
-00000761014i[BIOS ] Shutdown flag 0
-00000761695i[BIOS ] ram_size=0x02000000
-00000762173i[BIOS ] ram_end=32MB
-00000802745i[BIOS ] Found 1 cpu(s)
-00000822014i[BIOS ] bios_table_addr: 0x000fbc18 end=0x000fcc00
-00000822117i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
-00001149814i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
-00001477742i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
-00001477763i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
-00001477784i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
-00001477805i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
-00001477815i[P2I ] write: ELCR2 = 0x0a
-00001478700i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
-00001486658i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
-00001489220i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
-00001491621i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
-00001491851i[PIDE ] new BM-DMA address: 0xc000
-00001492555i[BIOS ] region 4: 0x0000c000
-00001494865i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
-00001495103i[ACPI ] new irq line = 11
-00001495117i[ACPI ] new irq line = 9
-00001495147i[ACPI ] new PM base address: 0xb000
-00001495161i[ACPI ] new SM base address: 0xb100
-00001495189i[PCI ] setting SMRAM control register to 0x4a
-00001659283i[CPU0 ] Enter to System Management Mode
-00001659293i[CPU0 ] RSM: Resuming from System Management Mode
-00001823313i[PCI ] setting SMRAM control register to 0x0a
-00001832484i[BIOS ] MP table addr=0x000fbcf0 MPC table addr=0x000fbc20 size=0xd0
-00001834543i[BIOS ] SMBIOS table addr=0x000fbd00
-00001836931i[BIOS ] ACPI tables: RSDP addr=0x000fbe20 ACPI DATA addr=0x01ff0000 size=0x988
-00001840169i[BIOS ] Firmware waking vector 0x1ff00cc
-00001851282i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
-00001852126i[BIOS ] bios_table_cur_addr: 0x000fbe44
-00014041543i[BIOS ] Booting from 0000:7c00
-00026325033i[KBD ] setting typematic info
-00026325046i[KBD ] setting delay to 500 mS (unused)
-00026325046i[KBD ] setting repeat rate to 10.9 cps (unused)
-00026325079i[KBD ] Switched to scancode set 2
-00026325154i[KBD ] keyboard: scan convert turned off
-00026326238i[FDD ] controller reset in software
-00026326585i[FDD ] io_write: config control register: 0x00
-00026326642e[FDD ] non DMA mode not fully implemented yet
-00055764602e[FDD ] non DMA mode not fully implemented yet
-00055764757e[FDD ] non DMA mode not fully implemented yet
-00067767563p[FDD ] >>PANIC<< write 0x03f5: receiving new command 0x03, old one (0xc6) pending
-00067767563i[CPU0 ] CPU is in protected mode (active)
-00067767563i[CPU0 ] CS.d_b = 32 bit
-00067767563i[CPU0 ] SS.d_b = 32 bit
-00067767563i[CPU0 ] EFER = 0x00000000
-00067767563i[CPU0 ] | RAX=0000000000000003 RBX=0000000000000000
-00067767563i[CPU0 ] | RCX=0000000000000012 RDX=00000000000003f5
-00067767563i[CPU0 ] | RSP=000000000008fd68 RBP=00000000c000a21c
-00067767563i[CPU0 ] | RSI=0000000000000000 RDI=0000000000000001
-00067767563i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
-00067767563i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
-00067767563i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
-00067767563i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
-00067767563i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf SF zf af pf cf
-00067767563i[CPU0 ] | SEG selector base limit G D
-00067767563i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
-00067767563i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
-00067767563i[CPU0 ] | MSR_FS_BASE:0000000000000000
-00067767563i[CPU0 ] | MSR_GS_BASE:0000000000000000
-00067767563i[CPU0 ] | RIP=00000000c00040be (00000000c00040bd)
-00067767563i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
-00067767563i[CPU0 ] | CR3=0x00001000 CR4=0x00000000
-00067767563i[CPU0 ] 0x00000000c00040bd>> out dx, al : EE
-00067767563i[CMOS ] Last time is 1289142623 (Sun Nov 07 17:10:23 2010)
-00067767563i[ ] restoring default signal behavior
-00067767563i[CTRL ] quit_sim called with exit code 1
diff --git a/SysCore/debug/VGABIOS-lgpl-latest b/SysCore/debug/VGABIOS-lgpl-latest
deleted file mode 100644
index a6c56a5..0000000
Binary files a/SysCore/debug/VGABIOS-lgpl-latest and /dev/null differ
diff --git a/SysCore/debug/bochs_config.bxrc b/SysCore/debug/bochs_config.bxrc
deleted file mode 100644
index e050631..0000000
--- a/SysCore/debug/bochs_config.bxrc
+++ /dev/null
@@ -1,17 +0,0 @@
-# ROM and VGA BIOS images ---------------------------------------------
-
-romimage: file=BIOS-bochs-latest, address=0xe0000
-vgaromimage: file=VGABIOS-lgpl-latest
-
-# boot from floppy using our disk image -------------------------------
-
-floppya: 1_44=ctaos.img, status=inserted
-
-# logging and reporting -----------------------------------------------
-
-log: OSDev.log # All errors and info logs will output to OSDev.log
-error: action=report
-info: action=report
-
-magic_break: enabled=1
-
diff --git a/SysCore/debug/ctaos.img b/SysCore/debug/ctaos.img
deleted file mode 100644
index 59bafcc..0000000
Binary files a/SysCore/debug/ctaos.img and /dev/null differ
diff --git a/SysCore/drivers/BSOD.c b/SysCore/drivers/BSOD.c
deleted file mode 100644
index 14b5de4..0000000
--- a/SysCore/drivers/BSOD.c
+++ /dev/null
@@ -1,85 +0,0 @@
-#include
-#include
-
-char *exception_messages[] = {
- "Division By Zero Exception",
- "Debug Exception",
- "Non Maskable Interrupt Exception",
- "Breakpoint Exception",
- "Into Detected Overflow Exception",
- "Out of Bounds Exception",
- "Invalid Opcode Exception",
- "No Coprocessor",
- "Double Fault Exception",
- "Coprocessor Segment Overrun Exception",
- "Bad TSS Exception",
- "Segment Not Present Exception",
- "Stack Fault Exception",
- "General Protection Fault Exception",
- "Page Fault Exception",
- "Unknown Interrupt Exception",
- "Coprocessor Fault Exception",
- "Alignment Check Exception",
- "Machine Check Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception",
- "Reserved Exception"
-};
-
-
-//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);
- puts_pos_font (10, 5, "fs", 0x01, 0x0B); put_hex_pos(15, 5, r->fs);
- puts_pos_font (10, 6, "es", 0x01, 0x0B); put_hex_pos(15, 6, r->es);
- puts_pos_font (10, 7, "ds", 0x01, 0x0B); put_hex_pos(15, 7, r->ds);
-
- puts_pos_font (40, 4, "edi", 0x01, 0x0B); put_hex_pos(45, 4, r->edi);
- puts_pos_font (40, 5, "esi", 0x01, 0x0B); put_hex_pos(45, 5, r->esi);
- puts_pos_font (40, 6, "ebp", 0x01, 0x0B); put_hex_pos(45, 6, r->ebp);
- puts_pos_font (40, 7, "esp", 0x01, 0x0B); put_hex_pos(45, 7, r->esp);
-
- puts_pos_font (10, 9, "eax", 0x01, 0x0B); put_hex_pos(15, 9, r->eax);
- puts_pos_font (10, 10, "ebx", 0x01, 0x0B); put_hex_pos(15, 10, r->ebx);
- puts_pos_font (40, 9, "ecx", 0x01, 0x0B); put_hex_pos(45, 9, r->ecx);
- puts_pos_font (40, 10, "edx", 0x01, 0x0B); put_hex_pos(45, 10, r->edx);
-
- puts_pos_font (10, 12, "int_no", 0x01, 0x0B); put_hex_pos(17, 12, r->int_no);
- puts_pos_font (10, 14, "Error code:", 0x01, 0x0B); put_hex_pos(24, 14, r->err_code);
- puts_pos_font (10, 15, "Error msg: ", 0x01, 0x0B); puts_pos(24, 15, exception_messages[r->int_no]);
-
- puts_pos_font (10, 17, "eip", 0x01, 0x0B); put_hex_pos(17, 17, r->eip);
- puts_pos_font (10, 18, "cs", 0x01, 0x0B); put_hex_pos(17, 18, r->cs);
- puts_pos_font (10, 19, "eflags", 0x01, 0x0B); put_hex_pos(17, 19, r->eflags);
- 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);*/
-//}
-
-/*void _STOP_ERROR_SCREEN (ISR_stack_regs *r)
-{
- puts_pos_font (30, 24, "Stop error 0x", 0x01, 0x0B); put_hex_pos(37, 24, r->int_no);
- puts_pos(50, 24, exception_messages[r->int_no]);
-
- puts_pos_font (5, 24, "!!! System Halted !!!", 0x01, 0x0C);
-}*/
-
-void _STOP_ERROR_SCREEN (ISR_stack_regs *r)
-{
- cprintf ("%#0C** Fatal Error: "); cprintf("%#0E %s \n\r", exception_messages[r->int_no]);
- for (;;);
-}
\ No newline at end of file
diff --git a/SysCore/drivers/clock/clock.h b/SysCore/drivers/clock/clock.h
deleted file mode 100644
index 1f18cc9..0000000
--- a/SysCore/drivers/clock/clock.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __PIT_H
-#define __PIT_H
-
-#include
-#include
-
-extern void i86_PitHandler(ISR_stack_regs *r);
-extern void i86_PitInitialize(int freq);
-extern unsigned char PitIsInitialized();
-extern void PitSetFrequency(int frequency);
-extern unsigned int PitGetFrequency();
-
-extern TIME ClockGetTime();
-extern unsigned int ClockSetTickCount(unsigned int i);
-extern unsigned int ClockGetTickCount();
-
-extern void i86_SetRTC (const TIME* time);
-extern void i86_GetRTC(TIME* tim);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/clock/pit.c b/SysCore/drivers/clock/pit.c
deleted file mode 100644
index 98d96a0..0000000
--- a/SysCore/drivers/clock/pit.c
+++ /dev/null
@@ -1,120 +0,0 @@
-#include
-#include
-#include "clock.h"
-
-volatile unsigned int ClockTicks = 0;
-volatile unsigned int ClockFrequency = 0;
-unsigned char PitInitialized = 0;
-volatile TIME _InternalClock;
-
-
-void PitSetFrequency(int frequency)
-{
- int divisor = 1193180/frequency; // Calculate the divisor
- outportb(0x43, 0x36); // Set our command byte 0x36
- outportb(0x40, divisor&0xFF); // Set low byte
- outportb(0x40, divisor>>8); // Set high byte
- ClockFrequency = frequency;
-}
-
-void i86_PitHandler(ISR_stack_regs *r)
-{
- ClockTicks++; // count tick
- if (ClockTicks % ClockFrequency == 0)
- _CLOCK_INC((TIME*)&_InternalClock); // update internal clock
-}
-
-unsigned int ClockSetTickCount(unsigned int i)
-{
- unsigned int r = ClockTicks;
- ClockTicks = i;
- return r;
-}
-
-unsigned int ClockGetTickCount()
-{
- return ClockTicks;
-}
-unsigned int PitGetFrequency()
-{
- return ClockFrequency;
-}
-
-void i86_PitInitialize(int freq)
-{
- PitSetFrequency(freq);
- ClockTicks = 0;
-
- i86_GetRTC((TIME*) &_InternalClock);
-
- PitInitialized = 1;
-}
-
-TIME ClockGetTime()
-{
- return _InternalClock;
-}
-
-unsigned char PitIsInitialized()
-{
- return PitInitialized;
-}
-
-
-inline unsigned char CmosRead (unsigned char address)
-{
- outportb(0x70, address); iowait();
- return inportb(0x71);
-}
-
-inline void CmosWrite (unsigned char address, unsigned char val)
-{
- outportb(0x70, address); iowait();
- outportb(0x71, val);
-}
-
-void i86_SetRTC (const TIME* time)
-{
- unsigned char BCD = ((CmosRead(0x0b)&4)==0) ? 1 : 0;
- unsigned char ampm = ((CmosRead(0x0b)&2)==0) ? 1 : 0;
-
- CmosWrite (0, (BCD) ? (time->second%10) | (time->second/10*16) : time->second); // Seconds
- CmosWrite (2, (BCD) ? (time->minute%10) | (time->minute/10*16) : time->minute); // Minutes
-
- if (ampm && time->hour > 12) // Hours
- CmosWrite (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
- CmosWrite (4, (BCD) ? 0x92 : 0x8C);
-
- else CmosWrite (4, (BCD) ? (time->hour%10) | (time->hour/10*16) : time->hour); // 24h / AM
-
- CmosWrite (6, (BCD) ? (time->weekday%10) | (time->weekday/10*16) : time->weekday); // Weekday
- CmosWrite (7, (BCD) ? (time->day%10) | (time->day/10*16) : time->day); // Day
- CmosWrite (8, (BCD) ? (time->month%10) | (time->month/10*16) : time->month); // Month
- CmosWrite (9, (BCD) ? (time->year%10) | (time->year/10*16) : time->year); // Year
- CmosWrite (0x32, (BCD) ? (time->century%10) | (time->century/10*16) : time->century); // Century
-}
-
-void i86_GetRTC(TIME* tim)
-{
- unsigned char BCD = ((CmosRead(0x0b)&4)==0) ? 1 : 0;
- unsigned char am_pm = ((CmosRead(0x0b)&2)==0) ? 1 : 0;
-
- tim->second = (BCD) ? (CmosRead(0x00)%16) + 10*(CmosRead(0x00)/16): CmosRead(0x00);
- tim->minute = (BCD) ? (CmosRead(0x02)%16) + 10*(CmosRead(0x02)/16): CmosRead(0x02);
-
- // Time is PM
- if (am_pm && CmosRead(0x04)&80) {
- tim->hour = (BCD) ? ((CmosRead(0x04)-0x80)%16) + 10*((CmosRead(0x04)-0x80)/16): CmosRead(0x04)-0x80;
- tim->hour += 12;
- }
- // 24Hour format, or AM
- else tim->hour = (BCD) ? (CmosRead(0x04)%16) + 10*(CmosRead(0x04)/16): CmosRead(0x04);
-
- tim->weekday = (BCD) ? (CmosRead(0x06)%16) + 10*(CmosRead(0x06)/16): CmosRead(0x06);
- tim->day = (BCD) ? (CmosRead(0x07)%16) + 10*(CmosRead(0x07)/16): CmosRead(0x07);
- tim->month = (BCD) ? (CmosRead(0x08)%16) + 10*(CmosRead(0x08)/16): CmosRead(0x08);
- tim->year = (BCD) ? (CmosRead(0x09)%16) + 10*(CmosRead(0x09)/16): CmosRead(0x09);
- tim->century = (BCD) ? (CmosRead(0x32)%16) + 10*(CmosRead(0x32)/16): CmosRead(0x32);
-}
\ No newline at end of file
diff --git a/SysCore/drivers/compile.bat b/SysCore/drivers/compile.bat
deleted file mode 100644
index 9f96b12..0000000
--- a/SysCore/drivers/compile.bat
+++ /dev/null
@@ -1,43 +0,0 @@
-@echo off
-
-set loader_name=loader
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-
-
-@echo ***************** CTA KERNEL *****************
-
-:KernelEntry
- @echo.
- @echo Building Kernel entry...
- @echo * Compiling kernel loader...
- %nasm_path%\nasm.exe -f aout -o ./objects/%loader_name%.o %loader_name%.asm
-
- @echo * Compiling kernel main...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./include -c -o ./objects/main.o main.c
-
-
-:KernelSTDLIB
- cd lib
- call compile.bat
- cd..
-
-:KernelMemoryManager
- cd memory
- call compile.bat
- cd..
-
-
-rem here go other sources:
-
-rem here go other sources ^
-
-:Finish
- cd objects
- @echo Linking...
- %djgpp_path%\ld -T link.ld
- @echo.
-
- echo Copying to floppy drive...
- copy KERNEL.BIN A:\KERNEL.CTA
- cd..
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/compile.bat b/SysCore/drivers/cpu/compile.bat
deleted file mode 100644
index 008276d..0000000
--- a/SysCore/drivers/cpu/compile.bat
+++ /dev/null
@@ -1,18 +0,0 @@
-@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:\mingw\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%/cpu.o cpu.c
-
-@echo off
-@echo .
-@echo Done!
-
-@pause
diff --git a/SysCore/drivers/cpu/cpu.c b/SysCore/drivers/cpu/cpu.c
deleted file mode 100644
index 6ed094f..0000000
--- a/SysCore/drivers/cpu/cpu.c
+++ /dev/null
@@ -1,40 +0,0 @@
-#include
-#include "cpu.h"
-#include "gdt/gdt.h"
-#include "idt/idt.h"
-#include "irq/irq.h"
-#include "isrs/isrs.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_CpuInitialize()
-{
- i86_GdtInstall();
- i86_IdtInstall();
- i86_IsrsInstall();
- i86_IrqInstall();
-}
-
-void i86_CpuShutdown()
-{
-
-}
-
-char* i86_CpuGetVendor()
-{
- unsigned unused;
- unsigned static arr[3];
-
- cpuid(0, unused, arr[0], arr[2], arr[1]);
-
- return (char*) arr;
-}
-
-_R32BIT i86_CpuID(unsigned function)
-{
- _R32BIT ret = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
-
- cpuid(function, ret.eax, ret.ebx, ret.ecx, ret.edx);
- return ret;
-}
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/cpu.h b/SysCore/drivers/cpu/cpu.h
deleted file mode 100644
index 3953c57..0000000
--- a/SysCore/drivers/cpu/cpu.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef _CPU_H_INCLUDED
-#define _CPU_H_INCLUDED
-
-#include
-#include
-#include "gdt/gdt.h"
-#include "idt/idt.h"
-#include "irq/irq.h"
-#include "irq/pic.h"
-#include "isrs/isrs.h"
-
-
-extern void i86_CpuInitialize ();
-extern void i86_CpuShutdown ();
-extern char* i86_CpuGetVendor ();
-
-#endif
diff --git a/SysCore/drivers/cpu/irq/irq.c b/SysCore/drivers/cpu/irq/irq.c
deleted file mode 100644
index ad502e3..0000000
--- a/SysCore/drivers/cpu/irq/irq.c
+++ /dev/null
@@ -1,99 +0,0 @@
-#include
-#include "pic.h"
-#include "irq.h"
-#include "../idt/idt.h"
-
-/* These are own ISRs that point to our special IRQ handler
-* instead of the regular 'fault_handler' function */
-extern void i86_irq0();
-extern void i86_irq1();
-extern void i86_irq2();
-extern void i86_irq3();
-extern void i86_irq4();
-extern void i86_irq5();
-extern void i86_irq6();
-extern void i86_irq7();
-extern void i86_irq8();
-extern void i86_irq9();
-extern void i86_irq10();
-extern void i86_irq11();
-extern void i86_irq12();
-extern void i86_irq13();
-extern void i86_irq14();
-extern void i86_irq15();
-
-/* This array is actually an array of function pointers. We use
-* this to handle custom IRQ handlers for a given IRQ */
-void *IrqRoutines[16] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-/* This installs a custom IRQ handler for the given IRQ */
-void i86_IrqInstallHandler (int irq, void (*handler)(ISR_stack_regs *r))
-{
- IrqRoutines[irq] = handler;
-}
-
-void i86_IrqUninstallHandler (int irq)
-{
- IrqRoutines[irq] = 0;
-}
-
-
-
-/* We first remap the interrupt controllers, and then we install
-* the appropriate ISRs to the correct entries in the IDT. This
-* is just like installing the exception handlers */
-void i86_IrqInstall()
-{
- i86_PicRemap(32,40);
-
- i86_IdtSetGate(32, (unsigned)i86_irq0, 0x08, 0x8E);
- i86_IdtSetGate(33, (unsigned)i86_irq1, 0x08, 0x8E);
- i86_IdtSetGate(34, (unsigned)i86_irq2, 0x08, 0x8E);
- i86_IdtSetGate(35, (unsigned)i86_irq3, 0x08, 0x8E);
- i86_IdtSetGate(36, (unsigned)i86_irq4, 0x08, 0x8E);
- i86_IdtSetGate(37, (unsigned)i86_irq5, 0x08, 0x8E);
- i86_IdtSetGate(38, (unsigned)i86_irq6, 0x08, 0x8E);
- i86_IdtSetGate(39, (unsigned)i86_irq7, 0x08, 0x8E);
- i86_IdtSetGate(40, (unsigned)i86_irq8, 0x08, 0x8E);
- i86_IdtSetGate(41, (unsigned)i86_irq9, 0x08, 0x8E);
- i86_IdtSetGate(42, (unsigned)i86_irq10, 0x08, 0x8E);
- i86_IdtSetGate(43, (unsigned)i86_irq11, 0x08, 0x8E);
- i86_IdtSetGate(44, (unsigned)i86_irq12, 0x08, 0x8E);
- i86_IdtSetGate(45, (unsigned)i86_irq13, 0x08, 0x8E);
- i86_IdtSetGate(46, (unsigned)i86_irq14, 0x08, 0x8E);
- i86_IdtSetGate(47, (unsigned)i86_irq15, 0x08, 0x8E);
-}
-
-/* Each of the IRQ ISRs point to this function, rather than
-* the 'fault_handler' in 'isrs.c'. The IRQ Controllers need
-* to be told when you are done servicing them, so you need
-* to send them an "End of Interrupt" command (0x20). There
-* are two 8259 chips: The first exists at 0x20, the second
-* exists at 0xA0. If the second controller (an IRQ from 8 to
-* 15) gets an interrupt, you need to acknowledge the
-* interrupt at BOTH controllers, otherwise, you only send
-* an EOI command to the first controller. If you don't send
-* an EOI, you won't raise any more IRQs */
-void i86_IrqHandler (ISR_stack_regs *r)
-{
- /* This is a blank function pointer */
- void (*handler)(ISR_stack_regs *r);
-
- /* Find out if we have a custom handler to run for this
- * IRQ, and then finally, run it */
- handler = IrqRoutines[r->int_no - 32];
- if (handler) handler(r);
-
- /* If the IDT entry that was invoked was greater than 40
- * (meaning IRQ8 - 15), then we need to send an EOI to
- * the slave controller */
- if (r->int_no >=40) outportb(0x0A, 0x20);
-
- /* In either case, we need to send an EOI to the master
- * interrupt controller too */
- outportb(0x20, 0x20);
-}
diff --git a/SysCore/drivers/cpu/irq/irq.h b/SysCore/drivers/cpu/irq/irq.h
deleted file mode 100644
index 77d3c33..0000000
--- a/SysCore/drivers/cpu/irq/irq.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __IRQ_H
-#define __IRQ_H
-
-#include
-
-extern void i86_IrqInstallHandler (int irq, void (*handler)(ISR_stack_regs *r));
-extern void i86_IrqUninstallHandler (int irq);
-extern void i86_IrqInstall();
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/irq/pic.h b/SysCore/drivers/cpu/irq/pic.h
deleted file mode 100644
index f6d9075..0000000
--- a/SysCore/drivers/cpu/irq/pic.h
+++ /dev/null
@@ -1,6 +0,0 @@
-#ifndef _PIC_H
-#define _PIC_H
-
-extern void i86_PicRemap(int pic1, int pic2);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/cpu/isrs/isrs.c b/SysCore/drivers/cpu/isrs/isrs.c
deleted file mode 100644
index 5ce59d6..0000000
--- a/SysCore/drivers/cpu/isrs/isrs.c
+++ /dev/null
@@ -1,115 +0,0 @@
-#include
-#include
-#include "isrs.h"
-#include "../idt/idt.h"
-
-// Assembly coded
-extern void i86_isr0();
-extern void i86_isr1();
-extern void i86_isr2();
-extern void i86_isr3();
-extern void i86_isr4();
-extern void i86_isr5();
-extern void i86_isr6();
-extern void i86_isr7();
-extern void i86_isr8();
-extern void i86_isr9();
-extern void i86_isr10();
-extern void i86_isr11();
-extern void i86_isr12();
-extern void i86_isr13();
-extern void i86_isr14();
-extern void i86_isr15();
-extern void i86_isr16();
-extern void i86_isr17();
-extern void i86_isr18();
-extern void i86_isr19();
-extern void i86_isr20();
-extern void i86_isr21();
-extern void i86_isr22();
-extern void i86_isr23();
-extern void i86_isr24();
-extern void i86_isr25();
-extern void i86_isr26();
-extern void i86_isr27();
-extern void i86_isr28();
-extern void i86_isr29();
-extern void i86_isr30();
-extern void i86_isr31();
-
-
-void* IdtFaultHandlers[32] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- };
-
-void i86_IsrsInstall()
-{
- i86_IdtSetGate(0, (unsigned)i86_isr0, 0x08, 0x8E);
- i86_IdtSetGate(1, (unsigned)i86_isr1, 0x08, 0x8E);
- i86_IdtSetGate(2, (unsigned)i86_isr2, 0x08, 0x8E);
- i86_IdtSetGate(3, (unsigned)i86_isr3, 0x08, 0x8E);
- i86_IdtSetGate(4, (unsigned)i86_isr4, 0x08, 0x8E);
- i86_IdtSetGate(5, (unsigned)i86_isr5, 0x08, 0x8E);
- i86_IdtSetGate(6, (unsigned)i86_isr6, 0x08, 0x8E);
- i86_IdtSetGate(7, (unsigned)i86_isr7, 0x08, 0x8E);
- i86_IdtSetGate(8, (unsigned)i86_isr8, 0x08, 0x8E);
- i86_IdtSetGate(9, (unsigned)i86_isr9, 0x08, 0x8E);
- i86_IdtSetGate(10, (unsigned)i86_isr10, 0x08, 0x8E);
- i86_IdtSetGate(11, (unsigned)i86_isr11, 0x08, 0x8E);
- i86_IdtSetGate(12, (unsigned)i86_isr12, 0x08, 0x8E);
- i86_IdtSetGate(13, (unsigned)i86_isr13, 0x08, 0x8E);
- i86_IdtSetGate(14, (unsigned)i86_isr14, 0x08, 0x8E);
- i86_IdtSetGate(15, (unsigned)i86_isr15, 0x08, 0x8E);
- i86_IdtSetGate(16, (unsigned)i86_isr16, 0x08, 0x8E);
- i86_IdtSetGate(17, (unsigned)i86_isr17, 0x08, 0x8E);
- i86_IdtSetGate(18, (unsigned)i86_isr18, 0x08, 0x8E);
- i86_IdtSetGate(19, (unsigned)i86_isr19, 0x08, 0x8E);
- i86_IdtSetGate(20, (unsigned)i86_isr20, 0x08, 0x8E);
- i86_IdtSetGate(21, (unsigned)i86_isr21, 0x08, 0x8E);
- i86_IdtSetGate(22, (unsigned)i86_isr22, 0x08, 0x8E);
- i86_IdtSetGate(23, (unsigned)i86_isr23, 0x08, 0x8E);
- i86_IdtSetGate(24, (unsigned)i86_isr24, 0x08, 0x8E);
- i86_IdtSetGate(25, (unsigned)i86_isr25, 0x08, 0x8E);
- i86_IdtSetGate(26, (unsigned)i86_isr26, 0x08, 0x8E);
- i86_IdtSetGate(27, (unsigned)i86_isr27, 0x08, 0x8E);
- i86_IdtSetGate(28, (unsigned)i86_isr28, 0x08, 0x8E);
- i86_IdtSetGate(29, (unsigned)i86_isr29, 0x08, 0x8E);
- i86_IdtSetGate(30, (unsigned)i86_isr30, 0x08, 0x8E);
- i86_IdtSetGate(31, (unsigned)i86_isr31, 0x08, 0x8E);
-}
-
-
-void i86_IsrsInstallHandler(int interr, void (*function)(ISR_stack_regs *r))
-{
- if (interr < 32) IdtFaultHandlers[interr] = function;
-}
-
-void i86_IsrsUninstallHandler(int interr)
-{
- if (interr < 32) IdtFaultHandlers[interr] = 0;
-}
-
-/* All of our Exception handling Interrupt Service Routines will
-* point to this function. This will tell us what exception has
-* happened! Right now, we simply halt the system by hitting an
-* endless loop. All ISRs disable interrupts while they are being
-* serviced as a 'locking' mechanism to prevent an IRQ from
-* happening and messing up kernel data structures */
-void i86_FaultHandler(ISR_stack_regs *r)
-{
- /* Is this a fault whose number is from 0 to 31? */
- if (r->int_no < 32)
- {
- void (*func)(ISR_stack_regs *r);
- func = IdtFaultHandlers[r->int_no];
-
- // Halt system if unhandled
- if (!func) {
- cprintf("%#0C*** %#0EFatal error: Unhandled interrupt (INT%u)", r->int_no);
- for(;;);
- }
-
- else (*func)(r);
- }
-}
diff --git a/SysCore/drivers/cpu/isrs/isrs.h b/SysCore/drivers/cpu/isrs/isrs.h
deleted file mode 100644
index 4dd2425..0000000
--- a/SysCore/drivers/cpu/isrs/isrs.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __ISRS_H_
-#define __ISRS_H_
-
-extern void i86_IsrsInstall();
-extern void i86_IsrsInstallHandler(int interr, void (*function)(ISR_stack_regs *r));
-extern void i86_IsrsUninstallHandler(int interr);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/drivers.c b/SysCore/drivers/drivers.c
deleted file mode 100644
index 8a93d14..0000000
--- a/SysCore/drivers/drivers.c
+++ /dev/null
@@ -1,55 +0,0 @@
-#include
-#include "cpu/cpu.h"
-#include "clock/clock.h"
-#include "floppy/floppy.h"
-#include
-//BSOD
-
-extern void _STOP_ERROR_SCREEN(ISR_stack_regs *);
-
-void DriversInstall()
-{
- // Initialize CPU stuff (GDT, IDT etc)
- i86_CpuInitialize();
-
- // Install default fault handler
- int i;
- for (i=0; i<32; i++)
- i86_IsrsInstallHandler(i, _STOP_ERROR_SCREEN);
-
-
- // Start installing keyboard
- i86_IrqInstallHandler(1, i86_KeyboardHandler);
- KeyboardInstallA();
-
- // Install PIT
- i86_PitInitialize(100);
- i86_IrqInstallHandler(0, i86_PitHandler);
-
- // Finish installing keyboard
- KeyboardInstallB();
-
- // Install floppy driver
- asm volatile ("sti");
- i86_IrqInstallHandler(6, i86_FloppyHandler);
- FloppyInstall();
-
-}
-
-void SystemShutDown()
-{
- i86_CpuShutdown();
- // TODO: real shutdown
-}
-
-void SystemReboot()
-{
- unsigned char good = 0x02;
- while ((good & 0x02) != 0)
- good = inportb(0x64);
- outportb(0x64, 0xFE);
-
- asm volatile ("cli");
- asm volatile ("hlt");
-}
-
diff --git a/SysCore/drivers/drivers.h b/SysCore/drivers/drivers.h
deleted file mode 100644
index 57840e0..0000000
--- a/SysCore/drivers/drivers.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#ifndef __DRIVERS__H__
-#define __DRIVERS__H__
-
-
-extern void DriversInstall();
-extern void SystemShutDown();
-extern void SystemReboot();
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/filesys/fat.c b/SysCore/drivers/filesys/fat.c
deleted file mode 100644
index fe82398..0000000
--- a/SysCore/drivers/filesys/fat.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include "../floppy/floppy.h"
-//#include "vfs.h"
-#include "fat.h"
-
-#include
-
-// Detect what FAT is used
-unsigned FATDetect(unsigned TotalClusters)
-{
- if (TotalClusters == 0) return 0;
- if (TotalClusters < 4085) return 12;
- if (TotalClusters < 65525) return 16;
- return 32;
-}
-
-
-
-/*FatMountInfo FloppyMount(int drive)
-{
- FatMountInfo a;
- FATBootSectorPointer fat = (FATBootSectorPointer)0x7e00;
- FloppyReadSector((unsigned*)fat, drive, 0);
-
- // Write mount info
- a.FATEntrySize = 8;
- a.FATOffset = 1;
- a.FATSize = (unsigned)fat->SectorsPerFAT;
- a.NumberOfRootEntries = (unsigned)fat->NumberOfDirectoryEntries;
- a.NumberOfSectors = (unsigned)(fat->NumberOfSectors == 0) ? (fat->NumberOfSectorsLong) : (fat->NumberOfSectors);
- a.RootOffset = (unsigned)(fat->NumberOfFATs)*a.FATSize + 1;
- a.RootSize = (a.NumberOfRootEntries * 32) / (unsigned)fat->BytesPerSector;
-
- return a;
-}*/
\ No newline at end of file
diff --git a/SysCore/drivers/filesys/fat.h b/SysCore/drivers/filesys/fat.h
deleted file mode 100644
index d84e318..0000000
--- a/SysCore/drivers/filesys/fat.h
+++ /dev/null
@@ -1,91 +0,0 @@
-#ifndef __FAT_H__
-#define __FAT_H__
-
-typedef struct {
- unsigned char Drive; //useless
- unsigned char FlagsNT;
- unsigned char Signature; // 0x28 or 0x29
- unsigned SerialNumber;
- char VolumeLabel[11];
- char SysIDString[8]; // unreliable
-} __attribute__((packed)) BPB_EXT_16;
-
-
-typedef struct {
- unsigned SectorsPerFAT;
- unsigned short Flags;
- unsigned short Version;
- unsigned ClusterOfRootDirectory;
- unsigned short ClusterOfFSInfo;
- unsigned short ClusterOfBackupBootSector;
- unsigned char Reserved[12]; // Should be 0 at format
- unsigned char Drive;
- unsigned char FlagsNT;
- unsigned char Signature; // 0x28 or 0x29
- unsigned SerialNumber;
- char VolumeLabel[11];
- char SysIDString[8]; // always FAT12
-
-} __attribute__((packed)) BPB_EXT_32;
-
-
-typedef struct {
- unsigned char _ignore[3];
-
- // Bios Parameter Block
- char OEMIdentify[8];
- unsigned short BytesPerSector;
- unsigned char SectorsPerCluster;
- unsigned short ReservedSectors;
- unsigned char NumberOfFATs;
- unsigned short NumberOfDirectoryEntries;
- unsigned short NumberOfSectors;
- unsigned char MediaDescriptorType;
- unsigned short SectorsPerFAT;
- unsigned short SectorsPerTrack;
- unsigned short HeadsPerCylinder;
- unsigned HiddenSectors;
- unsigned NumberOfSectorsLong;
-
- union {
- BPB_EXT_16 Ext16;
- BPB_EXT_32 Ext32;
- } Extended;
-
-} __attribute__((packed)) FATBootSector, *FATBootSectorPointer;
-
-
-typedef struct {
- unsigned NumberOfSectors;
- unsigned SizeOfSector;
- unsigned FatOffset;
- unsigned NumberOfRootEntries;
- unsigned RootOffset;
- unsigned SizeOfRoot;
- unsigned SizeOfFat;
- unsigned SizeOfFatEntry;
- unsigned SizeOfCluster;
- void (*ReadSector) (void* buffer, int lba);
-} FatMountInfo, *FatMountInfoPointer;
-
-
-typedef struct {
- char FileName[8];
- char Extension[3];
- unsigned char Atributes;
- unsigned char Reserved;
- unsigned char CreateTimeFine;
- unsigned short CreateTime;
- unsigned short CreateDate;
- unsigned short LastAccessedDate;
- unsigned short EAIndex;
- unsigned short LastModifiedTime;
- unsigned short LastModifiedDate;
- unsigned short FirstCluster;
- unsigned FileSize;
-} __attribute__((packed)) FatDirectoryEntry, *FatDirectoryEntryPointer;
-
-
-extern FatMountInfo FloppyMount(int drive);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/filesys/vfs.c b/SysCore/drivers/filesys/vfs.c
deleted file mode 100644
index 9009d38..0000000
--- a/SysCore/drivers/filesys/vfs.c
+++ /dev/null
@@ -1,98 +0,0 @@
-#include "vfs.h"
-#define MaxDevices 256
-
-#define ReturnInvalid() { File ret; ret.Type = FileTypeInvalid; return ret;}
-
-unsigned CurrentDevice = 0;
-unsigned DeviceCount = 0;
-
-FileSystemPointer _FileSystems[MaxDevices];
-
-File VFSOpenFile (const char* FileName)
-{
- unsigned Device = CurrentDevice;
-
- // No filename specified.
- if (!FileName) ReturnInvalid();
-
- // File length
- int len = strlen(FileName);
- // File name without drive
- char* Name = 0;
-
- // Check if relative or absolute path
- int i;
- for (i=0; i < len; i++)
- if (FileName[i] == ':') {
- Name = &FileName[i+1];
- FileName[i] = 0;
- len = i;
- }
-
- // If absolute path, find device
- if (Name != 0) {
- for (i=0; i < MaxDevices; i++)
- if (_FileSystems[i]) {
- if (strcmp(_FileSystems[i]->Name, FileName) == 0) Device = i;
- }
- }
- // Drive is nonexistant or current drive not mounted
- if (i==MaxDevices || !_FileSystems[Device]) ReturnInvalid();
-
- // Open file
- return _FileSystems[Device]->Open((Name) ? Name : FileName);
-}
-
-
-int VFSInstallFileSystem(FileSystemPointer fs)
-{
- // Sanity check
- if (!fs) return 0;
-
- // Verify device does not exist
- int i;
- for (i=0; i < DeviceCount; i++)
- if (_FileSystems[i])
- if (strcmp (fs->Name, _FileSystems[i]->Name) == 0) return 0;
-
- _FileSystems[DeviceCount] = fs; DeviceCount++;
-}
-
-void VFSUninstallFileSystem(FileSystemPointer fs)
-{
- if (!fs) return;
-
- int i;
- for (i=0; iName, fs) == 0){
- _FileSystems[i] = 0;
- return;
- }
-}
-
-void VFSReadFile (FilePointer f, unsigned char* buffer, unsigned len)
-{
- if (!f || !_FileSystems[f->Device]) return;
- _FileSystems[f->Device]->Read (f, buffer, len);
-}
-
-void VFSCloseFile (FilePointer f)
-{
- if (!f || !_FileSystems[f->Device]) return;
- _FileSystems[f->Device]->Close(f);
-}
-
diff --git a/SysCore/drivers/filesys/vfs.h b/SysCore/drivers/filesys/vfs.h
deleted file mode 100644
index 1a83b9f..0000000
--- a/SysCore/drivers/filesys/vfs.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/***** vfs.h *********************************************************
- * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
- * *
- * Virtual File System (VFS) Implementation *
- * ======================================== *
- * *
- ************************************************************ cta os */
-#ifndef __VFS__H___
-#define __VFS__H___
-
-#include
-
-typedef enum {
- FileTypeInvalid,
- FileTypeFile,
- FileTypeDirectory,
- FileTypeSymbolicLink
-} FileType;
-
-enum FileFlags {
- FileFlagReadOnly = 0x1,
- FileFlagHidden = 0x2,
- FileFlagSystem = 0x4,
- FileFlagVolumeID = 0x8,
- FileFlagDirectory = 0x10,
- FileFlagArchive = 0x20
-};
-
-
-typedef struct {
- char Name[256];
- FileType Type;
- unsigned Flags;
- unsigned Length;
- unsigned EndOfFile;
- unsigned ID;
- unsigned Position, CurrentCluster;
- unsigned Device;
- TIME Created;
- DATE LastAccessed;
- TIME LastModified;
-} File, *FilePointer;
-
-
-typedef struct {
- char Name[256];
-
- File (*Directory) (const char* DirectoryName);
- void (*Mount) ();
- void (*Read) (FilePointer, unsigned char*, unsigned);
- void (*Close) (FilePointer);
- FILE (*Open) (const char*);
-
-} FileSystem, *FileSystemPointer;
-
-
-#endif
diff --git a/SysCore/drivers/floppy/dma.c b/SysCore/drivers/floppy/dma.c
deleted file mode 100644
index 1afe8cd..0000000
--- a/SysCore/drivers/floppy/dma.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/***** 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 DMA0InputOutput {
- DMA0StatusRegister = 0x08,
- DMA0CommandRegister = 0x08,
- DMA0RequestRegister = 0x09,
- DMA0ChannelMaskRegister = 0x0a,
- DMA0ModeRegister = 0x0b,
- DMA0ClearByteFlipFlopRegister = 0x0c,
- DMA0TempRegister = 0x0d,
- DMA0MasterClearRegister = 0x0d,
- DMA0ClearMaskRegister = 0x0e,
- DMA0MaskRegister = 0x0f
-};
-
-enum DMA1InputOutput {
- DMA1StatusRegister = 0xd0,
- DMA1CommandRegister = 0xd0,
- DMA1RequestRegister = 0xd2,
- DMA1ChannelMaskRegister = 0xd4,
- DMA1ModeRegister = 0xd6,
- DMA1ClearByteFlipFlopRegister = 0xd8,
- DMA1InterRegister = 0xda,
- DMA1UnmaskAllRegister = 0xdc,
- DMA1MaskRegister = 0xde
-};
-
-void DMASetAddress(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 DMASetCount (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 DMASetExternalPageRegisters (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 DMAMaskChannel (unsigned char channel)
-{
- if (channel <= 4) outportb (DMA0ChannelMaskRegister, (1<< (channel -1)));
- else outportb (DMA1ChannelMaskRegister, (1<< (channel -5)));
-}
-
-
-void DMAUnmaskChannel (unsigned char channel)
-{
- if (channel <= 4) outportb (DMA0ChannelMaskRegister, channel);
- else outportb (DMA1ChannelMaskRegister, channel);
-}
-
-
-void DMAUnmaskAll()
-{
- outportb (DMA1UnmaskAllRegister, 0xff);
-}
-
-
-void DMAResetFlipFlop (unsigned char dma)
-{
- switch (dma) {
- case 0: outportb (DMA0ClearByteFlipFlopRegister, 0xff);
- case 1: outportb (DMA1ClearByteFlipFlopRegister, 0xff);
- }
-}
-
-void DMAReset ()
-{
- outportb (DMA0TempRegister, 0xff);
-}
-
-
-void DMASetMode(unsigned char channel, unsigned char mode)
-{
- unsigned char dma = (channel < 4) ? 0:1;
- unsigned char chan = (dma == 0) ? channel : channel-4;
-
- DMAMaskChannel (channel);
- outportb ((channel < 4) ? DMA0ModeRegister : DMA1ModeRegister, chan | mode);
- DMAUnmaskAll ();
-}
-
-
-void DMASetRead (unsigned char channel)
-{
- DMASetMode (channel, DMAModeReadTransfer | DMAModeTransferSingle);
-}
-
-
-void DMASetWrite (unsigned char channel)
-{
- DMASetMode (channel, DMAModeWriteTransfer | DMAModeTransferSingle);
-}
diff --git a/SysCore/drivers/floppy/dma.h b/SysCore/drivers/floppy/dma.h
deleted file mode 100644
index a687e16..0000000
--- a/SysCore/drivers/floppy/dma.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/***** 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 {
- DMAModeMaskSelect = 3,
-
- DMAModeMaskTra = 0xc,
- DMAModeSelfTest = 0,
- DMAModeReadTransfer = 4,
- DMAModeWriteTransfer = 8,
-
- DMAModeMaskAuto = 0x10,
- DMAModeMaskIdec = 0x20,
-
- DMAModeMask = 0xc0,
- DMAModeTransferOnDemand = 0,
- DMAModeTransferSingle = 0x40,
- DMAModeTransferBlock = 0x80,
- DMAModeTransferCascade = 0xC0
-};
-
-extern void DMASetAddress(unsigned short channel, unsigned char low, unsigned char high);
-extern void DMASetCount (unsigned short channel, unsigned char low, unsigned char high);
-extern void DMASetExternalPageRegisters (unsigned char channel, unsigned char val);
-extern void DMAMaskChannel (unsigned char channel);
-extern void DMAUnmaskChannel (unsigned char channel);
-extern void DMAUnmaskAll();
-extern void DMAResetFlipFlop (unsigned char dma);
-extern void DMAReset ();
-extern void DMASetMode(unsigned char channel, unsigned char mode);
-extern void DMASetRead (unsigned char channel);
-extern void DMASetWrite (unsigned char channel);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/floppy/floppy.c b/SysCore/drivers/floppy/floppy.c
deleted file mode 100644
index ff3b499..0000000
--- a/SysCore/drivers/floppy/floppy.c
+++ /dev/null
@@ -1,494 +0,0 @@
-/***** floppy.c ******************************************************
- * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
- * *
- * Floppy Drive I/O Routines *
- * ========================= *
- * *
- ************************************************************ cta os */
-#include
-#include
-#include
-#include "dma.h"
-#include "storage.h"
-
-unsigned char CmosReadFloppyData ()
-{
- outportb (0x70, 0x10);
- return inportb(0x71);
-}
-
-unsigned char FloppyDrivesInstalled;
-volatile unsigned char FloppyNewInterrupt;
-
-
-typedef struct {
- unsigned char Type;
- unsigned Size;
- unsigned char SectorsPerTrack;
- unsigned char Heads;
- unsigned char Tracks;
- unsigned char DataRate;
- unsigned char StepRateTime;
- unsigned char HeadLoadTime;
- unsigned char HeadUnloadTime;
- unsigned char Gap3;
- unsigned char Gap3Format;
-} FloppyType;
-
-FloppyType fd[2];
-
-void FloppyReset();
-enum FloppyRegisters {
- FloppyRegDOR = 0x3f2,
- FloppyRegMSR = 0x3f4,
- FloppyRegFIFO = 0x3f5,
- FloppyRegCTRL = 0x3f7
-};
-
-enum FloppyCommands {
- FloppyCommandReadTrack = 2,
- FloppyCommandSpecify = 3,
- FloppyCommandCheckStatus = 4,
- FloppyCommandWriteSector = 5,
- FloppyCommandReadSector = 6,
- FloppyCommandCalibrate = 7,
- FloppyCommandCheckInt = 8,
- FloppyCommandFormatTrack = 0xd,
- FloppyCommandSeek = 0xf,
-
- FloppyCommandExtSkip = 0x20,
- FloppyCommandExtDensity = 0x40,
- FloppyCommandExtMultiTrack = 0x80
-};
-
-// Initialize DMA
-unsigned char FloppyInitializeDMA(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;
-
- DMAReset();
- DMAMaskChannel(2); // Mask channel 2
- DMAResetFlipFlop(1); // FlipFlop reset on DMA1
-
- DMASetAddress(2, a.byt[0], a.byt[1]); // Buffer address
- DMAResetFlipFlop(1); // FlipFlop reset on DMA2
-
- DMASetCount(2, c.byt[0], c.byt[1]); // Set count
- DMASetRead(2);
- DMAUnmaskAll();
-
- return 1;
-}
-
-
-
-
-inline void FloppyDisableController() {
- outportb (FloppyRegDOR, 0);
-}
-
-inline void FloppyEnableController() {
- outportb (FloppyRegDOR, 4 | 8);
-}
-
-
-inline unsigned char FloppySendCommand (unsigned char command)
-{
- int i;
- for (i = 0; i < 750; i++)
- if (inportb(FloppyRegMSR) & 128) {
- outportb(FloppyRegFIFO, command); return 1;
- }
- return 0;
-}
-
-
-inline unsigned char FloppyReadData ()
-{
- int i;
- for (i = 0; i < 750; i++)
- if (inportb(FloppyRegMSR) & 0x80)
- return inportb(FloppyRegFIFO);
- return 0;
-}
-
-
-inline void FloppyCheckInt(unsigned* st0, unsigned* cyl)
-{
- int t;
- for (t=3; t>=0; t--) {
- if (!FloppySendCommand(0x8)) FloppyReset();
- else break;
- }
- for (t=50; !(inportb(FloppyRegMSR) & 0x80) && t>0; --t);
-
- *st0 = FloppyReadData();
- *cyl = FloppyReadData();
-}
-
-
-inline unsigned char FloppyWaitIRQ()
-{
- unsigned tick = ClockGetTickCount();
- unsigned freq = PitGetFrequency();
- tick = tick + (freq * 3); // Wait 3 seconds
-
- while (FloppyNewInterrupt==0)
- if (tick <= ClockGetTickCount()) return 0; // timeout
-
- FloppyNewInterrupt = 0;
- return 1;
-}
-
-
-void FloppyMotor (unsigned char drive, unsigned char on)
-{
- if (drive >= FloppyDrivesInstalled) return;
-
- // Read DOR register
- unsigned char dor = inportb(FloppyRegDOR);
-
- // Un/set selected drive motor
- if (on) dor |= 1 << (4+drive);
- else dor &= ~(1 << (4+drive));
-
- // Write DOR
- outportb (FloppyRegDOR, dor);
-
- // Wait a fifth of a second for motor to turn on
- unsigned temp = ClockGetTickCount();
- unsigned freq = PitGetFrequency();
- while (temp + (freq/5) > ClockGetTickCount());
-}
-
-
-void i86_FloppyHandler(ISR_stack_regs *r)
-{
- FloppyNewInterrupt = 1;
-}
-
-
-void FloppyDriveData (unsigned char drv, unsigned char dma)
-{
- unsigned data = 0;
- if (drv >= FloppyDrivesInstalled) return;
-
- outportb(FloppyRegCTRL, fd[drv].DataRate);
-
- FloppySendCommand (0x3);
-
- data = ((fd[drv].StepRateTime & 0xf) << 4) | (fd[drv].HeadUnloadTime & 0xf);
- FloppySendCommand (data);
-
- data = (fd[drv].HeadLoadTime <<1 ) | (dma) ? 1 : 0;
- FloppySendCommand (data);
-}
-
-
-inline void FloppySelect(unsigned char drive)
-{
- if (drive >= FloppyDrivesInstalled) return;
-
- unsigned char dor = inportb(FloppyRegDOR) & 0xf0;
-
- // Send mechanical drive data
- FloppyDriveData(drive, 1);
-
- // Select drive in DOR register
- outportb (FloppyRegDOR, dor | 4 | 8 | drive);
-
-}
-
-
-unsigned char FloppyCalibrate(unsigned drive)
-{
- unsigned st0, cyl;
-
- if (drive >= FloppyDrivesInstalled) return 0;
-
- FloppyMotor (drive, 1);
-
- int i;
- for (i = 0; i < 15; i++) {
- FloppyNewInterrupt = 0;
- FloppySendCommand(FloppyCommandCalibrate);
- FloppySendCommand(drive);
- FloppyWaitIRQ();
- FloppyCheckInt(&st0, &cyl);
-
- if (!cyl) {
- FloppyMotor(drive, 0);
- return 1;
- }
- }
- FloppyMotor(drive, 0);
- return 0;
-}
-
-
-void FloppyReset()
-{
- unsigned st0, cyl;
-
- FloppyNewInterrupt = 0;
- FloppyDisableController();
- FloppyEnableController();
- FloppyWaitIRQ();
-
- int i;
- for (i = 0; i < 4; i++)
- FloppyCheckInt(&st0, &cyl);
-
- unsigned char drive;
- for (drive = 0; drive < FloppyDrivesInstalled; drive++) {
- FloppyDriveData(drive, 1);
- FloppyCalibrate(drive);
- }
-}
-
-
-unsigned FloppyReadSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector)
-{
- int t, fail;
- for (t=3; t>=0; t--) {
- fail = 0;
- FloppySelect (drive);
- FloppyInitializeDMA((unsigned char*) where, 512);
- DMASetRead(2);
-
- FloppyNewInterrupt = 0;
-
- fail += 1-FloppySendCommand(0x06 | 0x80 | 0x40 );
- fail += 1-FloppySendCommand(head<<2 | drive);
- fail += 1-FloppySendCommand(track);
- fail += 1-FloppySendCommand(head);
- fail += 1-FloppySendCommand(sector);
- fail += 1-FloppySendCommand(2);
- fail += 1-FloppySendCommand( ((sector+1) >= fd[drive].SectorsPerTrack) ? fd[drive].SectorsPerTrack : sector+1);
- fail += 1-FloppySendCommand(fd[drive].Gap3);
- fail += 1-FloppySendCommand(0xff);
-
- if (fail) {
- FloppyReset(); continue;
- }
-
- FloppyWaitIRQ();
- while (!(inportb(FloppyRegMSR) & 0x80));
-
- int i; unsigned ccc=0;
-
- for (i = 0; i < 7; i++) {
- if (i<3) ccc |= FloppyReadData() << (i*4);
- else FloppyReadData();
- }
-
- return ccc;
- }
- return 0xFFFFFFFF;
-}
-
-
-unsigned FloppyWriteSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector)
-{
- int t, fail;
- for (t=3; t>=0; t--) {
- fail = 0;
- FloppySelect (drive);
- FloppyInitializeDMA((unsigned char*) where, 512);
- DMASetWrite(2);
-
- FloppyNewInterrupt = 0;
-
- fail += 1-FloppySendCommand(0x05 | 0x80 | 0x40 );
- fail += 1-FloppySendCommand(head<<2 | drive);
- fail += 1-FloppySendCommand(track);
- fail += 1-FloppySendCommand(head);
- fail += 1-FloppySendCommand(sector);
- fail += 1-FloppySendCommand(2);
- fail += 1-FloppySendCommand( ((sector+1) >= fd[drive].SectorsPerTrack) ? fd[drive].SectorsPerTrack : sector+1);
- fail += 1-FloppySendCommand(fd[drive].Gap3);
- fail += 1-FloppySendCommand(0xff);
-
- if (fail) {
- FloppyReset(); continue;
- }
-
- FloppyWaitIRQ();
-
- int i; unsigned ccc=0;
- for (i = 0; i < 7; i++)
- if (i<3) ccc |= FloppyReadData() << (i*4);
- else FloppyReadData();
-
- return ccc;
- }
- return 0xFFFFFFFF;
-}
-
-unsigned char FloppySeek (unsigned drive, unsigned cyl, unsigned head)
-{
- unsigned st0, cyl0;
-
- if (drive >= FloppyDrivesInstalled) return 0;
-
- FloppySelect (drive);
-
- int i;
- for (i = 0; i < 20; i++) {
- FloppyNewInterrupt = 0;
- FloppySendCommand (0xF);
- FloppySendCommand ( (head) << 2 | drive);
- FloppySendCommand (cyl);
-
- FloppyWaitIRQ();
- FloppyCheckInt(&st0, &cyl0);
-
- if (cyl0 == cyl) return 1;
- }
- return 0;
-}
-
-
-inline void FloppyLBAtoCHS (int lba, unsigned char drive, unsigned char *head, unsigned char *track, unsigned char *sectors)
-{
- *head = (lba % (fd[drive].SectorsPerTrack * 2)) / fd[drive].SectorsPerTrack;
- *track = lba / (fd[drive].SectorsPerTrack * 2);
- *sectors = lba % fd[drive].SectorsPerTrack + 1;
-}
-
-
-/*const char* types[] = {
- "Nonexistant", "5.25\", unsupported.", "5.25\", unsupported.",
- "3.5\", 720kb", "3.5\", 1.44mb", "3.5\", 2.88 mb"};*/
-
-void FloppyInstall()
-{
- unsigned char temp = CmosReadFloppyData();
- 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) FloppyDrivesInstalled++; // 5.25" drives unsupported
- if (fd[i].Type == 3) { // 720 kb, DD
- fd[i].DataRate = 2; // speed = 250 kbps
- fd[i].StepRateTime = 12; // 16 - (ms * 250000 / 500000), ms = 8
- fd[i].HeadLoadTime = 7;
- fd[i].HeadUnloadTime = 7;
- fd[i].SectorsPerTrack = 9;
- fd[i].Size = 1440;
- fd[i].Gap3 = 0x2A;
- fd[i].Gap3Format = 0x50;
- fd[i].Heads = 2;
- fd[i].Tracks = 80;
- }
- else if (fd[i].Type == 4) { // 1.44 MB, HD
- fd[i].DataRate = 0; // speed = 500 kbps
- fd[i].StepRateTime = 8;
- fd[i].HeadLoadTime = 15;
- fd[i].HeadUnloadTime = 15;
- fd[i].SectorsPerTrack = 18;
- fd[i].Size = 2880;
- fd[i].Gap3 = 0x1B;
- fd[i].Gap3Format = 0x6C;
- fd[i].Heads = 2;
- fd[i].Tracks = 80;
- }
- else if (fd[i].Type == 5) { // 2.88 MB, ED
- fd[i].DataRate = 3; // speed = 1000 kbps;
- fd[i].StepRateTime = 0;
- fd[i].HeadLoadTime = 30;
- fd[i].HeadUnloadTime = 30;
- fd[i].SectorsPerTrack = 36;
- fd[i].Size = 5760;
- fd[i].Gap3 = 0x1B;
- fd[i].Gap3Format = 0x54;
- fd[i].Heads = 2;
- fd[i].Tracks = 80;
- }
- }
- if (FloppyDrivesInstalled == 0) return; // No drives to set
-
-
- FloppyReset();
-}
-
-
-unsigned char FloppyIsDriverEnabled()
-{
- return FloppyDrivesInstalled;
-}
-
-unsigned* FloppyReadSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count)
-{
- if (drive >= FloppyDrivesInstalled || !where) return 0;
-
- unsigned head=0, track=0, sector=1, i, addr = (unsigned)where;
-
- // start motor, seek to track
- FloppyMotor(drive, 1);
-
- // read count sectors
- for (i=0; i= FloppyDrivesInstalled || !where) return 0;
-
- unsigned head=0, track=0, sector=1, i, addr = (unsigned)where;
-
- // start motor, seek to track
- FloppyMotor(drive, 1);
-
- // read count sectors
- for (i=0; i
-
-extern unsigned char FloppyInitializeDMA(unsigned char* buffer, unsigned length);
-extern void FloppyMotor (unsigned char drive, unsigned char on);
-extern void i86_FloppyHandler(ISR_stack_regs *r);
-extern void FloppyDriveData (unsigned char drv, unsigned char dma);
-extern unsigned char FloppyCalibrate(unsigned drive);
-extern void FloppyReset();
-
-extern unsigned char FloppySeek (unsigned drive, unsigned cyl, unsigned head);
-extern void FloppyInstall();
-extern unsigned char FloppyIsDriverEnabled();
-
-// Read/Write routines
-extern unsigned* FloppyReadSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
-extern unsigned* FloppyWriteSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
-
-extern void FloppyReadSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);
-extern void FloppyWritedSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);
\ No newline at end of file
diff --git a/SysCore/drivers/floppy/storage.h b/SysCore/drivers/floppy/storage.h
deleted file mode 100644
index f6d4ec7..0000000
--- a/SysCore/drivers/floppy/storage.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __STORAGE__H__
-#define __STORAGE__H__
-
-/**Structure used by the file system drivers.\n
- \Warning: the driver that provides the Read/Write routines must
- include conversions for partitions on hard drives.*/
-typedef struct {
- unsigned NumberOfSectors;
- unsigned SizeOfSector;
- void (*ReadSectors) (void* buffer, int startlba, int endlba);
- void (*WriteSectors) (void* buffer, int startlba, int endlba);
-} StorageDeviceInterface, *StorageDeviceInterfacePointer;
-
-#endif
\ No newline at end of file
diff --git a/SysCore/drivers/keyboard/compile.bat b/SysCore/drivers/keyboard/compile.bat
deleted file mode 100644
index b100048..0000000
--- a/SysCore/drivers/keyboard/compile.bat
+++ /dev/null
@@ -1,16 +0,0 @@
-@echo off
-
-rem NASM and DJGPP executable paths:
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\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%/drivers/keyboard.o keyboard.c
-
-@echo off
-@echo .
-@echo Done!
-
-@pause
diff --git a/SysCore/drivers/keyboard/key_list.txt b/SysCore/drivers/keyboard/key_list.txt
deleted file mode 100644
index 5ff143e..0000000
--- a/SysCore/drivers/keyboard/key_list.txt
+++ /dev/null
@@ -1,135 +0,0 @@
-*0x00 Pause/Break
-0x01 F9
-0x02 F7
-0x03 F5
-0x04 F3
-0x05 F1
-0x06 F2
-0x07 F12
-0x08 Print Screen
-0x09 F10
-0x0A F8
-0x0B F6
-0x0C F4
-0x0D Tab
-0x0E `~
-0x0F
-
-0x10
-0x11
-0x12
-0x13
-0x14
-0x15 Q
-0x16 1!
-0x17
-0x18
-0x19
-0x1A Z
-0x1B S
-0x1C A
-0x1D W
-0x1E 2@
-0x1F LeftWin
-
-0x20
-0x21 C
-0x22 X
-0x23 D
-0x24 E
-0x25 4$
-0x26 3#
-0x27 RightWin
-0x28
-0x29 Space
-0x2A V
-0x2B F
-0x2C T
-0x2D R
-0x2E 5%
-0x2F Menu
-
-0x30
-0x31 N
-0x32 B
-0x33 H
-0x34 G
-0x35 Y
-0x36 6^
-0x37
-0x38
-0x39
-0x3A M
-0x3B J
-0x3C U
-0x3D 7&
-0x3E 8*
-0x3F
-
-0x40
-0x41 ,<
-0x42 K
-0x43 I
-0x44 O
-0x45 0)
-0x46 9(
-0x47
-0x48
-0x49 .>
-0x4A /?
-0x4B L
-0x4C ;:
-0x4D P
-0x4E -_
-0x4F
-
-0x50
-0x51
-0x52 '"
-0x53
-0x54 [{
-0x55 =+
-0x56
-0x57
-0x58
-0x59 Numpad Enter
-0x5A Enter
-0x5B ]}
-0x5C
-0x5D \|
-0x5E End
-0x5F Left
-
-0x60 Home
-0x61 Insert
-0x62 Delete
-0x63 Down
-0x64 Right
-0x65 Up
-0x66 Backspace
-0x67 PageDown
-0x68 PageUp
-0x69 Numpad 1 (end)
-0x6A Numpad /
-0x6B Numpad 4 (left)
-0x6C Numpad 7 (Home)
-0x6D
-0x6E
-0x6F
-
-0x70 Numpad 0 (insert)
-0x71 Numpad . (del)
-0x72 Numpad 2 (down)
-0x73 Numpad 5
-0x74 Numpad 6 (right)
-0x75 Numpad 8 (up)
-0x76 Esc
-0x77
-0x78 F11
-0x79 Numpad +
-0x7A Numpad 3 (pgdwn)
-0x7B Numpad -
-0x7C Numpad *
-0x7D Numpad 9 (pgup)
-0x7E
-0x7F
\ No newline at end of file
diff --git a/SysCore/drivers/keyboard/keyboard.c b/SysCore/drivers/keyboard/keyboard.c
deleted file mode 100644
index e753f9e..0000000
--- a/SysCore/drivers/keyboard/keyboard.c
+++ /dev/null
@@ -1,306 +0,0 @@
-#include
-#include
-
-const char KeyMap[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '`', 0,
- 0, 0, 0, 0, 0, 'q', '1', 0, 0, 0, 'z', 's', 'a', 'w', '2', 0,
- 0, 'c', 'x', 'd', 'e', '4', '3', 0, 0, ' ', 'v', 'f', 't', 'r', '5', 0,
- 0, 'n', 'b', 'h', 'g', 'y', '6', 0, 0, 0, 'm', 'j', 'u', '7', '8', 0,
- 0, ',', 'k', 'i', 'o', '0', '9', 0, 0, '.', '/', 'l', ';', 'p', '-', 0,
- 0, 0, '\'', 0, '[', '=', 0, 0, 0, '\n', '\n', ']', 0, '\\', 0, 0,
- 0, 0, 0x7F, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', 0, 0, 0,
- '0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
- };
-
-const char KeyMapShift[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '\t', '~', 0,
- 0, 0, 0, 0, 0, 'Q', '!', 0, 0, 0, 'Z', 'S', 'A', 'W', '@', 0,
- 0, 'C', 'X', 'D', 'E', '$', '#', 0, 0, ' ', 'V', 'F', 'T', 'R', '%', 0,
- 0, 'N', 'B', 'H', 'G', 'Y', '^', 0, 0, 0, 'M', 'J', 'U', '&', '*', 0,
- 0, '<', 'K', 'I', 'O', ')', '(', 0, 0, '>', '?', 'L', ':', 'P', '_', 0,
- 0, 0, '\"', 0, '{', '+', 0, 0, 0, '\n', '\n', '}', 0, '|', 0, 0,
- 0, 0, 0x7F, 0, 0, 0, '\b', 0, 0, '1', '/', '4', '7', 0, 0, 0,
- '0', '.', '2', '5', '6', '8', 0, 0, 0, '+', '3', '-', '*', '9', 0, 0
- };
-
-volatile unsigned char KeyArray[16];
-volatile unsigned char KeyboardNewData;
-volatile unsigned char KeyModifierStatus;
-volatile unsigned char KeyScancodePrefix;
-volatile unsigned char KeyLightsStatus;
-unsigned char KeyboardScancodeSet;
-
-
-void KeyboardSetKey(unsigned char scancode, unsigned char val)
-{
- unsigned char pos = scancode/8;
- unsigned char offset = scancode%8;
-
- if (val) {
- KeyArray[pos] |= 1<3 || delay>31) return;
-
- unsigned char out = rate<<5 | delay;
- while ((inportb(0x64)&2) != 0);
- outportb(0x60, 0xF3);
- while ((inportb(0x64)&2) != 0);
- outportb(0x60, out);
-}
-
-
-/***************************************
- * Set keyboard LEDs *
- ***************************************
- +-----------+-------+-------+--------+
- | Bits 7-3 | Bit 2 | Bit 1 | Bit 0 |
- | 0 | Caps | Num | Scroll |
- |(reserved) | lock | lock | lock |
- +-----------+-------+-------+--------+
- ***************************************/
-void KeyboardSetLEDs(unsigned char status)
-{
- while ((inportb (0x64)&2)!=0);
- outportb (0x60, 0xED);
-
- while ((inportb (0x64)&2)!=0);
- outportb (0x60, status);
-}
-
-/***************************************
- * Set scancode set *
- ***************************************
- 0 Get current scancode set
- 1 Set to scancode set 1
- 2 Set to scancode set 2
- 3 Set to scancode set 3
- ***************************************/
-void KeyboardSetScancodeSet(unsigned char set)
-{
- if (set>3) return;
-
- while ((inportb (0x64)&2)!=0);
- outportb (0x60, 0xF0);
-
- while ((inportb (0x64)&2)!=0);
- outportb (0x60, set);
-
- KeyboardScancodeSet = set;
-}
-
-/*unsigned char i86_kb_get_scancodeset() {
- return KeyboardScancodeSet;
-}*/
-
-void KeyboardWaitInput()
-{
- int fail_safe=200000;
- while ((inportb(0x64)&2)!=0 && fail_safe>0) fail_safe--;
-}
-
-void KeyboardWaitOutput()
-{
- int fail_safe=200000;
- while ((inportb(0x64)&1)==0 && fail_safe>0) fail_safe--;
-}
-
-
-void KeyboardInstallA()
-{
- KeyboardWaitInput(); outportb(0x60, 0xFF); // Reset kb
-
- // Initialize variables
- KeyboardNewData = 0;
- KeyModifierStatus = 0;
- KeyScancodePrefix = 0;
- KeyLightsStatus = 0;
- KeyboardScancodeSet = 0;
-
- memset((void*)KeyArray, 0, 16);
-}
-
-
-void KeyboardInstallB()
-{
- // Wait for BAT test results
- unsigned char temp;
- do temp = inportb(0x60);
- while (temp!=0xAA && temp!=0xFC);
-
- // Error
- if (temp == 0xFC) return;
-
- // Set new repeat rate
- KeyboardSetRepeatRate(1, 11);
-
- // Set scancode set 2
- KeyboardSetScancodeSet(2); // Set new scancode set
-
- KeyboardWaitInput();
- 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
- KeyboardWaitInput(); outportb(0x64, 0x60); // Function to write cmd unsigned char
- KeyboardWaitInput(); outportb(0x60, temp); // Send it
-}
diff --git a/SysCore/drivers/keyboard/keyboard.deprecated.h b/SysCore/drivers/keyboard/keyboard.deprecated.h
deleted file mode 100644
index 261e9fb..0000000
--- a/SysCore/drivers/keyboard/keyboard.deprecated.h
+++ /dev/null
@@ -1,135 +0,0 @@
-
-#define KB_KEY_LSHIFT 0x81 // 1000 0001
-#define KB_KEY_RSHIFT 0X82 // 1000 0010
-#define KB_KEY_LALT 0X84 // 1000 0100
-#define KB_KEY_RALT 0x88 // 1000 1000
-#define KB_KEY_LCTRL 0x90 // 1001 0000
-#define KB_KEY_RCTRL 0xA0 // 1010 0000
-#define KB_KEY_FSHIFT 0xC0 // 1100 0000
-extern volatile unsigned char KeyModifierStatus;
-
-#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 unsigned char from pause/break
-extern volatile unsigned char KeyScancodePrefix;
-
-#define KB_KEY_SCROLL 0xF1 // 1111 0001
-#define KB_KEY_NUM 0xF2 // 1111 0010
-#define KB_KEY_CAPS 0xF4 // 1111 0100
-extern volatile unsigned char KeyLightsStatus;
-
-extern unsigned char KeyboardScancodeSet;
-
-enum KeyboardKeys {
- KeyboardKeyPAUSE = 0x00,
- KeyboardKeyF9 = 0x01,
- KeyboardKeyF7 = 0x02,
- KeyboardKeyF5 = 0X03,
- KeyboardKeyF3 = 0x04,
- KeyboardKeyF1 = 0x05,
- KeyboardKeyF2 = 0x06,
- KeyboardKeyF12 = 0x07,
- KeyboardKeyPRINTSCRN = 0x08,
- KeyboardKeyF10 = 0x09,
- KeyboardKeyF8 = 0x0A,
- KeyboardKeyF6 = 0x0B,
- KeyboardKeyF4 = 0x0C,
- KeyboardKeyTAB = 0x0D,
- KeyboardKeyTILDA = 0x0E,
- KeyboardKeyQ = 0x15,
- KeyboardKey1 = 0x16,
- KeyboardKeyZ = 0x1A,
- KeyboardKeyS = 0x1B,
- KeyboardKeyA = 0x1C,
- KeyboardKeyW = 0x1D,
- KeyboardKey2 = 0x1E,
- KeyboardKeyLWIN = 0x1F,
- KeyboardKeyC = 0x21,
- KeyboardKeyX = 0x22,
- KeyboardKeyD = 0x23,
- KeyboardKeyE = 0x24,
- KeyboardKey4 = 0x25,
- KeyboardKey3 = 0x26,
- KeyboardKeyRWIN = 0x27,
- KeyboardKeySPACE = 0x29,
- KeyboardKeyV = 0x2A,
- KeyboardKeyF = 0x2B,
- KeyboardKeyT = 0x2C,
- KeyboardKeyR = 0x2D,
- KeyboardKey5 = 0x2E,
- KeyboardKeyMENU = 0x2F,
- KeyboardKeyN = 0x31,
- KeyboardKeyB = 0x32,
- KeyboardKeyH = 0x33,
- KeyboardKeyG = 0x34,
- KeyboardKeyY = 0x35,
- KeyboardKey6 = 0x36,
- KeyboardKeyM = 0x3A,
- KeyboardKeyJ = 0x3B,
- KeyboardKeyU = 0x3C,
- KeyboardKey7 = 0x3D,
- KeyboardKey8 = 0x3E,
- KeyboardKeyCOMMA = 0x41,
- KeyboardKeyK = 0x42,
- KeyboardKeyI = 0x43,
- KeyboardKeyO = 0x44,
- KeyboardKey0 = 0x45,
- KeyboardKey9 = 0x46,
- KeyboardKeyPERIOD = 0x49,
- KeyboardKeySLASH = 0x4A,
- KeyboardKeyL = 0x4B,
- KeyboardKeySEMICOLON = 0x4C,
- KeyboardKeyP = 0x4D,
- KeyboardKeyDASH = 0x4E,
- KeyboardKeyAPOSTROPHE = 0x52,
- KeyboardKeyLBRACKET = 0x54,
- KeyboardKeyEQUAL = 0x55,
- KeyboardKeyNUMPAD_ENTER = 0x59,
- KeyboardKeyENTER = 0x5A,
- KeyboardKeyRBRACKET = 0x5B,
- KeyboardKeyBACKSLASH = 0x5D,
- KeyboardKeyEND = 0x5E,
- KeyboardKeyLEFT = 0x5F,
- KeyboardKeyHOME = 0x60,
- KeyboardKeyINSERT = 0x61,
- KeyboardKeyDELETE = 0x62,
- KeyboardKeyDOWN = 0x63,
- KeyboardKeyRIGHT = 0x64,
- KeyboardKeyUP = 0x65,
- KeyboardKeyBACKSPACE = 0x66,
- KeyboardKeyPGDOWN = 0x67,
- KeyboardKeyPGUP = 0x68,
- KeyboardKeyNUMPAD_1 = 0x69,
- KeyboardKeyNUMPAD_SLASH = 0x6A,
- KeyboardKeyNUMPAD_4 = 0x6B,
- KeyboardKeyNUMPAD_7 = 0x6C,
- KeyboardKeyNUMPAD_0 = 0x70,
- KeyboardKeyNUMPAD_COLON = 0x71,
- KeyboardKeyNUMPAD_2 = 0x72,
- KeyboardKeyNUMPAD_5 = 0x73,
- KeyboardKeyNUMPAD_6 = 0x74,
- KeyboardKeyNUMPAD_8 = 0x75,
- KeyboardKeyESC = 0x76,
- KeyboardKeyF11 = 0x78,
- KeyboardKeyNUMPAD_PLUS = 0x79,
- KeyboardKeyNUMPAD_3 = 0x7A,
- KeyboardKeyNUMPAD_MINUS = 0x7B,
- KeyboardKeyNUMPAD_ASTERISK = 0x7C,
- KeyboardKeyNUMPAD_9 = 0x7D
-};
-
-typedef struct {
- unsigned char status;
- unsigned char lights;
- unsigned char scancode;
- unsigned char character;
-} kb_key;
-
-
-extern char getch();
-extern kb_key get_key();
-extern char 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(unsigned char status);
\ No newline at end of file
diff --git a/SysCore/drivers/keyboard/keyboard.h.deprecated b/SysCore/drivers/keyboard/keyboard.h.deprecated
deleted file mode 100644
index b7979f4..0000000
--- a/SysCore/drivers/keyboard/keyboard.h.deprecated
+++ /dev/null
@@ -1,135 +0,0 @@
-
-#define KB_KEY_LSHIFT 0x81 // 1000 0001
-#define KB_KEY_RSHIFT 0X82 // 1000 0010
-#define KB_KEY_LALT 0X84 // 1000 0100
-#define KB_KEY_RALT 0x88 // 1000 1000
-#define KB_KEY_LCTRL 0x90 // 1001 0000
-#define KB_KEY_RCTRL 0xA0 // 1010 0000
-#define KB_KEY_FSHIFT 0xC0 // 1100 0000
-extern volatile unsigned char KeyModifierStatus;
-
-#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 unsigned char from pause/break
-extern volatile unsigned char KeyScancodePrefix;
-
-#define KB_KEY_SCROLL 0xF1 // 1111 0001
-#define KB_KEY_NUM 0xF2 // 1111 0010
-#define KB_KEY_CAPS 0xF4 // 1111 0100
-extern volatile unsigned char KeyLightsStatus;
-
-extern unsigned char KeyboardScancodeSet;
-
-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 {
- unsigned char status;
- unsigned char lights;
- unsigned char scancode;
- unsigned char character;
-} kb_key;
-
-
-extern char getch();
-extern kb_key get_key();
-extern char 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(unsigned char status);
\ No newline at end of file
diff --git a/SysCore/drivers/makeall.bat b/SysCore/drivers/makeall.bat
deleted file mode 100644
index 569ffc3..0000000
--- a/SysCore/drivers/makeall.bat
+++ /dev/null
@@ -1,158 +0,0 @@
-@echo off
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-
-goto this
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:this
- @echo Building Drivers...
- set objpath=..\objects\drivers
- set incpath=../include
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o drivers.o drivers.c
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o BSOD.o BSOD.c
-
- if not exist drivers.o goto error
- if not exist BSOD.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
-
-:clock
- set objpath=..\..\objects\drivers
- set incpath=../../include
-
- cd clock
- @echo * Compiling internal clock...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o pit.o pit.c
- if not exist pit.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
-
- cd..
-
-
-:floppy
- cd floppy
- @echo * Compiling floppy driver...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o dma.o dma.c
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o floppy.o floppy.c
- if not exist dma.o goto error
- if not exist floppy.o goto error
- xcopy /Y *.o %objpath% >nul
- del *.o
-
- cd..
-
-:filesys
- cd filesys
- @echo * Compiling file systems...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o fat.o fat.c
- rem %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o floppy.o floppy.c
- if not exist fat.o goto error
- rem if not exist floppy.o goto error
- xcopy /Y *.o %objpath% >nul
- del *.o
-
- cd..
-
-:keyboard
- cd keyboard
- @echo * Compiling keyboard driver...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o keyboard.o keyboard.c
- if not exist keyboard.o goto error
- xcopy /Y *.o %objpath% >nul
- del *.o
-
- cd..
-
-
-:cpu
- cd cpu
- @echo * Compiling Central Processing Unit (CPU) modules...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o cpu.o cpu.c
- if not exist cpu.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
-
- set objpath=..\..\..\objects\drivers
- set incpath=../../../include
-
- :gdt
- @echo + Global Descriptor Table
- cd gdt
-
- rem Assembly File:
- %nasm_path%\nasm.exe -f aout -o gdt_asm.o gdt.asm
- if not exist gdt_asm.o goto error
-
- rem C File:
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o gdt.o gdt.c
- if not exist gdt.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
- cd..
-
- :idt
- @echo + Interrupt Descriptor Table
- cd idt
-
- rem Assembly File:
- %nasm_path%\nasm.exe -f aout -o idt_asm.o idt.asm
- if not exist idt_asm.o goto error
-
- rem C File:
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o idt.o idt.c
- if not exist idt.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
- cd..
-
- :irq
- @echo + Interrupt Requests
- cd irq
-
- rem IRQ Assembly File:
- %nasm_path%\nasm.exe -f aout -o irq_asm.o irq.asm
- if not exist irq_asm.o goto error
-
- rem IRQ C File:
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o irq.o irq.c
- if not exist irq.o goto error
-
- @echo + Programmable Interrupt Controller
- rem PIC C File:
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o pic.o pic.c
- if not exist pic.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
- cd..
-
- :isrs
- @echo + Interrupt Service Routines
- cd isrs
-
- rem Assembly File:
- %nasm_path%\nasm.exe -f aout -o isrs_asm.o isrs.asm
- if not exist isrs_asm.o goto error
-
- rem C File:
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o isrs.o isrs.c
- if not exist isrs.o goto error
-
- xcopy /Y *.o %objpath% >nul
- del *.o
- cd..
-
-
- cd..
\ No newline at end of file
diff --git a/SysCore/filelist.txt b/SysCore/filelist.txt
deleted file mode 100644
index 9188990..0000000
--- a/SysCore/filelist.txt
+++ /dev/null
@@ -1,82 +0,0 @@
-.:
-compile.bat drivers include loader.asm makeall.bat memory shell
-debug filelist.txt lib main.c makeallh.bat objects video
-
-./debug:
-BIOS-bochs-latest bochs_config.bxrc ctaos.img OSDev.log VGABIOS-lgpl-latest
-
-./drivers:
-BSOD.c compile.bat drivers.c filesys keyboard makeall.bat.bak
-clock cpu drivers.h floppy makeall.bat
-
-./drivers/clock:
-clock.h pit.c
-
-./drivers/cpu:
-compile.bat cpu.c cpu.h gdt idt irq isrs
-
-./drivers/cpu/gdt:
-gdt.asm gdt.c gdt.h
-
-./drivers/cpu/idt:
-idt.asm idt.c idt.h
-
-./drivers/cpu/irq:
-irq.asm irq.c irq.h pic.c pic.h
-
-./drivers/cpu/isrs:
-isrs.asm isrs.c isrs.h
-
-./drivers/filesys:
-fat.c fat.h vfs.c vfs.h
-
-./drivers/floppy:
-dma.c dma.h floppy.c floppy.h storage.h
-
-./drivers/keyboard:
-compile.bat keyboard.deprecated.h key_list.txt
-keyboard.c keyboard.h.deprecated
-
-./include:
-bootinfo.h crtdefs.h cstring hal.h size_t.h stdlib.h system.h
-cctype cstdarg ctype.h _null.h stdarg.h string.h time.h
-conio.h cstdint drivers regs.h stdint.h sys va_list.h
-
-./include/drivers:
-floppy.h keyboard.h
-
-./include/sys:
-declarat.h
-
-./lib:
-compile.bat conio.c ctype.c stdlib.c string.c system.c time.c
-
-./memory:
-compile.bat lib mmngr.asm mmngr_ph.c mmngr_ph.h mmngr_vi.c mmngr_vi.h
-
-./memory/lib:
-pde.c pde.h pte.c pte.h
-
-./objects:
-compile.bat drivers main.o mmngr_ph.o release string.o video
-conio.o link.ld mmngr_de.o mmngr_te.o shell.o system.o
-ctype.o loader.o mmngr.o mmngr_vi.o stdlib.o time.o
-
-./objects/drivers:
-BSOD.o drivers.o floppy.o idt_asm.o irq.o keyboard.o
-cpu.o fat12.o gdt_asm.o idt.o isrs_asm.o pic.o
-dma.o fat.o gdt.o irq_asm.o isrs.o pit.o
-
-./objects/release:
-
-./objects/video:
-vga03h.o
-
-./shell:
-apps.h compile.bat shell.c
-
-./video:
-color compile.bat vga03h.c vga03h.h vga.h
-
-./video/color:
-color.c color.h
diff --git a/SysCore/include/_null.h b/SysCore/include/_null.h
deleted file mode 100644
index 8d731bf..0000000
--- a/SysCore/include/_null.h
+++ /dev/null
@@ -1,30 +0,0 @@
-
-#ifndef __NULL_H
-#define __NULL_H
-
-/******************************
- * _null.h *
- * - NULL declaration *
- ******************************/
-
-#if defined (_MSC_VER) && (_MSC_VER >= 1020)
-# pragma once
-#endif
-
-#ifdef NULL
-#undef NULL
-#endif
-
-#ifdef __cplusplus
-extern "C"
-{
-/* standard NULL declaration */
-#define NULL 0
-}
-#else
-/* standard NULL declaration */
-#define NULL (void*)0
-#endif
-
-
-#endif
diff --git a/SysCore/include/bootinfo.h b/SysCore/include/bootinfo.h
deleted file mode 100644
index 3215d82..0000000
--- a/SysCore/include/bootinfo.h
+++ /dev/null
@@ -1,192 +0,0 @@
-#ifndef _BOOTINFO_H
-#define _BOOTINFO_H
-//****************************************************************************
-//** bootinfo.h
-//****************************************************************************
-
-#include
-
-/**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;
-
-
-} multiboot_info ;
-
-
-#endif
-
diff --git a/SysCore/include/cctype b/SysCore/include/cctype
deleted file mode 100644
index 7ce3762..0000000
--- a/SysCore/include/cctype
+++ /dev/null
@@ -1,9 +0,0 @@
-// cerrno standard header
-
-#ifndef _CSTDCTYPE_
-#define _CSTDCTYPE_
-#include
-
-#endif /* _CSTDCTYPE_ */
-
-
diff --git a/SysCore/include/conio.h b/SysCore/include/conio.h
deleted file mode 100644
index a80343d..0000000
--- a/SysCore/include/conio.h
+++ /dev/null
@@ -1,104 +0,0 @@
-#ifndef __CONIO_H
-#define __CONIO_H
-
-#include
-//#define _ATTRIB 0x0F
-
-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 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/crtdefs.h b/SysCore/include/crtdefs.h
deleted file mode 100644
index 42c63aa..0000000
--- a/SysCore/include/crtdefs.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#ifndef _CRTDEFS_H
-#define _CRTDEFS_H
-
-/******************************
- * crtdefs.h *
- * - basic definitions *
- ******************************/
-
-#if !defined (CRT_EXPORTS) && !defined (CRT_IMPORTS)
-#define CRT_EXPORTS
-#endif
-
-#undef far
-#undef near
-#undef pascal
-
-#define far
-#define near
-
-#ifdef _WIN32
-#if (!defined(_MAC)) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED))
-#define pascal __stdcall
-#else
-#define pascal
-#endif
-#endif
-
-#ifdef _MAC
-#ifndef _CRTLIB
-#define _CRTLIB __cdecl
-#endif
-#ifdef _68K_
-#ifndef __pascal
-#define __pascal
-#endif
-#endif
-#elif defined( _WIN32)
-#if (_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)
-#ifndef _CRTLIB
-#define _CRTLIB __stdcall
-#endif
-#else
-#ifndef _CRTLIB
-#define _CRTLIB
-#endif
-#endif
-#endif
-
-
-#endif
diff --git a/SysCore/include/cstdarg b/SysCore/include/cstdarg
deleted file mode 100644
index 37ccae7..0000000
--- a/SysCore/include/cstdarg
+++ /dev/null
@@ -1,7 +0,0 @@
-// cerrno standard header
-
-#ifndef _CSTDARG_
-#define _CSTDARG_
-#include
-
-#endif /* _CSTDARG_ */
diff --git a/SysCore/include/cstdint b/SysCore/include/cstdint
deleted file mode 100644
index 7629317..0000000
--- a/SysCore/include/cstdint
+++ /dev/null
@@ -1,9 +0,0 @@
-// cerrno standard header
-
-#ifndef _CSTDINT_
-#define _CSTDINT_
-#include
-
-#endif /* _CSTDINT_ */
-
-
diff --git a/SysCore/include/cstring b/SysCore/include/cstring
deleted file mode 100644
index beb9135..0000000
--- a/SysCore/include/cstring
+++ /dev/null
@@ -1,9 +0,0 @@
-// cstring standard header
-
-#ifndef _CSTDSTRING_
-#define _CSTDSTRING_
-#include
-
-#endif /* _CSTDINT_ */
-
-
diff --git a/SysCore/include/drivers/floppy.h b/SysCore/include/drivers/floppy.h
deleted file mode 100644
index 13ad970..0000000
--- a/SysCore/include/drivers/floppy.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/***** floppy.h ******************************************************
- * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
- * *
- * Floppy Drive I/O Routines *
- * ========================= *
- * *
- ************************************************************ cta os */
-#include
-
-extern unsigned char FloppyInitializeDMA(unsigned char* buffer, unsigned length);
-extern void FloppyMotor (unsigned char drive, unsigned char on);
-extern void i86_FloppyHandler(ISR_stack_regs *r);
-extern void FloppyDriveData (unsigned char drv, unsigned char dma);
-extern unsigned char FloppyCalibrate(unsigned drive);
-extern void FloppyReset();
-
-extern unsigned char FloppySeek (unsigned drive, unsigned cyl, unsigned head);
-extern void FloppyInstall();
-extern unsigned char FloppyIsDriverEnabled();
-
-// Read/Write routines
-extern unsigned* FloppyReadSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
-extern unsigned* FloppyWriteSectors (unsigned* where, unsigned char drive, int sectorLBA, unsigned count);
-
-extern void FloppyReadSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);
-extern void FloppyWritedSectorImp (unsigned* where, unsigned char drive, unsigned char head, unsigned char track, unsigned char sector);
\ No newline at end of file
diff --git a/SysCore/include/drivers/keyboard.h b/SysCore/include/drivers/keyboard.h
deleted file mode 100644
index 671f3a8..0000000
--- a/SysCore/include/drivers/keyboard.h
+++ /dev/null
@@ -1,173 +0,0 @@
-#ifndef __KEYBOARD_H
-#define __KEYBOARD_H
-
-#include
-
-#define KeyboardKeyModifierLeftShift 0x81 // 1000 0001
-#define KeyboardKeyModifierRightShift 0x82 // 1000 0010
-#define KeyboardKeyModifierLeftAlt 0x84 // 1000 0100
-#define KeyboardKeyModifierRightAlt 0x88 // 1000 1000
-#define KeyboardKeyModifierLeftCtrl 0x90 // 1001 0000
-#define KeyboardKeyModifierRightCtrl 0xA0 // 1010 0000
-#define KeyboardKeyFakeShift 0xC0 // 1100 0000
-
-#define KeyboardLightScroll 0xF1 // 1111 0001
-#define KeyboardLightNum 0xF2 // 1111 0010
-#define KeyboardLightCaps 0xF4 // 1111 0100
-
-
-enum KeyboardKeys {
- KeyboardKeyPause = 0x00,
- KeyboardKeyF9 = 0x01,
- KeyboardKeyF7 = 0x02,
- KeyboardKeyF5 = 0X03,
- KeyboardKeyF3 = 0x04,
- KeyboardKeyF1 = 0x05,
- KeyboardKeyF2 = 0x06,
- KeyboardKeyF12 = 0x07,
- KeyboardKeyPrintScreen = 0x08,
- KeyboardKeyF10 = 0x09,
- KeyboardKeyF8 = 0x0A,
- KeyboardKeyF6 = 0x0B,
- KeyboardKeyF4 = 0x0C,
- KeyboardKeyTab = 0x0D,
- KeyboardKeyTilda = 0x0E,
- KeyboardKeyQ = 0x15,
- KeyboardKey1 = 0x16,
- KeyboardKeyZ = 0x1A,
- KeyboardKeyS = 0x1B,
- KeyboardKeyA = 0x1C,
- KeyboardKeyW = 0x1D,
- KeyboardKey2 = 0x1E,
- KeyboardKeyLeftWin = 0x1F,
- KeyboardKeyC = 0x21,
- KeyboardKeyX = 0x22,
- KeyboardKeyD = 0x23,
- KeyboardKeyE = 0x24,
- KeyboardKey4 = 0x25,
- KeyboardKey3 = 0x26,
- KeyboardKeyRightWin = 0x27,
- KeyboardKeySpace = 0x29,
- KeyboardKeyV = 0x2A,
- KeyboardKeyF = 0x2B,
- KeyboardKeyT = 0x2C,
- KeyboardKeyR = 0x2D,
- KeyboardKey5 = 0x2E,
- KeyboardKeyMenu = 0x2F,
- KeyboardKeyN = 0x31,
- KeyboardKeyB = 0x32,
- KeyboardKeyH = 0x33,
- KeyboardKeyG = 0x34,
- KeyboardKeyY = 0x35,
- KeyboardKey6 = 0x36,
- KeyboardKeyM = 0x3A,
- KeyboardKeyJ = 0x3B,
- KeyboardKeyU = 0x3C,
- KeyboardKey7 = 0x3D,
- KeyboardKey8 = 0x3E,
- KeyboardKeyComma = 0x41,
- KeyboardKeyK = 0x42,
- KeyboardKeyI = 0x43,
- KeyboardKeyO = 0x44,
- KeyboardKey0 = 0x45,
- KeyboardKey9 = 0x46,
- KeyboardKeyPeriod = 0x49,
- KeyboardKeySlash = 0x4A,
- KeyboardKeyL = 0x4B,
- KeyboardKeySemicolon = 0x4C,
- KeyboardKeyP = 0x4D,
- KeyboardKeyDash = 0x4E,
- KeyboardKeyApostrophe = 0x52,
- KeyboardKeyLeftBracket = 0x54,
- KeyboardKeyEqual = 0x55,
- KeyboardKeyNumpadEnter = 0x59,
- KeyboardKeyReturn = 0x5A,
- KeyboardKeyRightBracket = 0x5B,
- KeyboardKeyBackSlash = 0x5D,
- KeyboardKeyEnd = 0x5E,
- KeyboardKeyLeft = 0x5F,
- KeyboardKeyHome = 0x60,
- KeyboardKeyInsert = 0x61,
- KeyboardKeyDelete = 0x62,
- KeyboardKeyDown = 0x63,
- KeyboardKeyRight = 0x64,
- KeyboardKeyUp = 0x65,
- KeyboardKeyBackspace = 0x66,
- KeyboardKeyPageDown = 0x67,
- KeyboardKeyPageUp = 0x68,
- KeyboardKeyNumpad1 = 0x69,
- KeyboardKeyNumpadSlash = 0x6A,
- KeyboardKeyNumpad4 = 0x6B,
- KeyboardKeyNumpad7 = 0x6C,
- KeyboardKeyNumpad0 = 0x70,
- KeyboardKeyNumpadColon = 0x71,
- KeyboardKeyNumpad2 = 0x72,
- KeyboardKeyNumpad5 = 0x73,
- KeyboardKeyNumpad6 = 0x74,
- KeyboardKeyNumpad8 = 0x75,
- KeyboardKeyEscape = 0x76,
- KeyboardKeyF11 = 0x78,
- KeyboardKeyNumpadPlus = 0x79,
- KeyboardKeyNumpad3 = 0x7A,
- KeyboardKeyNumpadMinus = 0x7B,
- KeyboardKeyNumpadAsterisk = 0x7C,
- KeyboardKeyNumpad9 = 0x7D
-};
-
-typedef struct {
- unsigned char ModifierStatus;
- unsigned char Lights;
- unsigned char Scancode;
- unsigned char Character;
-} KeyboardKey;
-
-extern void KeyboardSetKey(unsigned char scancode, unsigned char val);
-extern unsigned char KeyIsPressed(unsigned char scancode);
-extern void i86_KeyboardHandler(ISR_stack_regs *r);
-extern KeyboardKey GetKey();
-
-/**\n
- Sets the repeat rate/delay\n
- \n\Delay:
- Values for inter-character delay (bits 4-0)\n
- (characters per second; default is 10.9)\n
- | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 \n
- ----+----+----+----+----+----+----+----+----\n
- 0 |30.0|26.7|24.0|21.8|20.0|18.5|17.1|16.0\n
- 8 |15.0|13.3|12.0|10.9|10.0|9.2 |8.6 |8.0\n
- 16 |7.5 |6.7 |6.0 |5.5 |5.0 |4.6 |4.3 |4.0\n
- 24 |3.7 |3.3 |3.0 |2.7 |2.5 |2.3 |2.1 |2.0\n
- \n
- Values for delay:\n
- (miliseconds; default is 500)\n
- 0 | 1 | 2 | 3\n
- -----+-----+-----+-----\n
- 250 | 500 | 750 | 1000\n \n*/
-extern void KeyboardSetRepeatRate(unsigned char rate, unsigned char delay);
-
-/***************************************
- * Set keyboard LEDs *
- ***************************************
- +-----------+-------+-------+--------+
- | Bits 7-3 | Bit 2 | Bit 1 | Bit 0 |
- | 0 | Caps | Num | Scroll |
- |(reserved) | lock | lock | lock |
- +-----------+-------+-------+--------+
- ***************************************/
-extern void KeyboardSetLEDs(unsigned char status);
-
-/***************************************
- * Set scancode set *
- ***************************************
- 0 Get current scancode set
- 1 Set to scancode set 1
- 2 Set to scancode set 2
- 3 Set to scancode set 3
- ***************************************/
-extern void KeyboardSetScancodeSet(unsigned char set);
-extern void KeyboardWaitInput();
-extern void KeyboardWaitOutput();
-extern void KeyboardInstallA();
-extern void KeyboardInstallB();
-
-#endif
\ No newline at end of file
diff --git a/SysCore/include/hal.h b/SysCore/include/hal.h
deleted file mode 100644
index cf49b24..0000000
--- a/SysCore/include/hal.h
+++ /dev/null
@@ -1,167 +0,0 @@
-#ifndef _HAL_H
-#define _HAL_H
-
-#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 TIME ClockGetTime() ;
-extern unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA);
-// initialize hardware abstraction layer
-extern void i86_hal_initialize ();
-
-// shutdown hardware abstraction layer
-extern int i86_hal_shutdown ();
-
-//! notifies hal interrupt is done
-//extern void interruptdone (unsigned int intno);
-
-//! output sound to speaker
-extern void sound (unsigned frequency);
-
-//! read unsigned char from device using port mapped io
-//extern unsigned char inportb (unsigned short _port);
-
-//! write unsigned char to device through port mapped io
-//extern void outportb (unsigned short _port, unsigned char _data);
-
-//! sets new interrupt vector
-//extern void setvect (int intno, void ( far &vect) ( ) );
-
-//! returns current interrupt vector
-//extern void ( far * getvect (int intno)) ( );
-
-//! returns cpu vender
-extern const char* get_cpu_vender ();
-
-extern void SystemReboot();
-
-
-/**********************************************************************
- * KEYBOARD STUFF *
- **********************************************************************/
-
-#define KeyboardKeyModifierLeftShift 0x81 // 1000 0001
-#define KeyboardKeyModifierRightShift 0x82 // 1000 0010
-#define KeyboardKeyModifierLeftAlt 0x84 // 1000 0100
-#define KeyboardKeyModifierRightAlt 0x88 // 1000 1000
-#define KeyboardKeyModifierLeftCtrl 0x90 // 1001 0000
-#define KeyboardKeyModifierRightCtrl 0xA0 // 1010 0000
-#define KeyboardKeyFakeShift 0xC0 // 1100 0000
-
-#define KeyboardLightScroll 0xF1 // 1111 0001
-#define KeyboardLightNum 0xF2 // 1111 0010
-#define KeyboardLightCaps 0xF4 // 1111 0100
-
-enum KeyboardKeys {
- KeyboardKeyPause = 0x00,
- KeyboardKeyF9 = 0x01,
- KeyboardKeyF7 = 0x02,
- KeyboardKeyF5 = 0X03,
- KeyboardKeyF3 = 0x04,
- KeyboardKeyF1 = 0x05,
- KeyboardKeyF2 = 0x06,
- KeyboardKeyF12 = 0x07,
- KeyboardKeyPrintScreen = 0x08,
- KeyboardKeyF10 = 0x09,
- KeyboardKeyF8 = 0x0A,
- KeyboardKeyF6 = 0x0B,
- KeyboardKeyF4 = 0x0C,
- KeyboardKeyTab = 0x0D,
- KeyboardKeyTilda = 0x0E,
- KeyboardKeyQ = 0x15,
- KeyboardKey1 = 0x16,
- KeyboardKeyZ = 0x1A,
- KeyboardKeyS = 0x1B,
- KeyboardKeyA = 0x1C,
- KeyboardKeyW = 0x1D,
- KeyboardKey2 = 0x1E,
- KeyboardKeyLeftWin = 0x1F,
- KeyboardKeyC = 0x21,
- KeyboardKeyX = 0x22,
- KeyboardKeyD = 0x23,
- KeyboardKeyE = 0x24,
- KeyboardKey4 = 0x25,
- KeyboardKey3 = 0x26,
- KeyboardKeyRightWin = 0x27,
- KeyboardKeySpace = 0x29,
- KeyboardKeyV = 0x2A,
- KeyboardKeyF = 0x2B,
- KeyboardKeyT = 0x2C,
- KeyboardKeyR = 0x2D,
- KeyboardKey5 = 0x2E,
- KeyboardKeyMenu = 0x2F,
- KeyboardKeyN = 0x31,
- KeyboardKeyB = 0x32,
- KeyboardKeyH = 0x33,
- KeyboardKeyG = 0x34,
- KeyboardKeyY = 0x35,
- KeyboardKey6 = 0x36,
- KeyboardKeyM = 0x3A,
- KeyboardKeyJ = 0x3B,
- KeyboardKeyU = 0x3C,
- KeyboardKey7 = 0x3D,
- KeyboardKey8 = 0x3E,
- KeyboardKeyComma = 0x41,
- KeyboardKeyK = 0x42,
- KeyboardKeyI = 0x43,
- KeyboardKeyO = 0x44,
- KeyboardKey0 = 0x45,
- KeyboardKey9 = 0x46,
- KeyboardKeyPeriod = 0x49,
- KeyboardKeySlash = 0x4A,
- KeyboardKeyL = 0x4B,
- KeyboardKeySemicolon = 0x4C,
- KeyboardKeyP = 0x4D,
- KeyboardKeyDash = 0x4E,
- KeyboardKeyApostrophe = 0x52,
- KeyboardKeyLeftBracket = 0x54,
- KeyboardKeyEqual = 0x55,
- KeyboardKeyNumpadEnter = 0x59,
- KeyboardKeyReturn = 0x5A,
- KeyboardKeyRightBracket = 0x5B,
- KeyboardKeyBackSlash = 0x5D,
- KeyboardKeyEnd = 0x5E,
- KeyboardKeyLeft = 0x5F,
- KeyboardKeyHome = 0x60,
- KeyboardKeyInsert = 0x61,
- KeyboardKeyDelete = 0x62,
- KeyboardKeyDown = 0x63,
- KeyboardKeyRight = 0x64,
- KeyboardKeyUp = 0x65,
- KeyboardKeyBackspace = 0x66,
- KeyboardKeyPageDown = 0x67,
- KeyboardKeyPageUp = 0x68,
- KeyboardKeyNumpad1 = 0x69,
- KeyboardKeyNumpadSlash = 0x6A,
- KeyboardKeyNumpad4 = 0x6B,
- KeyboardKeyNumpad7 = 0x6C,
- KeyboardKeyNumpad0 = 0x70,
- KeyboardKeyNumpadColon = 0x71,
- KeyboardKeyNumpad2 = 0x72,
- KeyboardKeyNumpad5 = 0x73,
- KeyboardKeyNumpad6 = 0x74,
- KeyboardKeyNumpad8 = 0x75,
- KeyboardKeyEscape = 0x76,
- KeyboardKeyF11 = 0x78,
- KeyboardKeyNumpadPlus = 0x79,
- KeyboardKeyNumpad3 = 0x7A,
- KeyboardKeyNumpadMinus = 0x7B,
- KeyboardKeyNumpadAsterisk = 0x7C,
- KeyboardKeyNumpad9 = 0x7D
-};
-
-typedef struct {
- unsigned char ModifierStatus;
- unsigned char Lights;
- unsigned char Scancode;
- unsigned char Character;
-} KeyboardKey;
-
-
-#endif
\ No newline at end of file
diff --git a/SysCore/include/regs.h b/SysCore/include/regs.h
deleted file mode 100644
index 492ee1f..0000000
--- a/SysCore/include/regs.h
+++ /dev/null
@@ -1,100 +0,0 @@
-#ifndef _REGS_H_INCLUDED
-#define _REGS_H_INCLUDED
-//****************************************************************************
-//**
-//** regs.h
-//**
-//** processor register structures and declarations. This interface abstracts
-//** register names behind a common, portable interface
-//**
-//****************************************************************************
-
-//============================================================================
-// INTERFACE REQUIRED HEADERS
-//============================================================================
-
-#include
-
-//============================================================================
-// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
-//============================================================================
-//============================================================================
-// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
-//============================================================================
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-
-//! 32 bit registers
-typedef struct {
- uint32_t eax, ebx, ecx, edx, esi, edi, ebp, esp, eflags;
- uint8_t cflag;
-} _R32BIT;
-
-//! 16 bit registers
-typedef struct {
- uint16_t ax, bx, cx, dx, si, di, bp, sp, es, cs, ss, ds, flags;
- uint8_t cflag;
-} _R16BIT ;
-
-//! 16 bit registers expressed in 32 bit registers
-typedef struct {
- uint16_t ax, axh, bx, bxh, cx, cxh, dx, dxh;
- uint16_t si, di, bp, sp, es, cs, ss, ds, flags;
- uint8_t cflags;
-} _R16BIT32 ;
-
-//! 8 bit registers
-typedef struct {
- uint8_t al, ah, bl, bh, cl, ch, dl, dh;
-} _R8BIT;
-
-//! 8 bit registers expressed in 32 bit registers
-typedef struct {
- uint8_t al, ah; uint16_t axh;
- uint8_t bl, bh; uint16_t bxh;
- uint8_t cl, ch; uint16_t cxh;
- uint8_t dl, dh; uint16_t dxh;
-} _R8BIT32;
-
-//! 8 and 16 bit registers union
-typedef union {
- _R16BIT x;
- _R8BIT h;
-}_INTR16;
-
-//! 32 bit, 16 bit and 8 bit registers union
-typedef union {
- _R32BIT x;
- _R16BIT32 l;
- _R8BIT32 h;
-} _INTR32;
-
-/* This defines what the stack looks like after an ISR was running */
-typedef struct
-{
- unsigned int gs, fs, es, ds; /* pushed the segs last */
- unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax; /* pushed by 'pusha' */
- unsigned int int_no, err_code; /* our 'push byte #' and ecodes do this */
- unsigned int eip, cs, eflags, useresp, ss; /* pushed by the processor automatically */
-} ISR_stack_regs;
-
-
-//============================================================================
-// INTERFACE DATA DECLARATIONS
-//============================================================================
-//============================================================================
-// INTERFACE FUNCTION PROTOTYPES
-//============================================================================
-//============================================================================
-// INTERFACE OBJECT CLASS DEFINITIONS
-//============================================================================
-//============================================================================
-// INTERFACE TRAILING HEADERS
-//============================================================================
-//****************************************************************************
-//**
-//** END regs.h
-//**
-//****************************************************************************
-#endif
diff --git a/SysCore/include/size_t.h b/SysCore/include/size_t.h
deleted file mode 100644
index 7e4b1cc..0000000
--- a/SysCore/include/size_t.h
+++ /dev/null
@@ -1,23 +0,0 @@
-#ifndef __SIZE_T_H
-#define __SIZE_T_H
-
-/************************************
- * size_t.h *
- * - Standard C/C++ size_t type *
- ************************************/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* standard size_t type */
-typedef unsigned size_t;
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif
diff --git a/SysCore/include/stdint.h b/SysCore/include/stdint.h
deleted file mode 100644
index 3338763..0000000
--- a/SysCore/include/stdint.h
+++ /dev/null
@@ -1,163 +0,0 @@
-
-#ifndef _STDINT_H
-#define _STDINT_H
-
-#define __need_wint_t
-#define __need_wchar_t
-
-
-/***************************************
- * stdint.h *
- * - Standard C++ integral types *
- ***************************************/
-
-/* 7.18.1.1 Exact-width integer types */
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef short int16_t;
-typedef unsigned short uint16_t;
-typedef int int32_t;
-typedef unsigned uint32_t;
-typedef long long int64_t;
-typedef unsigned long long uint64_t;
-
-/* 7.18.1.2 Minimum-width integer types */
-typedef signed char int_least8_t;
-typedef unsigned char uint_least8_t;
-typedef short int_least16_t;
-typedef unsigned short uint_least16_t;
-typedef int int_least32_t;
-typedef unsigned uint_least32_t;
-typedef long long int_least64_t;
-typedef unsigned long long uint_least64_t;
-
-/* 7.18.1.3 Fastest minimum-width integer types
- * Not actually guaranteed to be fastest for all purposes
- * Here we use the exact-width types for 8 and 16-bit ints.
- */
-typedef char int_fast8_t;
-typedef unsigned char uint_fast8_t;
-typedef short int_fast16_t;
-typedef unsigned short uint_fast16_t;
-typedef int int_fast32_t;
-typedef unsigned int uint_fast32_t;
-typedef long long int_fast64_t;
-typedef unsigned long long uint_fast64_t;
-
-/* 7.18.1.4 Integer types capable of holding object pointers */
-typedef int intptr_t;
-typedef unsigned uintptr_t;
-
-/* 7.18.1.5 Greatest-width integer types */
-typedef long long intmax_t;
-typedef unsigned long long uintmax_t;
-
-/* 7.18.2 Limits of specified-width integer types */
-#if !defined ( __cplusplus) || defined (__STDC_LIMIT_MACROS)
-
-/* 7.18.2.1 Limits of exact-width integer types */
-#define INT8_MIN (-128)
-#define INT16_MIN (-32768)
-#define INT32_MIN (-2147483647 - 1)
-#define INT64_MIN (-9223372036854775807LL - 1)
-
-#define INT8_MAX 127
-#define INT16_MAX 32767
-#define INT32_MAX 2147483647
-#define INT64_MAX 9223372036854775807LL
-
-#define UINT8_MAX 0xff /* 255U */
-#define UINT16_MAX 0xffff /* 65535U */
-#define UINT32_MAX 0xffffffff /* 4294967295U */
-#define UINT64_MAX 0xffffffffffffffffULL /* 18446744073709551615ULL */
-
-/* 7.18.2.2 Limits of minimum-width integer types */
-#define INT_LEAST8_MIN INT8_MIN
-#define INT_LEAST16_MIN INT16_MIN
-#define INT_LEAST32_MIN INT32_MIN
-#define INT_LEAST64_MIN INT64_MIN
-
-#define INT_LEAST8_MAX INT8_MAX
-#define INT_LEAST16_MAX INT16_MAX
-#define INT_LEAST32_MAX INT32_MAX
-#define INT_LEAST64_MAX INT64_MAX
-
-#define UINT_LEAST8_MAX UINT8_MAX
-#define UINT_LEAST16_MAX UINT16_MAX
-#define UINT_LEAST32_MAX UINT32_MAX
-#define UINT_LEAST64_MAX UINT64_MAX
-
-/* 7.18.2.3 Limits of fastest minimum-width integer types */
-#define INT_FAST8_MIN INT8_MIN
-#define INT_FAST16_MIN INT16_MIN
-#define INT_FAST32_MIN INT32_MIN
-#define INT_FAST64_MIN INT64_MIN
-
-#define INT_FAST8_MAX INT8_MAX
-#define INT_FAST16_MAX INT16_MAX
-#define INT_FAST32_MAX INT32_MAX
-#define INT_FAST64_MAX INT64_MAX
-
-#define UINT_FAST8_MAX UINT8_MAX
-#define UINT_FAST16_MAX UINT16_MAX
-#define UINT_FAST32_MAX UINT32_MAX
-#define UINT_FAST64_MAX UINT64_MAX
-
-/* 7.18.2.4 Limits of integer types capable of holding
- object pointers */
-#define INTPTR_MIN INT32_MIN
-#define INTPTR_MAX INT32_MAX
-#define UINTPTR_MAX UINT32_MAX
-
-/* 7.18.2.5 Limits of greatest-width integer types */
-#define INTMAX_MIN INT64_MIN
-#define INTMAX_MAX INT64_MAX
-#define UINTMAX_MAX UINT64_MAX
-
-/* 7.18.3 Limits of other integer types */
-#define PTRDIFF_MIN INT32_MIN
-#define PTRDIFF_MAX INT32_MAX
-
-#define SIG_ATOMIC_MIN INT32_MIN
-#define SIG_ATOMIC_MAX INT32_MAX
-
-#define SIZE_MAX UINT32_MAX
-
-#ifndef WCHAR_MIN /* also in wchar.h */
-#define WCHAR_MIN 0
-#define WCHAR_MAX ((wchar_t)-1) /* UINT16_MAX */
-#endif
-
-/*
- * wint_t is unsigned short for compatibility with MS runtime
- */
-#define WINT_MIN 0
-#define WINT_MAX ((wint_t)-1) /* UINT16_MAX */
-
-#endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */
-
-
-/* 7.18.4 Macros for integer constants */
-#if !defined ( __cplusplus) || defined (__STDC_CONSTANT_MACROS)
-
-/* 7.18.4.1 Macros for minimum-width integer constants */
-
-#define INT8_C(val) ((int8_t) + (val))
-#define UINT8_C(val) ((uint8_t) + (val##U))
-#define INT16_C(val) ((int16_t) + (val))
-#define UINT16_C(val) ((uint16_t) + (val##U))
-
-#define INT32_C(val) val##L
-#define UINT32_C(val) val##UL
-#define INT64_C(val) val##LL
-#define UINT64_C(val) val##ULL
-
-/* 7.18.4.2 Macros for greatest-width integer constants */
-#define INTMAX_C(val) INT64_C(val)
-#define UINTMAX_C(val) UINT64_C(val)
-
-#endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */
-
-
-
-#endif
diff --git a/SysCore/include/stdlib.h b/SysCore/include/stdlib.h
deleted file mode 100644
index 9558dd0..0000000
--- a/SysCore/include/stdlib.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#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/string.h b/SysCore/include/string.h
deleted file mode 100644
index 54a553f..0000000
--- a/SysCore/include/string.h
+++ /dev/null
@@ -1,46 +0,0 @@
-#ifndef _STRING_H
-#define _STRING_H
-//****************************************************************************
-//**
-//** [string.h]
-//** - Standard C String routines
-//**
-//****************************************************************************
-//============================================================================
-// INTERFACE REQUIRED HEADERS
-//============================================================================
-
-#include
-
-//============================================================================
-// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
-//============================================================================
-//============================================================================
-// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
-//============================================================================
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-//============================================================================
-// INTERFACE DATA DECLARATIONS
-//============================================================================
-//============================================================================
-// INTERFACE FUNCTION PROTOTYPES
-//============================================================================
-
-extern size_t strlen (const char *str);
-extern int strcmp(const char *pStr1, const char *pStr2);
-
-//============================================================================
-// INTERFACE OBJECT CLASS DEFINITIONS
-//============================================================================
-//============================================================================
-// INTERFACE TRAILING HEADERS
-//============================================================================
-//****************************************************************************
-//**
-//** END [string.h]
-//**
-//****************************************************************************
-
-#endif
diff --git a/SysCore/include/sys/declarat.h b/SysCore/include/sys/declarat.h
deleted file mode 100644
index 8b9c97f..0000000
--- a/SysCore/include/sys/declarat.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifndef __DECLARAT_H
-#define __DECLARAT_H
-
-// Data type declarations
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int dword;
-
-// Functions
-void system_init();
-
-void isrs_install();
-
-void irq_install_handler(int irq, void (*handler)(ISR_stack_regs *r));
-void irq_uninstall_handler(int irq);
-void irq_install();
-void kb_handler(ISR_stack_regs *r);
-void reboot();
-void kb_waitin();
-
-#endif
\ No newline at end of file
diff --git a/SysCore/include/system.h b/SysCore/include/system.h
deleted file mode 100644
index 106fdf6..0000000
--- a/SysCore/include/system.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************
- * system.c - Basic system functions and variables declaration *
- *******************************************************************/
-#ifndef __SYSTEM_H
-#define __SYSTEM_H
-#include
-
-#define true 1
-#define false 0
-
-// Data type declarations
-typedef unsigned char byte;
-typedef unsigned short word;
-typedef unsigned int dword;
-
-extern byte *TextVideoRam;
-extern volatile int cursor_x, cursor_y;
-extern int current_mode_width;
-extern int current_mode_height;
-
-extern void *memcpy(void *dest, const void *src, int count);
-extern void *memset(void *dest, char val, int count);
-extern unsigned short *memsetw(unsigned short *dest, unsigned short val, int count);
-
-extern byte inportb (word _port);
-extern byte inb (word _port);
-
-static inline void outportb (word _port, byte _data) {
- __asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
-}
-static inline void outb (word _port, byte _data) {
- __asm__ __volatile__ ("outb %1, %0" : : "dN" (_port), "a" (_data));
-}
-
-static inline void iowait() {
- asm volatile ("outb %al, $0x80");
-}
-
-
-#endif
\ No newline at end of file
diff --git a/SysCore/include/time.h b/SysCore/include/time.h
deleted file mode 100644
index 46df665..0000000
--- a/SysCore/include/time.h
+++ /dev/null
@@ -1,25 +0,0 @@
-#ifndef __TIME_C
-#define __TIME_C
-
-extern const char* clock_month[13];
-extern const char* clock_weekday[8];
-extern unsigned char clock_month_len[13];
-
-typedef struct {
- 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);
-
-#include "../drivers/clock/clock.h"
-
-//extern char* asctime (TIME time);
-
-#endif
\ No newline at end of file
diff --git a/SysCore/include/va_list.h b/SysCore/include/va_list.h
deleted file mode 100644
index 2eaabc8..0000000
--- a/SysCore/include/va_list.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef __VA_LIST_H
-#define __VA_LIST_H
-//****************************************************************************
-//**
-//** va_list.h
-//** - varable length parameter definition
-//**
-//****************************************************************************
-//============================================================================
-// INTERFACE REQUIRED HEADERS
-//============================================================================
-//============================================================================
-// INTERFACE DEFINITIONS / ENUMERATIONS / SIMPLE TYPEDEFS
-//============================================================================
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* va list parameter list */
-typedef unsigned char *va_list;
-
-#ifdef __cplusplus
-}
-#endif
-
-//============================================================================
-// INTERFACE CLASS PROTOTYPES / EXTERNAL CLASS REFERENCES
-//============================================================================
-//============================================================================
-// INTERFACE STRUCTURES / UTILITY CLASSES
-//============================================================================
-//============================================================================
-// INTERFACE DATA DECLARATIONS
-//============================================================================
-//============================================================================
-// INTERFACE FUNCTION PROTOTYPES
-//============================================================================
-//============================================================================
-// INTERFACE OBJECT CLASS DEFINITIONS
-//============================================================================
-//============================================================================
-// INTERFACE TRAILING HEADERS
-//============================================================================
-//****************************************************************************
-//**
-//** END va_list.h
-//**
-//****************************************************************************
-
-#endif
diff --git a/SysCore/lib/compile.bat b/SysCore/lib/compile.bat
deleted file mode 100644
index 229f2fb..0000000
--- a/SysCore/lib/compile.bat
+++ /dev/null
@@ -1,51 +0,0 @@
-@echo off
-
-rem NASM and DJGPP executable paths:
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-set objpath=..\objects
-set incpath=../include
-
-@echo Building Kernel Standard Libraries...
-
-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
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:build
- @echo * Compiling SYSTEM.C ...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/system.o system.c
-
- @echo * Compiling STRING.C ...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/string.o string.c
-
- @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
-
-:check
- 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
deleted file mode 100644
index ff8e91a..0000000
--- a/SysCore/lib/conio.c
+++ /dev/null
@@ -1,695 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include "../memory/mmngr_ph.h"
-
-unsigned char ColorDefault;
-unsigned char ConsoleScreenInstalled = 0;
-/*char hex[] = "0123456789ABCDEF"; */
-
-/* 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);
-
-/* Other external routines */
-extern void *memset(void *dest, char val, int count);
-
-/* Important variables */
-UPoint ScreenSize, Cursor;
-
-void ConsoleInstall(ConsoleScreen screen)
-{
-
- _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;
- KeyboardKey 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 KeyboardKeyInsert: __cgets__key_insert(); break;
-
- // Finish writing (return)
- case KeyboardKeyReturn: __cgets__key_enter(); break;
- case KeyboardKeyNumpadEnter: __cgets__key_enter(); break;
-
- // Left
- case KeyboardKeyLeft:
- __cgets__move_cursor(string, 0, Len, &CurPos, ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl)));
- break;
-
- // Right
- case KeyboardKeyRight:
- __cgets__move_cursor(string, 1, Len, &CurPos, ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl)));
- break;
-
- case KeyboardKeyHome:
- CurPos = 0;
- break;
-
- case KeyboardKeyEnd:
- CurPos = Len;
- break;
-
- case KeyboardKeyBackspace:
- if (CurPos > 0) {
- int tmp;
- if ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl))
- tmp = __cgets__skip_word(string, Len, CurPos, 0);
- else tmp = CurPos-1;
-
- __cgets__delete(string, tmp, CurPos, &Len);
- CurPos = tmp;
-
- };
- break;
-
- // Delete
- case KeyboardKeyDelete:
- if (CurPos < Len) {
- int tmp;
- // If CTRL is pressed, foward one word
- if ((Key.ModifierStatus & KeyboardKeyModifierLeftCtrl) || (Key.ModifierStatus & KeyboardKeyModifierRightCtrl))
- 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 & KeyboardLightCaps) && 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()
-{
- KeyboardKey k;
- k = GetKey();
-
- if ((k.Lights & KeyboardLightCaps) && 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()
-{
-
-}
-
-// Change cursor position
-void text_mode_cursor(int x, int y)
-{
- unsigned temp = y*current_mode_width + x;
-
- outportb (0x3D4, 14);
- outportb (0x3D5, temp >> 8);
- outportb (0x3D4, 15);
- outportb (0x3D5, temp);
-}
-
-// Set the default colors; max is 0x0F
-void set_default_colors(unsigned char back, unsigned char fore)
-{
- if (back < 0x10) ColorDefaultBack = back;
- if (fore < 0x10) ColorDefaultFore = fore;
-}
-
-
-// Clear screen, and set font to default font
-void clrscr()
-{
- unsigned char font = ColorDefaultFore | (ColorDefaultBack<<4);
- int i = 0;
- for (i = 0; i < current_mode_width*current_mode_height; i++)
- { TextVideoRam[2*i] = 0;
- TextVideoRam[2*i+1] = font;
- }
- cursor_x = 0; cursor_y = 0;
-}
-
-void scroll(int n)
-{
- memcpy(TextVideoRam,
- TextVideoRam+(current_mode_width*n*2),
- 2*current_mode_width*(current_mode_height - n));
-
- unsigned char blank = ColorDefaultFore | (ColorDefaultBack<<4);
-
- int i;
- for (i = current_mode_width*(current_mode_height-n);
- i < current_mode_width*current_mode_height; i++){
- TextVideoRam[2*i] = 0;
- TextVideoRam[2*i+1] = blank;
- }
-}
-
-
-void prev_line()
-{
- cursor_x = 79;
- if (--cursor_y < 0) {
- cursor_y = 0; cursor_x=0;
- }
-}
-
-void next_line()
-{
- cursor_x = 0;
- if (++cursor_y >=25) {
- cursor_y = 24; scroll(1);
- }
-}
-
-
-// Put character on screen in specified position; can use different font colors
-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);
-}
-// Put character on screen in specified position; use default font colors
-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, unsigned char back, unsigned char fore)
-{
- if (cursor_x >= current_mode_width) next_line();
-
- if (c == '\n') {next_line(); return;};
- TextVideoRam[2*(cursor_y*current_mode_width+cursor_x)] = c;
- TextVideoRam[2*(cursor_y*current_mode_width+cursor_x)+1] = fore|(back<<4);
- cursor_x++;
-}
-// Put character on screen in the current cursor position; default font colors
-void putc(char c)
-{
- if (cursor_x >= current_mode_width) next_line();
-
- if (c == '\n') {next_line(); return;};
- if (c == '\r') {cursor_x = 0; return; };
- TextVideoRam[2*(cursor_y*current_mode_width+cursor_x)] = c;
- cursor_x++;
-}
-
-
-
-
-// Put string on screen in specified position; can use different font colors
-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++)
- putc_pos_font(x+i, y, str[i], back, fore);
-
-}
-
-// Put string on screen in specified position; use default font colors
-void puts_pos(int x, int y, const char *str)
-{
- int i;
- for (i = 0; str[i] != 0; i++)
- putc_pos(x+i, y, str[i]);
-}
-void puts(const char *str)
-{
- int i;
- for (i = 0; str[i] != 0; i++)
- putc(str[i]);
-}
-
-void puts_font(const char *str, unsigned char back, unsigned char fore)
-{
- int i;
- for (i = 0; str[i] != 0; i++)
- putc_font(str[i], back, fore);
-}
-
-void put_hex(unsigned int alpha)
-{
- char nr[9];
- int i;
- for (i = 7; i >= 0; i--) {
- nr[i] = hex[alpha%16];
- alpha /= 16;
- }
- nr[8] = 0;
- puts(nr);
-}
-void put_hex_pos(int x, int y, unsigned int alpha)
-{
- char nr[9];
- int i;
- for (i = 7; i >= 0; i--) {
- nr[i] = hex[alpha%16];
- alpha /= 16;
- }
- nr[8] = 0;
- puts_pos(x,y,nr);
-}
-
-void put_bin (int x, int y, unsigned char xz)
-{
- int i;
- char arr[9] = {0,0,0,0,0,0,0,0,0};
- for(i=7; i>=0; i--) {
- arr[i] = (xz%2) + '0'; xz/=2;
- }
- puts_pos (x, y, arr);
-}
-
-
-
-
-*/
\ No newline at end of file
diff --git a/SysCore/lib/stdlib.c b/SysCore/lib/stdlib.c
deleted file mode 100644
index f4ea5db..0000000
--- a/SysCore/lib/stdlib.c
+++ /dev/null
@@ -1,286 +0,0 @@
-#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
deleted file mode 100644
index 35e2e29..0000000
--- a/SysCore/lib/string.c
+++ /dev/null
@@ -1,23 +0,0 @@
-#include
-
-unsigned strlen (const char *str)
-{
- unsigned i;
- for (i = 0; *str!=0; str++) i++;
- return i;
-}
-
-int strcmp(const char *pStr1, const char *pStr2)
-{
- char c1, c2;
- int v;
-
- do {
- c1 = *pStr1++;
- c2 = *pStr2++;
- /* the casts are necessary when pStr1 is shorter & char is signed */
- v = (unsigned int)c1 - (unsigned int)c2;
- } while ((v == 0) && (c1 != '\0'));
-
- return v;
-}
diff --git a/SysCore/lib/system.c b/SysCore/lib/system.c
deleted file mode 100644
index fbaee98..0000000
--- a/SysCore/lib/system.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/******************************************************************
- * system.c - Basic system functions *
- ******************************************************************/
-
-#include
-
-extern unsigned char *TextVideoRam;
-volatile int cursor_x, cursor_y;
-int current_mode_width;
-int current_mode_height;
-
-void *memcpy(void *dest, const void *src, int count)
-{
- const char *sp = (const char *)src;
- char *dp = (char *)dest;
- for(; count != 0; count--) *dp++ = *sp++;
- return dest;
-}
-
-void *memset(void *dest, char val, int count)
-{
- char *temp = (char *)dest;
- for( ; count != 0; count--) *temp++ = val;
- return dest;
-}
-
-unsigned short *memsetw(unsigned short *dest, unsigned short val, int count)
-{
- unsigned short *temp = (unsigned short *)dest;
- for( ; count != 0; count--) *temp++ = val;
- return dest;
-}
-
-
-unsigned char inportb (word _port) {
- unsigned char rv;
- __asm__ __volatile__ ("inb %1, %0" : "=a" (rv) : "dN" (_port));
- return 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
deleted file mode 100644
index 50baf6f..0000000
--- a/SysCore/lib/time.c
+++ /dev/null
@@ -1,78 +0,0 @@
-#include
-#include
-
-const char* clock_month[] = {0,
- "January", "February", "March", "April", "May", "June",
- "July", "August", "September", "October", "November", "December"};
-const char* clock_weekday[] = {0,
- "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
-
-unsigned char clock_months_len[] = {
- 0,
- 31, // January
- 28, // February
- 31, // March
- 30, // April
- 31, // May
- 30, // June
- 31, // July
- 31, // August
- 30, // September
- 31, // October
- 30, // November
- 31 // December
-};
-
-void _CLOCK_INC(TIME *tim)
-{
- // New minute
- if (++tim->second > 59) {
- tim->second = 0;
- // New hour
- 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
- if ((tim->day==28) && (tim->month==2)) { tim->day++; return; }
- // New month
- if (++tim->day > clock_months_len[tim->month]) {
- tim->day = 1;
- // New year
- if (++tim->month>12) {
- tim->month = 1;
- // New century
- if (++tim->year > 99) { tim->year = 0; tim->century++;}
- }
- }
- }
- }
- }
-}
-
-
-/* ASCTIME Formats: ****************************************************************
-* 1 W = weekday, M = month, D = day, H = Hour, M = Minute, S = Second, Y = year) *
-* A = AM/PM *
-* 2 Use capital letter for one letter/digit; else, use lower *
-* *
-* Example: asctime (time, "Today is: %W3 %D2 %m") *
-* Result: Today is: Mon 22 June *
-************************************************************************************/
-
-/*char* asctime (TIME time, char* format)
-{
- char str[100];
- int l = strlen(format), i;
- unsigned char special = 0;
-
- for (i=0; i
-#include
-#include
-//#include
-//#include "hal/floppy/floppy.h"
-#include "drivers/drivers.h"
-#include
-#include
-#include "memory/mmngr_ph.h"
-#include "memory/mmngr_vi.h"
-#include "video/vga03h.h"
-
-#include
-
-// format of a memory region
-typedef struct {
- 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[] = {
- "",
- "Available", //memory_region.type==0
- "Reserved", //memory_region.type==1
- "ACPI Reclaim", //memory_region.type==2
- "ACPI NVS Memory" //memory_region.type==3
-};*/
-
-extern void _code, _data, _bss, _end;
-
-void k_init(multiboot_info* bootinfo)
-{
- memset(&_bss, 0, &_end - &_bss); // zero the bss
- unsigned int i;
-
- // Start phyiscal memory manager
- unsigned memSize = bootinfo->Memory;
-
- memory_region* memMap = bootinfo->MemoryMapAddress;
- pmmngr_init (memSize, (unsigned)&_end);
-
- // Initialize graphics & HAL
- //graphics_init();
- DriversInstall();
-
- // 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();
-}
-
-
-extern void shell();
-void k_main(unsigned kernel_size, multiboot_info* bootinfo)
-{
- k_init(bootinfo);
- vga03h_install();
-
- shell();
- for(;;);
-}
diff --git a/SysCore/makeall.bat b/SysCore/makeall.bat
deleted file mode 100644
index 1f603a1..0000000
--- a/SysCore/makeall.bat
+++ /dev/null
@@ -1,76 +0,0 @@
-@echo off
-
-set loader_name=loader
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-
-
-@echo ***************** CTA KERNEL *****************
-
-goto KernelEntry
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:KernelEntry
- del objects\%loader_name%.o
- del objects\main.o
-
- @echo.
- @echo Building Kernel entry...
- @echo * Compiling kernel loader...
- %nasm_path%\nasm.exe -f aout -o ./objects/%loader_name%.o %loader_name%.asm
-
- @echo * Compiling kernel main...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./include -c -o ./objects/main.o main.c
- if not exist objects\%loader_name%.o goto error
- if not exist objects\main.o goto error
-
- @echo.
-
-:KernelSTDLIB
- cd lib
- rem call compile.bat
- @echo.
- cd..
-
-:KernelMemoryManager
- cd memory
- rem call compile.bat
- @echo.
- cd..
-
-:KernelDrivers
- cd drivers
- rem 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 ^
-
-:Finish
- cd objects
- @echo Linking...
- del kernel.bin
- %djgpp_path%\ld -T link.ld
- if not exist kernel.bin goto error
-
- @echo.
-
- echo Copying to floppy drive...
- copy KERNEL.BIN A:\KERNEL.CTA >nul
- cd..
\ No newline at end of file
diff --git a/SysCore/makeallh.bat b/SysCore/makeallh.bat
deleted file mode 100644
index 01132bb..0000000
--- a/SysCore/makeallh.bat
+++ /dev/null
@@ -1,76 +0,0 @@
-@echo off
-
-set loader_name=loader
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-
-
-@echo ***************** CTA KERNEL *****************
-
-goto KernelEntry
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:KernelEntry
- del objects\%loader_name%.o
- del objects\main.o
-
- @echo.
- @echo Building Kernel entry...
- @echo * Compiling kernel loader...
- %nasm_path%\nasm.exe -f aout -o ./objects/%loader_name%.o %loader_name%.asm
-
- @echo * Compiling kernel main...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I./include -c -o ./objects/main.o main.c
- if not exist objects\%loader_name%.o goto error
- if not exist objects\main.o goto error
-
- @echo.
-
-:KernelSTDLIB
- cd lib
- call compile.bat
- @echo.
- cd..
-
-:KernelMemoryManager
- cd memory
- call compile.bat
- @echo.
- cd..
-
-:KernelDrivers
- cd drivers
- 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 ^
-
-:Finish
- cd objects
- @echo Linking...
- del kernel.bin
- %djgpp_path%\ld -T link.ld
- if not exist kernel.bin goto error
-
- @echo.
-
- echo Copying to floppy drive...
- copy KERNEL.BIN A:\KERNEL.CTA >nul
- cd..
\ No newline at end of file
diff --git a/SysCore/memory/compile.bat b/SysCore/memory/compile.bat
deleted file mode 100644
index aead81c..0000000
--- a/SysCore/memory/compile.bat
+++ /dev/null
@@ -1,35 +0,0 @@
-@echo off
-
-rem NASM and DJGPP executable paths:
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-set objpath=..\objects
-set incpath=../include
-goto build
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:build
- @echo Building Memory Manager...
-
- del %objpath%\mmngr.o
- del %objpath%\mmngr_ph.o
-
- @echo * Compiling Physical Memory Manager...
- %nasm_path%\nasm.exe -f aout -o %objpath%/mmngr.o mmngr.asm
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/mmngr_ph.o mmngr_ph.c
-
- @echo * Compiling Virtual Memory Manager...
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/mmngr_vi.o mmngr_vi.c
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/mmngr_de.o lib/pde.c
- %djgpp_path%\gcc.exe -Wall -O -fstrength-reduce -fomit-frame-pointer -nostdinc -fno-builtin -I%incpath% -c -o %objpath%/mmngr_te.o lib/pte.c
-:check
- if not exist %objpath%\mmngr_vi.o goto error
- if not exist %objpath%\mmngr_de.o goto error
- if not exist %objpath%\mmngr_te.o goto error
- if not exist %objpath%\mmngr.o goto error
- if not exist %objpath%\mmngr_ph.o goto error
diff --git a/SysCore/memory/lib/pde.c b/SysCore/memory/lib/pde.c
deleted file mode 100644
index 0e07272..0000000
--- a/SysCore/memory/lib/pde.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#include "pde.h"
-
-void pd_entry_add_attrib (pd_entry* entry, unsigned mask) {
- *entry |= mask;
-}
-
-void pd_entry_del_attrib (pd_entry* entry, unsigned mask) {
- *entry &= ~mask;
-}
-
-void pd_entry_set_frame (pd_entry* entry, unsigned address) {
- *entry = (*entry & ~_I86_PDE_FRAME) | address;
-}
-
-unsigned pd_entry_get_frame (pd_entry entry) {
- return entry&_I86_PDE_FRAME;
-}
-
-unsigned char pd_entry_is_present (pd_entry entry) {
- return (entry & _I86_PDE_PRESENT);
-}
-
-unsigned char pd_entry_is_user (pd_entry entry) {
- return (entry & _I86_PDE_USER);
-}
-
-unsigned char pd_entry_is_4mb (pd_entry entry) {
- return (entry & _I86_PDE_4MB);
-}
-
-unsigned char pd_entry_is_writable (pd_entry entry) {
- return (entry & _I86_PDE_WRITABLE);
-}
-
-void pd_entry_enable_global (pd_entry entry) {
-}
\ No newline at end of file
diff --git a/SysCore/memory/lib/pde.h b/SysCore/memory/lib/pde.h
deleted file mode 100644
index fe77351..0000000
--- a/SysCore/memory/lib/pde.h
+++ /dev/null
@@ -1,30 +0,0 @@
-#ifndef __PAGE_DIRECTORY_ENTRY_
-#define __PAGE_DIRECTORY_ENTRY_
-
-enum __PAGE_PDE_FLAGS {
- _I86_PDE_PRESENT = 1,
- _I86_PDE_WRITABLE = 2,
- _I86_PDE_USER = 4,
- _I86_PDE_PWT = 8,
- _I86_PDE_PCD = 0x10,
- _I86_PDE_ACCESSED = 0x20,
- _I86_PDE_DIRTY = 0x40,
- _I86_PDE_4MB = 0x80,
- _I86_PDE_CPU_GLOBAL = 0x100,
- _I86_PDE_LV4_GLOBAL = 0x200,
- _I86_PDE_FRAME = 0x7FFFF000
- };
-
-typedef unsigned pd_entry;
-
-extern void pd_entry_add_attrib (pd_entry* entry, unsigned mask);
-extern void pd_entry_del_attrib (pd_entry* entry, unsigned mask);
-extern void pd_entry_set_frame (pd_entry* entry, unsigned address);
-extern unsigned pd_entry_get_frame (pd_entry entry);
-
-extern unsigned char pd_entry_is_present (pd_entry entry);
-extern unsigned char pd_entry_is_user (pd_entry entry);
-extern unsigned char pd_entry_is_4mb (pd_entry entry);
-extern unsigned char pd_entry_is_writable (pd_entry entry);
-extern void pd_entry_enable_global (pd_entry entry);
-#endif
\ No newline at end of file
diff --git a/SysCore/memory/lib/pte.c b/SysCore/memory/lib/pte.c
deleted file mode 100644
index 5f8bb35..0000000
--- a/SysCore/memory/lib/pte.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "pte.h"
-
-void pt_entry_add_attrib (pt_entry* entry, unsigned mask) {
- *entry |= mask;
-}
-
- void pt_entry_del_attrib (pt_entry* entry, unsigned mask) {
- *entry &= ~mask;
-}
-
- void pt_entry_set_frame (pt_entry* entry, unsigned address) {
- *entry = (*entry & ~_I86_PTE_FRAME) | address;
- }
-
- unsigned pt_entry_get_frame (pt_entry entry) {
- return (entry & _I86_PTE_FRAME);
-}
-
- unsigned char pt_entry_is_present (pt_entry entry) {
- return (entry & _I86_PTE_PRESENT);
- }
-
- unsigned char pt_entry_is_writable (pt_entry entry) {
- return (entry & _I86_PTE_WRITABLE);
-}
-
-
-/*#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
deleted file mode 100644
index 246f007..0000000
--- a/SysCore/memory/lib/pte.h
+++ /dev/null
@@ -1,29 +0,0 @@
-#ifndef __PAGE_TABLE_ENTRY_
-#define __PAGE_TABLE_ENTRY_
-
-enum __PAGE_FLAGS {
- _I86_PTE_PRESENT = 1,
- _I86_PTE_WRITABLE = 2,
- _I86_PTE_USER = 4,
- _I86_PTE_WRITETHROUGH = 8,
- _I86_PTE_NOT_CACHEABLE = 0x10,
- _I86_PTE_ACCESSED = 0x20,
- _I86_PTE_DIRTY = 0x40,
- _I86_PTE_PAT = 0x80,
- _I86_PTE_CPU_GLOBAL = 0x100,
- _I86_PTE_LV4_GLOBAL = 0x200,
- _I86_PTE_FRAME = 0x7FFFF000
- };
-
-typedef unsigned pt_entry;
-
-extern void pt_entry_add_attrib (pt_entry* entry, unsigned mask);
-extern void pt_entry_del_attrib (pt_entry* entry, unsigned mask);
-extern void pt_entry_set_frame (pt_entry* entry, unsigned address);
-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
deleted file mode 100644
index 8c4421d..0000000
--- a/SysCore/memory/mmngr.asm
+++ /dev/null
@@ -1,38 +0,0 @@
-bits 32
-
-global _read_cr0
-_read_cr0:
- mov eax, cr0
- retn
-
-global _write_cr0
-_write_cr0:
- push ebp
- mov ebp, esp
- mov eax, [ebp+8]
- mov cr0, eax
- pop ebp
- retn
-
-global _read_cr3
-_read_cr3:
- mov eax, cr3
- retn
-
-global _write_cr3
-_write_cr3:
- ;xchg bx, bx ; bochs magic breakpoint
- push ebp
- mov ebp, esp
- mov eax, [ebp+8]
- mov cr3, eax
- pop ebp
- retn
-
-global _vmmngr_flush_tbl_entry
-_vmmngr_flush_tbl_entry:
- mov eax, [ebp+8]
- cli
- invlpg [eax]
- sti
- retn
\ No newline at end of file
diff --git a/SysCore/memory/mmngr_ph.c b/SysCore/memory/mmngr_ph.c
deleted file mode 100644
index a3374e8..0000000
--- a/SysCore/memory/mmngr_ph.c
+++ /dev/null
@@ -1,352 +0,0 @@
-/*********************************************************************
- * (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
- * *
- * Physical Memory Manager *
- * ======================= *
- ************************************************************ cta os */
-
-// +==============================================+
-// | HEADERS |
-// +===================================== cta os =+
-#include "mmngr_ph.h"
-
-
-// +==============================================+
-// | DEFINITIONS |
-// +===================================== cta os =+
-#define PMMNGR_BLOCK_SIZE 4096 // block size (4k)
-#define PMMNGR_BLOCK_ALIGN PMMNGR_BLOCK_SIZE // block alignment
-
-
-// +==============================================+
-// | DATA DECLARATIONS |
-// +===================================== cta os =+
-static unsigned _mmngr_memory_size=0; // size of physical memory
-static unsigned _mmngr_used_blocks=0; // number of blocks currently in use
-static unsigned _mmngr_max_blocks=0; // maximum number of available memory blocks
-static unsigned _mmngr_index = 0;
-
-static mstack* _mmngr_memory_stack= 0; // memory stack
-
-
-// +==============================================+
-// | LOCAL FUNCTIONS |
-// +===================================== cta os =+
-inline mstack mstack_pop ()
-{
- mstack temp;
- temp.low = _mmngr_memory_stack[--_mmngr_index].low;
- temp.high = _mmngr_memory_stack[_mmngr_index].high;
- _mmngr_used_blocks++;
-
- _mmngr_memory_stack[_mmngr_index].low = 0xFFFF;
- _mmngr_memory_stack[_mmngr_index].high = 0xFF;
-
- return temp;
-}
-
-inline void mstack_push (const mstack *block)
-{
- if (block->low == 0 && block-> high == 0) return;
-
- _mmngr_memory_stack[_mmngr_index].low = block->low;
- _mmngr_memory_stack[_mmngr_index].high = block->high;
-
- _mmngr_index++;
- _mmngr_used_blocks--;
-}
-
-inline int mstack_test (const mstack *block)
-{
- unsigned i;
- for (i = 0; i < _mmngr_index; i++)
- if (_mmngr_memory_stack[i].low == block->low && _mmngr_memory_stack[i].high == block->high)
- return (int) i;
-
- return -1;
-}
-
-inline int mstack_qsort_cmp (mstack a, mstack b)
-{
- return (a.high == b.high) ? (int)a.low - (int)b.low : (int)a.high - (int)b.high;
-}
-
-void mstack_qsort(int beg, int end)
-{
-
- mstack piv; mstack tmp;
-
- int l,r,p;
-
- while (beg 0)) r--;
-
- if (l>r) break;
-
- tmp.low = _mmngr_memory_stack[l].low;
- tmp.high = _mmngr_memory_stack[l].high;
-
- _mmngr_memory_stack[l].low = _mmngr_memory_stack[r].low;
- _mmngr_memory_stack[l].high = _mmngr_memory_stack[r].high;
-
- _mmngr_memory_stack[r].low = tmp.low;
- _mmngr_memory_stack[r].high = tmp.high;
-
- if (p==r) p=l;
-
- l++; r--;
- }
-
- _mmngr_memory_stack[p].low = _mmngr_memory_stack[r].low;
- _mmngr_memory_stack[p].high = _mmngr_memory_stack[r].high;
-
- _mmngr_memory_stack[r].low = piv.low;
- _mmngr_memory_stack[r].high = piv.high;
- r--;
-
- // Recursion on the shorter side & loop (with new indexes) on the longer
- if ((r-beg)<(end-l)) {
- mstack_qsort(beg, r);
- beg=l;
- }
- else {
- mstack_qsort(l, end);
- end=r;
- }
- }
-}
-
-
-// +==============================================+
-// | DEBUGGING FUNCTIONS |
-// +===================================== cta os =+
-/*void print_stack()
-{
- int i;
- for (i = 0; i < _mmngr_index; i++) \n\r (" %u", _mmngr_memory_stack[i].low);
-}
-extern char getch();*/
-
-// +==============================================+
-// | INITIALISATION FUNCTIONS |
-// +===================================== cta os =+
-void pmmngr_init (unsigned memSize, unsigned stack) {
-
- _mmngr_memory_size = memSize;
- _mmngr_memory_stack = (mstack*) stack;
- _mmngr_max_blocks = (_mmngr_memory_size*1024) / PMMNGR_BLOCK_SIZE;
- _mmngr_used_blocks = _mmngr_max_blocks;
- _mmngr_index = 0;
-
- // By default, all of memory is in use
-}
-
-void pmmngr_init_region (unsigned base, unsigned size) {
-
- mstack block;
-
-
- unsigned int count = size / PMMNGR_BLOCK_SIZE;
- unsigned int start = base / PMMNGR_BLOCK_SIZE;
-
- for (; count!=0; count--) {
- block.low = (start + count) & 0xFFFF;
- block.high = ((start + count) << 16) & 0xFF;
- mstack_push(&block);
-
- }
-
-}
-
-void pmmngr_deinit_region (unsigned base, unsigned size) {
- unsigned int start = base / PMMNGR_BLOCK_SIZE;
- unsigned int count = size / PMMNGR_BLOCK_SIZE;
- int temp;
-
- unsigned int i;
- unsigned int j;
-
- // Find free blocks in the area and zero them
- for (i = 0; i < _mmngr_index; i++) {
- temp = (_mmngr_memory_stack[i].high << 16) | _mmngr_memory_stack[i].low;
- if (temp >=start && temp < start+count)
- { _mmngr_memory_stack[i].high = 0;
- _mmngr_memory_stack[i].low = 0;
- }
- }
-
- // Eliminate zero blocks
- for (i = 0; i<_mmngr_index; i++)
- if (_mmngr_memory_stack[i].high == 0 && _mmngr_memory_stack[i].low == 0)
- {
- // Find next non-zero
- for (j = i; _mmngr_memory_stack[j].high == 0 && _mmngr_memory_stack[j].low == 0; j++)
- if (j == _mmngr_index-1) {
- j = 0; break; }
-
- if (j == 0) {
- _mmngr_index = i;
- break;
- }
-
- _mmngr_memory_stack[i].high = _mmngr_memory_stack[j].high;
- _mmngr_memory_stack[i].low = _mmngr_memory_stack[j].low;
- _mmngr_memory_stack[j].high = 0;
- _mmngr_memory_stack[j].low = 0;
-
- }
-}
-
-
-// +==============================================+
-// | MEMORY MANAGING FUNCTIONS |
-// +===================================== cta os =+
-unsigned char pmmngr_test_block (unsigned block)
-{
- mstack temp;
- temp.low = block & 0xFFFF;
- temp.high = (block>>16) & 0xFF;
-
- return (mstack_test(&temp) == -1)? 0 : 1;
-}
-
-void pmmngr_free_block(void* address)
-{
- // Calculate block
- mstack block;
- unsigned temp = (unsigned)address / PMMNGR_BLOCK_SIZE;
- block.low = temp & 0xFFFF;
- block.high = (temp>>16) & 0xFF;
-
- // Push it
- mstack_push (&block);
-}
-
-void pmmngr_free_blocks (unsigned base, unsigned size)
-{
- mstack start, end, i;
-
- // 4k align
- base /= PMMNGR_BLOCK_SIZE;
- size /= PMMNGR_BLOCK_SIZE;
-
- // Calculate blocks
- start.low = base & 0xFFFF;
- start.high = (base >> 16) & 0xFF;
- end.low = (base + size) & 0xFFFF;
- end.high = ((base + size)>>16) & 0xFF;
-
- for (i.low = start.low, i.high = start.high; // i = start
- i.low < end.low || i.high < end.high;) // i != end
- {
- // only push if block is used
- if (mstack_test(&i) == -1) mstack_push(&i);
-
- // increment i.high
- if (i.low == 0xFFFF) {
- i.low = 0; i.high++;
- }
- else i.low++;
- }
-}
-
-void* pmmngr_alloc_block()
-{
- if (_mmngr_index == 0) return 0;// Out of memory
- // pop a block
- mstack block = mstack_pop();
-
- // Calculate and return address;
- void* address;
- unsigned temp = block.low | (block.high<<16);
- address = (void *)(temp * PMMNGR_BLOCK_SIZE);
-
- return address;
-}
-
-void* pmmngr_alloc_blocks (unsigned blocks)
-{
- // Less than 2 blocks requested
- if (blocks == 0) return 0;
- if (blocks == 1) return pmmngr_alloc_block();
-
- // Sort the stack for the next step
- mstack_qsort(0, (int)_mmngr_index);
-
- int i = (int) _mmngr_index-1; // i = counter
- int l = 1; // l = number of consecutive blocks
- unsigned temp; // temp = temporary storage
- unsigned prev = _mmngr_memory_stack[i].low | (_mmngr_memory_stack[i].high<<16); --i;
-
- // Search consecutive blocks
- for (i = 0; i < _mmngr_index; i++) {
- temp = _mmngr_memory_stack[i].low | (_mmngr_memory_stack[i].high<<16);
-
- 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-l+1) * PMMNGR_BLOCK_SIZE);
- }
-
- prev = temp;
- }
-
- return 0; // Could not find so many free blocks
-}
-
-
-
-
-// +==============================================+
-// | GET DATA FUNCTIONS |
-// +===================================== cta os =+
-unsigned pmmngr_get_memory_size () {
- return _mmngr_memory_size;
-}
-
-unsigned pmmngr_get_block_count () {
- return _mmngr_max_blocks;
-}
-
-unsigned pmmngr_get_use_block_count () {
- return _mmngr_used_blocks;
-}
-
-unsigned pmmngr_get_free_block_count () {
- return _mmngr_index;
-}
-
-unsigned pmmngr_get_block_size () {
- return PMMNGR_BLOCK_SIZE;
-}
-
-
-// +==============================================+
-// | PAGING RELATED FUNCTIONS |
-// +===================================== cta os =+
-void pmmngr_paging_enable (unsigned char b) {
- unsigned temp;
-
- temp = read_cr0();
- // Enable
- if (b) temp |= 0x80000000;
- else temp &= ~0x80000000;
-
- write_cr0(temp);
-}
-
-unsigned char pmmngr_is_paging () {
- unsigned temp = read_cr0();
- return ((temp&0x80000000)>0);
-}
\ No newline at end of file
diff --git a/SysCore/memory/mmngr_ph.h b/SysCore/memory/mmngr_ph.h
deleted file mode 100644
index d80425c..0000000
--- a/SysCore/memory/mmngr_ph.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef _MMNGR_PHYS_H
-#define _MMNGR_PHYS_H
-
-#define pmmngr_load_PDBR(addr) write_cr3(addr)
-#define pmmngr_get_PDBR() read_cr3()
-
-// physical address
-typedef unsigned physical_addr;
-
-struct memory_stack_entry{
- unsigned short low;
- unsigned char high;
-} __attribute__ ((__packed__));
-typedef struct memory_stack_entry mstack;
-
-// CR registers r/w operations
-extern unsigned read_cr0();
-extern unsigned read_cr3();
-extern void write_cr0(unsigned data);
-extern void write_cr3(unsigned data);
-
-// Free/Alloc memory block(s)
-extern void pmmngr_free_block(void* address);
-extern void pmmngr_free_blocks(unsigned base, unsigned size);
-extern void* pmmngr_alloc_block ();
-extern void* pmmngr_alloc_blocks (unsigned blocks);
-
-// De/Initialisation routines
-extern void pmmngr_init (unsigned memSize, unsigned stack);
-extern void pmmngr_init_region (unsigned base, unsigned size);
-extern void pmmngr_deinit_region (unsigned base, unsigned size);
-
-// Useful information
-extern unsigned pmmngr_get_memory_size (); // returns amount of physical memory the manager is set to use
-extern unsigned pmmngr_get_use_block_count (); // returns number of blocks currently in use
-extern unsigned pmmngr_get_free_block_count (); // returns number of blocks not in use
-extern unsigned pmmngr_get_block_count (); // returns number of memory blocks
-extern unsigned pmmngr_get_block_size (); // returns default memory block size in unsigned chars
-extern unsigned char pmmngr_test_block (unsigned block);
-
-// Paging
-extern void pmmngr_paging_enable (unsigned char b); // enable or disable paging
-extern unsigned char pmmngr_is_paging (); // test if paging is enabled
-
-extern void print_stack();
-
-#endif
diff --git a/SysCore/memory/mmngr_vi.c b/SysCore/memory/mmngr_vi.c
deleted file mode 100644
index 21c2363..0000000
--- a/SysCore/memory/mmngr_vi.c
+++ /dev/null
@@ -1,193 +0,0 @@
-// +==============================================+
-// | HEADERS |
-// +===================================== cta os =+
-#include "mmngr_vi.h"
-#include "mmngr_ph.h"
-
-// +==============================================+
-// | 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);
-
-// +==============================================+
-// | PAGE FUNCTIONS |
-// +===================================== cta os =+
-unsigned char vmmngr_alloc_page (pt_entry* entry)
-{
- void* p = pmmngr_alloc_block ();
- if (!p) return 0;
-
- pt_entry_set_frame(entry, (unsigned)p);
- pt_entry_add_attrib (entry, _I86_PTE_PRESENT);
-
- return 1;
-}
-
-void vmmngr_free_page (pt_entry* entry)
-{
- void* p = (void*) pt_entry_get_frame(*entry);
-
- if (p) pmmngr_free_block (p);
-
- pt_entry_del_attrib (entry, _I86_PTE_PRESENT);
-}
-
-
-// +==============================================+
-// | PAGE TABLE FUNCTIONS |
-// +===================================== cta os =+
-inline void vmmngr_ptable_clear(ptable* p)
-{
- if(p) memset ((unsigned char*)p, 0, sizeof(ptable));
-}
-
-inline unsigned vmmngr_ptable_virt_to_index (unsigned addr)
-{
- return (addr >= PTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
-}
-
-inline pt_entry* vmmngr_ptable_lookup_entry (ptable* p, unsigned addr)
-{
- if (p) return &p->m_entries[vmmngr_ptable_virt_to_index(addr)];
- return 0;
-}
-
-
-// +==============================================+
-// | PAGE DIRECTORY FUNCTIONS |
-// +===================================== cta os =+
-inline void vmmngr_pdirectory_clear(pdirectory* dir)
-{
- if(dir) memset ((unsigned char*)dir, 0, sizeof(pdirectory));
-}
-
-inline unsigned vmmngr_pdirectory_virt_to_index (unsigned addr)
-{
- return (addr > DTABLE_ADDR_SPACE_SIZE) ? 0 : addr/PAGE_SIZE;
-}
-
-inline pd_entry* vmmngr_pdirectory_lookup_entry (pdirectory* dir, unsigned addr)
-{
- if (dir) return &dir->m_entries[vmmngr_ptable_virt_to_index(addr)];
- return 0;
-}
-
-// +==============================================+
-// | VIRTUAL MEMORY MANAGER |
-// +===================================== cta os =+
-inline unsigned char vmmngr_switch_pdirectory (pdirectory* dir)
-{
- if (!dir) return 0;
- _current_directory = dir;
-
- write_cr3 (_current_page_directory_base_register);
- return 1;
-}
-
-pdirectory* vmmngr_get_directory() {
- return _current_directory;
-}
-
-
-unsigned char vmmngr_map_page (unsigned phys, unsigned virt)
-{
- pdirectory* dir = _current_directory; // get page directory
- pd_entry* e = &dir->m_entries [PAGE_DIRECTORY_INDEX (virt)]; // get 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
- virt = 0; frame = 0;
- for (i = 0; i < 1024; i++, virt+=4096, frame += 4096)
- {
- 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);
- }
-
- // 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;
-
- // Switch to our page directory
- vmmngr_switch_pdirectory (dir);
-
- // 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
deleted file mode 100644
index 765a336..0000000
--- a/SysCore/memory/mmngr_vi.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef __MEMORY_MANAGER_VIRTUAL__
-#define __MEMORY_MANAGER_VIRTUAL__
-
-#include "lib/pde.h"
-#include "lib/pte.h"
-
-#define PAGES_PER_TABLE 1024
-#define PAGES_PER_DIR 1024
-
-typedef unsigned virtual_address;
-
-typedef struct {
- pt_entry m_entries[PAGES_PER_TABLE];
-} ptable ;
-
-typedef struct {
- pd_entry m_entries[PAGES_PER_DIR];
-} pdirectory ;
-
-//extern pdirectory* _current_directory;
-
-extern void vmmngr_flush_tbl_entry (unsigned addr);
-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/CONIO.O b/SysCore/objects/CONIO.O
deleted file mode 100644
index 589edf5..0000000
Binary files a/SysCore/objects/CONIO.O and /dev/null differ
diff --git a/SysCore/objects/CTYPE.O b/SysCore/objects/CTYPE.O
deleted file mode 100644
index d29f25a..0000000
Binary files a/SysCore/objects/CTYPE.O and /dev/null differ
diff --git a/SysCore/objects/LOADER.O b/SysCore/objects/LOADER.O
deleted file mode 100644
index 14e7e1c..0000000
Binary files a/SysCore/objects/LOADER.O and /dev/null differ
diff --git a/SysCore/objects/MAIN.O b/SysCore/objects/MAIN.O
deleted file mode 100644
index aaf55d4..0000000
Binary files a/SysCore/objects/MAIN.O and /dev/null differ
diff --git a/SysCore/objects/MMNGR.O b/SysCore/objects/MMNGR.O
deleted file mode 100644
index bc7bef7..0000000
Binary files a/SysCore/objects/MMNGR.O and /dev/null differ
diff --git a/SysCore/objects/MMNGR_PH.O b/SysCore/objects/MMNGR_PH.O
deleted file mode 100644
index 5235d2c..0000000
Binary files a/SysCore/objects/MMNGR_PH.O and /dev/null differ
diff --git a/SysCore/objects/SHELL.O b/SysCore/objects/SHELL.O
deleted file mode 100644
index 8a47567..0000000
Binary files a/SysCore/objects/SHELL.O and /dev/null differ
diff --git a/SysCore/objects/STDLIB.O b/SysCore/objects/STDLIB.O
deleted file mode 100644
index eb82997..0000000
Binary files a/SysCore/objects/STDLIB.O and /dev/null differ
diff --git a/SysCore/objects/STRING.O b/SysCore/objects/STRING.O
deleted file mode 100644
index 86b2567..0000000
Binary files a/SysCore/objects/STRING.O and /dev/null differ
diff --git a/SysCore/objects/SYSTEM.O b/SysCore/objects/SYSTEM.O
deleted file mode 100644
index ef974d6..0000000
Binary files a/SysCore/objects/SYSTEM.O and /dev/null differ
diff --git a/SysCore/objects/TIME.O b/SysCore/objects/TIME.O
deleted file mode 100644
index 91fd98d..0000000
Binary files a/SysCore/objects/TIME.O and /dev/null differ
diff --git a/SysCore/objects/compile.bat b/SysCore/objects/compile.bat
deleted file mode 100644
index bd60274..0000000
--- a/SysCore/objects/compile.bat
+++ /dev/null
@@ -1,16 +0,0 @@
-@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:\mingw\bin
-
-@echo on
-ld -T link.ld
-@echo off
-@echo.
-@echo Done!
-
-@pause
-copy KERNEL.BIN A:\KERNEL.CTA
\ No newline at end of file
diff --git a/SysCore/objects/drivers/BSOD.o b/SysCore/objects/drivers/BSOD.o
deleted file mode 100644
index 67d5d9b..0000000
Binary files a/SysCore/objects/drivers/BSOD.o and /dev/null differ
diff --git a/SysCore/objects/drivers/cpu.o b/SysCore/objects/drivers/cpu.o
deleted file mode 100644
index e4c4489..0000000
Binary files a/SysCore/objects/drivers/cpu.o and /dev/null differ
diff --git a/SysCore/objects/drivers/dma.o b/SysCore/objects/drivers/dma.o
deleted file mode 100644
index 3fb8978..0000000
Binary files a/SysCore/objects/drivers/dma.o and /dev/null differ
diff --git a/SysCore/objects/drivers/drivers.o b/SysCore/objects/drivers/drivers.o
deleted file mode 100644
index 9485c04..0000000
Binary files a/SysCore/objects/drivers/drivers.o and /dev/null differ
diff --git a/SysCore/objects/drivers/fat.o b/SysCore/objects/drivers/fat.o
deleted file mode 100644
index 93f3741..0000000
Binary files a/SysCore/objects/drivers/fat.o and /dev/null differ
diff --git a/SysCore/objects/drivers/fat12.o b/SysCore/objects/drivers/fat12.o
deleted file mode 100644
index 17658c2..0000000
Binary files a/SysCore/objects/drivers/fat12.o and /dev/null differ
diff --git a/SysCore/objects/drivers/floppy.o b/SysCore/objects/drivers/floppy.o
deleted file mode 100644
index 022f877..0000000
Binary files a/SysCore/objects/drivers/floppy.o and /dev/null differ
diff --git a/SysCore/objects/drivers/gdt.o b/SysCore/objects/drivers/gdt.o
deleted file mode 100644
index 0b0ac12..0000000
Binary files a/SysCore/objects/drivers/gdt.o and /dev/null differ
diff --git a/SysCore/objects/drivers/gdt_asm.o b/SysCore/objects/drivers/gdt_asm.o
deleted file mode 100644
index 2a3f089..0000000
Binary files a/SysCore/objects/drivers/gdt_asm.o and /dev/null differ
diff --git a/SysCore/objects/drivers/idt.o b/SysCore/objects/drivers/idt.o
deleted file mode 100644
index 9480815..0000000
Binary files a/SysCore/objects/drivers/idt.o and /dev/null differ
diff --git a/SysCore/objects/drivers/idt_asm.o b/SysCore/objects/drivers/idt_asm.o
deleted file mode 100644
index c03174e..0000000
Binary files a/SysCore/objects/drivers/idt_asm.o and /dev/null differ
diff --git a/SysCore/objects/drivers/irq.o b/SysCore/objects/drivers/irq.o
deleted file mode 100644
index abd0270..0000000
Binary files a/SysCore/objects/drivers/irq.o and /dev/null differ
diff --git a/SysCore/objects/drivers/irq_asm.o b/SysCore/objects/drivers/irq_asm.o
deleted file mode 100644
index 402a397..0000000
Binary files a/SysCore/objects/drivers/irq_asm.o and /dev/null differ
diff --git a/SysCore/objects/drivers/isrs.o b/SysCore/objects/drivers/isrs.o
deleted file mode 100644
index 797e8ed..0000000
Binary files a/SysCore/objects/drivers/isrs.o and /dev/null differ
diff --git a/SysCore/objects/drivers/isrs_asm.o b/SysCore/objects/drivers/isrs_asm.o
deleted file mode 100644
index 4179b13..0000000
Binary files a/SysCore/objects/drivers/isrs_asm.o and /dev/null differ
diff --git a/SysCore/objects/drivers/keyboard.o b/SysCore/objects/drivers/keyboard.o
deleted file mode 100644
index 6882fd2..0000000
Binary files a/SysCore/objects/drivers/keyboard.o and /dev/null differ
diff --git a/SysCore/objects/drivers/pic.o b/SysCore/objects/drivers/pic.o
deleted file mode 100644
index 6f618c6..0000000
Binary files a/SysCore/objects/drivers/pic.o and /dev/null differ
diff --git a/SysCore/objects/drivers/pit.o b/SysCore/objects/drivers/pit.o
deleted file mode 100644
index 51514da..0000000
Binary files a/SysCore/objects/drivers/pit.o and /dev/null differ
diff --git a/SysCore/objects/mmngr_de.o b/SysCore/objects/mmngr_de.o
deleted file mode 100644
index ae55cba..0000000
Binary files a/SysCore/objects/mmngr_de.o and /dev/null differ
diff --git a/SysCore/objects/mmngr_te.o b/SysCore/objects/mmngr_te.o
deleted file mode 100644
index a8a6d77..0000000
Binary files a/SysCore/objects/mmngr_te.o and /dev/null differ
diff --git a/SysCore/objects/mmngr_vi.o b/SysCore/objects/mmngr_vi.o
deleted file mode 100644
index d81956d..0000000
Binary files a/SysCore/objects/mmngr_vi.o and /dev/null differ
diff --git a/SysCore/objects/video/VGA03H.O b/SysCore/objects/video/VGA03H.O
deleted file mode 100644
index 9b66a1f..0000000
Binary files a/SysCore/objects/video/VGA03H.O and /dev/null differ
diff --git a/SysCore/shell/apps.h b/SysCore/shell/apps.h
deleted file mode 100644
index 1d27fd8..0000000
--- a/SysCore/shell/apps.h
+++ /dev/null
@@ -1,207 +0,0 @@
-#define hex(x) (x < 10) ? x+'0' : x-10+'a'
-
-const char *apps_lst[] = {
-/*0*/ "",
-/*1*/ "reboot",
-/*2*/ "osver",
-/*3*/ "time",
-/*4*/ "place",
-/*5*/ "cls",
-/*6*/ "dump",
-/*7*/ "help",
-/*8*/ "cpuid",
-/*9*/ "memstat",
-/*A*/ "read",
-/*B*/ "mount",
-/*C*/ "write"
- };
-int apps_count = 13;
-
-
-void apps_osver()
-{
- cprintf ("%#0BC%#0CT%#0AA %#0F32bit Operating System v0.1\n\r");
- cprintf ("(c) CTA 2010\n\r");
-}
-
-void apps_time()
-{
- TIME _internal_clock = ClockGetTime();
- 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()
-{
- cprintf ("%#0FOn your desk, %#07if you didn't notice... \n\r");
-}
-
-void apps_clrscr()
-{
- clrscr();
-}
-
-void apps_dump(const int pn, const char* param[])
-{
- unsigned pause=0, i=0;
- if (pn<3) {
- cprintf ("%#0CCorrect syntax: %#07dump %#0F[start_address] %#0F[end_address] %#0C(in hex)\n\r");
- return;
- }
-
- if (pn==4 && strcmp(param[3], "--p") == 0)
- pause=1;
-
- unsigned char *start, *end;
- start = (unsigned char *) atox (param[1]);
- end = (unsigned char *) atox (param[2]);
- unsigned char* count;
-
- while (start <= end) {
- cprintf("%#0D%x%#07: ", (unsigned int) start);
-
- for (count = start; count < start+16; count++) {
- if (*count == 0) cprintf ("%#0800 ");
- else cprintf ("%#0F%c%c ", hex(*count/16), hex(*count%16));
- }
-
- cprintf(" ");
- for (count = start; count < start+16; count++) {
- if (*count < 32) cprintf(".");
- else cprintf("%#0A%c", *count);
- }
-
- cprintf("\n\r");
- start+=16; i++;
-
- if ((i%22 == 0) && (pause==1)) {
- cprintf("\n\r%#08Press %#07any key %#08to continue scrolling, %#07Esc %#08to exit.");
- KeyboardKey t;
- t = GetKey();
- if (t.Scancode == KeyboardKeyEscape) return;
- cprintf("\n\n\r");
- }
- }
-}
-
-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;
-
- for (i = 0; i < apps_count; i++)
- arr[i] = i;
-
- qsort((void*)arr, apps_count, sizeof(short), apps_help_sort);
-
- if (pn==1) {
- 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 "../drivers/drivers.h"
-#include "../drivers/cpu/cpu.h"
-#include
-#include
-#include
-#include
-#include "../memory/mmngr_ph.h"
-#include "../drivers/filesys/fat.h"
-#include "apps.h"
-
-
-void shell()
-{
- apps_osver();
- char str[256];
- char* param[16];
- int i, len, params=0;
-
- for (;;) {
- cprintf("%#0A\n] ");
- cgets(str, 256);
- cprintf("\n\r");
-
- 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
-
-
- 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++;
- }
- }
-
- 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
deleted file mode 100644
index f879fe3..0000000
--- a/SysCore/video/color/color.h
+++ /dev/null
@@ -1,66 +0,0 @@
-#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
deleted file mode 100644
index 3197f6e..0000000
--- a/SysCore/video/compile.bat
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo off
-
-rem NASM and DJGPP executable paths:
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-set objpath=..\objects\video
-set incpath=../include
-
-@echo Building Video Drivers...
-
-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 vga03h.o vga03h.c
- if not exist vga03h.o goto error
- xcopy /Y *.o %objpath% >nul
- del *.o
-
\ No newline at end of file
diff --git a/SysCore/video/vga.h b/SysCore/video/vga.h
deleted file mode 100644
index 451a85a..0000000
--- a/SysCore/video/vga.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#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
deleted file mode 100644
index f7917cf..0000000
--- a/SysCore/video/vga03h.c
+++ /dev/null
@@ -1,30 +0,0 @@
-//#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
deleted file mode 100644
index c9a91b0..0000000
--- a/SysCore/video/vga03h.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#ifndef __DEFAULT__TEXT__MODE__H__
-#define __DEFAULT__TEXT__MODE__H__
-
-void vga03h_install();
-
-
-#endif
\ No newline at end of file
diff --git a/VIDEO.CPP b/VIDEO.CPP
deleted file mode 100644
index ecfb604..0000000
--- a/VIDEO.CPP
+++ /dev/null
@@ -1,476 +0,0 @@
-/*****************************************************************
- * INCLUDE DIRECTIVES *
- *****************************************************************/
-#include
-#include
-#include
-#include
-#include
-
-/*****************************************************************
- * UNIVERSAL DATA TYPES, CONSTANTS *
- *****************************************************************/
-typedef unsigned char byte;
-
-typedef struct {
- int X, Y;
-} Point;
-
-
-#define DEBUG 1
-#define LOG(x) printf(x);
-
-
-/*****************************************************************
- * VIDEO DRIVER *
- *****************************************************************/
-
-// Used variables
-byte far* VGAMem = (byte far *)0xA0000000L;
-byte* Buffer;
-
-// Used by cursor. Need to be initialized here
-int SaveX, SaveY;
-
-// Change video mode routine
-void VideoMode(byte mode)
-{
- asm {
- mov ah, 0
- mov al, mode
- int 0x10
- }
-}
-
-// Initialize graphic mode 0x13, use duble buffering if possible
-void InitGraph()
-{
- Buffer = (byte*)malloc(320 * 200);
-
- if (Buffer) memset(Buffer, 0, 320*200);
-
- #if DEBUG == 1
- if (!Buffer) LOG("Error: Not enough memory. Double buffering disabled.");
- #endif
-
- VideoMode(0x13);
-
- SaveX = SaveY = 400;
-}
-
-// Go back to normal text mode 0x03
-void ExitGraph()
-{
- free(Buffer);
- VideoMode(0x03);
-}
-
-// Put a pixel in specified position. Does not put it on the screen if double buffering.
-void PutPixel(int x, int y, int c)
-{
- if (y >= 200 || x >= 320) return;
-
- if (Buffer) Buffer[y*320 + x] = c;
- else VGAMem[y*320 + x] = c;
-}
-
-// Get a pixel from screen/double buffer
-byte GetPixel(int x, int y)
-{
- return (Buffer) ? Buffer[320*y + x] : VGAMem[320*y+x];
-}
-
-// Put double buffer on the screen. Should be called after e.g. displaying something new.
-void Update()
-{
- if (Buffer) memcpy(VGAMem, Buffer, 320*200);
-}
-
-
-
-
-/*****************************************************************
- * MOUSE DRIVER *
- *****************************************************************/
-
-// Defines cursor size and array
-#define cX 7
-#define cY 7
-byte Cursor[cY][cX] = { {1, 0, 0, 1, 1, 1, 1},
- {1, 0, 0, 1, 0, 0, 0},
- {1, 0, 0, 1, 0, 0, 0},
- {1, 1, 1, 1, 1, 1, 1},
- {0, 0, 0, 1, 0, 0, 1},
- {0, 0, 0, 1, 0, 0, 1},
- {1, 1, 1, 1, 0, 0, 1}};
-
-// Save what is under the cursor
-byte Save[cY][cX];
-void SaveUnder(int x, int y)
-{
- for (int i = 0; i < cX; i++)
- for (int j = 0; j < cY; j++)
- Save[i][j] = GetPixel(i+x, j+y);
-
- SaveX = x; SaveY = y;
-}
-
-// Restore what was under the cursor
-void RestoreUnder ()
-{
- for (int i = 0; i < cX; i++)
- for (int j = 0; j < cY; j++)
- PutPixel(i+SaveX, j+SaveY, Save[j][i]);
-}
-
-// Display the cursor
-void PutCursor(int x, int y, byte c)
-{
- // restore old
- RestoreUnder();
- SaveUnder(x, y);
- for (int i = 0; i < cX; i++)
- for (int j = 0; j < cY; j++)
- {
- Save[j][i] = GetPixel(i+x, j+y);
- if (Cursor[j][i] == 1) PutPixel(i+x, j+y, Cursor[j][i] * c);
- if (Cursor[j][i] == 2) PutPixel(i+x, j+y, 256-(Cursor[j][i] * c));
-
- }
-
-}
-
-// Check if mouse cursor is in specified area
-unsigned char MouseIsInArea (int MouseX, int MouseY, int left, int top, int right, int bottom)
-{
- if (MouseX >= left && MouseX <= right
- && MouseY >= top && MouseY <= bottom) return 1;
- return 0;
-}
-
-// Bit masks for mouse buttons
-const byte MouseLeftB = 1, MouseRightB = 2, MouseMiddleB = 4;
-
-// Initialize mouse driver
-int MouseInit(int *NumberOfButtons)
-{
- int r;
- int tmp;
- asm {
- mov ax, 0
- int 0x33
- mov tmp, ax
- mov r, bx
- }
-
- *NumberOfButtons = tmp;
- return r;
-}
-
-// Get the status of the mouse (buttons, etc)
-byte MouseGetStatus()
-{
- byte re;
- asm {
- mov ax, 3
- int 0x33
- mov re, bl
- }
- return re;
-}
-
-// Get movement
-void MouseGetDirection (int *x, int *y)
-{
- int tx, ty;
- asm {
- mov ax, 0x0B
- int 0x33
- mov tx, cx
- mov ty, dx
- }
- *x = tx; *y = ty;
-}
-
-
-
-/*****************************************************************
- * FONT MANAGER *
- *****************************************************************/
-
-class Font {
- char Path[256];
- ifstream file;
-
- public:
- byte Error;
- Font(char* c);
- Font();
-
- ~Font() {
- file.close();
- }
-
- Point PutChar(int x, int y, char c);
-
- void PutString(int x, int y, char* str);
-
- void OpenNew(char* c);
-};
-
-Font::Font(char* c) {
- int len = strlen(c);
-
- for (int i = 0; i < len && i<256; i++)
- Path[i] = c[i];
-
- file.open(c);
-
- if (!file) Error = 1;
- else Error = 0;
-}
-
-Font::Font() {
- Path[0] = 0;
-}
-
-void Font::OpenNew(char* c)
-{
- int len = strlen(c);
- for (int i = 0; i < len && i<256; i++)
- Path[i] = c[i];
- file.open(c);
- if (!file) Error = 1;
- else Error = 0;
-}
-
-
-Point Font::PutChar(int x, int y, char c)
-{
- Point ret;
- int cSizeX, cSizeY;
- if (Error) return ret;
-
- int tmp = 0;
- file.seekg(0, ios::beg);
-
- for (int i = 0; i < c; i++) {
- file>>cSizeX>>cSizeY;
- for (int j = 0; j < cSizeX * cSizeY; j++) file>>tmp;
- }
-
- file>>cSizeX>>cSizeY;
- for (int yy=0; yy>tmp;
- if (tmp) PutPixel(xx+x, yy+y, c);
- }
-
- ret.X = cSizeX;
- ret.Y = cSizeY;
- return ret;
-}
-
-void Font::PutString(int x, int y, char* str)
-{
- if (Error) return;
-
- Point temp; int sum = 0;
-
- // Use a default kerning value of 1 pixels.
- int len = strlen(str);
- for (int i=0; i < len; i++) {
-
- temp = PutChar(x+sum, y, str[i]);
- sum += temp.X+1;
- }
-}
-
-
-
-
-
-/*****************************************************************
- * WINDOW MANAGER *
- *****************************************************************/
-
-class Window
-{
- byte Visible;
-
- char Title[256];
- Font Fnt;
-
-public:
- Point Pos, Size;
-
- Window(char* s);
- Window();
- Window(Point pos, Point siz, char* s);
-
- void Show();
- void Hide();
-
- void DrawPixel(int x, int y, int c)
- {
- if (x < this->Size.X && y < this->Size.Y)
- PutPixel (x+this->Pos.X, y+this->Pos.Y, c);
- }
-
- void Update();
-
- void MouseAction(int X, int Y, byte Buttons)
- {
- if (Buttons & MouseLeftB) DrawPixel(5,5, 150);
- else DrawPixel(5, 5, 0);
-
- }
-
-
-};
-
-Window::Window(char* s)
-{
- memcpy(Title, s, 256);
- Visible = 0;
- Size.X = 0; Size.Y = 0; Pos.X = 0; Pos.Y = 0;
-
- Fnt.OpenNew("font.txt");
-}
-
-Window::Window()
-{
- Visible = 0;
- Size.X = 0; Size.Y = 0; Pos.X = 0; Pos.Y = 0;
- Title[0] = 0;
-
- Fnt.OpenNew("font.txt");
-}
-
-Window::Window(Point pos, Point siz, char* s)
-{
- Visible = 0;
- Size = siz; Pos = pos;
- memcpy(Title, s, 256);
-}
-
-
-void Window::Show()
-{
- Visible = 1;
- for (int i = Pos.X; i < Size.X + Pos.X; i++) {
- for (int j = Pos.Y+10; j < Size.Y + Pos.Y; j++)
- PutPixel(i, j, 7);
-
- for (j = Pos.Y; j < Pos.Y+10; j++)
- PutPixel(i, j, 12);
- }
- Fnt.PutString(Pos.X+3, Pos.Y+2, Title);
-}
-
-void Window::Hide()
-{
- Visible = 0;
-
- for (int i = Pos.X; i < Size.X + Pos.X; i++)
- for (int j = Pos.Y; j < Size.Y + Pos.Y; j++)
- PutPixel(i, j, 0);
-}
-
-
-
-/*****************************************************************
- * MAIN FUNCTION *
- *****************************************************************/
-
-int main()
-{
- int a;
- InitGraph();
- MouseInit(&a);
-
- Window alpha("AaBbCcXyZhSgGZz@,HEL");
- alpha.Pos.X = 320/2;
- alpha.Pos.Y = 200/2;
- alpha.Size.X = 140;
- alpha.Size.Y = 80;
-
-
- int MouseX = 320/2, MouseY = 200/2;
- int dx, dy, oldX, oldY;
- int Col = 15;
-
- for (;;)
- {
- if (oldX != MouseX || oldY != MouseY) {
- memset (Buffer, 0, 320*200);
- alpha.Show();
- PutCursor(MouseX, MouseY, Col);
-
-
- Update();
-
- }
-
- oldX = MouseX; oldY = MouseY;
-
- MouseGetDirection(&dx, &dy);
- MouseX+=dx;
- MouseY+=dy;
-
- if (MouseX > 320) MouseX = 320;
- if (MouseY > 200) MouseY = 200;
- if (MouseX < 0) MouseX = 0;
- if (MouseY < 0) MouseY = 0;
-
- int ok=0;
-
- if (MouseGetStatus() & MouseLeftB) {
- alpha.MouseAction(MouseX, MouseY, MouseGetStatus());
-
- // Check if bottom right corner => ok=2
- if (MouseIsInArea (oldX, oldY, alpha.Pos.X+alpha.Size.X-5, alpha.Pos.Y + alpha.Size.Y-5,
- alpha.Pos.X+alpha.Size.X, alpha.Pos.Y + alpha.Size.Y))
- ok = 2;
-
- else if (MouseIsInArea (oldX, oldY, alpha.Pos.X, alpha.Pos.Y,
- alpha.Pos.X+alpha.Size.X, alpha.Pos.Y + alpha.Size.Y))
- ok = 1;
-
- if (ok==1)
- {
- alpha.Pos.X += dx;
- alpha.Pos.Y += dy;
-
- if (alpha.Pos.X < 0) alpha.Pos.X = 0;
- if (alpha.Pos.Y < 0) alpha.Pos.Y = 0;
- if (alpha.Pos.X > 320 - alpha.Size.X) alpha.Pos.X = 320-alpha.Size.X;
- if (alpha.Pos.Y > 200 - alpha.Size.Y) alpha.Pos.Y = 200-alpha.Size.Y;
-
- }
-
- else if (ok==2)
- {
- alpha.Size.X += dx;
- alpha.Size.Y += dy;
-
- if (alpha.Size.X > 300) alpha.Size.X = 300;
- if (alpha.Size.X < 40) alpha.Size.X = 40;
- if (alpha.Size.Y > 150) alpha.Size.Y = 150;
- if (alpha.Size.Y < 30) alpha.Size.Y = 30;
- }
- }
-
- if (!(MouseGetStatus() & MouseLeftB)) ok=0;
-
-
- if(kbhit()) break;
-
-
- }
-
-
- ExitGraph();
- return 0;
-}
diff --git a/Video.exe b/Video.exe
deleted file mode 100644
index fdbfea5..0000000
Binary files a/Video.exe and /dev/null differ
diff --git a/WPROOT~1.SF b/WPROOT~1.SF
deleted file mode 100644
index fde6199..0000000
Binary files a/WPROOT~1.SF and /dev/null differ
diff --git a/_play/fat16.img.gz b/_play/fat16.img.gz
deleted file mode 100644
index 63e6fd8..0000000
Binary files a/_play/fat16.img.gz and /dev/null differ
diff --git a/_play/stage1.asm b/_play/stage1.asm
deleted file mode 100644
index 315a2ef..0000000
--- a/_play/stage1.asm
+++ /dev/null
@@ -1,105 +0,0 @@
-bits 16
-org 0x07C0
-
-xchg bx, bx
-jmp main
-
-VideoAddrSeg dw 0xB800
-VideoAddrOff dw 0x0000
-Cursor dw 0
-
-; Print character to screen; AL = character
-PrintCh:
- pusha ; save all registers
-
- push ax ; save ax
- mov ax, [Cursor] ; get cursor position
- mov bx, 2
- xor dx, dx
- mul bx ; multiply by two
-
- mov bx, [VideoAddrSeg] ; es = video memory segment
- mov cx, [VideoAddrOff] ; di = video memory offset
-
- add cx, ax ; add it to di
- pop ax
- mov byte [bx:cx], al ; put character
-
- inc word[Cursor] ; Cursor++
-
- call UpdateCursor
-
- popa
- ret
-
-; Add 80 to cursor
-NewLine:
- add word[Cursor], 80
- call UpdateCursor
- ret
-
-; Go to the beginning of the line
-BeginLine:
- pusha ; save all registers
-
- mov ax, [Cursor] ; get cursor position
- mov bx, 80 ; number of chars/line
- xor dx, dx ; empty dx
- div bx ; divide ax/bx
- sub word[Cursor], dx ; subtract remainder from cursor
-
- call UpdateCursor
-
- popa
- ret
-
-; Update cursor position
-UpdateCursor:
- ret
-
-
-main:
- mov ax, 0
-
- .loop:
- push ax
- mov bx, 10
- xor dx, dx
-
- div bx
- cmp dx, 0
- je .newline
-
- .back:
-
- cmp ax, 256
- je .done
-
- call PrintCh
-
- inc ax
-
- jmp .loop
-
- .newline:
- call NewLine
- call BeginLine
- jmp .back
-
- .done:
-
- mov ax, 'D'
- call PrintCh
- mov ax, 'O'
- call PrintCh
- mov ax, 'N'
- call PrintCh
- mov ax, 'E'
- call PrintCh
-
-
- cli
- hlt
-
-TIMES 510-($-$$) db 0
-DW 0xAA55
diff --git a/_play/stage2/MAKE.BAT b/_play/stage2/MAKE.BAT
deleted file mode 100644
index fc0dc23..0000000
--- a/_play/stage2/MAKE.BAT
+++ /dev/null
@@ -1,24 +0,0 @@
-@echo off
-set nasm_path=C:\nasm
-set djgpp_path=C:\DJGPP\bin
-
-goto build
-
-:error
- @echo.
- @echo There have been build errors. Building halted.
- @pause
- exit
-
-:build
-
- @echo Compiling stage 2...
- del stage2.cta
- %nasm_path%\nasm.exe -f bin stage2.asm -o stage2.cta
-
-:test
- if not exist stage2.cta goto error
-
-:copy
- @echo Copying stage 2 to floppy...
- copy stage2.cta A:\stage2.cta >nul
\ No newline at end of file
diff --git a/_play/stage2/STAGE2.CTA b/_play/stage2/STAGE2.CTA
deleted file mode 100644
index a496df9..0000000
Binary files a/_play/stage2/STAGE2.CTA and /dev/null differ
diff --git a/_play/stage2/stage2.asm b/_play/stage2/stage2.asm
deleted file mode 100644
index ad53ee3..0000000
--- a/_play/stage2/stage2.asm
+++ /dev/null
@@ -1,201 +0,0 @@
-;***** stage2.asm ****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Playground........ *
-;* ================== *
-;* *
-;************************************************************ cta os */
-bits 16
-
-org 0x500
-
-xchg bx,bx
-jmp main ; go to start
-
-;*******************************************************
-; Preprocessor directives
-;*******************************************************
-
-%include "stdio.inc" ; basic i/o routines
-
-;*******************************************************
-; Data Section
-;*******************************************************
-
-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
- vbeControllerInfoReserved times 1EEh db 0
-
-
-TemporaryStorage dd 0 ; temporary storage
-
-printSuccess db 0x0D, 0x0A, "Information received successfully: ", 0x0A, 0x0D, 0x00
-printInfo1 db "-> Signature: ", 0x00
-printInfo2 db 0x0D, 0x0A, "-> Version: 0x", 0x00
-printInfo3 db 0x0D, 0x0A, "-> OEMString (address): 0x", 0x00
-printInfo4 db 0x0D, 0x0A, "-> Capabilities: 0x", 0x00
-printInfo5 db 0x0D, 0x0A, "-> Video modes (address): 0x", 0x00
-printInfo6 db 0x0D, 0x0A, "-> Total memory (KB): ", 0x00
-printFailure db "Error, unexpected return: ", 0x00
-
-;*******************************************************
-; Code Section
-;*******************************************************
-main:
-
- ;-------------------------------;
- ; Setup segments and stack ;
- ;-------------------------------;
-
- cli ; clear interrupts
- xor ax, ax ; null segments
- mov ds, ax
- mov es, ax
- mov ax, 0x0000 ; stack begins at 0x9000-0xffff
- mov ss, ax
- mov sp, 0xFFFF
- sti ; enable interrupts
-
-; Switch to graphic mode
- mov ax, 0012h
- int 10h
- int 09h
-
- mov ax, 0
- int 16h
-; **************************************
-; * Start by getting some VESA info *
-; **************************************
- xor eax, eax
- mov ebx, eax
- mov ecx, 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, 4F00h
- int 10h
-
- ; See if interrupt returned ok.
- cmp ax, 004Fh
- je .yes
-
- ; no:
- mov si, printFailure ; print error message
- call Puts16
- call PrintHEX ; print error code
- jmp .done
-
-.yes:
- mov si, printSuccess ; print success message
- call Puts16
-
-; Print Info1
- mov si, printInfo1
- call Puts16
-
- mov si, vbeControllerInfo_signature
- call Puts16
-
-
-; Print Info2
- mov si, printInfo2
- call Puts16
- xor eax, eax
- mov ax, [vbeControllerInfo_version]
- call PrintHEX
-
-; Print Info3
- mov si, printInfo3
- call Puts16
- mov eax, [vbeControllerInfo_oemString]
- call PrintHEX
-
-; Print Info4
- mov si, printInfo4
- call Puts16
- mov eax, [vbeControllerInfo_capabilities]
- call PrintHEX
-
-; Print Info5
- mov si, printInfo5
- call Puts16
- mov eax, [vbeControllerInfo_videomodes]
- call PrintHEX
-
-; Print Info6
- mov si, printInfo6
- call Puts16
- xor eax, eax
- mov ax, [vbeControllerInfo_totalMemory]
- call PrintINT
-
-.done:
- cli
- hlt
-
-
-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/_play/stage2/stdio.inc b/_play/stage2/stdio.inc
deleted file mode 100644
index 479ad79..0000000
--- a/_play/stage2/stdio.inc
+++ /dev/null
@@ -1,386 +0,0 @@
-;***** stdio.inc *****************************************************
-;* (c) 2010 CTA Systems Inc. All rights reserved. Glory To God *
-;* *
-;* Standard Input/Output routines *
-;* ============================== *
-;* *
-;************************************************************ cta os */
-
-
-%ifndef __STDIO_INC_CTA008__
-%define __STDIO_INC_CTA008__
-
-
-;==========================================================
-;
-; 16 Bit Real Mode Routines
-;==========================================================
-
-
-;************************************************;
-; Puts16 ()
-; -Prints a null terminated string
-; DS=>SI: 0 terminated string
-;************************************************;
-tmpStr db " ", 0x0D, 0x0A, 0x00
-hex db "0123456789abcdef"
-
-bits 16
-
-Puts16:
- pusha ; save registers
-.Loop1:
- lodsb ; load next byte from string from SI to AL
- or al, al ; Does AL=0?
- jz Puts16Done ; Yep, null terminator found-bail out
- mov ah, 0eh ; Nope-Print the character
- int 10h ; invoke BIOS
- jmp .Loop1 ; Repeat until null terminator found
-Puts16Done:
- popa ; restore registers
- ret ; we are done, so return
-
-
-;************************************************;
-; PrintINT (uint16_t number)
-; -Prints an integer on the screen
-;
-; Parameters: ax = number
-;************************************************;
-PrintINT:
- pusha
-
- push ax ; save ax
- mov bx, 10 ; base 10 in bx
- call DigitsINT ; get number of digits
-
- mov cx, ax ; move in cx number of digits
- pop ax ; restore ax = number
-
- mov byte[tmpStr+ecx], 0x00 ; Mark end of string
-
- .loop:
- xor dx, dx
- div bx ; divide by base
- add dx, '0'
-
- mov byte[tmpStr+ecx-1], dl ; write in position
- loop .loop ; loop while cx > 0
-
- mov si, tmpStr
- call Puts16
-
- .done:
- popa
- ret
-
-;************************************************;
-; PrintHEX (uint32_t number)
-; -Prints an integer in hex on the screen
-;
-; Parameters: push on the stack number
-;************************************************;
-PrintHEX:
- pusha
-
- push eax ; save ax
- call DigitsHEX ; get number of digits
-
- mov ecx, eax ; move in cx number of digits
- pop eax ; restore ax = number
-
- mov byte[tmpStr+ecx], 0x00 ; Mark end of string
-
- .loop:
- mov edx, eax ; Put number in edx
- and edx, 0x0f ; Remove all digits but the last
-
- shr eax, 4 ; Remove digit from end
-
- push eax ; save eax
- xor eax, eax ; make it 0
- mov al, [hex+edx]
-
- mov byte[tmpStr+ecx-1], al ; write in position
-
- pop eax
-
- loop .loop ; loop while cx > 0
-
- mov si, tmpStr
- call Puts16
-
- .done:
- popa
- ret
-
-
-;************************************************;
-; DigitsHEX (uint32_t number)
-; -Calculate number of digits of a number in hex
-;
-; Parameters: number in eax
-; Returns: value in eax
-;************************************************;
-_Number dd 0
-DigitsHEX:
- pusha ; Save all registers
-
- xor ebx, ebx ; Empty registers
- mov ecx, ebx
- mov edx, ebx
-
- .loop:
- cmp eax, 0
- je .done
- shr eax, 4
- inc ecx
- jmp .loop
-
- .done:
- mov dword[_Number], ecx
- popa
- mov eax, [_Number]
- ret
-
-;************************************************;
-; DigitsINT (uint16_t number, uint16_t base)
-; -Calculate number of digits of a number in the specified base
-;
-; Parameters: number in ax, base in bx
-; Returns: value in ax
-;************************************************;
-DigitsINT:
- pusha ; Save all registers
-
- xor cx, cx ; Empty registers
-
- .loop:
- cmp ax, 0
- je .done
- xor dx, dx
- div bx
- inc cx
- jmp .loop
-
- .done:
- mov word[_Number], cx
- popa
- mov ax, [_Number]
- ret
-;==========================================================
-;
-; 32 Bit Protected Mode Routines
-;==========================================================
-
- ;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)
-
-;_CurX db 0 ; current x/y location
-;_CurY db 0
-
-;**************************************************;
-; Putch32 ()
-; - Prints a character to screen
-; 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
-
- ; 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
-
- ; add the position to draw to the base of vid memory
-
-; 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
-;
- ; print the character
-
-; mov dl, bl ; Get character
-; mov dh, CHAR_ATTRIB ; the character attribute
-; mov word [edi], dx ; write to video display
-;
-; ; go to next location
-
-; 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
-
-;.done:
-; popa
-; ret
-
-;**************************************************;
-; Puts32 ()
-; - Prints a null terminated string
-; parm\ EBX = address of string to print
-;**************************************************;
-
-;Puts32:
-
-; pusha
-; push ebx ; copy the string address
-; pop edi
-
-;.loop:
-
- ;-------------------------------;
- ; Get character ;
- ;-------------------------------;
-
-; 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
-
- ;-------------------------------;
- ; Go to next character ;
- ;-------------------------------;
-
-; inc edi ; go to next character
-; jmp .loop
-
-;.done:
-
- ;-------------------------------;
- ; Update hardware cursor ;
- ;-------------------------------;
-
-; mov bh, byte [_CurY] ; get current position
-; mov bl, byte [_CurX]
-; call MovCur ; update cursor
-
-; popa ; restore registers, and return
-; ret
-
-;**************************************************;
-; MoveCur ()
-; - Update hardware cursor
-; parm/ bh = Y pos
-; parm/ bl = x pos
-;**************************************************;
-
-
-
-;bits 32
-
-;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
-;
- ;--------------------------------------;
- ; 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
-
- ;---------------------------------------;
- ; Set high byte index to VGA register ;
- ;---------------------------------------;
-
-; xor eax, eax
-
-; mov al, 0x0e
-; mov dx, 0x03D4
-; out dx, al
-
-; mov al, bh
-; mov dx, 0x03D5
-; out dx, al ; high byte
-
-; 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
-
-;**************************************************;
-; GotoXY ()
-; - Set current X/Y location
-; parm\ AL=X position
-; parm\ AH=Y position
-;**************************************************;
-
-;bits 32
-
-;GotoXY:
-; pusha
-; mov [_CurX], al
-; mov [_CurY], ah
-; popa
-; ret
-
-
-%endif ;__STDIO_INC_67343546FDCC56AAB872_INCLUDED__
diff --git a/bochs/.bochsrc b/bochs/.bochsrc
new file mode 100644
index 0000000..a7be8a6
--- /dev/null
+++ b/bochs/.bochsrc
@@ -0,0 +1,9 @@
+megs: 32
+
+
+floppya: 1_44=../luxos.img, status=inserted
+boot: a
+log: bochs_run.log
+mouse: enabled=0
+magic_break: enabled=1
+display_library: x, options="gui_debug"
\ No newline at end of file
diff --git a/bochs/.bochsrc~ b/bochs/.bochsrc~
new file mode 100644
index 0000000..490468d
--- /dev/null
+++ b/bochs/.bochsrc~
@@ -0,0 +1,10 @@
+megs: 32
+romimage: file="/usr/share/bochs/BIOS-bochs-latest"
+vgaromimage: file="C:\Program Files\Bochs-2.4.6\VGABIOS-lgpl-latest"
+
+floppya: 1_44=../luxos.img, status=inserted
+boot: a
+log: bochs_run.log
+mouse: enabled=0
+magic_break: enabled=1
+display_library: x, options="gui_debug"
\ No newline at end of file
diff --git a/bochs/bochs_run.log b/bochs/bochs_run.log
new file mode 100644
index 0000000..16cd2dd
--- /dev/null
+++ b/bochs/bochs_run.log
@@ -0,0 +1,206 @@
+00000000000i[ ] Bochs x86 Emulator 2.4.6
+00000000000i[ ] Build from CVS snapshot, on February 22, 2011
+00000000000i[ ] Compiled at Aug 28 2011, 16:32:50
+00000000000i[ ] System configuration
+00000000000i[ ] processors: 1 (cores=1, HT threads=1)
+00000000000i[ ] A20 line support: yes
+00000000000i[ ] CPU configuration
+00000000000i[ ] level: 6
+00000000000i[ ] SMP support: yes, quantum=5
+00000000000i[ ] APIC support: yes
+00000000000i[ ] FPU support: yes
+00000000000i[ ] MMX support: yes
+00000000000i[ ] 3dnow! support: yes
+00000000000i[ ] SEP support: yes
+00000000000i[ ] SSE support: sse2
+00000000000i[ ] XSAVE support: no
+00000000000i[ ] AES support: no
+00000000000i[ ] MOVBE support: no
+00000000000i[ ] x86-64 support: yes
+00000000000i[ ] 1G paging support: no
+00000000000i[ ] VMX support: 1
+00000000000i[ ] Optimization configuration
+00000000000i[ ] RepeatSpeedups support: yes
+00000000000i[ ] Trace cache support: yes
+00000000000i[ ] Fast function calls: yes
+00000000000i[ ] Devices configuration
+00000000000i[ ] ACPI support: yes
+00000000000i[ ] NE2000 support: no
+00000000000i[ ] PCI support: yes, enabled=yes
+00000000000i[ ] SB16 support: yes
+00000000000i[ ] USB support: no
+00000000000i[ ] VGA extension support: vbe
+00000000000i[MEM0 ] allocated memory at 0xb4116008. after alignment, vector=0xb4117000
+00000000000i[MEM0 ] 32.00MB
+00000000000i[MEM0 ] mem block size = 0x00100000, blocks=32
+00000000000i[MEM0 ] rom at 0xfffe0000/131072 ('/usr/local/share/bochs/BIOS-bochs-latest')
+00000000000i[MEM0 ] rom at 0xc0000/40448 ('/usr/local/share/bochs/VGABIOS-lgpl-latest')
+00000000000i[CMOS ] Using local time for initial clock
+00000000000i[CMOS ] Setting initial clock to: Mon Aug 29 10:21:59 2011 (time0=1314602519)
+00000000000i[DMA ] channel 4 used by cascade
+00000000000i[DMA ] channel 2 used by Floppy Drive
+00000000000i[FDD ] fd0: '../luxos.img' ro=0, h=2,t=80,spt=18
+00000000000i[PCI ] 440FX Host bridge present at device 0, function 0
+00000000000i[PCI ] PIIX3 PCI-to-ISA bridge present at device 1, function 0
+00000000000i[VGA ] interval=50000
+00000000000i[MEM0 ] Register memory access handlers: 0x00000000000a0000 - 0x00000000000bffff
+00000000000i[XGUI ] test_alloc_colors: 16 colors available out of 16 colors tried
+00000000000i[XGUI ] font 8 wide x 16 high, display depth = 24
+00000000000i[MEM0 ] Register memory access handlers: 0x00000000e0000000 - 0x00000000e0ffffff
+00000000000i[VGA ] VBE Bochs Display Extension Enabled
+00000000000i[ ] init_dev of 'unmapped' plugin device by virtual method
+00000000000i[ ] init_dev of 'biosdev' plugin device by virtual method
+00000000000i[ ] init_dev of 'speaker' plugin device by virtual method
+00000000000i[SPEAK] Failed to open /dev/console: Resource temporarily unavailable
+00000000000i[SPEAK] Deactivating beep on console
+00000000000i[ ] init_dev of 'extfpuirq' plugin device by virtual method
+00000000000i[ ] init_dev of 'gameport' plugin device by virtual method
+00000000000i[ ] init_dev of 'iodebug' plugin device by virtual method
+00000000000i[ ] init_dev of 'pci_ide' plugin device by virtual method
+00000000000i[PCI ] PIIX3 PCI IDE controller present at device 1, function 1
+00000000000i[ ] init_dev of 'acpi' plugin device by virtual method
+00000000000i[PCI ] ACPI Controller present at device 1, function 3
+00000000000i[ ] init_dev of 'ioapic' plugin device by virtual method
+00000000000i[IOAP ] initializing I/O APIC
+00000000000i[MEM0 ] Register memory access handlers: 0x00000000fec00000 - 0x00000000fec00fff
+00000000000i[ ] init_dev of 'keyboard' plugin device by virtual method
+00000000000i[KBD ] will paste characters every 1000 keyboard ticks
+00000000000i[ ] init_dev of 'harddrv' plugin device by virtual method
+00000000000i[HD ] Using boot sequence floppy, none, none
+00000000000i[HD ] Floppy boot signature check is enabled
+00000000000i[ ] init_dev of 'serial' plugin device by virtual method
+00000000000i[SER ] com1 at 0x03f8 irq 4
+00000000000i[ ] init_dev of 'parallel' plugin device by virtual method
+00000000000i[PAR ] parallel port 1 at 0x0378 irq 7
+00000000000i[ ] register state of 'unmapped' plugin device by virtual method
+00000000000i[ ] register state of 'biosdev' plugin device by virtual method
+00000000000i[ ] register state of 'speaker' plugin device by virtual method
+00000000000i[ ] register state of 'extfpuirq' plugin device by virtual method
+00000000000i[ ] register state of 'gameport' plugin device by virtual method
+00000000000i[ ] register state of 'iodebug' plugin device by virtual method
+00000000000i[ ] register state of 'pci_ide' plugin device by virtual method
+00000000000i[ ] register state of 'acpi' plugin device by virtual method
+00000000000i[ ] register state of 'ioapic' plugin device by virtual method
+00000000000i[ ] register state of 'keyboard' plugin device by virtual method
+00000000000i[ ] register state of 'harddrv' plugin device by virtual method
+00000000000i[ ] register state of 'serial' plugin device by virtual method
+00000000000i[ ] register state of 'parallel' plugin device by virtual method
+00000000000i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
+00000000000i[CPU0 ] cpu hardware reset
+00000000000i[APIC0] allocate APIC id=0 (MMIO enabled) to 0x00000000fee00000
+00000000000i[CPU0 ] CPU[0] is the bootstrap processor
+00000000000i[CPU0 ] CPUID[0x00000000]: 00000003 68747541 444d4163 69746e65
+00000000000i[CPU0 ] CPUID[0x00000001]: 00000f23 00000800 00002020 07cbfbff
+00000000000i[CPU0 ] CPUID[0x00000002]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x00000003]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x00000004]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x00000007]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x80000000]: 80000008 68747541 444d4163 69746e65
+00000000000i[CPU0 ] CPUID[0x80000001]: 00000f23 00000000 00000001 ebd3fbff
+00000000000i[CPU0 ] CPUID[0x80000002]: 20444d41 6c687441 74286e6f 7020296d
+00000000000i[CPU0 ] CPUID[0x80000003]: 65636f72 726f7373 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x80000004]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x80000005]: 01ff01ff 01ff01ff 40020140 40020140
+00000000000i[CPU0 ] CPUID[0x80000006]: 00000000 42004200 02008140 00000000
+00000000000i[CPU0 ] CPUID[0x80000007]: 00000000 00000000 00000000 00000000
+00000000000i[CPU0 ] CPUID[0x80000008]: 00003028 00000000 00000000 00000000
+00000000000i[ ] reset of 'unmapped' plugin device by virtual method
+00000000000i[ ] reset of 'biosdev' plugin device by virtual method
+00000000000i[ ] reset of 'speaker' plugin device by virtual method
+00000000000i[ ] reset of 'extfpuirq' plugin device by virtual method
+00000000000i[ ] reset of 'gameport' plugin device by virtual method
+00000000000i[ ] reset of 'iodebug' plugin device by virtual method
+00000000000i[ ] reset of 'pci_ide' plugin device by virtual method
+00000000000i[ ] reset of 'acpi' plugin device by virtual method
+00000000000i[ ] reset of 'ioapic' plugin device by virtual method
+00000000000i[ ] reset of 'keyboard' plugin device by virtual method
+00000000000i[ ] reset of 'harddrv' plugin device by virtual method
+00000000000i[ ] reset of 'serial' plugin device by virtual method
+00000000000i[ ] reset of 'parallel' plugin device by virtual method
+00000000000i[XGUI ] [x] Mouse off
+00000003305i[BIOS ] $Revision: 1.257 $ $Date: 2011/01/26 09:52:02 $
+00000318072i[KBD ] reset-disable command received
+00000444792i[VBIOS] VGABios $Id: vgabios.c,v 1.69 2009/04/07 18:18:20 vruppert Exp $
+00000444863i[VGA ] VBE known Display Interface b0c0
+00000444895i[VGA ] VBE known Display Interface b0c5
+00000447820i[VBIOS] VBE Bios $Id: vbe.c,v 1.62 2009/01/25 15:46:25 vruppert Exp $
+00000600000i[XGUI ] charmap update. Font Height is 16
+00000760509i[BIOS ] Starting rombios32
+00000761006i[BIOS ] Shutdown flag 0
+00000761687i[BIOS ] ram_size=0x02000000
+00000762165i[BIOS ] ram_end=32MB
+00000802749i[BIOS ] Found 1 cpu(s)
+00000821736i[BIOS ] bios_table_addr: 0x000fb928 end=0x000fcc00
+00000821839i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
+00001149536i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
+00001477464i[P2I ] PCI IRQ routing: PIRQA# set to 0x0b
+00001477485i[P2I ] PCI IRQ routing: PIRQB# set to 0x09
+00001477506i[P2I ] PCI IRQ routing: PIRQC# set to 0x0b
+00001477527i[P2I ] PCI IRQ routing: PIRQD# set to 0x09
+00001477537i[P2I ] write: ELCR2 = 0x0a
+00001478422i[BIOS ] PIIX3/PIIX4 init: elcr=00 0a
+00001486380i[BIOS ] PCI: bus=0 devfn=0x00: vendor_id=0x8086 device_id=0x1237 class=0x0600
+00001488942i[BIOS ] PCI: bus=0 devfn=0x08: vendor_id=0x8086 device_id=0x7000 class=0x0601
+00001491343i[BIOS ] PCI: bus=0 devfn=0x09: vendor_id=0x8086 device_id=0x7010 class=0x0101
+00001491573i[PIDE ] new BM-DMA address: 0xc000
+00001492277i[BIOS ] region 4: 0x0000c000
+00001494587i[BIOS ] PCI: bus=0 devfn=0x0b: vendor_id=0x8086 device_id=0x7113 class=0x0680
+00001494825i[ACPI ] new irq line = 11
+00001494839i[ACPI ] new irq line = 9
+00001494869i[ACPI ] new PM base address: 0xb000
+00001494883i[ACPI ] new SM base address: 0xb100
+00001494911i[PCI ] setting SMRAM control register to 0x4a
+00001659005i[CPU0 ] Enter to System Management Mode
+00001659005i[CPU0 ] enter_system_management_mode: temporary disable VMX while in SMM mode
+00001659015i[CPU0 ] RSM: Resuming from System Management Mode
+00001823035i[PCI ] setting SMRAM control register to 0x0a
+00001832206i[BIOS ] MP table addr=0x000fba00 MPC table addr=0x000fb930 size=0xd0
+00001834265i[BIOS ] SMBIOS table addr=0x000fba10
+00001836653i[BIOS ] ACPI tables: RSDP addr=0x000fbb30 ACPI DATA addr=0x01ff0000 size=0x988
+00001839891i[BIOS ] Firmware waking vector 0x1ff00cc
+00001851004i[PCI ] 440FX PMC write to PAM register 59 (TLB Flush)
+00001851848i[BIOS ] bios_table_cur_addr: 0x000fbb54
+00014041552i[BIOS ] Booting from 0000:7c00
+00023137422i[BIOS ] int13_harddisk: function 41, unmapped device for ELDL=80
+00023142203i[BIOS ] int13_harddisk: function 08, unmapped device for ELDL=80
+00023146854i[BIOS ] *** int 15h function AX=00c0, BX=0000 not yet supported!
+00037427421i[CPU0 ] [37427421] Stopped on MAGIC BREAKPOINT
+00037475097i[KBD ] setting typematic info
+00037475122i[KBD ] setting delay to 500 mS (unused)
+00037475122i[KBD ] setting repeat rate to 10.9 cps (unused)
+00037475183i[KBD ] Switched to scancode set 2
+00037475271i[KBD ] keyboard: scan convert turned off
+00037475895i[KBD ] keyboard: scan convert turned off
+00037491918i[FDD ] controller reset in software
+00039078683i[FDD ] io_write: config control register: 0x00
+00055400059i[CPU0 ] [55400059] Stopped on MAGIC BREAKPOINT
+00165600000i[ ] dbg: Quit
+00165600000i[CPU0 ] CPU is in protected mode (active)
+00165600000i[CPU0 ] CS.d_b = 32 bit
+00165600000i[CPU0 ] SS.d_b = 32 bit
+00165600000i[CPU0 ] EFER = 0x00000000
+00165600000i[CPU0 ] | RAX=00000000000000ff RBX=000000000010d78c
+00165600000i[CPU0 ] | RCX=00000000000003d4 RDX=000000000010d6ca
+00165600000i[CPU0 ] | RSP=000000000010d68c RBP=000000000010d6a4
+00165600000i[CPU0 ] | RSI=000000000010d6ca RDI=0000000000000002
+00165600000i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
+00165600000i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
+00165600000i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
+00165600000i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
+00165600000i[CPU0 ] | IOPL=0 id vip vif ac vm rf nt of df IF tf sf ZF af PF cf
+00165600000i[CPU0 ] | SEG selector base limit G D
+00165600000i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
+00165600000i[CPU0 ] | CS:0008( 0001| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | SS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 1
+00165600000i[CPU0 ] | MSR_FS_BASE:0000000000000000
+00165600000i[CPU0 ] | MSR_GS_BASE:0000000000000000
+00165600000i[CPU0 ] | RIP=0000000000105eb4 (0000000000105eb4)
+00165600000i[CPU0 ] | CR0=0xe0000011 CR2=0x0000000000000000
+00165600000i[CPU0 ] | CR3=0x00110000 CR4=0x00000000
+00165600000i[CMOS ] Last time is 1314602560 (Mon Aug 29 10:22:40 2011)
+00165600000i[XGUI ] Exit
+00165600000i[CTRL ] quit_sim called with exit code 0
diff --git a/bochs/bochsrc.bxrc b/bochs/bochsrc.bxrc
new file mode 100644
index 0000000..db458f5
--- /dev/null
+++ b/bochs/bochsrc.bxrc
@@ -0,0 +1,9 @@
+megs: 32
+romimage: file="C:\Program Files\Bochs-2.4.6\BIOS-bochs-latest"
+vgaromimage: file="C:\Program Files\Bochs-2.4.6\VGABIOS-lgpl-latest"
+
+floppya: 1_44=a:, status=inserted
+boot: a
+log: bochs_run.log
+mouse: enabled=0
+magic_break: enabled=1
\ No newline at end of file
diff --git a/build.sh b/build.sh
new file mode 100644
index 0000000..84d6b2d
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,79 @@
+#!/bin/sh
+
+# ----------------- lux Operating System -----------------
+OBJ=build
+COMPILER=gcc
+LINKER=ld
+
+BuildC()
+{
+ Percent=10
+
+ while read descript
+ do
+ read line
+ read empty
+ echo "[ $Percent%] KERNEL :: $descript"
+ File=${line##*/}
+ File=${File%%.*}
+ $COMPILER -Wall -Wextra -O -nostdinc -fno-builtin -I./Kernel/include -c -o $OBJ/$File.o $line -nostdlib -nostartfiles -nodefaultlibs
+ Percent=$(($Percent + 2)) #Increase PERCENT
+ done < $1
+
+ return 0
+}
+
+BuildAsm()
+{
+ Percent=85
+
+ while read descript
+ do
+ read line
+ read empty
+ echo "[ $Percent%] KERNEL :: $descript"
+ File=${line##*/}
+ File=${File%%.*}
+ nasm -f elf -o $OBJ/$File.o $line
+ Percent=$(($Percent + 1)) #Increase PERCENT
+ done < $1
+
+ return 0
+}
+
+
+echo "lux operating system v0.1"
+
+# Clean up
+echo "[ 1%] CLEANUP"
+rm $OBJ/* 2>/dev/null
+
+# Calculate version number
+read buildno < ./scripts/version.txt
+buildno=$(($buildno + 1))
+echo $buildno > ./scripts/version.txt
+echo "#define OS_BUILD \"0.1.0.$buildno\"" > ./Kernel/include/version.h
+
+# Build kernel
+BuildC "filelistC.txt"
+BuildAsm "filelistAsm.txt"
+
+# Link
+echo "[ 95%] LINKING..."
+$LINKER -T link.ld $OBJ/*.o
+
+# Make floppy image
+echo "[ 97%] WRITING FLOPPY IMAGE..."
+cp floppy/original.img luxos.img
+mkdir /media/floppy1
+mount -o loop luxos.img /media/floppy1
+cp kernel.bin /media/floppy1/
+sleep 1
+umount /media/floppy1
+rm -r /media/floppy1
+
+# DONE
+echo "[100%] DONE!\n"
+
+
+exit 0
diff --git a/build.sh~ b/build.sh~
new file mode 100644
index 0000000..400ef01
--- /dev/null
+++ b/build.sh~
@@ -0,0 +1,78 @@
+#!/bin/sh
+
+# ----------------- lux Operating System -----------------
+OBJ=build
+COMPILER=gcc
+LINKER=ld
+
+BuildC()
+{
+ Percent=10
+
+ while read descript
+ do
+ read line
+ read empty
+ echo "[ $Percent%] KERNEL :: $descript"
+ File=${line##*/}
+ File=${File%%.*}
+ $COMPILER -Wall -Wextra -O -nostdinc -fno-builtin -I./Kernel/include -c -o $OBJ/$File.o $line -nostdlib -nostartfiles -nodefaultlibs
+ Percent=$(($Percent + 2)) #Increase PERCENT
+ done < $1
+
+ return 0
+}
+
+BuildAsm()
+{
+ Percent=85
+
+ while read descript
+ do
+ read line
+ read empty
+ echo "[ $Percent%] KERNEL :: $descript"
+ File=${line##*/}
+ File=${File%%.*}
+ nasm -f elf -o $OBJ/$File.o $line
+ Percent=$(($Percent + 1)) #Increase PERCENT
+ done < $1
+
+ return 0
+}
+
+
+echo "lux operating system v0.1"
+
+# Clean up
+echo "[ 1%] CLEANUP"
+rm $OBJ/* 2>/dev/null
+
+# Calculate version number
+read buildno < ./scripts/version.txt
+buildno=$(($buildno + 1))
+echo $buildno > ./scripts/version.txt
+echo "#define OS_BUILD \"0.1.0.$buildno\"" > ./Kernel/include/version.h
+
+# Build kernel
+BuildC "filelistC.txt"
+BuildAsm "filelistAsm.txt"
+
+# Link
+echo "[ 95%] LINKING..."
+$LINKER -T link.ld $OBJ/*.o
+
+# Make floppy image
+echo "[ 97%] WRITING FLOPPY IMAGE..."
+cp floppy/original.img luxos.img
+mkdir /media/floppy1
+mount -o loop luxos.img /media/floppy1
+cp kernel.bin /media/floppy1/
+umount /media/floppy1
+rm -r /media/floppy1
+
+# DONE
+echo "[100%] DONE!\n"
+
+
+exit 0
diff --git a/build/clock.o b/build/clock.o
new file mode 100644
index 0000000..a85951d
Binary files /dev/null and b/build/clock.o differ
diff --git a/build/cmos.o b/build/cmos.o
new file mode 100644
index 0000000..ff52882
Binary files /dev/null and b/build/cmos.o differ
diff --git a/build/console-base.o b/build/console-base.o
new file mode 100644
index 0000000..c552d92
Binary files /dev/null and b/build/console-base.o differ
diff --git a/build/console-in.o b/build/console-in.o
new file mode 100644
index 0000000..fb25b7e
Binary files /dev/null and b/build/console-in.o differ
diff --git a/build/console-out.o b/build/console-out.o
new file mode 100644
index 0000000..777f353
Binary files /dev/null and b/build/console-out.o differ
diff --git a/build/console.o b/build/console.o
new file mode 100644
index 0000000..1a17ea0
Binary files /dev/null and b/build/console.o differ
diff --git a/build/convert_ops.o b/build/convert_ops.o
new file mode 100644
index 0000000..40a7650
Binary files /dev/null and b/build/convert_ops.o differ
diff --git a/build/crash.o b/build/crash.o
new file mode 100644
index 0000000..766a54e
Binary files /dev/null and b/build/crash.o differ
diff --git a/build/ctype.o b/build/ctype.o
new file mode 100644
index 0000000..a69db89
Binary files /dev/null and b/build/ctype.o differ
diff --git a/build/dma.o b/build/dma.o
new file mode 100644
index 0000000..595a708
Binary files /dev/null and b/build/dma.o differ
diff --git a/build/drivers.o b/build/drivers.o
new file mode 100644
index 0000000..01acae9
Binary files /dev/null and b/build/drivers.o differ
diff --git a/build/floppy.o b/build/floppy.o
new file mode 100644
index 0000000..37cc4d2
Binary files /dev/null and b/build/floppy.o differ
diff --git a/build/gdt-asm.o b/build/gdt-asm.o
new file mode 100644
index 0000000..194b365
Binary files /dev/null and b/build/gdt-asm.o differ
diff --git a/build/gdt.o b/build/gdt.o
new file mode 100644
index 0000000..c1a82da
Binary files /dev/null and b/build/gdt.o differ
diff --git a/build/hal.o b/build/hal.o
new file mode 100644
index 0000000..f0d70f9
Binary files /dev/null and b/build/hal.o differ
diff --git a/build/idt-asm.o b/build/idt-asm.o
new file mode 100644
index 0000000..acd131d
Binary files /dev/null and b/build/idt-asm.o differ
diff --git a/build/idt.o b/build/idt.o
new file mode 100644
index 0000000..de6058e
Binary files /dev/null and b/build/idt.o differ
diff --git a/build/irq-asm.o b/build/irq-asm.o
new file mode 100644
index 0000000..7146c0a
Binary files /dev/null and b/build/irq-asm.o differ
diff --git a/build/irq.o b/build/irq.o
new file mode 100644
index 0000000..4e1ea31
Binary files /dev/null and b/build/irq.o differ
diff --git a/build/isrs-asm.o b/build/isrs-asm.o
new file mode 100644
index 0000000..54d7daa
Binary files /dev/null and b/build/isrs-asm.o differ
diff --git a/build/isrs.o b/build/isrs.o
new file mode 100644
index 0000000..6c33f78
Binary files /dev/null and b/build/isrs.o differ
diff --git a/build/keyboard.o b/build/keyboard.o
new file mode 100644
index 0000000..994a60f
Binary files /dev/null and b/build/keyboard.o differ
diff --git a/build/mem-heap.o b/build/mem-heap.o
new file mode 100644
index 0000000..3577932
Binary files /dev/null and b/build/mem-heap.o differ
diff --git a/build/mem-paging.o b/build/mem-paging.o
new file mode 100644
index 0000000..5a20177
Binary files /dev/null and b/build/mem-paging.o differ
diff --git a/build/mem-phys.o b/build/mem-phys.o
new file mode 100644
index 0000000..da17ca2
Binary files /dev/null and b/build/mem-phys.o differ
diff --git a/build/mem_ops.o b/build/mem_ops.o
new file mode 100644
index 0000000..5a6a2f5
Binary files /dev/null and b/build/mem_ops.o differ
diff --git a/build/memory_alloc.o b/build/memory_alloc.o
new file mode 100644
index 0000000..eeccbef
Binary files /dev/null and b/build/memory_alloc.o differ
diff --git a/build/memory_free.o b/build/memory_free.o
new file mode 100644
index 0000000..11f8c7c
Binary files /dev/null and b/build/memory_free.o differ
diff --git a/build/memory_info.o b/build/memory_info.o
new file mode 100644
index 0000000..cd3c9a2
Binary files /dev/null and b/build/memory_info.o differ
diff --git a/build/memory_init.o b/build/memory_init.o
new file mode 100644
index 0000000..1036ac1
Binary files /dev/null and b/build/memory_init.o differ
diff --git a/build/mouse.o b/build/mouse.o
new file mode 100644
index 0000000..14f5fe2
Binary files /dev/null and b/build/mouse.o differ
diff --git a/build/num_ops.o b/build/num_ops.o
new file mode 100644
index 0000000..83186f9
Binary files /dev/null and b/build/num_ops.o differ
diff --git a/build/ord_arr.o b/build/ord_arr.o
new file mode 100644
index 0000000..69a37a6
Binary files /dev/null and b/build/ord_arr.o differ
diff --git a/build/pic.o b/build/pic.o
new file mode 100644
index 0000000..6c12c61
Binary files /dev/null and b/build/pic.o differ
diff --git a/build/pit.o b/build/pit.o
new file mode 100644
index 0000000..14d683f
Binary files /dev/null and b/build/pit.o differ
diff --git a/build/stdio.o b/build/stdio.o
new file mode 100644
index 0000000..6a6ca22
Binary files /dev/null and b/build/stdio.o differ
diff --git a/build/storage.o b/build/storage.o
new file mode 100644
index 0000000..0523a7e
Binary files /dev/null and b/build/storage.o differ
diff --git a/build/str_ops.o b/build/str_ops.o
new file mode 100644
index 0000000..5de848b
Binary files /dev/null and b/build/str_ops.o differ
diff --git a/build/sysinfo.o b/build/sysinfo.o
new file mode 100644
index 0000000..77cc6f5
Binary files /dev/null and b/build/sysinfo.o differ
diff --git a/build/time.o b/build/time.o
new file mode 100644
index 0000000..460f5d6
Binary files /dev/null and b/build/time.o differ
diff --git a/buildOS.bat b/buildOS.bat
deleted file mode 100644
index eeab5cc..0000000
--- a/buildOS.bat
+++ /dev/null
@@ -1,41 +0,0 @@
-@echo off
-
-@echo ********************************************************
-@echo ** CTA OS Builder **
-@echo ** **
-@echo ** CTA Operating System version 0.1 **
-@echo ** (c) 2010 CTA Systems Inc. **
-@echo ********************************************************
-@echo.
-
-set nasm_path=C:\nasm
-set djgpp_path=C:\mingw\bin
-
-:floppy_no
- xcopy A:\NUL >nul
- if errorlevel 5 goto floppy_yes
-
- @echo Insert a floppy disk, and press any key to continue.
- @pause >nul
- goto floppy_yes
-
-
-:floppy_yes
- @echo Formatting disk...
- format A: /q nul
- @echo.
-
-:bootloader
- cd SysBoot
- @echo.
- call makeall.bat
- cd..
-
-:kernel
- cd SysCore
- call makeallh.bat
- cd..
-
-@echo ************************ Done ************************
-@echo.
-@pause
\ No newline at end of file
diff --git a/change.log b/change.log
new file mode 100644
index 0000000..bf6e22a
--- /dev/null
+++ b/change.log
@@ -0,0 +1,28 @@
+[GOOD] BUILD 0.1.0.450 DATE 8/29/2011 AT 10:30 AM
+====================================================
++ Changed 'align 0x4' line above multiboot header in loader.asm to 'align 4'
++ Removed -e option for echo in build.sh
++ Modified build.sh for linux
++ Fixed triple fault when enabling paging
++ Fixed page faults at memory manager initialization
++ Fixed 'mem' console function
++ Added more info about page fault at crash screen
++ Added Panic() macro
++ Added verbose mode for memory manager
+
+[ BAD] BUILD 0.1.0.390 DATE 8/27/2011 AT 10:54 PM
+====================================================
++ Added stdlib routines, separated in different files
++ Rewritten physical memory manager
++ Added virtual mem manager
++ Added memory allocation/freeing
++ Added memory library
++ Added temporary allocation (at end of kernel), until paging is started
+- Removed functionality from debug console function 'mem'
+- Removed system.h, the one remaining function now in stdio.h
+
+TODO:
+Debug initialization
+Bug hunt
+Implement verbose mode for memmgr
+Fix function 'mem'
diff --git a/change.log~ b/change.log~
new file mode 100644
index 0000000..437ddfb
--- /dev/null
+++ b/change.log~
@@ -0,0 +1,24 @@
+[????] BUILD 0.1.0.??? DATE 8/27/2011 AT ??:?? ??
+====================================================
++ Changed 'align 0x4' line above multiboot header in loader.asm to 'align 4'
++ Removed -e option for echo in build.sh
++ Modified build.sh for linux
++ Fixed triple fault when enabling paging
+
+
+[ BAD] BUILD 0.1.0.390 DATE 8/27/2011 AT 10:54 PM
+====================================================
++ Added stdlib routines, separated in different files
++ Rewritten physical memory manager
++ Added virtual mem manager
++ Added memory allocation/freeing
++ Added memory library
++ Added temporary allocation (at end of kernel), until paging is started
+- Removed functionality from debug console function 'mem'
+- Removed system.h, the one remaining function now in stdio.h
+
+TODO:
+Debug initialization
+Bug hunt
+Implement verbose mode for memmgr
+Fix function 'mem'
\ No newline at end of file
diff --git a/filelistAsm.txt b/filelistAsm.txt
new file mode 100644
index 0000000..ab982af
--- /dev/null
+++ b/filelistAsm.txt
@@ -0,0 +1,15 @@
+Kernel loader
+Kernel/loader.asm
+
+HAL :: Global Descriptor Table assembly module
+Kernel/hal/cpu/gdt-asm.asm
+
+HAL :: Interrupt Descriptor Table assembly module
+Kernel/hal/cpu/idt-asm.asm
+
+HAL :: Interrupt Service Routines assembly module
+Kernel/hal/cpu/isrs-asm.asm
+
+HAL :: Interrupt Requests assembly module
+Kernel/hal/cpu/irq-asm.asm
+
diff --git a/filelistC.txt b/filelistC.txt
new file mode 100644
index 0000000..17b6b65
--- /dev/null
+++ b/filelistC.txt
@@ -0,0 +1,111 @@
+Main file
+Kernel/main.c
+
+Debug :: Console
+Kernel/debug/console.c
+
+Debug :: Console base routines
+Kernel/debug/console-base.c
+
+Debug :: Console output
+Kernel/debug/console-out.c
+
+Debug :: Console input
+Kernel/debug/console-in.c
+
+Drivers
+Kernel/drivers/drivers.c
+
+Drivers :: Complementary Metal Oxide Semiconductor (CMOS)
+Kernel/drivers/cmos/cmos.c
+
+Drivers :: Direct Memory Access Controller (DMAC)
+Kernel/drivers/dma/dma.c
+
+Drivers :: Floppy driver
+Kernel/drivers/floppy/floppy.c
+
+Drivers :: Programmable Interval Timer (PIT)
+Kernel/drivers/pit/pit.c
+
+HAL (Hardware abstraction layer)
+Kernel/hal/hal.c
+
+HAL :: Crash message
+Kernel/hal/crash.c
+
+HAL :: Global Descriptor Table
+Kernel/hal/cpu/gdt.c
+
+HAL :: Interrupt Descriptor Table
+Kernel/hal/cpu/idt.c
+
+HAL :: Interrupt Service Routines
+Kernel/hal/cpu/isrs.c
+
+HAL :: Interrupt Requests
+Kernel/hal/cpu/irq.c
+
+HAL :: Programmable Interrupt Controller
+Kernel/hal/cpu/pic.c
+
+HAL :: Internal clock
+Kernel/hal/clock/clock.c
+
+HAL :: Keyboard
+Kernel/hal/keyboard/keyboard.c
+
+HAL :: Mouse
+Kernel/hal/mouse/mouse.c
+
+HAL :: System info and tools
+Kernel/hal/sysinfo.c
+
+Libraries :: Character types
+Kernel/library/ctype.c
+
+Libraries :: Memory :: Allocation
+Kernel/library/memory/memory_alloc.c
+
+Libraries :: Memory :: Free
+Kernel/library/memory/memory_free.c
+
+Libraries :: Memory :: Information
+Kernel/library/memory/memory_info.c
+
+Libraries :: Memory :: Initialization
+Kernel/library/memory/memory_init.c
+
+Libraries :: Standard input/output
+Kernel/library/stdio.c
+
+Libraries :: Standard library :: Convert operations
+Kernel/library/stdlib/convert_ops.c
+
+Libraries :: Standard library :: Memory operations
+Kernel/library/stdlib/mem_ops.c
+
+Libraries :: Standard library :: Number operations
+Kernel/library/stdlib/num_ops.c
+
+Libraries :: Standard library :: Ordered array
+Kernel/library/stdlib/ord_arr.c
+
+Libraries :: Standard library :: String operations
+Kernel/library/stdlib/str_ops.c
+
+Libraries :: Storage
+Kernel/library/storage.c
+
+Libraries :: Time
+Kernel/library/time.c
+
+Memory Manager :: Memory heap
+Kernel/memory/mem-heap.c
+
+Memory Manager :: Physical memory manager
+Kernel/memory/mem-phys.c
+
+Memory Manager :: Paging
+Kernel/memory/mem-paging.c
+
diff --git a/floppy/floppy_mount.sh b/floppy/floppy_mount.sh
new file mode 100644
index 0000000..6c3a21b
--- /dev/null
+++ b/floppy/floppy_mount.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+case $1 in
+-m)
+ mkdir /media/floppy1
+ mount -o loop $2 /media/floppy1/
+ echo "Done." ;;
+-u)
+ umount /media/floppy1/
+ rm -r /media/floppy1/
+ echo "Done." ;;
+*)
+ echo "Usage: sudo floppy_mount [-m/-u] floppy_image.img\n" ;;
+
+esac
diff --git a/_play/fat16.img/fat16.img b/floppy/grub_aux.img
similarity index 93%
rename from _play/fat16.img/fat16.img
rename to floppy/grub_aux.img
index 54b8e03..0b0dfbb 100644
Binary files a/_play/fat16.img/fat16.img and b/floppy/grub_aux.img differ
diff --git a/floppy/original.img b/floppy/original.img
new file mode 100644
index 0000000..bff4c76
Binary files /dev/null and b/floppy/original.img differ
diff --git a/kernel.bin b/kernel.bin
new file mode 100644
index 0000000..e26c061
Binary files /dev/null and b/kernel.bin differ
diff --git a/link.ld b/link.ld
new file mode 100644
index 0000000..d0b1666
--- /dev/null
+++ b/link.ld
@@ -0,0 +1,45 @@
+ENTRY(start)
+OUTPUT_FORMAT("elf32-i386")
+OUTPUT(kernel.bin)
+
+SECTIONS
+{
+ . = 0x100000;
+
+ .__mbHeader :
+ {
+ *(.__mbHeader)
+ }
+
+ .setup :
+ {
+ *(.setup)
+ }
+
+ /* . += 0xC0000000; */
+
+
+
+ .text : /* AT(ADDR(.text) - 0xC0000000) */
+ {
+ _code = .;
+ *(.text)
+ *(.rodata*)
+ }
+
+ .data ALIGN(0x1000) : /* AT(ADDR(.data) - 0xC0000000) */
+ {
+ _data = .;
+ *(.data)
+ }
+
+ .bss ALIGN(0x1000) : /* AT(ADDR(.bss) - 0xC0000000) */
+ {
+ _bss = .;
+ *(COMMON)
+ *(.bss)
+ }
+
+ . = ALIGN(0x1000);
+ _end = .;
+}
diff --git a/luxos.img b/luxos.img
new file mode 100644
index 0000000..9e49dfd
Binary files /dev/null and b/luxos.img differ
diff --git a/preview/booting.png b/preview/booting.png
deleted file mode 100644
index 253c11b..0000000
Binary files a/preview/booting.png and /dev/null differ
diff --git a/preview/floppy.png b/preview/floppy.png
deleted file mode 100644
index 4b6abe2..0000000
Binary files a/preview/floppy.png and /dev/null differ
diff --git a/preview/help&input.png b/preview/help&input.png
deleted file mode 100644
index a47cc40..0000000
Binary files a/preview/help&input.png and /dev/null differ
diff --git a/preview/help.png b/preview/help.png
deleted file mode 100644
index 847614b..0000000
Binary files a/preview/help.png and /dev/null differ
diff --git a/preview/memory.png b/preview/memory.png
deleted file mode 100644
index 4fe0018..0000000
Binary files a/preview/memory.png and /dev/null differ
diff --git a/preview/pageFault.png b/preview/pageFault.png
deleted file mode 100644
index 94cd199..0000000
Binary files a/preview/pageFault.png and /dev/null differ
diff --git a/scripts/build.bat b/scripts/build.bat
new file mode 100644
index 0000000..bc1dc65
--- /dev/null
+++ b/scripts/build.bat
@@ -0,0 +1,6 @@
+@echo off
+
+C:
+chdir C:\Dev\lux
+
+C:\cygwin\bin\bash /cygdrive/c/Dev/lux/build.sh
\ No newline at end of file
diff --git a/scripts/format b/scripts/format
deleted file mode 100644
index 8d03dab..0000000
--- a/scripts/format
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-n
diff --git a/scripts/pack.bat b/scripts/pack.bat
new file mode 100644
index 0000000..666a8c3
--- /dev/null
+++ b/scripts/pack.bat
@@ -0,0 +1,6 @@
+@echo off
+
+C:
+chdir C:\Dev\lux
+
+C:\cygwin\bin\bash /cygdrive/c/Dev/lux/scripts/pack.sh
diff --git a/scripts/pack.sh b/scripts/pack.sh
new file mode 100644
index 0000000..931d8f2
--- /dev/null
+++ b/scripts/pack.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+cd /cygdrive/c/Dev
+
+# Get version number
+read version < ./lux/Kernel/include/version.h
+version=${version##"#define OS_BUILD \""}
+version=${version%%"\""}
+
+echo "Packing lux operating system build $version ..."
+
+# Pack files
+tar cfj lux-$version.tar.bz2 lux/
\ No newline at end of file
diff --git a/scripts/run.bat b/scripts/run.bat
new file mode 100644
index 0000000..7108c70
--- /dev/null
+++ b/scripts/run.bat
@@ -0,0 +1,6 @@
+@echo off
+
+set virtualbox=C:\PROGRA~1\oracle\Virtua~1\
+set machineName="lux Testbed"
+
+%virtualbox%\vboxmanage startvm %machineName%
\ No newline at end of file
diff --git a/scripts/stage1d b/scripts/stage1d
deleted file mode 100644
index 8667502..0000000
--- a/scripts/stage1d
+++ /dev/null
@@ -1,2 +0,0 @@
-w 100 0 0 1
-q
diff --git a/scripts/version.txt b/scripts/version.txt
new file mode 100644
index 0000000..29ba0df
--- /dev/null
+++ b/scripts/version.txt
@@ -0,0 +1 @@
+450
diff --git a/vidbackup.zip b/vidbackup.zip
deleted file mode 100644
index 0550e26..0000000
Binary files a/vidbackup.zip and /dev/null differ