Convert fb, console, klog to "static instance" namespacing structs
This commit is contained in:
1 parent
06242a0c9f
commit
98e992aad0
4 files changed
+102
-110
No files matched your search
+59
-62
@@ -7,70 +7,67 @@ import core.stdc.stdarg;
|
||||
import hulk.console;
|
||||
static import hulk.writef;
|
||||
|
||||
/**
|
||||
* Kernel buffer size log.
|
||||
* 16 gives a kernel buffer size of 64KB.
|
||||
*/
|
||||
enum size_t KLOG_SIZE_LOG = 16u;
|
||||
|
||||
/** Kernel buffer size. */
|
||||
enum size_t KLOG_SIZE = 1u << KLOG_SIZE_LOG;
|
||||
|
||||
/** Kernel log buffer. */
|
||||
private __gshared align(4096) char[KLOG_SIZE] klog_buffer;
|
||||
|
||||
/** Write index in the kernel log buffer. */
|
||||
private __gshared size_t klog_index;
|
||||
|
||||
/** Pointer to the console to use for kernel log output. */
|
||||
private __gshared Console * console;
|
||||
|
||||
/**
|
||||
* Initialize the klog module.
|
||||
*
|
||||
* @param console Pointer to the Console to use for kernel output.
|
||||
*/
|
||||
void initialize(Console * console)
|
||||
struct klog
|
||||
{
|
||||
.console = console;
|
||||
}
|
||||
/**
|
||||
* Kernel buffer size log.
|
||||
* 16 gives a kernel buffer size of 64KB.
|
||||
*/
|
||||
private enum size_t KLOG_SIZE_LOG = 16u;
|
||||
|
||||
/**
|
||||
* Write a formatted string to the kernel log.
|
||||
*
|
||||
* @param s Format string.
|
||||
* @param args Variable arguments structure.
|
||||
*/
|
||||
void writef(string s, va_list args)
|
||||
{
|
||||
hulk.writef.writef(s, args, function void(ubyte ch) {
|
||||
console.write(ch);
|
||||
});
|
||||
}
|
||||
/** Kernel buffer size. */
|
||||
private enum size_t KLOG_SIZE = 1u << KLOG_SIZE_LOG;
|
||||
|
||||
/**
|
||||
* Write a formatted string to the kernel log.
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
extern (C) void writef(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
writef(s, args);
|
||||
va_end(args);
|
||||
}
|
||||
/** Kernel log buffer. */
|
||||
private static __gshared align(4096) char[KLOG_SIZE] klog_buffer;
|
||||
|
||||
/**
|
||||
* Write a formatted string and newline to the console.
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
extern (C) void writefln(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
writef(s, args);
|
||||
writef("\n", args);
|
||||
va_end(args);
|
||||
/** Write index in the kernel log buffer. */
|
||||
private static __gshared size_t klog_index;
|
||||
|
||||
/**
|
||||
* Initialize the klog module.
|
||||
*/
|
||||
public static void initialize()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a formatted string to the kernel log.
|
||||
*
|
||||
* @param s Format string.
|
||||
* @param args Variable arguments structure.
|
||||
*/
|
||||
public static void writef(string s, va_list args)
|
||||
{
|
||||
hulk.writef.writef(s, args, function void(ubyte ch) {
|
||||
console.write(ch);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a formatted string to the kernel log.
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
public static extern (C) void writef(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
writef(s, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a formatted string and newline to the console.
|
||||
*
|
||||
* @param s Format string.
|
||||
*/
|
||||
public static extern (C) void writefln(string s, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, s);
|
||||
writef(s, args);
|
||||
writef("\n", args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user