git-svn-id: https://spexeah.com:8443/svn/Asuro@792 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
@ -20,12 +20,43 @@ procedure init();
|
||||
function receive(PORT : uint16; timeout : uint32) : uint8;
|
||||
function send(PORT : uint16; data : uint8; timeout : uint32) : boolean;
|
||||
function sendString(str : pchar) : boolean;
|
||||
function sendHex(i : uint32) : boolean;
|
||||
procedure soutb(port : uint16; val : uint8);
|
||||
function sinb(port : uint16) : uint8;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
console;
|
||||
|
||||
procedure soutb(port : uint16; val : uint8);
|
||||
begin
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
MOV DX, port
|
||||
MOV AL, val
|
||||
OUT DX, AL
|
||||
POP EDX
|
||||
POP EAX
|
||||
end;
|
||||
io_wait;
|
||||
end;
|
||||
|
||||
function sinb(port : uint16) : uint8;
|
||||
begin
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
MOV DX, port
|
||||
IN AL, DX
|
||||
MOV sinb, AL
|
||||
POP EDX
|
||||
POP EAX
|
||||
end;
|
||||
io_wait;
|
||||
end;
|
||||
|
||||
procedure IRQ_Hook();
|
||||
begin
|
||||
|
||||
@ -33,13 +64,13 @@ end;
|
||||
|
||||
procedure initPort(PORT : uint16);
|
||||
begin
|
||||
outb(PORT + 1, $00);
|
||||
outb(PORT + 3, $80);
|
||||
outb(PORT + 0, $03);
|
||||
outb(PORT + 1, $00);
|
||||
outb(PORT + 3, $03);
|
||||
outb(PORT + 2, $C7);
|
||||
outb(PORT + 4, $0B);
|
||||
soutb(PORT + 1, $00);
|
||||
soutb(PORT + 3, $80);
|
||||
soutb(PORT + 0, $03);
|
||||
soutb(PORT + 1, $00);
|
||||
soutb(PORT + 3, $03);
|
||||
soutb(PORT + 2, $C7);
|
||||
soutb(PORT + 4, $0B);
|
||||
end;
|
||||
|
||||
procedure init();
|
||||
@ -52,12 +83,12 @@ end;
|
||||
|
||||
function serial_received(PORT : uint16) : uint32;
|
||||
begin
|
||||
serial_received:= inb(PORT + 5) AND 1;
|
||||
serial_received:= sinb(PORT + 5) AND 1;
|
||||
end;
|
||||
|
||||
function is_transmit_empty(PORT : uint16) : uint32;
|
||||
begin
|
||||
is_transmit_empty:= inb(PORT + 5) AND $20;
|
||||
is_transmit_empty:= sinb(PORT + 5) AND $20;
|
||||
end;
|
||||
|
||||
function receive(PORT : uint16; timeout : uint32) : uint8;
|
||||
@ -71,7 +102,7 @@ begin
|
||||
dec(_timeout);
|
||||
end;
|
||||
if _timeout <> 0 then begin
|
||||
receive:= inb(PORT);
|
||||
receive:= sinb(PORT);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -86,7 +117,7 @@ begin
|
||||
dec(_timeout);
|
||||
end;
|
||||
if _timeout <> 0 then begin
|
||||
outb(PORT, data);
|
||||
soutb(PORT, data);
|
||||
send:= true;
|
||||
end;
|
||||
end;
|
||||
@ -104,4 +135,54 @@ begin
|
||||
sendString:= sendString AND send(COM1, uint8(10), 10000);
|
||||
end;
|
||||
|
||||
function sendHex(i : uint32) : boolean;
|
||||
var
|
||||
Hex : Array[0..7] of Byte;
|
||||
Res : DWORD;
|
||||
Rem : DWORD;
|
||||
c : Integer;
|
||||
|
||||
begin
|
||||
for c:=0 to 7 do begin
|
||||
Hex[c]:= 0;
|
||||
end;
|
||||
c:=0;
|
||||
Res:= i;
|
||||
Rem:= Res mod 16;
|
||||
while Res > 0 do begin
|
||||
Hex[c]:= Rem;
|
||||
Res:= Res div 16;
|
||||
Rem:= Res mod 16;
|
||||
c:=c+1;
|
||||
end;
|
||||
send(COM1, uint8('0'), 10000);
|
||||
send(COM1, uint8('x'), 10000);
|
||||
for c:=7 downto 0 do begin
|
||||
if Hex[c] <> 255 then begin
|
||||
case Hex[c] of
|
||||
0:send(COM1, uint8('0'), 10000);
|
||||
1:send(COM1, uint8('1'), 10000);
|
||||
2:send(COM1, uint8('2'), 10000);
|
||||
3:send(COM1, uint8('3'), 10000);
|
||||
4:send(COM1, uint8('4'), 10000);
|
||||
5:send(COM1, uint8('5'), 10000);
|
||||
6:send(COM1, uint8('6'), 10000);
|
||||
7:send(COM1, uint8('7'), 10000);
|
||||
8:send(COM1, uint8('8'), 10000);
|
||||
9:send(COM1, uint8('9'), 10000);
|
||||
10:send(COM1, uint8('A'), 10000);
|
||||
11:send(COM1, uint8('B'), 10000);
|
||||
12:send(COM1, uint8('C'), 10000);
|
||||
13:send(COM1, uint8('D'), 10000);
|
||||
14:send(COM1, uint8('E'), 10000);
|
||||
15:send(COM1, uint8('F'), 10000);
|
||||
else send(COM1,uint8('?'), 10000);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
send(COM1, uint8(13), 10000);
|
||||
send(COM1, uint8(10), 10000);
|
||||
sendHex:= true;
|
||||
end;
|
||||
|
||||
end.
|
@ -68,7 +68,7 @@ var
|
||||
implementation
|
||||
|
||||
uses
|
||||
console, RTC, cpu;
|
||||
console, RTC, cpu, serial, strings;
|
||||
|
||||
function MsSinceSystemBoot : uint64;
|
||||
begin
|
||||
@ -272,6 +272,9 @@ end;
|
||||
|
||||
procedure outl(port : uint16; val : uint32); [public, alias: 'util_outl'];
|
||||
begin
|
||||
//serial.sendString('[outl]');
|
||||
//serial.sendHex(port);
|
||||
//serial.sendHex(val);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
@ -286,6 +289,9 @@ end;
|
||||
|
||||
procedure outw(port : uint16; val : uint16); [public, alias: 'util_outw'];
|
||||
begin
|
||||
//serial.sendString('[outw]');
|
||||
//serial.sendHex(port);
|
||||
//serial.sendHex(val);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
@ -300,6 +306,9 @@ end;
|
||||
|
||||
procedure outb(port : uint16; val : uint8); [public, alias: 'util_outb'];
|
||||
begin
|
||||
//serial.sendString('[outb]');
|
||||
//serial.sendHex(port);
|
||||
//serial.sendHex(val);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
@ -328,6 +337,8 @@ end;
|
||||
|
||||
function inl(port : uint16) : uint32; [public, alias: 'util_inl'];
|
||||
begin
|
||||
//serial.sendString('[inl]');
|
||||
//serial.sendHex(port);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
@ -342,6 +353,8 @@ end;
|
||||
|
||||
function inw(port : uint16) : uint16; [public, alias: 'util_inw'];
|
||||
begin
|
||||
//serial.sendString('[inw]');
|
||||
//serial.sendHex(port);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
@ -356,6 +369,8 @@ end;
|
||||
|
||||
function inb(port : uint16) : uint8; [public, alias: 'util_inb'];
|
||||
begin
|
||||
//serial.sendString('[inb]');
|
||||
//serial.sendHex(port);
|
||||
asm
|
||||
PUSH EAX
|
||||
PUSH EDX
|
||||
|
Reference in New Issue
Block a user