-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9a78eb9
commit ca89089
Showing
28 changed files
with
5,801 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.cutekit | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
if [ -z "$CUTEKIT_PYTHON" ]; then | ||
export CUTEKIT_PYTHON="python3" | ||
fi | ||
|
||
if [ -z "$CUTEKIT_VERSION" ]; then | ||
export CUTEKIT_VERSION="stable" | ||
fi | ||
|
||
$CUTEKIT_PYTHON -m cutekit > /dev/null 2>/dev/null || { | ||
if [ ! -d "./.cutekit/.env" ]; then | ||
$CUTEKIT_PYTHON -m venv .cutekit/.env | ||
source .cutekit/.env/bin/activate | ||
$CUTEKIT_PYTHON -m pip install git+https://github.com/cute-engineering/cutekit.git@${CUTEKIT_VERSION} | ||
else | ||
source .cutekit/.env/bin/activate | ||
fi | ||
} | ||
|
||
$CUTEKIT_PYTHON -m cutekit $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
-std=gnu2x | ||
-Wall | ||
-Wextra | ||
-Werror | ||
-fcolor-diagnostics | ||
-I.cutekit/extern/cute-engineering | ||
-I.cutekit/extern/cute-engineering/ce-libc/src/ce-libc | ||
-I.cutekit/generated | ||
-I.cutekit/generated/__aliases__ | ||
-Isrc | ||
-D__ck_abi_ms__ | ||
-D__ck_abi_value=ms | ||
-D__ck_arch_value=x86_64 | ||
-D__ck_arch_x86_64__ | ||
-D__ck_sys_efi__ | ||
-D__ck_sys_value=efi | ||
-D__ck_toolchain_clang__ | ||
-D__ck_toolchain_value=clang | ||
-target | ||
x86_64-unknown-windows | ||
-ffreestanding | ||
-fno-stack-protector | ||
-fshort-wchar | ||
-mno-red-zone | ||
-fno-delayed-template-parsing | ||
-fno-ms-compatibility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#include <string.h> | ||
|
||
#include "config.h" | ||
#include "utils.h" | ||
|
||
static json_t entries; | ||
static Entry _selected_entry; | ||
|
||
void *_Nonnull _json_realloc(void *_Nullable ptr, size_t size) | ||
{ | ||
void *ret = NULL; | ||
efi_assert_success(efi_st()->boot_services->allocate_pool(EFI_LOADER_DATA, size, &ret)); | ||
if (ptr != NULL) | ||
{ | ||
memcpy(ret, ptr, size); | ||
efi_assert_success(efi_st()->boot_services->free_pool(ptr)); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
void _json_free(void *_Nonnull ptr, [[gnu::unused]] size_t size) | ||
{ | ||
efi_assert_success(efi_st()->boot_services->free_pool(ptr)); | ||
} | ||
|
||
EfiStatus config_parse(char const *json) | ||
{ | ||
json_reader_t reader = json_init(json, strlen(json)); | ||
json_t cfg = json_parse(&reader); | ||
|
||
if (cfg.type == JSON_ERROR) | ||
{ | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
entries = json_get(cfg, "entries"); | ||
if (entries.type != JSON_ARRAY) | ||
{ | ||
error$("invalid entries in config, entries must be an array"); | ||
return EFI_INVALID_PARAMETER; | ||
} | ||
|
||
return EFI_SUCCESS; | ||
} | ||
|
||
size_t config_entries_count(void) | ||
{ | ||
return entries.array.len; | ||
} | ||
|
||
EfiStatus config_entry(size_t index) | ||
{ | ||
json_t raw_entry = entries.array.buf[index]; | ||
|
||
if (raw_entry.type != JSON_OBJECT) | ||
{ | ||
error$("invalid entry in config, entry must be an object"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
json_t raw_label = json_get(raw_entry, "label"); | ||
if (raw_label.type != JSON_STRING) | ||
{ | ||
error$("invalid label in config, label must be a string"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
json_t raw_kernel = json_get(raw_entry, "kernel"); | ||
if (raw_kernel.type != JSON_STRING) | ||
{ | ||
error$("invalid kernel in config, kernel must be a string"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
json_t raw_protocol = json_get(raw_entry, "protocol"); | ||
if (raw_protocol.type != JSON_STRING) | ||
{ | ||
error$("invalid protocol in config, protocol must be a string"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
json_t raw_cmdline = json_get(raw_entry, "cmdline"); | ||
if (raw_cmdline.type != JSON_STRING) | ||
{ | ||
error$("invalid cmdline in config, cmdline must be a string"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
json_t raw_modules = json_get(raw_entry, "modules"); | ||
if (raw_modules.type != JSON_ARRAY) | ||
{ | ||
error$("invalid modules in config, modules must be an array"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
|
||
for (size_t i = 0; i < raw_modules.array.len; i++) | ||
{ | ||
json_t raw_module = raw_modules.array.buf[i]; | ||
if (raw_module.type != JSON_STRING) | ||
{ | ||
error$("invalid module items in config, must be strings"); | ||
return EFI_PROTOCOL_ERROR; | ||
} | ||
} | ||
|
||
_selected_entry = (Entry){ | ||
.label = raw_label.string, | ||
.kernel = raw_kernel.string, | ||
.cmdline = raw_cmdline.string, | ||
.modules = raw_modules.array, | ||
}; | ||
|
||
debug$("loading entry: %s", _selected_entry.label); | ||
return EFI_SUCCESS; | ||
} | ||
|
||
Entry selected_entry(void) | ||
{ | ||
return _selected_entry; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <tiny-efi/efi.h> | ||
#include <tiny-json/json.h> | ||
|
||
typedef struct | ||
{ | ||
char const *_Nonnull label; | ||
char const *_Nonnull kernel; | ||
char const *_Nonnull protocol; | ||
char const *_Nonnull cmdline; | ||
json_vec_t modules; | ||
} Entry; | ||
|
||
EfiStatus config_parse(char const *_Nonnull json); | ||
|
||
EfiStatus config_entry(size_t index); | ||
|
||
size_t config_entries_count(void); | ||
|
||
Entry selected_entry(void); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
section .text | ||
|
||
global __handoverEnterKernel | ||
__handoverEnterKernel: | ||
; rcx : entry to jump to | ||
; rdx : payload to pass | ||
; r8 : stack to use | ||
; r9 : vmm context | ||
cli | ||
mov rdi, 0xC001B001 | ||
mov rsi, rdx | ||
mov cr3, r9 | ||
mov rsp, r8 | ||
mov rbp, 0 | ||
|
||
call rcx |
Oops, something went wrong.