Don't require system_table in console
This commit is contained in:
@@ -2,10 +2,8 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <uefi/types.h>
|
#include <uefi/types.h>
|
||||||
#include <uefi/boot_services.h>
|
|
||||||
#include <uefi/graphics.h>
|
#include <uefi/graphics.h>
|
||||||
#include <uefi/protos/graphics_output.h>
|
#include <uefi/protos/graphics_output.h>
|
||||||
#include <uefi/protos/simple_text_output.h>
|
|
||||||
|
|
||||||
#include "console.h"
|
#include "console.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
@@ -25,18 +23,13 @@ console *console::s_console = nullptr;
|
|||||||
static const wchar_t digits[] = {u'0', u'1', u'2', u'3', u'4', u'5',
|
static const wchar_t digits[] = {u'0', u'1', u'2', u'3', u'4', u'5',
|
||||||
u'6', u'7', u'8', u'9', u'a', u'b', u'c', u'd', u'e', u'f'};
|
u'6', u'7', u'8', u'9', u'a', u'b', u'c', u'd', u'e', u'f'};
|
||||||
|
|
||||||
console::console(uefi::system_table *system_table) :
|
console::console(uefi::boot_services *bs, uefi::protos::simple_text_output *out) :
|
||||||
m_rows(0),
|
m_rows(0),
|
||||||
m_cols(0),
|
m_cols(0),
|
||||||
m_current_status_line(0)
|
m_current_status_line(0),
|
||||||
|
m_out(out)
|
||||||
{
|
{
|
||||||
uefi::status status;
|
pick_mode(bs);
|
||||||
|
|
||||||
s_console = this;
|
|
||||||
m_boot = system_table->boot_services;
|
|
||||||
m_out = system_table->con_out;
|
|
||||||
|
|
||||||
pick_mode();
|
|
||||||
|
|
||||||
try_or_raise(
|
try_or_raise(
|
||||||
m_out->query_mode(m_out->mode->mode, &m_cols, &m_rows),
|
m_out->query_mode(m_out->mode->mode, &m_cols, &m_rows),
|
||||||
@@ -54,17 +47,19 @@ console::console(uefi::system_table *system_table) :
|
|||||||
|
|
||||||
m_out->set_attribute(uefi::attribute::light_gray);
|
m_out->set_attribute(uefi::attribute::light_gray);
|
||||||
m_out->output_string(L" booting...\r\n\n");
|
m_out->output_string(L" booting...\r\n\n");
|
||||||
|
|
||||||
|
s_console = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
console::pick_mode()
|
console::pick_mode(uefi::boot_services *bs)
|
||||||
{
|
{
|
||||||
uefi::status status;
|
uefi::status status;
|
||||||
uefi::protos::graphics_output *gfx_out_proto;
|
uefi::protos::graphics_output *gfx_out_proto;
|
||||||
uefi::guid guid = uefi::protos::graphics_output::guid;
|
uefi::guid guid = uefi::protos::graphics_output::guid;
|
||||||
|
|
||||||
try_or_raise(
|
try_or_raise(
|
||||||
m_boot->locate_protocol(&guid, nullptr, (void **)&gfx_out_proto),
|
bs->locate_protocol(&guid, nullptr, (void **)&gfx_out_proto),
|
||||||
L"Failed to find a Graphics Output Protocol handle");
|
L"Failed to find a Graphics Output Protocol handle");
|
||||||
|
|
||||||
const uint32_t modes = gfx_out_proto->mode->max_mode;
|
const uint32_t modes = gfx_out_proto->mode->max_mode;
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <uefi/tables.h>
|
#include <uefi/boot_services.h>
|
||||||
|
#include <uefi/protos/simple_text_output.h>
|
||||||
|
|
||||||
namespace boot {
|
namespace boot {
|
||||||
|
|
||||||
class console
|
class console
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
console(uefi::system_table *system_table);
|
console(uefi::boot_services *bs, uefi::protos::simple_text_output *out);
|
||||||
|
|
||||||
void status_begin(const wchar_t *message);
|
void status_begin(const wchar_t *message);
|
||||||
void status_fail(const wchar_t *message, const wchar_t *error=nullptr) const;
|
void status_fail(const wchar_t *message, const wchar_t *error=nullptr) const;
|
||||||
@@ -25,12 +26,11 @@ public:
|
|||||||
static size_t print(const wchar_t *fmt, ...);
|
static size_t print(const wchar_t *fmt, ...);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void pick_mode();
|
void pick_mode(uefi::boot_services *bs);
|
||||||
size_t vprintf(const wchar_t *fmt, va_list args) const;
|
size_t vprintf(const wchar_t *fmt, va_list args) const;
|
||||||
|
|
||||||
size_t m_rows, m_cols;
|
size_t m_rows, m_cols;
|
||||||
int m_current_status_line;
|
int m_current_status_line;
|
||||||
uefi::boot_services *m_boot;
|
|
||||||
uefi::protos::simple_text_output *m_out;
|
uefi::protos::simple_text_output *m_out;
|
||||||
|
|
||||||
static console *s_console;
|
static console *s_console;
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ efi_main(uefi::handle image_handle, uefi::system_table *st)
|
|||||||
using namespace boot;
|
using namespace boot;
|
||||||
|
|
||||||
error::cpu_assert_handler handler;
|
error::cpu_assert_handler handler;
|
||||||
console con(st);
|
console con(st->boot_services, st->con_out);
|
||||||
|
|
||||||
return bootloader_main_uefi(st, con);
|
return bootloader_main_uefi(st, con);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user