Add output module for console output routines

This commit is contained in:
Josh Holtrop 2022-03-14 13:53:02 -04:00
parent d782b59768
commit 0be1b113aa
3 changed files with 29 additions and 3 deletions

View File

@ -76,7 +76,7 @@ hel_env = env "hel", use: %w[ldc2 x86_64-w64-mingw32-gcc] do |env|
env["sources"] = glob("src/hel/**/*.d")
env["sources"] += glob("uefi-d/source/**/*.d")
env["DFLAGS"] += %w[-mtriple=x86_64-unknown-windows-coff --betterC -release -O3]
env["D_IMPORT_PATH"] += %w[src uefi-d/source]
env["D_IMPORT_PATH"] += %w[src/hel uefi-d/source]
env["LD"] = "x86_64-w64-mingw32-gcc"
env["LDFLAGS"] += %w[-nostdlib -Wl,-dll -shared -Wl,--subsystem,10 -e efi_main -Wl,-Map,${_TARGET}.map]
env["LDCMD"] = %w[${LD} -o ${_TARGET} ${LDFLAGS} ${_SOURCES} ${LIBDIRPREFIX}${LIBPATH} ${LIBLINKPREFIX}${LIBS}]

View File

@ -1,11 +1,16 @@
import uefi;
import output;
__gshared EFI_SYSTEM_TABLE * g_st;
extern (C) EFI_STATUS efi_main(EFI_HANDLE image_handle, EFI_SYSTEM_TABLE * st)
{
g_st = st;
st.ConOut.ClearScreen(st.ConOut);
st.ConOut.OutputString(st.ConOut, cast(CHAR16 *)"HOS EFI loader\r\n"w);
st.ConOut.OutputString(st.ConOut, cast(CHAR16 *)"Press any key...\r\n"w);
writeln("HOS EFI loader");
writeln("Press any key...");
st.ConIn.Reset(st.ConIn, FALSE);
EFI_INPUT_KEY key;

21
src/hel/output.d Normal file
View File

@ -0,0 +1,21 @@
import uefi;
import hel;
void write(string s)
{
__gshared static CHAR16[256] s16;
size_t i = 0u;
while (i < s.length)
{
s16[i] = s[i];
i++;
}
s16[i++] = 0u;
g_st.ConOut.OutputString(g_st.ConOut, &s16[0]);
}
void writeln(string s)
{
write(s);
write("\r\n");
}