I want to make a DOS-inspired UEFI operating system, simple, a good place to start. Take in commands and run those commands, but I don't quite get the "Take in commands" part. In POSIX-UEFI, uefi.h has a custom printf, so I'm assuming it needs a custom scanf, given a different I/O system (educated guess).
I've tried quite a few things. I blatantly tried putting scanf in my code, and I got an implicit function declaration warning, so no scanf in uefi.h, it appears. I searched up loads of things and I didn't get anything back that was relevant to my problem, so I have came here.
Thanks in advance :).
From the looks of things, you end up using uefi services (fairly) directly. During startup, it initializes a global variable named ST
to point to the UEFI system table, which looks like this (uefi.h, line 846):
typedef struct {
efi_table_header_t Hdr;
wchar_t *FirmwareVendor;
uint32_t FirmwareRevision;
efi_handle_t ConsoleInHandle;
simple_input_interface_t *ConIn;
efi_handle_t ConsoleOutHandle;
simple_text_output_interface_t *ConOut;
efi_handle_t ConsoleErrorHandle;
simple_text_output_interface_t *StdErr;
efi_runtime_services_t *RuntimeServices;
efi_boot_services_t *BootServices;
uintn_t NumberOfTableEntries;
efi_configuration_table_t *ConfigurationTable;
} efi_system_table_t;
To read from the keyboard, you'll use the ConIn
, which is a pointer to a simple_input_interface_t
, which is defined as follows (uefi.h, line 576):
typedef struct {
efi_input_reset_t Reset;
efi_input_read_key_t ReadKeyStroke;
efi_event_t WaitForKey;
} simple_input_interface_t;
At a guess, you'll probably want to allocate a buffer of reasonable size. Then use WaitForKey
/ReadKeyStroke
to read keys and save them to the buffer until you get a carriage return.
Then you can use something like sscanf
to parse the content of the buffer.