mirror of https://gitlab.com/nakst/essence
misc
This commit is contained in:
parent
ee4a0e7a05
commit
d8906e84ab
|
@ -1,46 +1,38 @@
|
|||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
extern "C" void KernelInitialise();
|
||||
extern "C" int EsStringCompareRaw(const char *s1, size_t b1, const char *s2, size_t b2);
|
||||
void EsPrint(const char *format, ...);
|
||||
|
||||
extern "C" void KernelInitialise();
|
||||
extern "C" void ProcessorHalt();
|
||||
|
||||
struct ExportedKernelFunction {
|
||||
void *address;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
ExportedKernelFunction exportedKernelFunctions[] = {
|
||||
const ExportedKernelFunction exportedKernelFunctions[] = {
|
||||
#include <bin/kernel_symbols.h>
|
||||
};
|
||||
|
||||
static bool linked;
|
||||
|
||||
void *ResolveKernelSymbol(const char *name, size_t nameBytes) {
|
||||
// EsPrint("Resolve: '%s'.\n", nameBytes, name);
|
||||
|
||||
if (!linked) {
|
||||
linked = true;
|
||||
|
||||
// As we get the function addresses before the kernel is linked (this file needs to be linked with the kernel),
|
||||
// they are relative to wherever the kernel_all.o's text is placed in the executable's text section.
|
||||
|
||||
uintptr_t offset = (uintptr_t) ResolveKernelSymbol("KernelInitialise", 10) - (uintptr_t) KernelInitialise;
|
||||
|
||||
for (uintptr_t i = 0; i < sizeof(exportedKernelFunctions) / sizeof(exportedKernelFunctions[0]); i++) {
|
||||
exportedKernelFunctions[i].address = (void *) ((uintptr_t) exportedKernelFunctions[i].address - offset);
|
||||
}
|
||||
}
|
||||
static uintptr_t linkOffset;
|
||||
|
||||
void *_ResolveKernelSymbol(const char *name, size_t nameBytes) {
|
||||
for (uintptr_t i = 0; i < sizeof(exportedKernelFunctions) / sizeof(exportedKernelFunctions[0]); i++) {
|
||||
if (0 == EsStringCompareRaw(exportedKernelFunctions[i].name, -1, name, nameBytes)) {
|
||||
return exportedKernelFunctions[i].address;
|
||||
return (void *) ((uintptr_t) exportedKernelFunctions[i].address - linkOffset);
|
||||
}
|
||||
}
|
||||
|
||||
EsPrint("ResolveKernelSymbol - Could not find symbol '%s'.\n", nameBytes, name);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void *ResolveKernelSymbol(const char *name, size_t nameBytes) {
|
||||
if (!linkOffset) {
|
||||
// As we get the function addresses before the kernel is linked (this file needs to be linked with the kernel),
|
||||
// they are relative to wherever the kernel_all.o's text is placed in the executable's text section.
|
||||
linkOffset = (uintptr_t) _ResolveKernelSymbol("KernelInitialise", 10) - (uintptr_t) KernelInitialise;
|
||||
}
|
||||
|
||||
return _ResolveKernelSymbol(name, nameBytes);
|
||||
}
|
||||
|
|
|
@ -1819,7 +1819,7 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_DEBUG_COMMAND) {
|
|||
SYSCALL_RETURN(ES_SUCCESS, false);
|
||||
}
|
||||
|
||||
SyscallFunction syscallFunctions[ES_SYSCALL_COUNT + 1] {
|
||||
const SyscallFunction syscallFunctions[ES_SYSCALL_COUNT + 1] {
|
||||
#include <bin/syscall_array.h>
|
||||
};
|
||||
|
||||
|
|
|
@ -2674,6 +2674,8 @@ uint8_t DateCalculateDayOfWeek(const EsDateComponents *components) {
|
|||
}
|
||||
|
||||
void DateToComponents(uint64_t x, EsDateComponents *components) {
|
||||
components->_unused = 0;
|
||||
|
||||
components->millisecond = x % 1000, x /= 1000;
|
||||
components->second = x % 60, x /= 60;
|
||||
components->minute = x % 60, x /= 60;
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define VGA_FONT_WIDTH (9)
|
||||
#define VGA_FONT_HEIGHT (16)
|
||||
|
||||
uint64_t vgaFont[] = {
|
||||
const uint64_t vgaFont[] = {
|
||||
0x0000000000000000UL, 0x0000000000000000UL, 0xBD8181A5817E0000UL, 0x000000007E818199UL, 0xC3FFFFDBFF7E0000UL, 0x000000007EFFFFE7UL, 0x7F7F7F3600000000UL, 0x00000000081C3E7FUL,
|
||||
0x7F3E1C0800000000UL, 0x0000000000081C3EUL, 0xE7E73C3C18000000UL, 0x000000003C1818E7UL, 0xFFFF7E3C18000000UL, 0x000000003C18187EUL, 0x3C18000000000000UL, 0x000000000000183CUL,
|
||||
0xC3E7FFFFFFFFFFFFUL, 0xFFFFFFFFFFFFE7C3UL, 0x42663C0000000000UL, 0x00000000003C6642UL, 0xBD99C3FFFFFFFFFFUL, 0xFFFFFFFFFFC399BDUL, 0x331E4C5870780000UL, 0x000000001E333333UL,
|
||||
|
|
|
@ -965,7 +965,7 @@ void ParseKernelConfiguration() {
|
|||
}
|
||||
|
||||
FilePrintFormat(f, "#ifdef K_IN_CORE_KERNEL\n");
|
||||
FilePrintFormat(f, "KInstalledDriver builtinDrivers[] = {\n");
|
||||
FilePrintFormat(f, "const KInstalledDriver builtinDrivers[] = {\n");
|
||||
|
||||
s.buffer = (char *) kernelConfig;
|
||||
s.bytes = kernelConfigBytes;
|
||||
|
|
Loading…
Reference in New Issue