-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exiting UEFI and adding serial port support for debugging.
- Loading branch information
1 parent
621d809
commit d65ad9d
Showing
10 changed files
with
316 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
HARIBOOT | ||
CUSTOM | ||
1 1 1 | ||
1 1 0 | ||
1280 0800 | ||
053 080 112 000 | ||
109 089 122 000 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01HBdsDxe: failed to load Boot0001 "UEFI QEMU DVD-ROM QM00003 " from PciRoot(0x0)/Pci(0x1,0x1)/Ata(Secondary,Master,0x0): Not Found | ||
BdsDxe: loading Boot0002 "UEFI QEMU HARDDISK QM00001 " from PciRoot(0x0)/Pci(0x1,0x1)/Ata(Primary,Master,0x0) | ||
BdsDxe: starting Boot0002 "UEFI QEMU HARDDISK QM00001 " from PciRoot(0x0)/Pci(0x1,0x1)/Ata(Primary,Master,0x0) | ||
[2J[01;01H[=3h[2J[01;01H�Fichier ouvert avec succes. | ||
Fichier ferme avec succes. | ||
Fichier ouvert avec succes. | ||
Fichier ferme avec succes. | ||
[2J[01;01H[=3h[2J[01;01HHeader ELF confirme. | ||
Fichier ELF 64 bits. | ||
Fichier ELF essentiellement Little Endian. | ||
Type de segment: EXECUTABLE. | ||
Entry point: 0x100000 | ||
PT_PHDR Segment found. | ||
PT_INTERP Segment found. | ||
PT_LOAD Segment found. | ||
Physical Address: 0xff000 | ||
Virtual Address: 0xff000 | ||
Size of program header: 624 | ||
Memoire virtuelle alloue. | ||
PT_LOAD Segment found. | ||
Physical Address: 0x100000 | ||
Virtual Address: 0x100000 | ||
Size of program header: 464 | ||
Memoire virtuelle alloue. | ||
PT_DYNAMIC Segment found. | ||
PT_NOTE Segment found. | ||
PT_NOTE Segment found. | ||
No Segment Found. | ||
No Segment Found. | ||
No Segment Found. | ||
[2J[01;01H[=3h[2J[01;01HFichier ouvert avec succes. | ||
Fichier ferme avec succes. | ||
[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01H[2J[01;01H[=3h[2J[01;01HGetting memory map successfully !!! | ||
UEFI exited successfully.!!!! X64 Exception Type - 06(#UD - Invalid Opcode) CPU Apic ID - 00000000 !!!! | ||
RIP - 00000000000B0000, CS - 0000000000000038, RFLAGS - 0000000000000002 | ||
RAX - 0000000000000000, RCX - 000000007FEFA7A8, RDX - 000000007E532018 | ||
RBX - 0000000000000000, RSP - 000000007FEFA5A8, RBP - 000000007E67A898 | ||
RSI - 000000007E5E9320, RDI - 000000007E53B798 | ||
R8 - 000000007FEFA7A0, R9 - 000000007FEFA798, R10 - 000000007FEFA794 | ||
R11 - 00000000BA626FF9, R12 - 000000007EA3213C, R13 - 0000000000000000 | ||
R14 - 0000000000000000, R15 - 000000007DF93018 | ||
DS - 0000000000000030, ES - 0000000000000030, FS - 0000000000000030 | ||
GS - 0000000000000030, SS - 0000000000000030 | ||
CR0 - 0000000080010033, CR2 - 0000000000000000, CR3 - 000000007F801000 | ||
CR4 - 0000000000000668, CR8 - 0000000000000000 | ||
DR0 - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000 | ||
DR3 - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400 | ||
GDTR - 000000007F5DC000 0000000000000047, LDTR - 0000000000000000 | ||
IDTR - 000000007F050018 0000000000000FFF, TR - 0000000000000000 | ||
FXSAVE_STATE - 000000007FEFA200 | ||
!!!! Can't find image information. !!!! |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
|
||
#ifndef _IO_ | ||
#define _IO_ | ||
|
||
#include <efi.h> | ||
#include <efilib.h> | ||
|
||
inline void outb(UINT16 comPort, UINT8 value) { | ||
|
||
__asm__ volatile ( | ||
"outb %0, %1" | ||
:: "a"(value), | ||
"Nd"(comPort) : "memory"); | ||
} | ||
|
||
inline UINT8 inb(UINT16 comPort) { | ||
|
||
UINT8 result; | ||
|
||
__asm__ volatile ( | ||
"inb %1, %0" | ||
: "=a"(result) : "Nd"(comPort) : "memory"); | ||
|
||
return result; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
#ifndef _SERIAL_PORT_ | ||
#define _SERIAL_PORT_ | ||
|
||
#include <efi.h> | ||
#include <efilib.h> | ||
|
||
// Serial com port of the serial port. | ||
#define SERIAL_COM1 0x3F8 | ||
#define SERIAL_COM2 0x2F8 | ||
#define SERIAL_COM3 0x3E8 | ||
#define SERIAL_COM4 0x2E8 | ||
#define SERIAL_COM5 0x5F8 | ||
#define SERIAL_COM6 0x4F8 | ||
#define SERIAL_COM7 0x5E8 | ||
#define SERIAL_COM8 0x4E8 | ||
|
||
// All the registers of the serial port. | ||
#define SERIAL_DATA_REGISTER(x) (x) | ||
#define SERIAL_INTERRUPT_ENABLE_REGISTER(x) (x+1) | ||
#define SERIAL_FIFO_CONTROL_REGISTER(x) (x+2) | ||
#define SERIAL_LINE_CONTROL_REGISTER(x) (x+3) | ||
#define SERIAL_MODEM_CONTROL_REGISTER(x) (x+4) | ||
#define SERIAL_LINE_STATUS_REGISTER(x) (x+5) | ||
#define SERIAL_MODEM_STATUS_REGISTER(x) (x+6) | ||
#define SERIAL_SCRATCH_REGISTER(x) (x+7) | ||
|
||
// Parity for line protocol | ||
#define NONE (0x0 << 3) & 0xFF | ||
#define ODD (0x1 << 3) & 0xFF | ||
#define EVEN ((0x1 << 4) | (0x1 << 3)) | ||
#define MARK ((0x1 << 5) | (0x1 << 3)) | ||
#define SPACE ((0x1 << 5) | (0x1 << 4) | (0x1 << 3)) | ||
|
||
// Macro for line status register | ||
#define DATA_READY 0x0 | ||
#define OVERRUN_ERROR 0x1 | ||
#define PARITY_ERROR 0x2 | ||
#define FRAMING_ERROR 0x3 | ||
#define BREAK_INDICATOR 0x4 | ||
#define TRANSMITTER_HOLDING_REGISTER_EMPTY 0x5 | ||
#define TRANSMITTER_EMPTY 0x6 | ||
#define IMPENDING_ERROR 0x7 | ||
|
||
UINT32 readData(UINT16 comPort); | ||
void printString(UINT16 comPort, const CHAR8 *string); | ||
BOOLEAN initSerialPort(UINT16 comPort); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#include <efi.h> | ||
#include <efilib.h> | ||
#include "debug/io.h" | ||
#include "debug/serial_port.h" | ||
|
||
|
||
static void enableFIFO(UINT16 comPort) { | ||
|
||
outb(SERIAL_FIFO_CONTROL_REGISTER(comPort), 0xC7); | ||
} | ||
|
||
static void disableInterrupt(UINT16 comPort) { | ||
|
||
outb(comPort + 1, 0x00); | ||
} | ||
|
||
static UINT8 getStatus(UINT16 comPort) { | ||
|
||
return inb(SERIAL_LINE_STATUS_REGISTER(comPort)); | ||
} | ||
|
||
static void putChar(UINT16 comPort, CHAR8 character) { | ||
|
||
while ((getStatus(comPort) & 0x20) == 0); | ||
outb(comPort, character); | ||
} | ||
|
||
static void setBaudRate(UINT16 comPort, UINT16 divisorValue) { | ||
|
||
outb(SERIAL_LINE_CONTROL_REGISTER(comPort), 0x80); | ||
outb(SERIAL_DATA_REGISTER(comPort), (divisorValue >> 8) & 0x00FF); | ||
outb(SERIAL_INTERRUPT_ENABLE_REGISTER(comPort), divisorValue & 0x00FF); | ||
} | ||
|
||
static void setDataBits(UINT16 comPort, UINT16 charLenght) { | ||
|
||
switch (charLenght) { | ||
case 5: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), 0x00); break; | ||
case 6: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), 0x01); break; | ||
case 7: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), 0x02); break; | ||
case 8: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), 0x03); break; | ||
} | ||
} | ||
|
||
static void setStopBit(UINT16 comPort, BOOLEAN stopBit) { | ||
|
||
if (stopBit == FALSE) outb(SERIAL_LINE_CONTROL_REGISTER(comPort), (0x0 << 2) & 0xFF); | ||
else outb(SERIAL_LINE_CONTROL_REGISTER(comPort), (0x1 << 2) & 0xFF); | ||
} | ||
|
||
static void setParityBit(UINT16 comPort, UINT8 type) { | ||
|
||
switch (type) { | ||
case 0x0: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), NONE); break; | ||
case 0x1: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), ODD); break; | ||
case 0x2: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), EVEN); break; | ||
case 0x3: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), MARK); break; | ||
case 0x4: outb(SERIAL_LINE_CONTROL_REGISTER(comPort), SPACE); break; | ||
} | ||
} | ||
|
||
UINT32 readData(UINT16 comPort) { | ||
|
||
while ((getStatus(comPort) & 0x1) == DATA_READY); | ||
return inb(SERIAL_DATA_REGISTER(comPort)); | ||
} | ||
|
||
void printString(UINT16 comPort, const CHAR8 *string) { | ||
|
||
for (UINT16 i = 0; string[i] != '\0'; i++) putChar(comPort, string[i]); | ||
} | ||
|
||
BOOLEAN initSerialPort(UINT16 comPort) { | ||
|
||
disableInterrupt(comPort); | ||
setBaudRate(comPort, 0x0); | ||
setDataBits(comPort, 8); | ||
setStopBit(comPort, FALSE); | ||
setParityBit(comPort, 0x0); | ||
enableFIFO(comPort); | ||
|
||
outb(comPort + 0, 0xAE); | ||
if (inb(comPort + 0) != 0xAE) return TRUE; | ||
|
||
return FALSE; | ||
} |
Oops, something went wrong.