Skip to content

Commit 6fd7c23

Browse files
committed
Initial commit
0 parents  commit 6fd7c23

File tree

7 files changed

+113
-0
lines changed

7 files changed

+113
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*~
2+
*.fd
3+
fs
4+
.EFI

010_conout/BOOTX64.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
struct EFI_SYSTEM_TABLE {
2+
char _buf[60];
3+
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
4+
void *_buf;
5+
unsigned long long (*OutputString)(struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, unsigned short *);
6+
} *ConOut;
7+
};
8+
9+
int DllMainCRTStartup(void *ImageHandle __attribute__ ((unused)), struct EFI_SYSTEM_TABLE *SystemTable)
10+
{
11+
SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello UEFI!\n");
12+
while (1);
13+
return 0;
14+
}

010_conout/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: fs/EFI/BOOT/BOOTX64.EFI
2+
3+
fs/EFI/BOOT/BOOTX64.EFI: BOOTX64.c
4+
mkdir -p fs/EFI/BOOT
5+
x86_64-w64-mingw32-gcc -Wall -Wextra -nostdlib -Wl,--subsystem,10 -o $@ $<
6+
7+
run: fs/EFI/BOOT/BOOTX64.EFI
8+
qemu-system-x86_64 -nographic -bios OVMF.fd -hda fat:fs
9+
10+
clean:
11+
rm -rf *~ fs
12+
13+
.PHONY: clean

011_firmwarevendor/BOOTX64.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
struct EFI_SYSTEM_TABLE {
2+
char _buf1[24];
3+
unsigned short *FirmwareVendor;
4+
char _buf2[28];
5+
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
6+
void *_buf;
7+
unsigned long long (*OutputString)(struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, unsigned short *);
8+
} *ConOut;
9+
};
10+
11+
int DllMainCRTStartup(void *ImageHandle __attribute__ ((unused)), struct EFI_SYSTEM_TABLE *SystemTable)
12+
{
13+
SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello UEFI!\r\n");
14+
SystemTable->ConOut->OutputString(SystemTable->ConOut, SystemTable->FirmwareVendor);
15+
while (1);
16+
return 0;
17+
}

011_firmwarevendor/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: fs/EFI/BOOT/BOOTX64.EFI
2+
3+
fs/EFI/BOOT/BOOTX64.EFI: BOOTX64.c
4+
mkdir -p fs/EFI/BOOT
5+
x86_64-w64-mingw32-gcc -Wall -Wextra -nostdlib -Wl,--subsystem,10 -o $@ $<
6+
7+
run: fs/EFI/BOOT/BOOTX64.EFI
8+
qemu-system-x86_64 -nographic -bios OVMF.fd -hda fat:fs
9+
10+
clean:
11+
rm -rf *~ fs
12+
13+
.PHONY: clean

020_echoback/BOOTX64.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
struct EFI_INPUT_KEY {
2+
unsigned short ScanCode;
3+
unsigned short UnicodeChar;
4+
};
5+
6+
struct EFI_SYSTEM_TABLE {
7+
char _buf1[44];
8+
struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
9+
void *_buf;
10+
unsigned long long (*ReadKeyStroke)(struct EFI_SIMPLE_TEXT_INPUT_PROTOCOL *, struct EFI_INPUT_KEY *);
11+
} *ConIn;
12+
void *_buf2;
13+
struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
14+
void *_buf;
15+
unsigned long long (*OutputString)(struct EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *, unsigned short *);
16+
} *ConOut;
17+
};
18+
19+
int DllMainCRTStartup(void *ImageHandle __attribute__ ((unused)), struct EFI_SYSTEM_TABLE *SystemTable)
20+
{
21+
struct EFI_INPUT_KEY efi_input_key;
22+
unsigned short str[3];
23+
24+
while (1) {
25+
if (!SystemTable->ConIn->ReadKeyStroke(SystemTable->ConIn, &efi_input_key)) {
26+
if (efi_input_key.UnicodeChar != L'\r') {
27+
str[0] = efi_input_key.UnicodeChar;
28+
str[1] = L'\0';
29+
} else {
30+
str[0] = L'\r';
31+
str[1] = L'\n';
32+
str[2] = L'\0';
33+
}
34+
SystemTable->ConOut->OutputString(SystemTable->ConOut, str);
35+
}
36+
}
37+
38+
return 0;
39+
}

020_echoback/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
all: fs/EFI/BOOT/BOOTX64.EFI
2+
3+
fs/EFI/BOOT/BOOTX64.EFI: BOOTX64.c
4+
mkdir -p fs/EFI/BOOT
5+
x86_64-w64-mingw32-gcc -Wall -Wextra -nostdlib -Wl,--subsystem,10 -o $@ $<
6+
7+
run: fs/EFI/BOOT/BOOTX64.EFI
8+
qemu-system-x86_64 -nographic -bios OVMF.fd -hda fat:fs
9+
10+
clean:
11+
rm -rf *~ fs
12+
13+
.PHONY: clean

0 commit comments

Comments
 (0)