Compare commits
No commits in common. "f904ec2b48cfbae8b10947f2bc178d14a3bc8758" and "d86745d91d392ebc6f401e4982774b78882d0cc6" have entirely different histories.
f904ec2b48
...
d86745d91d
@ -7,8 +7,6 @@ import uefi;
|
||||
import hello.hello;
|
||||
import core.stdc.stdarg;
|
||||
|
||||
struct console
|
||||
{
|
||||
/**
|
||||
* Format a hexadecimal value to a string.
|
||||
*
|
||||
@ -17,7 +15,7 @@ struct console
|
||||
* @param ptr If true, always output all 16 digits, and separate the upper and
|
||||
* lower halves with an underscore.
|
||||
*/
|
||||
private static size_t format_hex(CHAR16 * s, ulong v, bool ptr)
|
||||
private size_t format_hex(CHAR16 * s, ulong v, bool ptr)
|
||||
{
|
||||
string hex_chars = "0123456789ABCDEF";
|
||||
bool print = ptr;
|
||||
@ -47,7 +45,7 @@ struct console
|
||||
* @param s String buffer.
|
||||
* @param v Value to format.
|
||||
*/
|
||||
private static size_t format_dec(CHAR16 * s, ulong v)
|
||||
private size_t format_dec(CHAR16 * s, ulong v)
|
||||
{
|
||||
string dec_chars = "0123456789";
|
||||
bool print;
|
||||
@ -72,7 +70,7 @@ struct console
|
||||
* @param s Format string.
|
||||
* @param args Variable arguments structure.
|
||||
*/
|
||||
public static void write(string s, va_list args)
|
||||
void write(string s, va_list args)
|
||||
{
|
||||
__gshared static CHAR16[256] s16;
|
||||
size_t i = 0u;
|
||||
@ -136,7 +134,7 @@ struct console
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
public static extern (C) void write(string s, ...)
|
||||
extern (C) void write(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
@ -149,7 +147,7 @@ struct console
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
public static extern (C) void writeln(string s, ...)
|
||||
extern (C) void writeln(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
@ -161,7 +159,7 @@ struct console
|
||||
/**
|
||||
* Write a message to press any key and wait for a key to be pressed.
|
||||
*/
|
||||
public static void wait_key()
|
||||
void wait_key()
|
||||
{
|
||||
writeln("Press any key...");
|
||||
st.ConIn.Reset(st.ConIn, FALSE);
|
||||
@ -174,8 +172,7 @@ struct console
|
||||
/**
|
||||
* Clear the console.
|
||||
*/
|
||||
public static void clear()
|
||||
void clear()
|
||||
{
|
||||
st.ConOut.ClearScreen(st.ConOut);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
module hello.hello;
|
||||
|
||||
import uefi;
|
||||
import hello.console;
|
||||
import hello.scratch;
|
||||
import console = hello.console;
|
||||
import scratch = hello.scratch;
|
||||
import hulk.bootinfo;
|
||||
import hulk.header;
|
||||
import hos.page_table;
|
||||
|
@ -3,18 +3,16 @@
|
||||
*/
|
||||
module hello.scratch;
|
||||
|
||||
struct scratch
|
||||
{
|
||||
/* Scratch buffer. */
|
||||
private static align(4096) __gshared ubyte[1024 * 1024] scratch;
|
||||
private align(4096) __gshared ubyte[1024 * 1024] scratch;
|
||||
|
||||
/* Number of scratch buffer bytes used. */
|
||||
private static __gshared size_t scratch_used;
|
||||
private __gshared size_t scratch_used;
|
||||
|
||||
/**
|
||||
* Get the number of free bytes in the scratch buffer.
|
||||
*/
|
||||
public static size_t free()
|
||||
size_t free()
|
||||
{
|
||||
return scratch.sizeof - scratch_used;
|
||||
}
|
||||
@ -22,7 +20,7 @@ struct scratch
|
||||
/**
|
||||
* Get the current free scratch buffer address.
|
||||
*/
|
||||
public static ubyte * current()
|
||||
ubyte * current()
|
||||
{
|
||||
return &scratch[scratch_used];
|
||||
}
|
||||
@ -30,10 +28,9 @@ struct scratch
|
||||
/**
|
||||
* Allocate pages from the scratch buffer.
|
||||
*/
|
||||
public static ubyte * alloc(size_t n = 1)
|
||||
ubyte * alloc(size_t n = 1)
|
||||
{
|
||||
ubyte * address = &scratch[scratch_used];
|
||||
scratch_used += 4096u * n;
|
||||
return address;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user