2015-10-10 22:45:02 +00:00
|
|
|
NATIVE print(...);
|
|
|
|
|
2015-10-12 12:32:38 +00:00
|
|
|
NATIVE shutdown();
|
|
|
|
|
2015-10-10 22:45:02 +00:00
|
|
|
NATIVE outb(port : UINT16, value : UINT8);
|
|
|
|
NATIVE inb(port : UINT16) → UINT8;
|
|
|
|
|
2015-10-11 10:48:01 +00:00
|
|
|
NATIVE toInt8(…) → INT8;
|
|
|
|
NATIVE toInt16(…) → INT16;
|
|
|
|
NATIVE toInt32(…) → INT32;
|
|
|
|
|
|
|
|
NATIVE toUInt8(…) → UINT8;
|
|
|
|
NATIVE toUInt16(…) → UINT16;
|
|
|
|
NATIVE toUInt32(…) → UINT32;
|
|
|
|
|
|
|
|
# NATIVE toBool(…) → BOOL;
|
|
|
|
# NATIVE toText(…) → TEXT;
|
|
|
|
|
2015-10-10 22:45:02 +00:00
|
|
|
PRI sendCommand(cmd : UINT8)
|
|
|
|
BEGIN
|
|
|
|
# Warten bis die Tastatur bereit ist, und der Befehlspuffer leer ist
|
|
|
|
WHILE (inb(100u16) & 2u8) =/= 0u8 DO
|
|
|
|
|
|
|
|
END
|
2015-10-11 10:48:01 +00:00
|
|
|
outb(toUInt16(96), cmd);
|
2015-10-10 22:45:02 +00:00
|
|
|
END
|
|
|
|
|
|
|
|
PRI initKeyboard()
|
|
|
|
BEGIN
|
|
|
|
# Tastaturpuffer leeren
|
|
|
|
WHILE (inb(100u16) & 1u8) =/= 0u8 DO
|
|
|
|
inb(96u16);
|
|
|
|
END
|
|
|
|
|
|
|
|
# Tastatur aktivieren
|
|
|
|
# sendCommand(244u8);
|
|
|
|
END
|
|
|
|
|
2015-10-09 23:41:38 +00:00
|
|
|
PUB main() | i : INT
|
|
|
|
BEGIN
|
2015-10-10 22:45:02 +00:00
|
|
|
print("Initialize keyboard...\n");
|
|
|
|
initKeyboard();
|
|
|
|
|
2015-10-11 10:48:01 +00:00
|
|
|
print(toInt8(16), "\n");
|
|
|
|
|
2015-10-10 22:45:02 +00:00
|
|
|
print("Hello World!\n");
|
2015-10-09 23:41:38 +00:00
|
|
|
1 → i;
|
|
|
|
WHILE i <= 5 DO
|
2015-10-10 22:45:02 +00:00
|
|
|
print(i, "\n");
|
2015-10-09 23:41:38 +00:00
|
|
|
(i + 1) → i;
|
|
|
|
END
|
|
|
|
END
|
|
|
|
|
2015-10-10 22:45:02 +00:00
|
|
|
TYPE CpuState IS
|
|
|
|
eax : UINT32;
|
|
|
|
ebx : UINT32;
|
|
|
|
ecx : UINT32;
|
|
|
|
END
|
|
|
|
|
|
|
|
PUB irq(id : INT, data : CpuState) | scancode : UINT8
|
2015-10-09 23:41:38 +00:00
|
|
|
BEGIN
|
2015-10-10 22:45:02 +00:00
|
|
|
# print("irq:", id, ", ", data.eax, " ", data.ebx, "\n");
|
|
|
|
IF id = 33 THEN
|
|
|
|
inb(96u16) → scancode;
|
|
|
|
print("keypress: ", scancode, "\n");
|
2015-10-12 12:32:38 +00:00
|
|
|
IF scancode = 1u8 THEN
|
|
|
|
shutdown();
|
|
|
|
END
|
2015-10-10 22:45:02 +00:00
|
|
|
END
|
2015-10-09 23:41:38 +00:00
|
|
|
END
|
|
|
|
|
|
|
|
#!
|
|
|
|
Was noch gemacht werden muss, bis der Tastatur-Treiber funktionieren könnte:
|
2015-10-10 22:45:02 +00:00
|
|
|
☑ Support für beliebige Typen in Copper
|
|
|
|
☑ Pushen von Typen != INT
|
|
|
|
☑ erweiterung von pushi um typcode (u?int(8|16|32), bool)
|
|
|
|
☑ erweiterung von pushr um typcode
|
|
|
|
☑ Simple type checks in Copper
|
|
|
|
☑ Custom types in Copper
|
|
|
|
☑ Native function calls in Copper
|
|
|
|
☑ Bitwise Operations
|
|
|
|
☑ outb und inb
|
|
|
|
☐ eventuell hex literals für Copper
|
2015-10-09 23:41:38 +00:00
|
|
|
!#
|