refactor and stub x86_32 implementation

This commit is contained in:
nakst 2021-10-29 10:44:26 +01:00
parent 21edea68d2
commit 4e6549d625
59 changed files with 2193 additions and 342 deletions

View File

@ -334,7 +334,7 @@ void ConnectedDriveAdd(EsMessageDevice device) {
}
// TODO EsObjectID might not necessarily fit in EsGeneric...
EsListViewFixedItemInsert(drivesList, information.model, information.modelBytes, device.id);
EsListViewFixedItemInsert(drivesList, information.model, information.modelBytes, (uintptr_t) device.id);
connectedDrives.Add(device);
}
@ -349,7 +349,7 @@ void ConnectedDriveRemove(EsMessageDevice device) {
for (uintptr_t i = 0; i < connectedDrives.Length(); i++) {
if (connectedDrives[i].id == device.id) {
EsListViewFixedItemRemove(drivesList, device.id);
EsListViewFixedItemRemove(drivesList, (uintptr_t) device.id);
connectedDrives.Delete(i);
return;
}

View File

@ -3,6 +3,7 @@ name=POSIX Launcher
icon=icon_utilities_terminal
permission_posix_subsystem=1
permission_run_temporary_application=1
needs_native_toolchain=1
[build]
source=apps/posix_launcher.cpp

46
arch/x86_32/api.s Normal file
View File

@ -0,0 +1,46 @@
[section .text]
[global _APISyscall]
_APISyscall:
; TODO
ret
[global _EsCRTsetjmp]
_EsCRTsetjmp:
; TODO
ret
[global _EsCRTlongjmp]
_EsCRTlongjmp:
; TODO
ret
[global EsCRTsqrt]
EsCRTsqrt:
sqrtsd xmm0,xmm0
ret
[global EsCRTsqrtf]
EsCRTsqrtf:
sqrtss xmm0,xmm0
ret
[global ProcessorReadTimeStamp]
ProcessorReadTimeStamp:
; TODO
ret
[global ProcessorCheckStackAlignment]
ProcessorCheckStackAlignment:
; TODO
ret
[global ProcessorTLSRead]
ProcessorTLSRead:
; TODO
ret
[global ProcessorTLSWrite]
ProcessorTLSWrite:
; TODO
ret

3
arch/x86_32/config.ini Normal file
View File

@ -0,0 +1,3 @@
additional_kernel_link_flags= -T util/linker/kernel32.ld
additional_common_compile_flags= -msse2 -DOS_ESSENCE
additional_common_assembly_flags= -felf

11
arch/x86_32/crti.s Normal file
View File

@ -0,0 +1,11 @@
[section .init]
[global _init]
_init:
push ebp
mov ebp,esp
[section .fini]
[global _fini]
_fini:
push ebp
mov ebp,esp

7
arch/x86_32/crtn.s Normal file
View File

@ -0,0 +1,7 @@
[section .init]
pop ebp
ret
[section .fini]
pop ebp
ret

287
arch/x86_32/kernel.cpp Executable file
View File

@ -0,0 +1,287 @@
#ifndef IMPLEMENTATION
struct MMArchVAS {
};
#define MM_KERNEL_SPACE_START (0xC0000000)
#define MM_KERNEL_SPACE_SIZE (0xE0000000 - 0xC0000000)
#define MM_MODULES_START (0xE0000000)
#define MM_MODULES_SIZE (0xE8000000 - 0xE0000000)
#define MM_CORE_REGIONS_START (0xE8000000)
#define MM_CORE_REGIONS_COUNT ((0xEC000000 - 0xE8000000) / sizeof(MMRegion))
#define ArchCheckBundleHeader() (header.mapAddress >= 0xC0000000ULL || header.mapAddress < 0x1000 || fileSize > 0x10000000ULL)
#define ArchCheckELFHeader() (header->virtualAddress >= 0xC0000000ULL || header->virtualAddress < 0x1000 || header->segmentSize > 0x10000000ULL)
#define K_ARCH_STACK_GROWS_DOWN
#define K_ARCH_NAME "x86_32"
#endif
#ifdef IMPLEMENTATION
#define KERNEL_PANIC_IPI (0) // NMIs ignore the interrupt vector.
size_t ProcessorSendIPI(uintptr_t interrupt, bool nmi = false, int processorID = -1); // Returns the number of processors the IPI was *not* sent to.
void ProcessorReset();
uintptr_t ArchFindRootSystemDescriptorPointer();
void ArchStartupApplicationProcessors();
uint32_t bootloaderID;
#include <drivers/acpi.cpp>
size_t ProcessorSendIPI(uintptr_t interrupt, bool nmi, int processorID) {
(void) interrupt;
(void) nmi;
(void) processorID;
// TODO.
return 0;
}
void ArchInitialise() {
// TODO.
}
void ArchNextTimer(size_t ms) {
// TODO.
}
uint64_t ArchGetTimeMs() {
// TODO.
return 0;
}
InterruptContext *ArchInitialiseThread(uintptr_t kernelStack, uintptr_t kernelStackSize,
Thread *thread, uintptr_t startAddress, uintptr_t argument1,
uintptr_t argument2, bool userland, uintptr_t stack, uintptr_t userStackSize) {
// TODO.
return nullptr;
}
void ArchSwitchContext(InterruptContext *context, MMArchVAS *virtualAddressSpace, uintptr_t threadKernelStack,
Thread *newThread, MMSpace *oldAddressSpace) {
// TODO.
}
EsError ArchApplyRelocation(uintptr_t type, uint8_t *buffer, uintptr_t offset, uintptr_t result) {
// TODO.
return ES_ERROR_UNSUPPORTED_FEATURE;
}
bool MMArchMapPage(MMSpace *space, uintptr_t physicalAddress, uintptr_t virtualAddress, unsigned flags) {
// TODO.
return false;
}
void MMArchUnmapPages(MMSpace *space, uintptr_t virtualAddressStart, uintptr_t pageCount, unsigned flags, size_t unmapMaximum, uintptr_t *resumePosition) {
// TODO.
}
bool MMArchMakePageWritable(MMSpace *space, uintptr_t virtualAddress) {
// TODO.
return false;
}
bool MMArchHandlePageFault(uintptr_t address, uint32_t flags) {
// TODO.
return false;
}
void MMArchInvalidatePages(uintptr_t virtualAddressStart, uintptr_t pageCount) {
// TODO.
}
bool MMArchIsBufferInUserRange(uintptr_t baseAddress, size_t byteCount) {
// TODO.
return false;
}
bool MMArchSafeCopy(uintptr_t destinationAddress, uintptr_t sourceAddress, size_t byteCount) {
// TODO.
return false;
}
bool MMArchCommitPageTables(MMSpace *space, MMRegion *region) {
// TODO.
return false;
}
bool MMArchInitialiseUserSpace(MMSpace *space, MMRegion *firstRegion) {
// TODO.
return false;
}
void MMArchInitialise() {
// TODO.
}
void MMArchFreeVAS(MMSpace *space) {
// TODO.
}
void MMArchFinalizeVAS(MMSpace *space) {
// TODO.
}
uintptr_t MMArchEarlyAllocatePage() {
// TODO.
return 0;
}
uint64_t MMArchPopulatePageFrameDatabase() {
// TODO.
return 0;
}
uintptr_t MMArchGetPhysicalMemoryHighest() {
// TODO.
return 0;
}
void ProcessorDisableInterrupts() {
// TODO.
}
void ProcessorEnableInterrupts() {
// TODO.
}
bool ProcessorAreInterruptsEnabled() {
// TODO.
return false;
}
void ProcessorHalt() {
// TODO.
}
void ProcessorSendYieldIPI(Thread *thread) {
// TODO.
}
void ProcessorFakeTimerInterrupt() {
// TODO.
}
void ProcessorInvalidatePage(uintptr_t virtualAddress) {
// TODO.
}
void ProcessorInvalidateAllPages() {
// TODO.
}
void ProcessorFlushCodeCache() {
// TODO.
}
void ProcessorFlushCache() {
// TODO.
}
void ProcessorSetLocalStorage(CPULocalStorage *cls) {
// TODO.
}
void ProcessorSetThreadStorage(uintptr_t tls) {
// TODO.
}
void ProcessorSetAddressSpace(MMArchVAS *virtualAddressSpace) {
// TODO.
}
uint64_t ProcessorReadTimeStamp() {
// TODO.
return 0;
}
CPULocalStorage *GetLocalStorage() {
// TODO.
return nullptr;
}
Thread *GetCurrentThread() {
// TODO.
return nullptr;
}
uintptr_t MMArchTranslateAddress(MMSpace *space, uintptr_t virtualAddress, bool writeAccess) {
// TODO.
return 0;
}
uint32_t KPCIReadConfig(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset, int size) {
// TODO.
return 0;
}
void KPCIWriteConfig(uint8_t bus, uint8_t device, uint8_t function, uint8_t offset, uint32_t value, int size) {
// TODO.
}
bool KRegisterIRQ(intptr_t interruptIndex, KIRQHandler handler, void *context, const char *cOwnerName, KPCIDevice *pciDevice) {
// TODO.
return false;
}
KMSIInformation KRegisterMSI(KIRQHandler handler, void *context, const char *cOwnerName) {
// TODO.
return {};
}
void KUnregisterMSI(uintptr_t tag) {
// TODO.
}
void ProcessorOut8(uint16_t port, uint8_t value) {
// TODO.
}
uint8_t ProcessorIn8(uint16_t port) {
// TODO.
return 0;
}
void ProcessorOut16(uint16_t port, uint16_t value) {
// TODO.
}
uint16_t ProcessorIn16(uint16_t port) {
// TODO.
return 0;
}
void ProcessorOut32(uint16_t port, uint32_t value) {
// TODO.
}
uint32_t ProcessorIn32(uint16_t port) {
// TODO.
return 0;
}
void ProcessorReset() {
// TODO.
}
uintptr_t ArchFindRootSystemDescriptorPointer() {
// TODO.
return 0;
}
void ArchStartupApplicationProcessors() {
// TODO.
}
uintptr_t GetBootloaderInformationOffset() {
// TODO.
return 0;
}
extern "C" void ProcessorDebugOutputByte(uint8_t byte) {
// TODO.
}
#include <kernel/terminal.cpp>
#endif

8
arch/x86_32/kernel.s Normal file
View File

@ -0,0 +1,8 @@
[bits 32]
[section .text]
[global _start]
_start:
; TODO
jmp $

View File

@ -1,47 +1,11 @@
#ifndef ARCH_X86_64_HEADER
#define ARCH_X86_64_HEADER
// --------------------------------- Standardised IO ports.
#ifndef ES_ARCH_X86_64
#error Included x86_64.h but not targeting x86_64.
#endif
#define IO_PIC_1_COMMAND (0x0020)
#define IO_PIC_1_DATA (0x0021)
#define IO_PIT_DATA (0x0040)
#define IO_PIT_COMMAND (0x0043)
#define IO_PS2_DATA (0x0060)
#define IO_PC_SPEAKER (0x0061)
#define IO_PS2_STATUS (0x0064)
#define IO_PS2_COMMAND (0x0064)
#define IO_RTC_INDEX (0x0070)
#define IO_RTC_DATA (0x0071)
#define IO_PIC_2_COMMAND (0x00A0)
#define IO_PIC_2_DATA (0x00A1)
#define IO_BGA_INDEX (0x01CE)
#define IO_BGA_DATA (0x01CF)
#define IO_ATA_1 (0x0170) // To 0x0177.
#define IO_ATA_2 (0x01F0) // To 0x01F7.
#define IO_COM_4 (0x02E8) // To 0x02EF.
#define IO_COM_2 (0x02F8) // To 0x02FF.
#define IO_ATA_3 (0x0376)
#define IO_VGA_AC_INDEX (0x03C0)
#define IO_VGA_AC_WRITE (0x03C0)
#define IO_VGA_AC_READ (0x03C1)
#define IO_VGA_MISC_WRITE (0x03C2)
#define IO_VGA_MISC_READ (0x03CC)
#define IO_VGA_SEQ_INDEX (0x03C4)
#define IO_VGA_SEQ_DATA (0x03C5)
#define IO_VGA_DAC_READ_INDEX (0x03C7)
#define IO_VGA_DAC_WRITE_INDEX (0x03C8)
#define IO_VGA_DAC_DATA (0x03C9)
#define IO_VGA_GC_INDEX (0x03CE)
#define IO_VGA_GC_DATA (0x03CF)
#define IO_VGA_CRTC_INDEX (0x03D4)
#define IO_VGA_CRTC_DATA (0x03D5)
#define IO_VGA_INSTAT_READ (0x03DA)
#define IO_COM_3 (0x03E8) // To 0x03EF.
#define IO_ATA_4 (0x03F6)
#define IO_COM_1 (0x03F8) // To 0x03FF.
#define IO_PCI_CONFIG (0x0CF8)
#define IO_PCI_DATA (0x0CFC)
#include "x86_pc.h"
// --------------------------------- Interrupt vectors.
@ -98,11 +62,9 @@ struct NewProcessorStorage {
NewProcessorStorage AllocateNewProcessorStorage(struct ArchCPU *archCPU);
extern "C" void SetupProcessor2(struct NewProcessorStorage *);
uintptr_t GetBootloaderInformationOffset();
void ArchDelay1Ms(); // Spin for approximately 1ms. Use only during initialisation. Not thread-safe.
uint64_t ArchGetTimeFromPITMs();
void *ACPIGetRSDP();
uint8_t ACPIGetCenturyRegisterIndex();
size_t ProcessorSendIPI(uintptr_t interrupt, bool nmi = false, int processorID = -1); // Returns the number of processors the IPI was *not* sent to.
void ArchSetPCIIRQLine(uint8_t slot, uint8_t pin, uint8_t line);
uintptr_t ArchFindRootSystemDescriptorPointer();

4
arch/x86_64/config.ini Normal file
View File

@ -0,0 +1,4 @@
additional_kernel_compile_flags= -mno-red-zone -mcmodel=kernel
additional_kernel_link_flags= -T util/linker/kernel64.ld -mno-red-zone
additional_common_assembly_flags= -felf64
has_native_toolchain=1

View File

@ -2,10 +2,10 @@
[global _init]
_init:
push rbp
mov rbp, rsp
mov rbp,rsp
[section .fini]
[global _fini]
_fini:
push rbp
mov rbp, rsp
mov rbp,rsp

View File

@ -45,6 +45,9 @@ struct MMArchVAS {
#ifdef IMPLEMENTATION
#include <arch/x86_64.h>
#include <drivers/acpi.cpp>
#define MM_CORE_SPACE_START (0xFFFF800100000000)
#define MM_CORE_SPACE_SIZE (0xFFFF8001F0000000 - 0xFFFF800100000000)
#define MM_USER_SPACE_START (0x100000000000)
@ -1574,4 +1577,6 @@ void ArchInitialise() {
SetupProcessor2(&storage);
}
#include <kernel/terminal.cpp>
#endif

55
arch/x86_pc.h Normal file
View File

@ -0,0 +1,55 @@
#ifndef ARCH_X86_PC_HEADER
#define ARCH_X86_PC_HEADER
#if !defined(ES_ARCH_X86_64) && !defined(ES_ARCH_X86_32)
#error Included x86_pc.h but not targeting x86_32 or x86_64.
#endif
// --------------------------------- Standardised IO ports.
#define IO_PIC_1_COMMAND (0x0020)
#define IO_PIC_1_DATA (0x0021)
#define IO_PIT_DATA (0x0040)
#define IO_PIT_COMMAND (0x0043)
#define IO_PS2_DATA (0x0060)
#define IO_PC_SPEAKER (0x0061)
#define IO_PS2_STATUS (0x0064)
#define IO_PS2_COMMAND (0x0064)
#define IO_RTC_INDEX (0x0070)
#define IO_RTC_DATA (0x0071)
#define IO_PIC_2_COMMAND (0x00A0)
#define IO_PIC_2_DATA (0x00A1)
#define IO_BGA_INDEX (0x01CE)
#define IO_BGA_DATA (0x01CF)
#define IO_ATA_1 (0x0170) // To 0x0177.
#define IO_ATA_2 (0x01F0) // To 0x01F7.
#define IO_COM_4 (0x02E8) // To 0x02EF.
#define IO_COM_2 (0x02F8) // To 0x02FF.
#define IO_ATA_3 (0x0376)
#define IO_VGA_AC_INDEX (0x03C0)
#define IO_VGA_AC_WRITE (0x03C0)
#define IO_VGA_AC_READ (0x03C1)
#define IO_VGA_MISC_WRITE (0x03C2)
#define IO_VGA_MISC_READ (0x03CC)
#define IO_VGA_SEQ_INDEX (0x03C4)
#define IO_VGA_SEQ_DATA (0x03C5)
#define IO_VGA_DAC_READ_INDEX (0x03C7)
#define IO_VGA_DAC_WRITE_INDEX (0x03C8)
#define IO_VGA_DAC_DATA (0x03C9)
#define IO_VGA_GC_INDEX (0x03CE)
#define IO_VGA_GC_DATA (0x03CF)
#define IO_VGA_CRTC_INDEX (0x03D4)
#define IO_VGA_CRTC_DATA (0x03D5)
#define IO_VGA_INSTAT_READ (0x03DA)
#define IO_COM_3 (0x03E8) // To 0x03EF.
#define IO_ATA_4 (0x03F6)
#define IO_COM_1 (0x03F8) // To 0x03FF.
#define IO_PCI_CONFIG (0x0CF8)
#define IO_PCI_DATA (0x0CFC)
// --------------------------------- Forward declarations.
uint8_t ACPIGetCenturyRegisterIndex();
uintptr_t GetBootloaderInformationOffset();
#endif

View File

@ -906,7 +906,7 @@ error_cannot_read_disk: db "Error: The disk could not be read.",0
error_file_too_large: db "Error: The file was too large to be loaded (more than 256KB).",0
error_kernel_too_large: db "Error: The kernel was too large for the 3MB buffer.",0
error_bad_kernel: db "Error: Invalid or unsupported kernel ELF format.",0
error_no_memory: db "Error: Not enough memory to load kernel"
error_no_memory: db "Error: Not enough memory to load kernel",0
error_no_long_mode: db "Error: The kernel is compiled for a 64-bit processor but the current processor is 32-bit only.",0
error_could_not_set_video_mode: db "Error: Could not set video mode 1024x768x24.",0

View File

@ -4,9 +4,6 @@
#define ES_DIRECT_API
#include <essence.h>
#define alloca __builtin_alloca
#define FT_EXPORT(x) extern "C" x
#ifdef USE_STB_IMAGE
#define STB_IMAGE_IMPLEMENTATION
#define STBI_MALLOC(sz) EsCRTmalloc(sz)

View File

@ -2189,7 +2189,7 @@ void InstanceAnnouncePathMoved(InstalledApplication *fromApplication, const char
EsMemoryCopy(data + sizeof(size_t) * 2 + oldPathBytes, newPath, newPathBytes);
EsMessage m = {};
m.type = ES_MSG_FILE_MANAGER_PATH_MOVED;
m.user.context2 = sizeof(size_t) * 2 + oldPathBytes + newPathBytes;
m.user.context2.u = sizeof(size_t) * 2 + oldPathBytes + newPathBytes;
m.user.context1 = EsConstantBufferCreate(data, m.user.context2.u, desktop.fileManager->singleProcess->handle);
EsMessagePostRemote(desktop.fileManager->singleProcess->handle, &m);
EsHeapFree(data);

View File

@ -1966,7 +1966,7 @@ function EsError EsHandleClose(EsHandle handle);
function void EsSystemShowShutdownDialog();
function void EsPOSIXInitialise(int *argc, char ***argv);
function intptr_t EsPOSIXSystemCall(intptr_t n, intptr_t a1, intptr_t a2, intptr_t a3, intptr_t a4, intptr_t a5, intptr_t a6);
function long EsPOSIXSystemCall(long n, long a1, long a2, long a3, long a4, long a5, long a6);
function char *EsPOSIXConvertPath(const char *path, size_t *outNameLength, bool addPOSIXMountPointPrefix);
private function void EsBatch(EsBatchCall *calls, size_t count);

View File

@ -746,7 +746,7 @@ void EsPOSIXInitialise(int *argc, char ***argv) {
// Add the auxillary vectors.
#ifdef ARCH_X86_64
#ifdef ES_ARCH_X86_64
Elf64_Phdr *tlsHeader = (Elf64_Phdr *) EsHeapAllocate(sizeof(Elf64_Phdr), true);
tlsHeader->p_type = PT_TLS;
tlsHeader->p_flags = 4 /* read */;

View File

@ -11,6 +11,18 @@
#endif
#include <stdarg.h>
// --------- Architecture defines:
#if defined(__i386__)
#define ES_ARCH_X86_32
#define ES_BITS_32
#elif defined(__x86_64__)
#define ES_ARCH_X86_64
#define ES_BITS_64
#else
#error Architecture is not supported.
#endif
// --------- C++/C differences:
#ifdef __cplusplus
@ -33,8 +45,10 @@ union EsGeneric {
inline EsGeneric() = default;
#ifdef ES_BITS_64
inline EsGeneric(uintptr_t y) { u = y; }
inline EsGeneric( intptr_t y) { i = y; }
#endif
inline EsGeneric(unsigned y) { u = y; }
inline EsGeneric( int y) { i = y; }
inline EsGeneric( void *y) { p = y; }
@ -60,7 +74,7 @@ typedef struct EsElementPublic EsElementPublic;
// --------- Macros:
#ifdef ARCH_X86_64
#ifdef ES_ARCH_X86_64
#define ES_API_BASE ((void **) 0x1000)
#define ES_SHARED_MEMORY_MAXIMUM_SIZE ((size_t) (1024) * 1024 * 1024 * 1024)
#define ES_PAGE_SIZE ((uintptr_t) 4096)
@ -69,19 +83,23 @@ typedef struct EsElementPublic EsElementPublic;
typedef struct EsCRTjmp_buf {
uintptr_t rsp, rbp, rbx, r12, r13, r14, r15, rip;
} EsCRTjmp_buf;
#endif
#ifdef ES_ARCH_X86_32
#define ES_API_BASE ((void **) 0x1000)
#define ES_SHARED_MEMORY_MAXIMUM_SIZE ((size_t) 1024 * 1024 * 1024)
#define ES_PAGE_SIZE ((uintptr_t) 4096)
#define ES_PAGE_BITS (12)
typedef struct EsCRTjmp_buf {
uintptr_t esp, ebp, ebx, eip, esi, edi;
} EsCRTjmp_buf;
#endif
ES_EXTERN_C int _EsCRTsetjmp(EsCRTjmp_buf *env);
ES_EXTERN_C __attribute__((noreturn)) void _EsCRTlongjmp(EsCRTjmp_buf *env, int val);
#define EsCRTsetjmp(x) _EsCRTsetjmp(&(x))
#define EsCRTlongjmp(x, y) _EsCRTlongjmp(&(x), (y))
#endif
#ifdef ARCH_X86_32
#define ES_API_BASE ((void **) 0x1000)
#define ES_SHARED_MEMORY_MAXIMUM_SIZE ((size_t) 1024 * 1024 * 1024)
#define ES_PAGE_SIZE ((uintptr_t) 4096)
#define ES_PAGE_BITS (12)
#endif
#define _ES_C_PREPROCESSOR_JOIN(x, y) x ## y
#define ES_C_PREPROCESSOR_JOIN(x, y) _ES_C_PREPROCESSOR_JOIN(x, y)
@ -261,12 +279,12 @@ struct _EsPOSIXSyscall {
#define BLEND_WINDOW_MATERIAL_GLASS (1)
#define BLEND_WINDOW_MATERIAL_LIGHT_BLUR (2)
#ifdef ARCH_X86_64
#ifdef ES_ARCH_X86_64
#define BUNDLE_FILE_MAP_ADDRESS (0x100000000UL)
#define BUNDLE_FILE_DESKTOP_MAP_ADDRESS (0xF0000000UL)
#endif
#ifdef ARCH_X86_32
#ifdef ES_ARCH_X86_32
#define BUNDLE_FILE_MAP_ADDRESS (0xA0000000UL)
#define BUNDLE_FILE_DESKTOP_MAP_ADDRESS (0xBC000000UL)
#endif

View File

@ -11,6 +11,7 @@
#endif
#ifdef USE_FREETYPE
#define FT_EXPORT(x) extern "C" x
#include <ft2build.h>
#include FT_FREETYPE_H
#include <freetype/ftoutln.h>
@ -1815,7 +1816,7 @@ void TextAddEllipsis(EsTextPlan *plan, int32_t maximumLineWidth, bool needFinalE
int32_t ellipsisWidth = 0;
uint32_t glyphCount, glyphCount2;
unsigned int glyphCount, glyphCount2;
hb_glyph_info_t *glyphInfos = hb_buffer_get_glyph_infos(plan->buffer, &glyphCount);
hb_glyph_position_t *glyphPositions = hb_buffer_get_glyph_positions(plan->buffer, &glyphCount2);
EsAssert(glyphCount == glyphCount2);
@ -2062,7 +2063,7 @@ int32_t TextBuildTextPieces(EsTextPlan *plan, uintptr_t sectionStart, uintptr_t
HB_SHAPE(plan, features, featureCount);
uint32_t glyphCount, glyphCount2;
unsigned int glyphCount, glyphCount2;
hb_glyph_info_t *glyphInfos = hb_buffer_get_glyph_infos(plan->buffer, &glyphCount);
hb_glyph_position_t *glyphPositions = hb_buffer_get_glyph_positions(plan->buffer, &glyphCount2);
EsAssert(glyphCount == glyphCount2);

View File

@ -329,6 +329,18 @@ void ArchShutdown(uintptr_t action) {
ProcessorDisableInterrupts();
ProcessorHalt();
}
EsError KACPIObjectSetDeviceNotificationHandler(KACPIObject *, KACPINotificationHandler, EsGeneric) {
return ES_ERROR_UNSUPPORTED_FEATURE;
}
EsError KACPIObjectEvaluateInteger(KACPIObject *, const char *, uint64_t *) {
return ES_ERROR_UNSUPPORTED_FEATURE;
}
EsError KACPIObjectEvaluateMethodWithInteger(KACPIObject *, const char *, uint64_t) {
return ES_ERROR_UNSUPPORTED_FEATURE;
}
#endif
void ACPIDeviceAttach(KDevice *parentDevice) {

View File

@ -524,7 +524,7 @@ void AHCIController::Initialise() {
commandSlotCount = ((capabilities >> 8) & 31) + 1;
dma64Supported = capabilities & (1 << 31);
#ifdef ARCH_64
#ifdef ES_BITS_64
if (!dma64Supported) {
KernelLog(LOG_ERROR, "AHCI", "controller cannot DMA", "The controller reports it cannot use 64-bit addresses in DMA transfer.\n");
return;

View File

@ -1,5 +1,5 @@
#include <module.h>
#include <kernel/x86_64.h>
#include <arch/x86_pc.h>
struct BGADisplay : KGraphicsTarget {
};

View File

@ -398,7 +398,7 @@ static void HDAControllerAttach(KDevice *_parent) {
uint16_t globalCapabilities = RD_REGISTER_GCAP();
bool supports64BitAddresses = globalCapabilities & (1 << 0);
#ifdef ARCH_64
#ifdef ES_BITS_64
if (!supports64BitAddresses) {
KernelLog(LOG_ERROR, "HDA", "controller unsupported", "Controller does not support 64-bit addresses.\n");
KDeviceDestroy(controller);

View File

@ -381,11 +381,15 @@ void Controller::Initialise() {
}
for (uintptr_t i = 0; i < RECEIVE_DESCRIPTOR_COUNT; i++) {
uintptr_t address;
if (!MMPhysicalAllocateAndMap(RECEIVE_BUFFER_SIZE + TRANSFER_BUFFER_EXTRA,
16, 64, false, 0, receiveBuffers + i, &receiveDescriptors[i].address)) {
16, 64, false, 0, receiveBuffers + i, &address)) {
KernelLog(LOG_ERROR, "I8254x", "allocation failure", "Could not allocate receive buffers.\n");
return;
}
receiveDescriptors[i].address = address;
}
// Disable flow control.

View File

@ -2,7 +2,7 @@
// TODO Inserting/removing ATAPI devices.
#include <module.h>
#include <kernel/x86_64.h>
#include <arch/x86_pc.h>
#define ATA_BUSES 2
#define ATA_DRIVES (ATA_BUSES * 2)

View File

@ -215,7 +215,7 @@ bool KPCIDevice::EnableSingleInterrupt(KIRQHandler irqHandler, void *context, co
// See the comment in InterruptHandler for what happens when passing -1.
intptr_t line = interruptLine;
#ifdef ARCH_X86_COMMON
#if defined(ES_ARCH_X86_32) || defined(ES_ARCH_X86_64)
extern uint32_t bootloaderID;
if (bootloaderID == 2) line = -1;
#endif
@ -271,7 +271,7 @@ bool KPCIDevice::EnableMSI(KIRQHandler irqHandler, void *context, const char *cO
return false;
}
#ifdef ARCH_64
#ifdef ES_BITS_64
if ((msi.address & 0xFFFFFFFF00000000) && (~control & (1 << 7))) {
KUnregisterMSI(msi.tag);
KernelLog(LOG_ERROR, "PCI", "unsupported MSI address", "MSI does not support 64-bit addresses. Requested: %x.\n", msi.address);

View File

@ -1,7 +1,7 @@
// TODO Scrolling.
#include <module.h>
#include <kernel/x86_64.h>
#include <arch/x86_pc.h>
struct PS2Update {
union {

View File

@ -1,5 +1,5 @@
#include <module.h>
#include <kernel/x86_64.h>
#include <arch/x86_pc.h>
struct RTCDevice : KClockDevice {};

View File

@ -1,5 +1,5 @@
#include <module.h>
#include <kernel/x86_64.h>
#include <arch/x86_pc.h>
struct VideoModeInformation {
uint8_t valid : 1, edidValid : 1;

View File

@ -958,7 +958,7 @@ void XHCIController::Initialise() {
contextSize64 = (hccp1 & (1 << 2)) ? true : false;
extendedCapabilitiesOffset = ((hccp1 >> 16) & 0xFFFF) << 2;
#ifdef ARCH_64
#ifdef ES_BITS_64
if (~hccp1 & (1 << 0)) {
KernelLog(LOG_ERROR, "xHCI", "missing feature", "xHCI controller does not support 64-bit addresses.\n");
return;
@ -1081,7 +1081,7 @@ void XHCIController::Initialise() {
KernelLog(LOG_INFO, "xHCI", "reset controller", "Controller successfully reset.\n");
#ifdef ARCH_X86_COMMON
#if defined(ES_ARCH_X86_32) || defined(ES_ARCH_X86_64)
// Any PS/2 emulation should have been disabled, so its controller is safe to initialise.
KPS2SafeToInitialise();
#endif

View File

@ -405,7 +405,7 @@ void CCActiveSectionReturnToLists(CCActiveSection *section, bool writeBack) {
}
}
void CCSpaceTruncate(CCSpace *cache, size_t newSize) {
void CCSpaceTruncate(CCSpace *cache, EsFileOffset newSize) {
// Concurrent calls to CCSpaceAccess must be prevented;
// this only handles concurrent calls to CCWriteSection.

View File

@ -15,7 +15,7 @@ struct ElfHeader {
uint16_t instructionSet; // 0x03 = x86, 0x28 = ARM, 0x3E = x86-64, 0xB7 = AArch64
uint32_t version2;
#ifdef ARCH_32
#ifdef ES_BITS_32
uint32_t entry;
uint32_t programHeaderTable;
uint32_t sectionHeaderTable;
@ -40,7 +40,7 @@ struct ElfHeader {
#endif
};
#ifdef ARCH_32
#ifdef ES_BITS_32
struct ElfSectionHeader {
uint32_t name;
uint32_t type;
@ -297,7 +297,7 @@ uint8_t *AllocateForModule(size_t size) {
}
EsError KLoadELFModule(KModule *module) {
#ifdef ARCH_X86_64
#ifdef ES_ARCH_X86_64
KMutexAcquire(&modulesMutex);
EsDefer(KMutexRelease(&modulesMutex));

View File

@ -29,9 +29,9 @@
#define CC_MODIFIED_GETTING_FULL (CC_MAX_MODIFIED * 2 / 3)
// The size of the kernel's address space used for mapping active sections.
#if defined(ARCH_32)
#if defined(ES_BITS_32)
#define CC_SECTION_BYTES (ClampIntptr(0, 64L * 1024 * 1024, pmm.commitFixedLimit * K_PAGE_SIZE / 4))
#elif defined(ARCH_64)
#elif defined(ES_BITS_64)
#define CC_SECTION_BYTES (ClampIntptr(0, 1024L * 1024 * 1024, pmm.commitFixedLimit * K_PAGE_SIZE / 4))
#endif
@ -68,11 +68,7 @@
// Core definitions.
// ---------------------------------------------------------------------------------------------------------------
#if defined(ARCH_X86_64)
#include "x86_64.cpp"
#elif defined(ARCH_X86_32)
#include "x86_32.cpp"
#endif
#include ARCH_KERNEL_SOURCE
struct AsyncTask {
KAsyncTaskCallback callback;
@ -108,6 +104,10 @@ struct PhysicalMemoryRegion {
void KernelInitialise();
void KernelShutdown(uintptr_t action);
uintptr_t DoSyscall(EsSyscallType index,
uintptr_t argument0, uintptr_t argument1, uintptr_t argument2, uintptr_t argument3,
bool batched, bool *fatal, uintptr_t *userStackPointer);
uint64_t timeStampTicksPerMs;
EsUniqueIdentifier installationID; // The identifier of this OS installation, given to us by the bootloader.
@ -170,6 +170,7 @@ extern "C" {
// void KUnregisterMSI(uintptr_t tag);
// size_t KGetCPUCount();
// struct CPULocalStorage *KGetCPULocal(uintptr_t index);
// ProcessorOut/ProcessorIn functions.
// The architecture layer must also define:
// - MM_CORE_REGIONS_START and MM_CORE_REGIONS_COUNT.
@ -190,18 +191,18 @@ extern "C" {
#include <shared/bitset.cpp>
#include <shared/range_set.cpp>
#include "memory.cpp"
#include "objects.cpp"
#include "syscall.cpp"
#include "memory.cpp"
#include "cache.cpp"
#include "scheduler.cpp"
#include "synchronisation.cpp"
#include "cache.cpp"
#include "elf.cpp"
#include "graphics.cpp"
#include "files.cpp"
#include "graphics.cpp"
#include "windows.cpp"
#include "networking.cpp"
#include "drivers.cpp"
#include "elf.cpp"
#include "syscall.cpp"
#ifdef ENABLE_POSIX_SUBSYSTEM
#include "posix.cpp"
@ -247,15 +248,6 @@ void EsAssertionFailure(const char *file, int line) {
KernelPanic("%z:%d - EsAssertionFailure called.\n", file, line);
}
#endif
#include ARCH_KERNEL_SOURCE
// ---------------------------------------------------------------------------------------------------------------
// Architecture specific layer implementation.
// ---------------------------------------------------------------------------------------------------------------
#if defined(ARCH_X86_64) && defined(IMPLEMENTATION)
#include "x86_64.h"
#include <drivers/acpi.cpp>
#include "x86_64.cpp"
#include "terminal.cpp"
#endif

View File

@ -253,6 +253,7 @@ extern MMSpace _kernelMMSpace, _coreMMSpace;
bool MMHandlePageFault(MMSpace *space, uintptr_t address, unsigned flags);
bool MMUnmapFilePage(uintptr_t frameNumber); // Returns true if the page became inactive.
void MMSharedDestroyRegion(MMSharedRegion *region);
// Public memory manager functions.
@ -2021,11 +2022,11 @@ bool MMPhysicalAllocateAndMap(size_t sizeBytes, size_t alignmentBytes, size_t ma
bool noBelow = false;
#ifdef ARCH_32
#ifdef ES_BITS_32
if (!maximumBits || maximumBits >= 32) noBelow = true;
#endif
#ifdef ARCH_64
#ifdef ES_BITS_64
if (!maximumBits || maximumBits >= 64) noBelow = true;
#endif

View File

@ -158,7 +158,7 @@ bool KInIRQ();
void KSwitchThreadAfterIRQ();
void KDebugKeyPressed();
#ifdef ARCH_X86_COMMON
#if defined(ES_ARCH_X86_32) || defined(ES_ARCH_X86_64)
void KPS2SafeToInitialise();
#endif

View File

@ -51,6 +51,25 @@ struct EventSinkTable {
EsGeneric data;
};
struct MessageQueue {
bool SendMessage(void *target, EsMessage *message); // Returns false if the message queue is full.
bool SendMessage(_EsMessageWithObject *message); // Returns false if the message queue is full.
bool GetMessage(_EsMessageWithObject *message);
#define MESSAGE_QUEUE_MAX_LENGTH (4096)
Array<_EsMessageWithObject, K_FIXED> messages;
uintptr_t mouseMovedMessage,
windowResizedMessage,
eyedropResultMessage,
keyRepeatMessage;
bool pinged;
KMutex mutex;
KEvent notEmpty;
};
size_t totalHandleCount;
struct HandleTableL2 {
@ -67,7 +86,7 @@ struct HandleTableL1 {
struct HandleTable {
HandleTableL1 l1r;
KMutex lock;
Process *process;
struct Process *process;
bool destroyed;
uint32_t handleCount;
@ -701,4 +720,83 @@ size_t Pipe::Access(void *_buffer, size_t bytes, bool write, bool user) {
return amount;
}
bool MessageQueue::SendMessage(void *object, EsMessage *_message) {
// TODO Remove unnecessary copy.
_EsMessageWithObject message = { object, *_message };
return SendMessage(&message);
}
bool MessageQueue::SendMessage(_EsMessageWithObject *_message) {
// TODO Don't send messages if the process has been terminated.
KMutexAcquire(&mutex);
EsDefer(KMutexRelease(&mutex));
if (messages.Length() == MESSAGE_QUEUE_MAX_LENGTH) {
KernelLog(LOG_ERROR, "Messages", "message dropped", "Message of type %d and target %x has been dropped because queue %x was full.\n",
_message->message.type, _message->object, this);
return false;
}
#define MERGE_MESSAGES(variable, change) \
do { \
if (variable && messages[variable - 1].object == _message->object) { \
if (change) EsMemoryCopy(&messages[variable - 1], _message, sizeof(_EsMessageWithObject)); \
} else if (messages.AddPointer(_message)) { \
variable = messages.Length(); \
} else { \
return false; \
} \
} while (0)
// NOTE Don't forget to update GetMessage with the merged messages!
if (_message->message.type == ES_MSG_MOUSE_MOVED) {
MERGE_MESSAGES(mouseMovedMessage, true);
} else if (_message->message.type == ES_MSG_WINDOW_RESIZED) {
MERGE_MESSAGES(windowResizedMessage, true);
} else if (_message->message.type == ES_MSG_EYEDROP_REPORT) {
MERGE_MESSAGES(eyedropResultMessage, true);
} else if (_message->message.type == ES_MSG_KEY_DOWN && _message->message.keyboard.repeat) {
MERGE_MESSAGES(keyRepeatMessage, false);
} else {
if (!messages.AddPointer(_message)) {
return false;
}
if (_message->message.type == ES_MSG_PING) {
pinged = true;
}
}
KEventSet(&notEmpty, false, true);
return true;
}
bool MessageQueue::GetMessage(_EsMessageWithObject *_message) {
KMutexAcquire(&mutex);
EsDefer(KMutexRelease(&mutex));
if (!messages.Length()) {
return false;
}
*_message = messages[0];
messages.Delete(0);
if (mouseMovedMessage) mouseMovedMessage--;
if (windowResizedMessage) windowResizedMessage--;
if (eyedropResultMessage) eyedropResultMessage--;
if (keyRepeatMessage) keyRepeatMessage--;
pinged = false;
if (!messages.Length()) {
KEventReset(&notEmpty);
}
return true;
}
#endif

View File

@ -2,116 +2,9 @@
// TODO Clean up the return values for system calls; with FATAL_ERRORs there should need to be less error codes returned.
// TODO If a file system call fails with an error indicating the file system is corrupted, or a drive is failing, report the problem to the user.
#ifndef IMPLEMENTATION
KMutex eventForwardMutex;
uintptr_t DoSyscall(EsSyscallType index,
uintptr_t argument0, uintptr_t argument1,
uintptr_t argument2, uintptr_t argument3,
bool batched, bool *fatal, uintptr_t *userStackPointer);
struct MessageQueue {
bool SendMessage(void *target, EsMessage *message); // Returns false if the message queue is full.
bool SendMessage(_EsMessageWithObject *message); // Returns false if the message queue is full.
bool GetMessage(_EsMessageWithObject *message);
#define MESSAGE_QUEUE_MAX_LENGTH (4096)
Array<_EsMessageWithObject, K_FIXED> messages;
uintptr_t mouseMovedMessage,
windowResizedMessage,
eyedropResultMessage,
keyRepeatMessage;
bool pinged;
KMutex mutex;
KEvent notEmpty;
};
#endif
#ifdef IMPLEMENTATION
bool MessageQueue::SendMessage(void *object, EsMessage *_message) {
// TODO Remove unnecessary copy.
_EsMessageWithObject message = { object, *_message };
return SendMessage(&message);
}
bool MessageQueue::SendMessage(_EsMessageWithObject *_message) {
// TODO Don't send messages if the process has been terminated.
KMutexAcquire(&mutex);
EsDefer(KMutexRelease(&mutex));
if (messages.Length() == MESSAGE_QUEUE_MAX_LENGTH) {
KernelLog(LOG_ERROR, "Messages", "message dropped", "Message of type %d and target %x has been dropped because queue %x was full.\n",
_message->message.type, _message->object, this);
return false;
}
#define MERGE_MESSAGES(variable, change) \
do { \
if (variable && messages[variable - 1].object == _message->object) { \
if (change) EsMemoryCopy(&messages[variable - 1], _message, sizeof(_EsMessageWithObject)); \
} else if (messages.AddPointer(_message)) { \
variable = messages.Length(); \
} else { \
return false; \
} \
} while (0)
// NOTE Don't forget to update GetMessage with the merged messages!
if (_message->message.type == ES_MSG_MOUSE_MOVED) {
MERGE_MESSAGES(mouseMovedMessage, true);
} else if (_message->message.type == ES_MSG_WINDOW_RESIZED) {
MERGE_MESSAGES(windowResizedMessage, true);
} else if (_message->message.type == ES_MSG_EYEDROP_REPORT) {
MERGE_MESSAGES(eyedropResultMessage, true);
} else if (_message->message.type == ES_MSG_KEY_DOWN && _message->message.keyboard.repeat) {
MERGE_MESSAGES(keyRepeatMessage, false);
} else {
if (!messages.AddPointer(_message)) {
return false;
}
if (_message->message.type == ES_MSG_PING) {
pinged = true;
}
}
KEventSet(&notEmpty, false, true);
return true;
}
bool MessageQueue::GetMessage(_EsMessageWithObject *_message) {
KMutexAcquire(&mutex);
EsDefer(KMutexRelease(&mutex));
if (!messages.Length()) {
return false;
}
*_message = messages[0];
messages.Delete(0);
if (mouseMovedMessage) mouseMovedMessage--;
if (windowResizedMessage) windowResizedMessage--;
if (eyedropResultMessage) eyedropResultMessage--;
if (keyRepeatMessage) keyRepeatMessage--;
pinged = false;
if (!messages.Length()) {
KEventReset(&notEmpty);
}
return true;
}
KMutex eventForwardMutex;
#define SYSCALL_BUFFER_LIMIT (64 * 1024 * 1024) // To prevent overflow and DOS attacks.
#define SYSCALL_BUFFER(address, length, index, write) \
@ -886,7 +779,7 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_EVENT_RESET) {
SYSCALL_IMPLEMENT(ES_SYSCALL_SLEEP) {
KTimer timer = {};
#ifdef ARCH_64
#ifdef ES_BITS_64
KTimerSet(&timer, (argument0 << 32) | argument1);
#else
KTimerSet(&timer, argument1);
@ -1872,9 +1765,11 @@ SYSCALL_IMPLEMENT(ES_SYSCALL_DEBUG_COMMAND) {
KernelPanic("Commit page count mismatch.\n");
}
#ifdef ES_BITS_64
if (_region0->data.normal.commit.Contains(argument2) != (argument3 >> 63)) {
KernelPanic("Commit contains mismatch at %x.\n", argument1);
}
#endif
} else if (argument0 == 6) {
// SYSCALL_RETURN(DriversDebugGetEnumeratedPCIDevices((EsPCIDevice *) argument1, argument2), false);
} else if (argument0 == 7) {

View File

@ -19,7 +19,7 @@ void DebugWriteCharacter(uintptr_t character);
extern "C" void ProcessorDebugOutputByte(uint8_t byte);
int KWaitKey();
#ifdef ARCH_X86_COMMON
#if defined(ES_ARCH_X86_32) || defined(ES_ARCH_X86_64)
bool printToDebugger = false;
uintptr_t terminalPosition = 80;
@ -209,7 +209,9 @@ void KernelPanic(const char *format, ...) {
EsPrint("Current thread = %x\n", GetCurrentThread());
EsPrint("Trace: %x\n", __builtin_return_address(0));
#ifdef ES_ARCH_X86_64
EsPrint("RSP: %x; RBP: %x\n", ProcessorGetRSP(), ProcessorGetRBP());
#endif
// EsPrint("Memory: %x/%x\n", pmm.pagesAllocated, pmm.startPageCount);
{
@ -220,8 +222,10 @@ void KernelPanic(const char *format, ...) {
while (item) {
Thread *thread = item->thisItem;
#ifdef ES_ARCH_X86_64
EsPrint("%z %d %x @%x:%x ", (GetCurrentThread() == thread) ? "=>" : " ",
thread->id, thread, thread->interruptContext->rip, thread->interruptContext->rbp);
#endif
if (thread->state == THREAD_WAITING_EVENT) {
EsPrint("WaitEvent(Count:%d, %x) ", thread->blocking.eventCount, thread->blocking.events[0]);
@ -242,9 +246,11 @@ void KernelPanic(const char *format, ...) {
CPULocalStorage *local = KGetCPULocal(i);
if (local->panicContext) {
#ifdef ES_ARCH_X86_64
EsPrint("CPU %d LS %x RIP/RBP %x:%x TID %d\n", local->processorID, local,
local->panicContext->rip, local->panicContext->rbp,
local->currentThread ? local->currentThread->id : 0);
#endif
}
}

View File

@ -1,26 +1,52 @@
if [ ! -d "bin/freetype" ]; then
echo "Downloading and building FreeType..."
echo "Downloading FreeType..."
if [ ! -f "bin/freetype-2.9.tar" ]; then
curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > bin/freetype-2.9.tar.gz 2> bin/freetype_dl.txt
gunzip bin/freetype-2.9.tar.gz
if [ ! -f "bin/cache/freetype-2.9.tar" ]; then
curl https://mirrors.up.pt/pub/nongnu/freetype/freetype-2.9.tar.gz > bin/cache/freetype-2.9.tar.gz 2> bin/freetype_dl.txt
gunzip bin/cache/freetype-2.9.tar.gz
fi
tar -xf bin/freetype-2.9.tar
tar -xf bin/cache/freetype-2.9.tar
mv freetype-2.9 bin/freetype
cp ports/freetype/patch-ftoption.h bin/freetype/include/freetype/config/ftoption.h
cp ports/freetype/patch-ftstdlib.h bin/freetype/include/freetype/config/ftstdlib.h
cp ports/freetype/patch-modules.cfg bin/freetype/modules.cfg
cd bin/freetype
./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \
CC=x86_64-essence-gcc CFLAGS="-g -ffreestanding -DARCH_X86_64 -Wno-unused-function -O3" \
LDFLAGS="-nostdlib -lgcc" --host=x86_64-essence > ../freetype_configure.txt
make ANSIFLAGS="" > /dev/null
cd ../..
fi
cp -p bin/freetype/objs/.libs/libfreetype.a root/Applications/POSIX/lib
if [ "$1" = "x86_64" ]; then
if [ ! -f "bin/freetype/libfreetype_x86_64.a" ]; then
echo "Building FreeType for x86_64..."
cd bin/freetype
rm -f objs/.libs/libfreetype.a
./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \
CC=x86_64-essence-gcc CFLAGS="-g -ffreestanding -Wno-unused-function -O3" \
LDFLAGS="-nostdlib -lgcc" --host=x86_64-essence > ../freetype_configure.txt 2>&1
make ANSIFLAGS="" > /dev/null
cp objs/.libs/libfreetype.a libfreetype_x86_64.a
cd ../..
fi
cp -p bin/freetype/libfreetype_x86_64.a root/Applications/POSIX/lib/libfreetype.a
fi
if [ "$1" = "x86_32" ]; then
if [ ! -f "bin/freetype/libfreetype_x86_32.a" ]; then
echo "Building FreeType for x86_32..."
INC=`realpath root/Applications/POSIX/include`
cd bin/freetype
rm -f objs/.libs/libfreetype.a
./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \
CC=i686-elf-gcc CFLAGS="-g -ffreestanding -Wno-unused-function -O3 -I$INC" \
LDFLAGS="-nostdlib -lgcc" --host=i686-elf > ../freetype_configure.txt 2>&1
sed -i '/define FT_USE_AUTOCONF_SIZEOF_TYPES/d' builds/unix/ftconfig.h
make ANSIFLAGS="" > /dev/null
cp objs/.libs/libfreetype.a libfreetype_x86_32.a
cd ../..
fi
cp -p bin/freetype/libfreetype_x86_32.a root/Applications/POSIX/lib/libfreetype.a
fi
cp -p bin/freetype/include/ft2build.h root/Applications/POSIX/include
cp -p -r bin/freetype/include/freetype root/Applications/POSIX/include

View File

@ -13,10 +13,7 @@
#define ENDFILE_SPEC " crtend.o%s crtn.o%s "
/* Additional predefined macros. */
#undef TARGET_OS_CPP_BUILTINS
#define TARGET_OS_CPP_BUILTINS() \
do { \
builtin_define ("ARCH_64"); \
builtin_define ("ARCH_X86_64"); \
builtin_define ("ARCH_X86_COMMON"); \
#define TARGET_OS_CPP_BUILTINS() \
do { \
builtin_define ("OS_ESSENCE"); \
} while(0)

View File

@ -1,43 +1,4 @@
if [ ! -d "bin/harfbuzz" ]; then
echo "Downloading and building Harfbuzz..."
if [ ! -f "bin/harfbuzz-2.6.4.tar" ]; then
curl https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz > bin/harfbuzz-2.6.4.tar.xz 2> bin/harfbuzz_dl.txt
xz -d bin/harfbuzz-2.6.4.tar.xz
fi
tar -xf bin/harfbuzz-2.6.4.tar
mv harfbuzz-2.6.4 bin/harfbuzz
cd bin/harfbuzz
./configure --with-glib=no --with-icu=no --with-freetype=no --with-cairo=no --with-fontconfig=no --enable-shared \
CFLAGS="-g -O3 -DHB_TINY" CXXFLAGS="-g -O3 -DHB_TINY" > ../harfbuzz_configure.txt
cd ../..
cp ports/harfbuzz/essence-config.h bin/harfbuzz/config.h
cd bin/harfbuzz/src
SED=sed
if [[ "$OSTYPE" == "darwin"* ]]; then
SED=gsed
fi
find . -type f -exec $SED -i 's/#include <assert.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <atomic.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <builtins.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <float.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <locale.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <math.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <stdio.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <stdlib.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <string.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <unistd.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <xlocale.h>/#include <essence.h>/g' {} \;
CC="x86_64-essence-g++ -DHAVE_CONFIG_H -I. -I.. -ffreestanding -fno-rtti -g -O2 -DHB_TINY -fno-exceptions -fno-threadsafe-statics -fvisibility-inlines-hidden"
function CompileHarfbuzz() {
$CC -c hb-aat-layout.cc -o hb-aat-layout.o
$CC -c hb-aat-map.cc -o hb-aat-map.o
$CC -c hb-blob.cc -o hb-blob.o
@ -86,11 +47,82 @@ if [ ! -d "bin/harfbuzz" ]; then
$CC -c hb-unicode.cc -o hb-unicode.o
$CC -c hb-ft.cc -o hb-ft.o
x86_64-essence-ar cr libharfbuzz.a hb-aat-layout.o hb-aat-map.o hb-blob.o hb-buffer-serialize.o hb-buffer.o hb-common.o hb-face.o hb-fallback-shape.o hb-font.o hb-map.o hb-number.o hb-ot-cff1-table.o hb-ot-cff2-table.o hb-ot-color.o hb-ot-face.o hb-ot-font.o hb-ot-layout.o hb-ot-map.o hb-ot-math.o hb-ot-meta.o hb-ot-metrics.o hb-ot-name.o hb-ot-shape-complex-arabic.o hb-ot-shape-complex-default.o hb-ot-shape-complex-hangul.o hb-ot-shape-complex-hebrew.o hb-ot-shape-complex-indic-table.o hb-ot-shape-complex-indic.o hb-ot-shape-complex-khmer.o hb-ot-shape-complex-myanmar.o hb-ot-shape-complex-thai.o hb-ot-shape-complex-use-table.o hb-ot-shape-complex-use.o hb-ot-shape-complex-vowel-constraints.o hb-ot-shape-fallback.o hb-ot-shape-normalize.o hb-ot-shape.o hb-ot-tag.o hb-ot-var.o hb-set.o hb-shape-plan.o hb-shape.o hb-shaper.o hb-static.o hb-ucd.o hb-unicode.o hb-ft.o
$AR libharfbuzz.a hb-aat-layout.o hb-aat-map.o hb-blob.o hb-buffer-serialize.o hb-buffer.o hb-common.o hb-face.o hb-fallback-shape.o hb-font.o hb-map.o hb-number.o hb-ot-cff1-table.o hb-ot-cff2-table.o hb-ot-color.o hb-ot-face.o hb-ot-font.o hb-ot-layout.o hb-ot-map.o hb-ot-math.o hb-ot-meta.o hb-ot-metrics.o hb-ot-name.o hb-ot-shape-complex-arabic.o hb-ot-shape-complex-default.o hb-ot-shape-complex-hangul.o hb-ot-shape-complex-hebrew.o hb-ot-shape-complex-indic-table.o hb-ot-shape-complex-indic.o hb-ot-shape-complex-khmer.o hb-ot-shape-complex-myanmar.o hb-ot-shape-complex-thai.o hb-ot-shape-complex-use-table.o hb-ot-shape-complex-use.o hb-ot-shape-complex-vowel-constraints.o hb-ot-shape-fallback.o hb-ot-shape-normalize.o hb-ot-shape.o hb-ot-tag.o hb-ot-var.o hb-set.o hb-shape-plan.o hb-shape.o hb-shaper.o hb-static.o hb-ucd.o hb-unicode.o hb-ft.o
}
CFLAGS="-DHAVE_CONFIG_H -I. -I.. -ffreestanding -fno-rtti -g -O3 -DHB_TINY -fno-exceptions -fno-threadsafe-statics \
-fvisibility-inlines-hidden -DHB_NO_PRAGMA_GCC_DIAGNOSTIC_ERROR"
if [ ! -d "bin/harfbuzz" ]; then
echo "Downloading Harfbuzz..."
if [ ! -f "bin/cache/harfbuzz-2.6.4.tar" ]; then
curl https://www.freedesktop.org/software/harfbuzz/release/harfbuzz-2.6.4.tar.xz > bin/cache/harfbuzz-2.6.4.tar.xz 2> bin/harfbuzz_dl.txt
xz -d bin/cache/harfbuzz-2.6.4.tar.xz
fi
tar -xf bin/cache/harfbuzz-2.6.4.tar
mv harfbuzz-2.6.4 bin/harfbuzz
cd bin/harfbuzz
./configure --with-glib=no --with-icu=no --with-freetype=no --with-cairo=no --with-fontconfig=no --enable-shared \
CFLAGS="-g -O3 -DHB_TINY" CXXFLAGS="-g -O3 -DHB_TINY" > ../harfbuzz_configure.txt
cd ../..
cp ports/harfbuzz/essence-config.h bin/harfbuzz/config.h
cd bin/harfbuzz/src
SED=sed
if [[ "$OSTYPE" == "darwin"* ]]; then
SED=gsed
fi
find . -type f -exec $SED -i 's/#include <assert.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <atomic.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <builtins.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <float.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <locale.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <math.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <stdio.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <stdlib.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <string.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <unistd.h>/#include <essence.h>/g' {} \;
find . -type f -exec $SED -i 's/#include <xlocale.h>/#include <essence.h>/g' {} \;
cd ../../..
fi
cp -p bin/harfbuzz/src/libharfbuzz.a root/Applications/POSIX/lib
if [ "$1" = "x86_64" ]; then
if [ ! -f "bin/harfbuzz/libharfbuzz_x86_64.a" ]; then
cd bin/harfbuzz/src
CC="x86_64-essence-g++ $CFLAGS"
AR="x86_64-essence-ar cr"
echo "Building Harfbuzz for x86_64..."
CompileHarfbuzz
cp libharfbuzz.a ../libharfbuzz_x86_64.a
cd ../../..
fi
cp -p bin/harfbuzz/libharfbuzz_x86_64.a root/Applications/POSIX/lib/libharfbuzz.a
fi
if [ "$1" = "x86_32" ]; then
if [ ! -f "bin/harfbuzz/libharfbuzz_x86_32.a" ]; then
INC=`realpath root/Applications/POSIX/include`
cd bin/harfbuzz/src
CC="i686-elf-g++ $CFLAGS -I$INC"
AR="i686-elf-ar cr"
echo "Building Harfbuzz for x86_32..."
CompileHarfbuzz
i686-elf-ranlib libharfbuzz.a
cp libharfbuzz.a ../libharfbuzz_x86_32.a
cd ../../..
fi
cp -p bin/harfbuzz/libharfbuzz_x86_32.a root/Applications/POSIX/lib/libharfbuzz.a
fi
mkdir -p root/Applications/POSIX/include/harfbuzz
cp -p bin/harfbuzz/src/*.h root/Applications/POSIX/include/harfbuzz

View File

@ -16,7 +16,6 @@
#define HAVE_STRINGS_H 1
#define HAVE_STRING_H 1
#define HAVE_STRTOD_L 1
#define HAVE_SYS_MMAN_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_UNISTD_H 1

View File

@ -1,9 +1,12 @@
if [ ! -d "bin/musl" ]; then
echo " Downloading source for Musl..."
curl https://musl.libc.org/releases/musl-1.2.1.tar.gz > bin/musl-1.2.1.tar.gz
echo "Downloading Musl..."
gunzip bin/musl-1.2.1.tar.gz
tar -xf bin/musl-1.2.1.tar
if [ ! -f "bin/cache/musl-1.2.1.tar" ]; then
curl https://musl.libc.org/releases/musl-1.2.1.tar.gz > bin/cache/musl-1.2.1.tar.gz
gunzip bin/cache/musl-1.2.1.tar.gz
fi
tar -xf bin/cache/musl-1.2.1.tar
mv musl-1.2.1 bin/musl
cp ports/musl/changes/config.mak bin/musl/config.mak
@ -29,7 +32,15 @@ cp -p ports/musl/libc.a "root/Applications/POSIX/lib/libc.a"
cp -p ports/musl/empty.a "root/Applications/POSIX/lib/libm.a"
cp -p ports/musl/empty.a "root/Applications/POSIX/lib/libpthread.a"
cp -p ports/musl/empty.a "root/Applications/POSIX/lib/librt.a"
cp -p -r ports/musl/obj_bits/* "root/Applications/POSIX/include/"
cp -p -r bin/musl/arch/x86_64/* "root/Applications/POSIX/include/"
cp -p -r bin/musl/arch/generic/* "root/Applications/POSIX/include/"
cp -p -r bin/musl/include/* "root/Applications/POSIX/include/"
cp -p -r bin/musl/arch/generic/* "root/Applications/POSIX/include/"
if [ "$1" = "x86_64" ]; then
cp -p -r bin/musl/arch/x86_64/* "root/Applications/POSIX/include/"
cp -p -r ports/musl/obj_bits_x86_64/* "root/Applications/POSIX/include/"
fi
if [ "$1" = "x86_32" ]; then
cp -p -r bin/musl/arch/i386/* "root/Applications/POSIX/include/"
cp -p -r ports/musl/obj_bits_x86_32/* "root/Applications/POSIX/include/"
fi

View File

@ -0,0 +1,432 @@
#define _REDIR_TIME64 1
#define _Addr int
#define _Int64 long long
#define _Reg int
#define __BYTE_ORDER 1234
#define __LONG_MAX 0x7fffffffL
#ifndef __cplusplus
#ifdef __WCHAR_TYPE__
#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
typedef __WCHAR_TYPE__ wchar_t;
#define __DEFINED_wchar_t
#endif
#else
#if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t)
typedef long wchar_t;
#define __DEFINED_wchar_t
#endif
#endif
#endif
#if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 0
#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
typedef float float_t;
#define __DEFINED_float_t
#endif
#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
typedef double double_t;
#define __DEFINED_double_t
#endif
#else
#if defined(__NEED_float_t) && !defined(__DEFINED_float_t)
typedef long double float_t;
#define __DEFINED_float_t
#endif
#if defined(__NEED_double_t) && !defined(__DEFINED_double_t)
typedef long double double_t;
#define __DEFINED_double_t
#endif
#endif
#if !defined(__cplusplus)
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
typedef struct { _Alignas(8) long long __ll; long double __ld; } max_align_t;
#define __DEFINED_max_align_t
#endif
#elif defined(__GNUC__)
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
typedef struct { __attribute__((__aligned__(8))) long long __ll; long double __ld; } max_align_t;
#define __DEFINED_max_align_t
#endif
#else
#if defined(__NEED_max_align_t) && !defined(__DEFINED_max_align_t)
typedef struct { alignas(8) long long __ll; long double __ld; } max_align_t;
#define __DEFINED_max_align_t
#endif
#endif
#define __LITTLE_ENDIAN 1234
#define __BIG_ENDIAN 4321
#define __USE_TIME_BITS64 1
#if defined(__NEED_size_t) && !defined(__DEFINED_size_t)
typedef unsigned _Addr size_t;
#define __DEFINED_size_t
#endif
#if defined(__NEED_uintptr_t) && !defined(__DEFINED_uintptr_t)
typedef unsigned _Addr uintptr_t;
#define __DEFINED_uintptr_t
#endif
#if defined(__NEED_ptrdiff_t) && !defined(__DEFINED_ptrdiff_t)
typedef _Addr ptrdiff_t;
#define __DEFINED_ptrdiff_t
#endif
#if defined(__NEED_ssize_t) && !defined(__DEFINED_ssize_t)
typedef _Addr ssize_t;
#define __DEFINED_ssize_t
#endif
#if defined(__NEED_intptr_t) && !defined(__DEFINED_intptr_t)
typedef _Addr intptr_t;
#define __DEFINED_intptr_t
#endif
#if defined(__NEED_regoff_t) && !defined(__DEFINED_regoff_t)
typedef _Addr regoff_t;
#define __DEFINED_regoff_t
#endif
#if defined(__NEED_register_t) && !defined(__DEFINED_register_t)
typedef _Reg register_t;
#define __DEFINED_register_t
#endif
#if defined(__NEED_time_t) && !defined(__DEFINED_time_t)
typedef _Int64 time_t;
#define __DEFINED_time_t
#endif
#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t)
typedef _Int64 suseconds_t;
#define __DEFINED_suseconds_t
#endif
#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
typedef signed char int8_t;
#define __DEFINED_int8_t
#endif
#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
typedef signed short int16_t;
#define __DEFINED_int16_t
#endif
#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
typedef signed int int32_t;
#define __DEFINED_int32_t
#endif
#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
typedef signed _Int64 int64_t;
#define __DEFINED_int64_t
#endif
#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
typedef signed _Int64 intmax_t;
#define __DEFINED_intmax_t
#endif
#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
typedef unsigned char uint8_t;
#define __DEFINED_uint8_t
#endif
#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
typedef unsigned short uint16_t;
#define __DEFINED_uint16_t
#endif
#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
typedef unsigned int uint32_t;
#define __DEFINED_uint32_t
#endif
#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
typedef unsigned _Int64 uint64_t;
#define __DEFINED_uint64_t
#endif
#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
typedef unsigned _Int64 u_int64_t;
#define __DEFINED_u_int64_t
#endif
#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
typedef unsigned _Int64 uintmax_t;
#define __DEFINED_uintmax_t
#endif
#if defined(__NEED_mode_t) && !defined(__DEFINED_mode_t)
typedef unsigned mode_t;
#define __DEFINED_mode_t
#endif
#if defined(__NEED_nlink_t) && !defined(__DEFINED_nlink_t)
typedef unsigned _Reg nlink_t;
#define __DEFINED_nlink_t
#endif
#if defined(__NEED_off_t) && !defined(__DEFINED_off_t)
typedef _Int64 off_t;
#define __DEFINED_off_t
#endif
#if defined(__NEED_ino_t) && !defined(__DEFINED_ino_t)
typedef unsigned _Int64 ino_t;
#define __DEFINED_ino_t
#endif
#if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t)
typedef unsigned _Int64 dev_t;
#define __DEFINED_dev_t
#endif
#if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t)
typedef long blksize_t;
#define __DEFINED_blksize_t
#endif
#if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t)
typedef _Int64 blkcnt_t;
#define __DEFINED_blkcnt_t
#endif
#if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t)
typedef unsigned _Int64 fsblkcnt_t;
#define __DEFINED_fsblkcnt_t
#endif
#if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t)
typedef unsigned _Int64 fsfilcnt_t;
#define __DEFINED_fsfilcnt_t
#endif
#if defined(__NEED_wint_t) && !defined(__DEFINED_wint_t)
typedef unsigned wint_t;
#define __DEFINED_wint_t
#endif
#if defined(__NEED_wctype_t) && !defined(__DEFINED_wctype_t)
typedef unsigned long wctype_t;
#define __DEFINED_wctype_t
#endif
#if defined(__NEED_timer_t) && !defined(__DEFINED_timer_t)
typedef void * timer_t;
#define __DEFINED_timer_t
#endif
#if defined(__NEED_clockid_t) && !defined(__DEFINED_clockid_t)
typedef int clockid_t;
#define __DEFINED_clockid_t
#endif
#if defined(__NEED_clock_t) && !defined(__DEFINED_clock_t)
typedef long clock_t;
#define __DEFINED_clock_t
#endif
#if defined(__NEED_struct_timeval) && !defined(__DEFINED_struct_timeval)
struct timeval { time_t tv_sec; suseconds_t tv_usec; };
#define __DEFINED_struct_timeval
#endif
#if defined(__NEED_struct_timespec) && !defined(__DEFINED_struct_timespec)
struct timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); };
#define __DEFINED_struct_timespec
#endif
#if defined(__NEED_pid_t) && !defined(__DEFINED_pid_t)
typedef int pid_t;
#define __DEFINED_pid_t
#endif
#if defined(__NEED_id_t) && !defined(__DEFINED_id_t)
typedef unsigned id_t;
#define __DEFINED_id_t
#endif
#if defined(__NEED_uid_t) && !defined(__DEFINED_uid_t)
typedef unsigned uid_t;
#define __DEFINED_uid_t
#endif
#if defined(__NEED_gid_t) && !defined(__DEFINED_gid_t)
typedef unsigned gid_t;
#define __DEFINED_gid_t
#endif
#if defined(__NEED_key_t) && !defined(__DEFINED_key_t)
typedef int key_t;
#define __DEFINED_key_t
#endif
#if defined(__NEED_useconds_t) && !defined(__DEFINED_useconds_t)
typedef unsigned useconds_t;
#define __DEFINED_useconds_t
#endif
#ifdef __cplusplus
#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
typedef unsigned long pthread_t;
#define __DEFINED_pthread_t
#endif
#else
#if defined(__NEED_pthread_t) && !defined(__DEFINED_pthread_t)
typedef struct __pthread * pthread_t;
#define __DEFINED_pthread_t
#endif
#endif
#if defined(__NEED_pthread_once_t) && !defined(__DEFINED_pthread_once_t)
typedef int pthread_once_t;
#define __DEFINED_pthread_once_t
#endif
#if defined(__NEED_pthread_key_t) && !defined(__DEFINED_pthread_key_t)
typedef unsigned pthread_key_t;
#define __DEFINED_pthread_key_t
#endif
#if defined(__NEED_pthread_spinlock_t) && !defined(__DEFINED_pthread_spinlock_t)
typedef int pthread_spinlock_t;
#define __DEFINED_pthread_spinlock_t
#endif
#if defined(__NEED_pthread_mutexattr_t) && !defined(__DEFINED_pthread_mutexattr_t)
typedef struct { unsigned __attr; } pthread_mutexattr_t;
#define __DEFINED_pthread_mutexattr_t
#endif
#if defined(__NEED_pthread_condattr_t) && !defined(__DEFINED_pthread_condattr_t)
typedef struct { unsigned __attr; } pthread_condattr_t;
#define __DEFINED_pthread_condattr_t
#endif
#if defined(__NEED_pthread_barrierattr_t) && !defined(__DEFINED_pthread_barrierattr_t)
typedef struct { unsigned __attr; } pthread_barrierattr_t;
#define __DEFINED_pthread_barrierattr_t
#endif
#if defined(__NEED_pthread_rwlockattr_t) && !defined(__DEFINED_pthread_rwlockattr_t)
typedef struct { unsigned __attr[2]; } pthread_rwlockattr_t;
#define __DEFINED_pthread_rwlockattr_t
#endif
#if defined(__NEED_struct__IO_FILE) && !defined(__DEFINED_struct__IO_FILE)
struct _IO_FILE { char __x; };
#define __DEFINED_struct__IO_FILE
#endif
#if defined(__NEED_FILE) && !defined(__DEFINED_FILE)
typedef struct _IO_FILE FILE;
#define __DEFINED_FILE
#endif
#if defined(__NEED_va_list) && !defined(__DEFINED_va_list)
typedef __builtin_va_list va_list;
#define __DEFINED_va_list
#endif
#if defined(__NEED___isoc_va_list) && !defined(__DEFINED___isoc_va_list)
typedef __builtin_va_list __isoc_va_list;
#define __DEFINED___isoc_va_list
#endif
#if defined(__NEED_mbstate_t) && !defined(__DEFINED_mbstate_t)
typedef struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t;
#define __DEFINED_mbstate_t
#endif
#if defined(__NEED_locale_t) && !defined(__DEFINED_locale_t)
typedef struct __locale_struct * locale_t;
#define __DEFINED_locale_t
#endif
#if defined(__NEED_sigset_t) && !defined(__DEFINED_sigset_t)
typedef struct __sigset_t { unsigned long __bits[128/sizeof(long)]; } sigset_t;
#define __DEFINED_sigset_t
#endif
#if defined(__NEED_struct_iovec) && !defined(__DEFINED_struct_iovec)
struct iovec { void *iov_base; size_t iov_len; };
#define __DEFINED_struct_iovec
#endif
#if defined(__NEED_socklen_t) && !defined(__DEFINED_socklen_t)
typedef unsigned socklen_t;
#define __DEFINED_socklen_t
#endif
#if defined(__NEED_sa_family_t) && !defined(__DEFINED_sa_family_t)
typedef unsigned short sa_family_t;
#define __DEFINED_sa_family_t
#endif
#if defined(__NEED_pthread_attr_t) && !defined(__DEFINED_pthread_attr_t)
typedef struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t;
#define __DEFINED_pthread_attr_t
#endif
#if defined(__NEED_pthread_mutex_t) && !defined(__DEFINED_pthread_mutex_t)
typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t;
#define __DEFINED_pthread_mutex_t
#endif
#if defined(__NEED_mtx_t) && !defined(__DEFINED_mtx_t)
typedef struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t;
#define __DEFINED_mtx_t
#endif
#if defined(__NEED_pthread_cond_t) && !defined(__DEFINED_pthread_cond_t)
typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t;
#define __DEFINED_pthread_cond_t
#endif
#if defined(__NEED_cnd_t) && !defined(__DEFINED_cnd_t)
typedef struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t;
#define __DEFINED_cnd_t
#endif
#if defined(__NEED_pthread_rwlock_t) && !defined(__DEFINED_pthread_rwlock_t)
typedef struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t;
#define __DEFINED_pthread_rwlock_t
#endif
#if defined(__NEED_pthread_barrier_t) && !defined(__DEFINED_pthread_barrier_t)
typedef struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t;
#define __DEFINED_pthread_barrier_t
#endif
#undef _Addr
#undef _Int64
#undef _Reg

View File

@ -0,0 +1,855 @@
#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8
#define __NR_link 9
#define __NR_unlink 10
#define __NR_execve 11
#define __NR_chdir 12
#define __NR_time 13
#define __NR_mknod 14
#define __NR_chmod 15
#define __NR_lchown 16
#define __NR_break 17
#define __NR_oldstat 18
#define __NR_lseek 19
#define __NR_getpid 20
#define __NR_mount 21
#define __NR_umount 22
#define __NR_setuid 23
#define __NR_getuid 24
#define __NR_stime 25
#define __NR_ptrace 26
#define __NR_alarm 27
#define __NR_oldfstat 28
#define __NR_pause 29
#define __NR_utime 30
#define __NR_stty 31
#define __NR_gtty 32
#define __NR_access 33
#define __NR_nice 34
#define __NR_ftime 35
#define __NR_sync 36
#define __NR_kill 37
#define __NR_rename 38
#define __NR_mkdir 39
#define __NR_rmdir 40
#define __NR_dup 41
#define __NR_pipe 42
#define __NR_times 43
#define __NR_prof 44
#define __NR_brk 45
#define __NR_setgid 46
#define __NR_getgid 47
#define __NR_signal 48
#define __NR_geteuid 49
#define __NR_getegid 50
#define __NR_acct 51
#define __NR_umount2 52
#define __NR_lock 53
#define __NR_ioctl 54
#define __NR_fcntl 55
#define __NR_mpx 56
#define __NR_setpgid 57
#define __NR_ulimit 58
#define __NR_oldolduname 59
#define __NR_umask 60
#define __NR_chroot 61
#define __NR_ustat 62
#define __NR_dup2 63
#define __NR_getppid 64
#define __NR_getpgrp 65
#define __NR_setsid 66
#define __NR_sigaction 67
#define __NR_sgetmask 68
#define __NR_ssetmask 69
#define __NR_setreuid 70
#define __NR_setregid 71
#define __NR_sigsuspend 72
#define __NR_sigpending 73
#define __NR_sethostname 74
#define __NR_setrlimit 75
#define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */
#define __NR_getrusage 77
#define __NR_gettimeofday_time32 78
#define __NR_settimeofday_time32 79
#define __NR_getgroups 80
#define __NR_setgroups 81
#define __NR_select 82
#define __NR_symlink 83
#define __NR_oldlstat 84
#define __NR_readlink 85
#define __NR_uselib 86
#define __NR_swapon 87
#define __NR_reboot 88
#define __NR_readdir 89
#define __NR_mmap 90
#define __NR_munmap 91
#define __NR_truncate 92
#define __NR_ftruncate 93
#define __NR_fchmod 94
#define __NR_fchown 95
#define __NR_getpriority 96
#define __NR_setpriority 97
#define __NR_profil 98
#define __NR_statfs 99
#define __NR_fstatfs 100
#define __NR_ioperm 101
#define __NR_socketcall 102
#define __NR_syslog 103
#define __NR_setitimer 104
#define __NR_getitimer 105
#define __NR_stat 106
#define __NR_lstat 107
#define __NR_fstat 108
#define __NR_olduname 109
#define __NR_iopl 110
#define __NR_vhangup 111
#define __NR_idle 112
#define __NR_vm86old 113
#define __NR_wait4 114
#define __NR_swapoff 115
#define __NR_sysinfo 116
#define __NR_ipc 117
#define __NR_fsync 118
#define __NR_sigreturn 119
#define __NR_clone 120
#define __NR_setdomainname 121
#define __NR_uname 122
#define __NR_modify_ldt 123
#define __NR_adjtimex 124
#define __NR_mprotect 125
#define __NR_sigprocmask 126
#define __NR_create_module 127
#define __NR_init_module 128
#define __NR_delete_module 129
#define __NR_get_kernel_syms 130
#define __NR_quotactl 131
#define __NR_getpgid 132
#define __NR_fchdir 133
#define __NR_bdflush 134
#define __NR_sysfs 135
#define __NR_personality 136
#define __NR_afs_syscall 137
#define __NR_setfsuid 138
#define __NR_setfsgid 139
#define __NR__llseek 140
#define __NR_getdents 141
#define __NR__newselect 142
#define __NR_flock 143
#define __NR_msync 144
#define __NR_readv 145
#define __NR_writev 146
#define __NR_getsid 147
#define __NR_fdatasync 148
#define __NR__sysctl 149
#define __NR_mlock 150
#define __NR_munlock 151
#define __NR_mlockall 152
#define __NR_munlockall 153
#define __NR_sched_setparam 154
#define __NR_sched_getparam 155
#define __NR_sched_setscheduler 156
#define __NR_sched_getscheduler 157
#define __NR_sched_yield 158
#define __NR_sched_get_priority_max 159
#define __NR_sched_get_priority_min 160
#define __NR_sched_rr_get_interval 161
#define __NR_nanosleep 162
#define __NR_mremap 163
#define __NR_setresuid 164
#define __NR_getresuid 165
#define __NR_vm86 166
#define __NR_query_module 167
#define __NR_poll 168
#define __NR_nfsservctl 169
#define __NR_setresgid 170
#define __NR_getresgid 171
#define __NR_prctl 172
#define __NR_rt_sigreturn 173
#define __NR_rt_sigaction 174
#define __NR_rt_sigprocmask 175
#define __NR_rt_sigpending 176
#define __NR_rt_sigtimedwait 177
#define __NR_rt_sigqueueinfo 178
#define __NR_rt_sigsuspend 179
#define __NR_pread64 180
#define __NR_pwrite64 181
#define __NR_chown 182
#define __NR_getcwd 183
#define __NR_capget 184
#define __NR_capset 185
#define __NR_sigaltstack 186
#define __NR_sendfile 187
#define __NR_getpmsg 188
#define __NR_putpmsg 189
#define __NR_vfork 190
#define __NR_ugetrlimit 191
#define __NR_mmap2 192
#define __NR_truncate64 193
#define __NR_ftruncate64 194
#define __NR_stat64 195
#define __NR_lstat64 196
#define __NR_fstat64 197
#define __NR_lchown32 198
#define __NR_getuid32 199
#define __NR_getgid32 200
#define __NR_geteuid32 201
#define __NR_getegid32 202
#define __NR_setreuid32 203
#define __NR_setregid32 204
#define __NR_getgroups32 205
#define __NR_setgroups32 206
#define __NR_fchown32 207
#define __NR_setresuid32 208
#define __NR_getresuid32 209
#define __NR_setresgid32 210
#define __NR_getresgid32 211
#define __NR_chown32 212
#define __NR_setuid32 213
#define __NR_setgid32 214
#define __NR_setfsuid32 215
#define __NR_setfsgid32 216
#define __NR_pivot_root 217
#define __NR_mincore 218
#define __NR_madvise 219
#define __NR_getdents64 220
#define __NR_fcntl64 221
/* 223 is unused */
#define __NR_gettid 224
#define __NR_readahead 225
#define __NR_setxattr 226
#define __NR_lsetxattr 227
#define __NR_fsetxattr 228
#define __NR_getxattr 229
#define __NR_lgetxattr 230
#define __NR_fgetxattr 231
#define __NR_listxattr 232
#define __NR_llistxattr 233
#define __NR_flistxattr 234
#define __NR_removexattr 235
#define __NR_lremovexattr 236
#define __NR_fremovexattr 237
#define __NR_tkill 238
#define __NR_sendfile64 239
#define __NR_futex 240
#define __NR_sched_setaffinity 241
#define __NR_sched_getaffinity 242
#define __NR_set_thread_area 243
#define __NR_get_thread_area 244
#define __NR_io_setup 245
#define __NR_io_destroy 246
#define __NR_io_getevents 247
#define __NR_io_submit 248
#define __NR_io_cancel 249
#define __NR_fadvise64 250
/* 251 is available for reuse (was briefly sys_set_zone_reclaim) */
#define __NR_exit_group 252
#define __NR_lookup_dcookie 253
#define __NR_epoll_create 254
#define __NR_epoll_ctl 255
#define __NR_epoll_wait 256
#define __NR_remap_file_pages 257
#define __NR_set_tid_address 258
#define __NR_timer_create 259
#define __NR_timer_settime32 (__NR_timer_create+1)
#define __NR_timer_gettime32 (__NR_timer_create+2)
#define __NR_timer_getoverrun (__NR_timer_create+3)
#define __NR_timer_delete (__NR_timer_create+4)
#define __NR_clock_settime32 (__NR_timer_create+5)
#define __NR_clock_gettime32 (__NR_timer_create+6)
#define __NR_clock_getres_time32 (__NR_timer_create+7)
#define __NR_clock_nanosleep_time32 (__NR_timer_create+8)
#define __NR_statfs64 268
#define __NR_fstatfs64 269
#define __NR_tgkill 270
#define __NR_utimes 271
#define __NR_fadvise64_64 272
#define __NR_vserver 273
#define __NR_mbind 274
#define __NR_get_mempolicy 275
#define __NR_set_mempolicy 276
#define __NR_mq_open 277
#define __NR_mq_unlink (__NR_mq_open+1)
#define __NR_mq_timedsend (__NR_mq_open+2)
#define __NR_mq_timedreceive (__NR_mq_open+3)
#define __NR_mq_notify (__NR_mq_open+4)
#define __NR_mq_getsetattr (__NR_mq_open+5)
#define __NR_kexec_load 283
#define __NR_waitid 284
/* #define __NR_sys_setaltroot 285 */
#define __NR_add_key 286
#define __NR_request_key 287
#define __NR_keyctl 288
#define __NR_ioprio_set 289
#define __NR_ioprio_get 290
#define __NR_inotify_init 291
#define __NR_inotify_add_watch 292
#define __NR_inotify_rm_watch 293
#define __NR_migrate_pages 294
#define __NR_openat 295
#define __NR_mkdirat 296
#define __NR_mknodat 297
#define __NR_fchownat 298
#define __NR_futimesat 299
#define __NR_fstatat64 300
#define __NR_unlinkat 301
#define __NR_renameat 302
#define __NR_linkat 303
#define __NR_symlinkat 304
#define __NR_readlinkat 305
#define __NR_fchmodat 306
#define __NR_faccessat 307
#define __NR_pselect6 308
#define __NR_ppoll 309
#define __NR_unshare 310
#define __NR_set_robust_list 311
#define __NR_get_robust_list 312
#define __NR_splice 313
#define __NR_sync_file_range 314
#define __NR_tee 315
#define __NR_vmsplice 316
#define __NR_move_pages 317
#define __NR_getcpu 318
#define __NR_epoll_pwait 319
#define __NR_utimensat 320
#define __NR_signalfd 321
#define __NR_timerfd_create 322
#define __NR_eventfd 323
#define __NR_fallocate 324
#define __NR_timerfd_settime32 325
#define __NR_timerfd_gettime32 326
#define __NR_signalfd4 327
#define __NR_eventfd2 328
#define __NR_epoll_create1 329
#define __NR_dup3 330
#define __NR_pipe2 331
#define __NR_inotify_init1 332
#define __NR_preadv 333
#define __NR_pwritev 334
#define __NR_rt_tgsigqueueinfo 335
#define __NR_perf_event_open 336
#define __NR_recvmmsg 337
#define __NR_fanotify_init 338
#define __NR_fanotify_mark 339
#define __NR_prlimit64 340
#define __NR_name_to_handle_at 341
#define __NR_open_by_handle_at 342
#define __NR_clock_adjtime 343
#define __NR_syncfs 344
#define __NR_sendmmsg 345
#define __NR_setns 346
#define __NR_process_vm_readv 347
#define __NR_process_vm_writev 348
#define __NR_kcmp 349
#define __NR_finit_module 350
#define __NR_sched_setattr 351
#define __NR_sched_getattr 352
#define __NR_renameat2 353
#define __NR_seccomp 354
#define __NR_getrandom 355
#define __NR_memfd_create 356
#define __NR_bpf 357
#define __NR_execveat 358
#define __NR_socket 359
#define __NR_socketpair 360
#define __NR_bind 361
#define __NR_connect 362
#define __NR_listen 363
#define __NR_accept4 364
#define __NR_getsockopt 365
#define __NR_setsockopt 366
#define __NR_getsockname 367
#define __NR_getpeername 368
#define __NR_sendto 369
#define __NR_sendmsg 370
#define __NR_recvfrom 371
#define __NR_recvmsg 372
#define __NR_shutdown 373
#define __NR_userfaultfd 374
#define __NR_membarrier 375
#define __NR_mlock2 376
#define __NR_copy_file_range 377
#define __NR_preadv2 378
#define __NR_pwritev2 379
#define __NR_pkey_mprotect 380
#define __NR_pkey_alloc 381
#define __NR_pkey_free 382
#define __NR_statx 383
#define __NR_arch_prctl 384
#define __NR_io_pgetevents 385
#define __NR_rseq 386
#define __NR_semget 393
#define __NR_semctl 394
#define __NR_shmget 395
#define __NR_shmctl 396
#define __NR_shmat 397
#define __NR_shmdt 398
#define __NR_msgget 399
#define __NR_msgsnd 400
#define __NR_msgrcv 401
#define __NR_msgctl 402
#define __NR_clock_gettime64 403
#define __NR_clock_settime64 404
#define __NR_clock_adjtime64 405
#define __NR_clock_getres_time64 406
#define __NR_clock_nanosleep_time64 407
#define __NR_timer_gettime64 408
#define __NR_timer_settime64 409
#define __NR_timerfd_gettime64 410
#define __NR_timerfd_settime64 411
#define __NR_utimensat_time64 412
#define __NR_pselect6_time64 413
#define __NR_ppoll_time64 414
#define __NR_io_pgetevents_time64 416
#define __NR_recvmmsg_time64 417
#define __NR_mq_timedsend_time64 418
#define __NR_mq_timedreceive_time64 419
#define __NR_semtimedop_time64 420
#define __NR_rt_sigtimedwait_time64 421
#define __NR_futex_time64 422
#define __NR_sched_rr_get_interval_time64 423
#define __NR_pidfd_send_signal 424
#define __NR_io_uring_setup 425
#define __NR_io_uring_enter 426
#define __NR_io_uring_register 427
#define __NR_open_tree 428
#define __NR_move_mount 429
#define __NR_fsopen 430
#define __NR_fsconfig 431
#define __NR_fsmount 432
#define __NR_fspick 433
#define __NR_pidfd_open 434
#define __NR_clone3 435
#define SYS_restart_syscall 0
#define SYS_exit 1
#define SYS_fork 2
#define SYS_read 3
#define SYS_write 4
#define SYS_open 5
#define SYS_close 6
#define SYS_waitpid 7
#define SYS_creat 8
#define SYS_link 9
#define SYS_unlink 10
#define SYS_execve 11
#define SYS_chdir 12
#define SYS_time 13
#define SYS_mknod 14
#define SYS_chmod 15
#define SYS_lchown 16
#define SYS_break 17
#define SYS_oldstat 18
#define SYS_lseek 19
#define SYS_getpid 20
#define SYS_mount 21
#define SYS_umount 22
#define SYS_setuid 23
#define SYS_getuid 24
#define SYS_stime 25
#define SYS_ptrace 26
#define SYS_alarm 27
#define SYS_oldfstat 28
#define SYS_pause 29
#define SYS_utime 30
#define SYS_stty 31
#define SYS_gtty 32
#define SYS_access 33
#define SYS_nice 34
#define SYS_ftime 35
#define SYS_sync 36
#define SYS_kill 37
#define SYS_rename 38
#define SYS_mkdir 39
#define SYS_rmdir 40
#define SYS_dup 41
#define SYS_pipe 42
#define SYS_times 43
#define SYS_prof 44
#define SYS_brk 45
#define SYS_setgid 46
#define SYS_getgid 47
#define SYS_signal 48
#define SYS_geteuid 49
#define SYS_getegid 50
#define SYS_acct 51
#define SYS_umount2 52
#define SYS_lock 53
#define SYS_ioctl 54
#define SYS_fcntl 55
#define SYS_mpx 56
#define SYS_setpgid 57
#define SYS_ulimit 58
#define SYS_oldolduname 59
#define SYS_umask 60
#define SYS_chroot 61
#define SYS_ustat 62
#define SYS_dup2 63
#define SYS_getppid 64
#define SYS_getpgrp 65
#define SYS_setsid 66
#define SYS_sigaction 67
#define SYS_sgetmask 68
#define SYS_ssetmask 69
#define SYS_setreuid 70
#define SYS_setregid 71
#define SYS_sigsuspend 72
#define SYS_sigpending 73
#define SYS_sethostname 74
#define SYS_setrlimit 75
#define SYS_getrlimit 76 /* Back compatible 2Gig limited rlimit */
#define SYS_getrusage 77
#define SYS_gettimeofday_time32 78
#define SYS_settimeofday_time32 79
#define SYS_getgroups 80
#define SYS_setgroups 81
#define SYS_select 82
#define SYS_symlink 83
#define SYS_oldlstat 84
#define SYS_readlink 85
#define SYS_uselib 86
#define SYS_swapon 87
#define SYS_reboot 88
#define SYS_readdir 89
#define SYS_mmap 90
#define SYS_munmap 91
#define SYS_truncate 92
#define SYS_ftruncate 93
#define SYS_fchmod 94
#define SYS_fchown 95
#define SYS_getpriority 96
#define SYS_setpriority 97
#define SYS_profil 98
#define SYS_statfs 99
#define SYS_fstatfs 100
#define SYS_ioperm 101
#define SYS_socketcall 102
#define SYS_syslog 103
#define SYS_setitimer 104
#define SYS_getitimer 105
#define SYS_stat 106
#define SYS_lstat 107
#define SYS_fstat 108
#define SYS_olduname 109
#define SYS_iopl 110
#define SYS_vhangup 111
#define SYS_idle 112
#define SYS_vm86old 113
#define SYS_wait4 114
#define SYS_swapoff 115
#define SYS_sysinfo 116
#define SYS_ipc 117
#define SYS_fsync 118
#define SYS_sigreturn 119
#define SYS_clone 120
#define SYS_setdomainname 121
#define SYS_uname 122
#define SYS_modify_ldt 123
#define SYS_adjtimex 124
#define SYS_mprotect 125
#define SYS_sigprocmask 126
#define SYS_create_module 127
#define SYS_init_module 128
#define SYS_delete_module 129
#define SYS_get_kernel_syms 130
#define SYS_quotactl 131
#define SYS_getpgid 132
#define SYS_fchdir 133
#define SYS_bdflush 134
#define SYS_sysfs 135
#define SYS_personality 136
#define SYS_afs_syscall 137
#define SYS_setfsuid 138
#define SYS_setfsgid 139
#define SYS__llseek 140
#define SYS_getdents 141
#define SYS__newselect 142
#define SYS_flock 143
#define SYS_msync 144
#define SYS_readv 145
#define SYS_writev 146
#define SYS_getsid 147
#define SYS_fdatasync 148
#define SYS__sysctl 149
#define SYS_mlock 150
#define SYS_munlock 151
#define SYS_mlockall 152
#define SYS_munlockall 153
#define SYS_sched_setparam 154
#define SYS_sched_getparam 155
#define SYS_sched_setscheduler 156
#define SYS_sched_getscheduler 157
#define SYS_sched_yield 158
#define SYS_sched_get_priority_max 159
#define SYS_sched_get_priority_min 160
#define SYS_sched_rr_get_interval 161
#define SYS_nanosleep 162
#define SYS_mremap 163
#define SYS_setresuid 164
#define SYS_getresuid 165
#define SYS_vm86 166
#define SYS_query_module 167
#define SYS_poll 168
#define SYS_nfsservctl 169
#define SYS_setresgid 170
#define SYS_getresgid 171
#define SYS_prctl 172
#define SYS_rt_sigreturn 173
#define SYS_rt_sigaction 174
#define SYS_rt_sigprocmask 175
#define SYS_rt_sigpending 176
#define SYS_rt_sigtimedwait 177
#define SYS_rt_sigqueueinfo 178
#define SYS_rt_sigsuspend 179
#define SYS_pread64 180
#define SYS_pwrite64 181
#define SYS_chown 182
#define SYS_getcwd 183
#define SYS_capget 184
#define SYS_capset 185
#define SYS_sigaltstack 186
#define SYS_sendfile 187
#define SYS_getpmsg 188
#define SYS_putpmsg 189
#define SYS_vfork 190
#define SYS_ugetrlimit 191
#define SYS_mmap2 192
#define SYS_truncate64 193
#define SYS_ftruncate64 194
#define SYS_stat64 195
#define SYS_lstat64 196
#define SYS_fstat64 197
#define SYS_lchown32 198
#define SYS_getuid32 199
#define SYS_getgid32 200
#define SYS_geteuid32 201
#define SYS_getegid32 202
#define SYS_setreuid32 203
#define SYS_setregid32 204
#define SYS_getgroups32 205
#define SYS_setgroups32 206
#define SYS_fchown32 207
#define SYS_setresuid32 208
#define SYS_getresuid32 209
#define SYS_setresgid32 210
#define SYS_getresgid32 211
#define SYS_chown32 212
#define SYS_setuid32 213
#define SYS_setgid32 214
#define SYS_setfsuid32 215
#define SYS_setfsgid32 216
#define SYS_pivot_root 217
#define SYS_mincore 218
#define SYS_madvise 219
#define SYS_getdents64 220
#define SYS_fcntl64 221
#define SYS_gettid 224
#define SYS_readahead 225
#define SYS_setxattr 226
#define SYS_lsetxattr 227
#define SYS_fsetxattr 228
#define SYS_getxattr 229
#define SYS_lgetxattr 230
#define SYS_fgetxattr 231
#define SYS_listxattr 232
#define SYS_llistxattr 233
#define SYS_flistxattr 234
#define SYS_removexattr 235
#define SYS_lremovexattr 236
#define SYS_fremovexattr 237
#define SYS_tkill 238
#define SYS_sendfile64 239
#define SYS_futex 240
#define SYS_sched_setaffinity 241
#define SYS_sched_getaffinity 242
#define SYS_set_thread_area 243
#define SYS_get_thread_area 244
#define SYS_io_setup 245
#define SYS_io_destroy 246
#define SYS_io_getevents 247
#define SYS_io_submit 248
#define SYS_io_cancel 249
#define SYS_fadvise64 250
#define SYS_exit_group 252
#define SYS_lookup_dcookie 253
#define SYS_epoll_create 254
#define SYS_epoll_ctl 255
#define SYS_epoll_wait 256
#define SYS_remap_file_pages 257
#define SYS_set_tid_address 258
#define SYS_timer_create 259
#define SYS_timer_settime32 (__NR_timer_create+1)
#define SYS_timer_gettime32 (__NR_timer_create+2)
#define SYS_timer_getoverrun (__NR_timer_create+3)
#define SYS_timer_delete (__NR_timer_create+4)
#define SYS_clock_settime32 (__NR_timer_create+5)
#define SYS_clock_gettime32 (__NR_timer_create+6)
#define SYS_clock_getres_time32 (__NR_timer_create+7)
#define SYS_clock_nanosleep_time32 (__NR_timer_create+8)
#define SYS_statfs64 268
#define SYS_fstatfs64 269
#define SYS_tgkill 270
#define SYS_utimes 271
#define SYS_fadvise64_64 272
#define SYS_vserver 273
#define SYS_mbind 274
#define SYS_get_mempolicy 275
#define SYS_set_mempolicy 276
#define SYS_mq_open 277
#define SYS_mq_unlink (__NR_mq_open+1)
#define SYS_mq_timedsend (__NR_mq_open+2)
#define SYS_mq_timedreceive (__NR_mq_open+3)
#define SYS_mq_notify (__NR_mq_open+4)
#define SYS_mq_getsetattr (__NR_mq_open+5)
#define SYS_kexec_load 283
#define SYS_waitid 284
/* #define SYS_sys_setaltroot 285 */
#define SYS_add_key 286
#define SYS_request_key 287
#define SYS_keyctl 288
#define SYS_ioprio_set 289
#define SYS_ioprio_get 290
#define SYS_inotify_init 291
#define SYS_inotify_add_watch 292
#define SYS_inotify_rm_watch 293
#define SYS_migrate_pages 294
#define SYS_openat 295
#define SYS_mkdirat 296
#define SYS_mknodat 297
#define SYS_fchownat 298
#define SYS_futimesat 299
#define SYS_fstatat64 300
#define SYS_unlinkat 301
#define SYS_renameat 302
#define SYS_linkat 303
#define SYS_symlinkat 304
#define SYS_readlinkat 305
#define SYS_fchmodat 306
#define SYS_faccessat 307
#define SYS_pselect6 308
#define SYS_ppoll 309
#define SYS_unshare 310
#define SYS_set_robust_list 311
#define SYS_get_robust_list 312
#define SYS_splice 313
#define SYS_sync_file_range 314
#define SYS_tee 315
#define SYS_vmsplice 316
#define SYS_move_pages 317
#define SYS_getcpu 318
#define SYS_epoll_pwait 319
#define SYS_utimensat 320
#define SYS_signalfd 321
#define SYS_timerfd_create 322
#define SYS_eventfd 323
#define SYS_fallocate 324
#define SYS_timerfd_settime32 325
#define SYS_timerfd_gettime32 326
#define SYS_signalfd4 327
#define SYS_eventfd2 328
#define SYS_epoll_create1 329
#define SYS_dup3 330
#define SYS_pipe2 331
#define SYS_inotify_init1 332
#define SYS_preadv 333
#define SYS_pwritev 334
#define SYS_rt_tgsigqueueinfo 335
#define SYS_perf_event_open 336
#define SYS_recvmmsg 337
#define SYS_fanotify_init 338
#define SYS_fanotify_mark 339
#define SYS_prlimit64 340
#define SYS_name_to_handle_at 341
#define SYS_open_by_handle_at 342
#define SYS_clock_adjtime 343
#define SYS_syncfs 344
#define SYS_sendmmsg 345
#define SYS_setns 346
#define SYS_process_vm_readv 347
#define SYS_process_vm_writev 348
#define SYS_kcmp 349
#define SYS_finit_module 350
#define SYS_sched_setattr 351
#define SYS_sched_getattr 352
#define SYS_renameat2 353
#define SYS_seccomp 354
#define SYS_getrandom 355
#define SYS_memfd_create 356
#define SYS_bpf 357
#define SYS_execveat 358
#define SYS_socket 359
#define SYS_socketpair 360
#define SYS_bind 361
#define SYS_connect 362
#define SYS_listen 363
#define SYS_accept4 364
#define SYS_getsockopt 365
#define SYS_setsockopt 366
#define SYS_getsockname 367
#define SYS_getpeername 368
#define SYS_sendto 369
#define SYS_sendmsg 370
#define SYS_recvfrom 371
#define SYS_recvmsg 372
#define SYS_shutdown 373
#define SYS_userfaultfd 374
#define SYS_membarrier 375
#define SYS_mlock2 376
#define SYS_copy_file_range 377
#define SYS_preadv2 378
#define SYS_pwritev2 379
#define SYS_pkey_mprotect 380
#define SYS_pkey_alloc 381
#define SYS_pkey_free 382
#define SYS_statx 383
#define SYS_arch_prctl 384
#define SYS_io_pgetevents 385
#define SYS_rseq 386
#define SYS_semget 393
#define SYS_semctl 394
#define SYS_shmget 395
#define SYS_shmctl 396
#define SYS_shmat 397
#define SYS_shmdt 398
#define SYS_msgget 399
#define SYS_msgsnd 400
#define SYS_msgrcv 401
#define SYS_msgctl 402
#define SYS_clock_gettime64 403
#define SYS_clock_settime64 404
#define SYS_clock_adjtime64 405
#define SYS_clock_getres_time64 406
#define SYS_clock_nanosleep_time64 407
#define SYS_timer_gettime64 408
#define SYS_timer_settime64 409
#define SYS_timerfd_gettime64 410
#define SYS_timerfd_settime64 411
#define SYS_utimensat_time64 412
#define SYS_pselect6_time64 413
#define SYS_ppoll_time64 414
#define SYS_io_pgetevents_time64 416
#define SYS_recvmmsg_time64 417
#define SYS_mq_timedsend_time64 418
#define SYS_mq_timedreceive_time64 419
#define SYS_semtimedop_time64 420
#define SYS_rt_sigtimedwait_time64 421
#define SYS_futex_time64 422
#define SYS_sched_rr_get_interval_time64 423
#define SYS_pidfd_send_signal 424
#define SYS_io_uring_setup 425
#define SYS_io_uring_enter 426
#define SYS_io_uring_register 427
#define SYS_open_tree 428
#define SYS_move_mount 429
#define SYS_fsopen 430
#define SYS_fsconfig 431
#define SYS_fsmount 432
#define SYS_fspick 433
#define SYS_pidfd_open 434
#define SYS_clone3 435

View File

@ -1240,7 +1240,7 @@ void EsMemoryCopy(void *_destination, const void *_source, size_t bytes) {
uint8_t *destination = (uint8_t *) _destination;
uint8_t *source = (uint8_t *) _source;
#ifdef ARCH_X86_64
#ifdef ES_ARCH_X86_64
while (bytes >= 16) {
_mm_storeu_si128((__m128i *) destination,
_mm_loadu_si128((__m128i *) source));
@ -1512,7 +1512,7 @@ void EsSort(void *_base, size_t nmemb, size_t size, int (*compar)(const void *,
if (nmemb <= 1) return;
uint8_t *base = (uint8_t *) _base;
uint8_t *swap = (uint8_t *) alloca(size);
uint8_t *swap = (uint8_t *) __builtin_alloca(size);
intptr_t i = -1, j = nmemb;
@ -2221,7 +2221,7 @@ void EsCRTqsort(void *_base, size_t nmemb, size_t size, EsCRTComparisonCallback
if (nmemb <= 1) return;
uint8_t *base = (uint8_t *) _base;
uint8_t *swap = (uint8_t *) alloca(size);
uint8_t *swap = (uint8_t *) __builtin_alloca(size);
intptr_t i = -1, j = nmemb;

View File

@ -1112,11 +1112,11 @@ bool Format(uint64_t driveSize, const char *volumeName, EsUniqueIdentifier osIns
superblock.requiredReadVersion = ESFS_DRIVER_VERSION;
superblock.requiredWriteVersion = ESFS_DRIVER_VERSION;
if (driveSize < 2048l * 1024 * 1024) { // < 2GB
if (driveSize < 2048ll * 1024 * 1024) { // < 2GB
superblock.blockSize = 2048; // Must be >= sizeof(DirectoryEntry).
} else if (driveSize < 2l * 1024 * 1024 * 1024 * 1024) { // < 2TB
} else if (driveSize < 2ll * 1024 * 1024 * 1024 * 1024) { // < 2TB
superblock.blockSize = 4096;
} else if (driveSize < 256l * 1024 * 1024 * 1024 * 1024) { // < 256TB
} else if (driveSize < 256ll * 1024 * 1024 * 1024 * 1024) { // < 256TB
superblock.blockSize = 8192;
} else {
superblock.blockSize = 16384;

View File

@ -1110,7 +1110,7 @@ struct BigFloat {
uint8_t carry = subtract ? 1 : 0;
#ifdef ARCH_32
#ifdef ES_BITS_32
for (intptr_t i = MANTISSA_BITS - 1; i >= 0; i--) {
uint8_t xi = GET_MANTISSA_BIT(x, i);
uint8_t yi = GET_MANTISSA_BIT(y, i);
@ -1134,7 +1134,7 @@ struct BigFloat {
uint8_t carry = 1;
#ifdef ARCH_32
#ifdef ES_BITS_32
for (intptr_t i = MANTISSA_BITS - 1; i >= 0; i--) {
uint8_t xi = GET_MANTISSA_BIT(x, i);
uint8_t sum = xi + carry;

View File

@ -380,7 +380,7 @@ enum
STBI_rgb_alpha = 4
};
#include <stdlib.h>
// #include <stdlib.h>
typedef unsigned char stbi_uc;
typedef unsigned short stbi_us;

View File

@ -2,6 +2,16 @@
#define _GNU_SOURCE
#endif
#if 1
#define TOOLCHAIN_PREFIX "x86_64-essence"
#define TARGET_NAME "x86_64"
#define TOOLCHAIN_HAS_RED_ZONE
#define TOOLCHAIN_HAS_CSTDLIB
#else
#define TOOLCHAIN_PREFIX "i686-elf"
#define TARGET_NAME "x86_32"
#endif
#define WARNING_FLAGS \
" -Wall -Wextra -Wno-missing-field-initializers -Wno-pmf-conversions -Wno-frame-address -Wno-unused-function -Wno-format-truncation -Wno-invalid-offsetof "
#define WARNING_FLAGS_C \
@ -137,13 +147,9 @@ void BuildAPIDependencies() {
ParseDependencies("bin/api_header.d", "API Header", false);
}
CallSystem("cp `x86_64-essence-gcc -print-file-name=\"crtbegin.o\"` bin/crtbegin.o");
CallSystem("cp `x86_64-essence-gcc -print-file-name=\"crtend.o\"` bin/crtend.o");
CallSystem("ports/musl/build.sh > /dev/null");
CallSystem("ports/freetype/build.sh");
CallSystem("ports/harfbuzz/build.sh");
CallSystem("ports/musl/build.sh " TARGET_NAME);
CallSystem("ports/freetype/build.sh " TARGET_NAME);
CallSystem("ports/harfbuzz/build.sh " TARGET_NAME);
CallSystem("cp -p kernel/module.h root/Applications/POSIX/include");
}
@ -158,19 +164,21 @@ void OutputStartOfBuildINI(FILE *f, bool forceDebugBuildOff) {
fprintf(f, "[toolchain]\npath=%s\ntmpdir=%s\n"
"ar=%s/x86_64-essence-ar\n"
"cc=%s/x86_64-essence-gcc\n"
"cxx=%s/x86_64-essence-g++\n"
"ld=%s/x86_64-essence-ld\n"
"nm=%s/x86_64-essence-nm\n"
"strip=%s/x86_64-essence-strip\n"
"cc=%s/" TOOLCHAIN_PREFIX "-gcc\n"
"cxx=%s/" TOOLCHAIN_PREFIX "-g++\n"
"ld=%s/" TOOLCHAIN_PREFIX "-ld\n"
"nm=%s/" TOOLCHAIN_PREFIX "-nm\n"
"strip=%s/" TOOLCHAIN_PREFIX "-strip\n"
"nasm=%s\n"
"convert_svg=bin/render_svg\n"
"linker_scripts=util/\n"
"crt_objects=bin/\n"
"\n[general]\nsystem_build=1\nminimal_rebuild=1\ncolored_output=%d\nthread_count=%d\nskip_header_generation=1\nverbose=%d\ncommon_compile_flags=",
"compiler_objects=%s/../lib/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "\n"
"\n[general]\nsystem_build=1\nminimal_rebuild=1\ncolored_output=%d\nthread_count=%d\n"
"target=" TARGET_NAME "\nskip_header_generation=1\nverbose=%d\ncommon_compile_flags=",
compilerPath, getenv("TMPDIR") ?: "",
compilerPath, compilerPath, compilerPath, compilerPath, compilerPath, compilerPath,
buffer, coloredOutput, (int) sysconf(_SC_NPROCESSORS_CONF), IsOptionEnabled("BuildCore.Verbose"));
compilerPath, compilerPath, compilerPath, compilerPath, compilerPath, compilerPath,
buffer, compilerPath, coloredOutput, (int) sysconf(_SC_NPROCESSORS_CONF), IsOptionEnabled("BuildCore.Verbose"));
for (uintptr_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
Option *option = &options[i];
@ -337,7 +345,9 @@ void Compile(uint32_t flags, int partitionSize, const char *volumeLabel) {
fflush(stdout);
CallSystem("bin/build_core standard bin/build.ini");
CallSystem("x86_64-essence-gcc -o root/Applications/POSIX/bin/hello ports/gcc/hello.c");
#ifdef TOOLCHAIN_HAS_CSTDLIB
CallSystem(TOOLCHAIN_PREFIX "-gcc -o root/Applications/POSIX/bin/hello ports/gcc/hello.c");
#endif
forceRebuild = false;
}
@ -654,7 +664,7 @@ void BuildCrossCompiler() {
{
CallSystem("echo Preparing C standard library headers... >> bin/build_cross.log");
CallSystem("mkdir -p root/" SYSTEM_FOLDER_NAME " root/Applications/POSIX/include root/Applications/POSIX/lib root/Applications/POSIX/bin");
CallSystem("ports/musl/build.sh >> bin/build_cross.log 2>&1");
CallSystem("ports/musl/build.sh " TARGET_NAME ">> bin/build_cross.log 2>&1");
}
printf("Downloading and extracting source...\n");
@ -671,12 +681,12 @@ void BuildCrossCompiler() {
if (CallSystem("mkdir bin/build-binutils")) goto fail;
if (CallSystem("mkdir bin/build-gcc")) goto fail;
if (chdir("bin/build-binutils")) goto fail;
if (CallSystemF("../binutils-src/configure --target=x86_64-essence --prefix=\"%s\" --with-sysroot=%s --disable-nls --disable-werror >> ../build_cross.log 2>&1",
if (CallSystemF("../binutils-src/configure --target=" TOOLCHAIN_PREFIX " --prefix=\"%s\" --with-sysroot=%s --disable-nls --disable-werror >> ../build_cross.log 2>&1",
installationFolder, sysrootFolder)) goto fail;
if (chdir("../..")) goto fail;
if (chdir("bin/build-gcc")) goto fail;
// Add --without-headers for a x86_64-elf build.
if (CallSystemF("../gcc-src/configure --target=x86_64-essence --prefix=\"%s\" --enable-languages=c,c++ --with-sysroot=%s --disable-nls >> ../build_cross.log 2>&1",
if (CallSystemF("../gcc-src/configure --target=" TOOLCHAIN_PREFIX " --prefix=\"%s\" --enable-languages=c,c++ --with-sysroot=%s --disable-nls >> ../build_cross.log 2>&1",
installationFolder, sysrootFolder)) goto fail;
if (chdir("../..")) goto fail;
}
@ -704,12 +714,12 @@ void BuildCrossCompiler() {
{
CallSystem("echo Removing debug symbols... >> bin/build_cross.log");
CallSystemF("strip %s/bin/* >> bin/build_cross.log 2>&1", installationFolder);
CallSystemF("strip %s/libexec/gcc/x86_64-essence/" GCC_VERSION "/* >> bin/build_cross.log 2>&1", installationFolder);
CallSystemF("strip %s/libexec/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "/* >> bin/build_cross.log 2>&1", installationFolder);
}
{
CallSystem("echo Modifying headers... >> bin/build_cross.log");
sprintf(path, "%s/lib/gcc/x86_64-essence/" GCC_VERSION "/include/mm_malloc.h", installationFolder);
sprintf(path, "%s/lib/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "/include/mm_malloc.h", installationFolder);
FILE *file = fopen(path, "w");
if (!file) {
printf("Couldn't modify header files\n");
@ -771,6 +781,7 @@ void SaveConfig() {
}
const char *folders[] = {
"arch",
"apps",
"desktop",
"kernel",
@ -1599,7 +1610,7 @@ int main(int _argc, char **_argv) {
const char *runFirstCommand = NULL;
if (CallSystem("x86_64-essence-gcc --version > /dev/null 2>&1 ")) {
if (CallSystem("" TOOLCHAIN_PREFIX "-gcc --version > /dev/null 2>&1 ")) {
BuildCrossCompiler();
runFirstCommand = "b";
foundValidCrossCompiler = true;
@ -1616,8 +1627,9 @@ int main(int _argc, char **_argv) {
printf("Please rebuild the compiler using the command " ColorHighlight "build-cross" ColorNormal " before attempting to build the OS.\n");
}
#ifdef TOOLCHAIN_HAS_RED_ZONE
{
CallSystem("x86_64-essence-gcc -mno-red-zone -print-libgcc-file-name > bin/valid_compiler.txt");
CallSystem("" TOOLCHAIN_PREFIX "-gcc -mno-red-zone -print-libgcc-file-name > bin/valid_compiler.txt");
FILE *f = fopen("bin/valid_compiler.txt", "r");
char buffer[256];
buffer[fread(buffer, 1, 256, f)] = 0;
@ -1630,6 +1642,7 @@ int main(int _argc, char **_argv) {
unlink("bin/valid_compiler.txt");
}
#endif
printf("Enter 'help' to get a list of commands.\n");
char *prev = NULL;

View File

@ -140,17 +140,18 @@ File FileOpen(const char *path, char mode) {
// Toolchain flags:
const char *commonCompileFlagsFreestanding = " -ffreestanding -fno-exceptions ";
char commonCompileFlags[4096] = " -Wall -Wextra -Wno-missing-field-initializers -Wno-frame-address -Wno-unused-function -Wno-format-truncation -g -I. -fdiagnostics-column-unit=byte ";
char commonCompileFlags[4096] = " -Wall -Wextra -Wno-missing-field-initializers -Wno-frame-address -Wno-unused-function -Wno-format-truncation "
" -g -I. -Iroot/Applications/POSIX/include -fdiagnostics-column-unit=byte ";
char commonCompileFlagsWithCStdLib[4096];
char cCompileFlags[4096] = "";
char cppCompileFlags[4096] = " -std=c++14 -Wno-pmf-conversions -Wno-invalid-offsetof -fno-rtti ";
char kernelCompileFlags[4096] = " -mno-red-zone -mcmodel=kernel -fno-omit-frame-pointer ";
char kernelCompileFlags[4096] = " -fno-omit-frame-pointer ";
char applicationLinkFlags[4096] = " -ffreestanding -nostdlib -lgcc -g -z max-page-size=0x1000 ";
char apiLinkFlags1[4096] = " -T util/linker/api64.ld -ffreestanding -nostdlib -g -z max-page-size=0x1000 -Wl,--start-group ";
char apiLinkFlags1[4096] = " -T util/linker/api64.ld -ffreestanding -nostdlib -g -z max-page-size=0x1000 -Wl,--start-group "; // TODO Don't hardcode the target.
char apiLinkFlags2[4096] = " -lgcc ";
char apiLinkFlags3[4096] = " -Wl,--end-group -Lroot/Applications/POSIX/lib ";
char kernelLinkFlags[4096] = " -ffreestanding -nostdlib -lgcc -g -z max-page-size=0x1000 ";
char kernelAssemblyFlags[4096] = " -felf64 -Fdwarf ";
char commonAssemblyFlags[4096] = " -Fdwarf ";
// Specific configuration options:
@ -159,6 +160,7 @@ bool useColoredOutput;
bool forEmulator, bootUseVBE, noImportPOSIX;
bool systemBuild;
bool convertFonts = true;
bool hasNativeToolchain;
EsINIState *fontLines;
EsINIState *generalOptions;
@ -166,6 +168,7 @@ EsINIState *generalOptions;
char *builtinModules;
volatile uint8_t encounteredErrors;
volatile uint8_t encounteredErrorsInKernelModules;
//////////////////////////////////
@ -183,6 +186,8 @@ const char *toolchainNasm = "/Applications/POSIX/bin/nasm";
const char *toolchainConvertSVG = "/Applications/POSIX/bin/render_svg";
const char *toolchainLinkerScripts = "/Applications/POSIX/lib";
const char *toolchainCRTObjects = "/Applications/POSIX/lib";
const char *toolchainCompilerObjects = "/Applications/POSIX/lib/gcc/x86_64-essence/" GCC_VERSION;
const char *target = "x86_64"; // TODO Don't hardcode the target.
char *executeEnvironment[3] = {
(char *) "PATH=/Applications/POSIX/bin",
@ -559,7 +564,10 @@ const char **kernelModules;
} while (0)
void BuildDesktop(Application *application) {
ExecuteForApp(application, toolchainNasm, "-felf64", "desktop/api.s", "-MD", "bin/api1.d", "-o", "bin/api1.o", "-Fdwarf");
char buffer[4096];
snprintf(buffer, sizeof(buffer), "arch/%s/api.s", target);
ExecuteForApp(application, toolchainNasm, buffer, "-MD", "bin/api1.d", "-o", "bin/api1.o", ArgString(commonAssemblyFlags));
ExecuteForApp(application, toolchainCXX, "-MD", "-c", "desktop/api.cpp", "-o", "bin/api2.o", ArgString(commonCompileFlags));
ExecuteForApp(application, toolchainCXX, "-MD", "-c", "desktop/posix.cpp", "-o", "bin/api3.o", ArgString(commonCompileFlags));
ExecuteForApp(application, toolchainCC, "-o", "bin/Desktop", "bin/crti.o", "bin/crtbegin.o",
@ -569,7 +577,6 @@ void BuildDesktop(Application *application) {
for (uintptr_t i = 0; i < arrlenu(fontLines); i++) {
if (fontLines[i].key[0] == '.' || 0 == strcmp(fontLines[i].key, "license")) {
char buffer[4096];
snprintf(buffer, sizeof(buffer), "res/Fonts/%s", fontLines[i].value);
ADD_BUNDLE_INPUT(strdup(buffer), fontLines[i].value, 16);
}
@ -596,7 +603,7 @@ void BuildDesktop(Application *application) {
ADD_BUNDLE_INPUT("res/elementary Icons.dat", "Icons.dat", 16);
ADD_BUNDLE_INPUT("res/elementary Icons License.txt", "Icons License.txt", 16);
ADD_BUNDLE_INPUT("res/Cursors.png", "Cursors.png", 16);
ADD_BUNDLE_INPUT("bin/Desktop.no_symbols", "$Executables/x86_64", 0x1000);
ADD_BUNDLE_INPUT("bin/Desktop.no_symbols", "$Executables/x86_64", 0x1000); // TODO Don't hardcode the target.
MakeBundle("root/" SYSTEM_FOLDER_NAME "/Desktop.esx", application->bundleInputFiles, arrlenu(application->bundleInputFiles), 0);
}
@ -615,7 +622,7 @@ void BuildApplication(Application *application) {
snprintf(symbolFile, sizeof(symbolFile), "bin/%s", application->name);
snprintf(strippedFile, sizeof(strippedFile), "bin/%s.no_symbols", application->name);
snprintf(linkerScript, sizeof(linkerScript), "%s/linker/userland64.ld", toolchainLinkerScripts);
snprintf(linkerScript, sizeof(linkerScript), "%s/linker/userland64.ld", toolchainLinkerScripts); // TODO Don't hardcode the target.
snprintf(crti, sizeof(crti), "%s/crti.o", toolchainCRTObjects);
snprintf(crtbegin, sizeof(crtbegin), "%s/crtbegin.o", toolchainCRTObjects);
snprintf(crtend, sizeof(crtend), "%s/crtend.o", toolchainCRTObjects);
@ -665,7 +672,7 @@ void BuildApplication(Application *application) {
ExecuteForApp(application, toolchainStrip, "-o", strippedFile, "--strip-all", symbolFile);
ADD_BUNDLE_INPUT(strippedFile, "$Executables/x86_64", 0x1000);
ADD_BUNDLE_INPUT(strippedFile, "$Executables/x86_64", 0x1000); // TODO Don't hardcode the target.
// Convert any files for the bundle marked with a '!'.
@ -716,6 +723,7 @@ void ParseApplicationManifest(const char *manifestPath) {
s.buffer = manifest;
const char *require = "";
bool needsNativeToolchain = false;
bool disabled = false;
Application application = {};
@ -742,6 +750,7 @@ void ParseApplicationManifest(const char *manifestPath) {
} else if (0 == strcmp(s.section, "general")) {
INI_READ_STRING_PTR(name, application.name);
else INI_READ_BOOL(disabled, disabled);
else INI_READ_BOOL(needs_native_toolchain, needsNativeToolchain);
else if (s.keyBytes && s.valueBytes) arrput(application.properties, s);
} else if (0 == strcmp(s.sectionClass, "handler")) {
if (!s.keyBytes) {
@ -773,7 +782,8 @@ void ParseApplicationManifest(const char *manifestPath) {
}
}
if (disabled || (require[0] && !FileExists(require))) {
if (disabled || (require[0] && !FileExists(require))
|| (needsNativeToolchain && !hasNativeToolchain)) {
return;
}
@ -913,6 +923,8 @@ void BuildModule(Application *application) {
MakeDirectory("root/" SYSTEM_FOLDER_NAME "/Modules");
MoveFile(output, target);
}
if (application->error) __sync_fetch_and_or(&encounteredErrorsInKernelModules, 1);
}
bool IsModuleEnabled(const char *name, size_t nameBytes) {
@ -983,7 +995,7 @@ void ParseKernelConfiguration() {
anyArchitecturesListed = true;
if (IsStringEqual(s.value, s.valueBytes, "x86_common")
|| IsStringEqual(s.value, s.valueBytes, "x86_64")) {
|| IsStringEqual(s.value, s.valueBytes, "x86_64")) { // TODO Don't hardcode the target.
foundMatchingArchitecture = true;
}
}
@ -1024,9 +1036,13 @@ void ParseKernelConfiguration() {
}
void LinkKernel() {
if (encounteredErrorsInKernelModules) {
return;
}
arrput(builtinModules, 0);
if (Execute(toolchainLD, "-r", "bin/kernel.o", "bin/kernel_x86_64.o", ArgString(builtinModules), "-o" "bin/kernel_all.o")) {
if (Execute(toolchainLD, "-r", "bin/kernel.o", "bin/kernel_arch.o", ArgString(builtinModules), "-o" "bin/kernel_all.o")) {
return;
}
@ -1062,15 +1078,22 @@ void LinkKernel() {
}
}
Execute(toolchainCXX, "-T", "util/linker/kernel64.ld", "-o", "bin/Kernel", "bin/kernel_symbols.o", "bin/kernel_all.o", "-mno-red-zone", ArgString(kernelLinkFlags));
if (Execute(toolchainCXX, "-o", "bin/Kernel", "bin/kernel_symbols.o", "bin/kernel_all.o", ArgString(kernelLinkFlags))) {
return;
}
Execute(toolchainStrip, "-o", "bin/Kernel.esx", "--strip-all", "bin/Kernel");
CopyFile("bin/Kernel.esx", "root/" SYSTEM_FOLDER_NAME "/Kernel.esx", false);
}
void BuildKernel(Application *application) {
ExecuteForApp(application, toolchainNasm, "-MD", "bin/kernel2.d", "kernel/x86_64.s", "-o", "bin/kernel_x86_64.o", ArgString(kernelAssemblyFlags));
char buffer[4096];
snprintf(buffer, sizeof(buffer), "arch/%s/kernel.s", target);
ExecuteForApp(application, toolchainNasm, "-MD", "bin/kernel2.d", buffer, "-o", "bin/kernel_arch.o", ArgString(commonAssemblyFlags));
snprintf(buffer, sizeof(buffer), "-DARCH_KERNEL_SOURCE=<arch/%s/kernel.cpp>", target);
ExecuteForApp(application, toolchainCXX, "-MD", "-c", "kernel/main.cpp", "-o", "bin/kernel.o",
ArgString(kernelCompileFlags), ArgString(cppCompileFlags), ArgString(commonCompileFlags));
ArgString(kernelCompileFlags), ArgString(cppCompileFlags), ArgString(commonCompileFlags), buffer);
if (application->error) __sync_fetch_and_or(&encounteredErrorsInKernelModules, 1);
}
void BuildBootloader(Application *application) {
@ -1298,6 +1321,8 @@ int main(int argc, char **argv) {
toolchainLinkerScripts = s.value;
} else if (0 == strcmp(s.key, "crt_objects")) {
toolchainCRTObjects = s.value;
} else if (0 == strcmp(s.key, "compiler_objects")) {
toolchainCompilerObjects = s.value;
}
} else if (0 == strcmp(s.sectionClass, "application")) {
if (0 == strcmp(s.key, "manifest")) {
@ -1323,7 +1348,7 @@ int main(int argc, char **argv) {
} else if (0 == strcmp(s.key, "Flag._ALWAYS_USE_VBE")) {
bootUseVBE = !!atoi(s.value);
} else if (0 == strcmp(s.key, "Flag.COM_OUTPUT") && atoi(s.value)) {
strcat(kernelAssemblyFlags, " -DCOM_OUTPUT ");
strcat(commonAssemblyFlags, " -DCOM_OUTPUT ");
} else if (0 == strcmp(s.key, "BuildCore.NoImportPOSIX")) {
noImportPOSIX = !!atoi(s.value);
} else if (0 == memcmp(s.key, "General.", 8)) {
@ -1365,6 +1390,35 @@ int main(int argc, char **argv) {
#endif
} else if (0 == strcmp(s.key, "without_kernel")) {
withoutKernel = atoi(s.value);
} else if (0 == strcmp(s.key, "target")) {
target = s.value;
char buffer[4096];
snprintf(buffer, sizeof(buffer), "arch/%s/config.ini", target);
EsINIState s2 = {};
s2.buffer = (char *) LoadFile(buffer, &s2.bytes);
if (!s2.buffer) {
Log("Error: could not load target configuration file '%s'.\n", buffer);
return 1;
}
while (EsINIParse(&s2)) {
EsINIZeroTerminate(&s2);
if (0 == strcmp(s2.key, "additional_kernel_compile_flags")) {
strcat(kernelCompileFlags, s2.value);
} else if (0 == strcmp(s2.key, "additional_kernel_link_flags")) {
strcat(kernelLinkFlags, s2.value);
} else if (0 == strcmp(s2.key, "additional_common_assembly_flags")) {
strcat(commonAssemblyFlags, s2.value);
} else if (0 == strcmp(s2.key, "additional_common_compile_flags")) {
strcat(commonCompileFlags, s2.value);
} else if (0 == strcmp(s2.key, "has_native_toolchain")) {
hasNativeToolchain = atoi(s2.value);
}
}
}
} else if (0 == strcmp(s.section, "install")) {
if (0 == strcmp(s.key, "file")) {
@ -1463,8 +1517,18 @@ int main(int argc, char **argv) {
if (!skipCompile) {
if (systemBuild) {
Execute(toolchainNasm, "-felf64", "desktop/crti.s", "-o", "bin/crti.o", "-Fdwarf");
Execute(toolchainNasm, "-felf64", "desktop/crtn.s", "-o", "bin/crtn.o", "-Fdwarf");
char buffer[4096];
snprintf(buffer, sizeof(buffer), "arch/%s/crti.s", target);
Execute(toolchainNasm, buffer, "-o", "bin/crti.o", ArgString(commonAssemblyFlags));
snprintf(buffer, sizeof(buffer), "arch/%s/crtn.s", target);
Execute(toolchainNasm, buffer, "-o", "bin/crtn.o", ArgString(commonAssemblyFlags));
snprintf(buffer, sizeof(buffer), "%s/crtbegin.o", toolchainCompilerObjects);
CopyFile(buffer, "bin/crtbegin.o", false);
snprintf(buffer, sizeof(buffer), "%s/crtend.o", toolchainCompilerObjects);
CopyFile(buffer, "bin/crtend.o", false);
Execute(toolchainCC, "-c", "desktop/crt1.c", "-o", "bin/crt1.o", ArgString(cCompileFlags), ArgString(commonCompileFlags));
Execute(toolchainCC, "-c", "desktop/crtglue.c", "-o" "bin/crtglue.o", ArgString(cCompileFlags), ArgString(commonCompileFlags));
CopyFile("bin/crti.o", "root/Applications/POSIX/lib/crti.o", false);
@ -1473,14 +1537,15 @@ int main(int argc, char **argv) {
CopyFile("bin/crtn.o", "root/Applications/POSIX/lib/crtn.o", false);
CopyFile("bin/crt1.o", "root/Applications/POSIX/lib/crt1.o", false);
CopyFile("bin/crtglue.o", "root/Applications/POSIX/lib/crtglue.o", false);
CopyFile("bin/crt1.o", "cross/lib/gcc/x86_64-essence/" GCC_VERSION "/crt1.o", true);
CopyFile("bin/crt1.o", "cross/lib/gcc/x86_64-essence/" GCC_VERSION "/crt1.o", true); // TODO Don't hardcode the target.
CopyFile("bin/crtglue.o", "cross/lib/gcc/x86_64-essence/" GCC_VERSION "/crtglue.o", true);
CopyFile("util/linker/userland64.ld", "root/Applications/POSIX/lib/linker/userland64.ld", false);
char linkerScript[256];
snprintf(linkerScript, sizeof(linkerScript), "%s/linker/userland64.ld", toolchainLinkerScripts);
Execute(toolchainCC, "util/build_core.c", "-o", "root/Applications/POSIX/bin/build_core", "-g",
"-nostdlib", "bin/crti.o", "bin/crtbegin.o", "bin/crtend.o", "bin/crtn.o", "-T", linkerScript);
if (hasNativeToolchain) {
snprintf(buffer, sizeof(buffer), "%s/linker/userland64.ld", toolchainLinkerScripts); // TODO Don't hardcode the target.
Execute(toolchainCC, "util/build_core.c", "-o", "root/Applications/POSIX/bin/build_core", "-g",
"-nostdlib", "bin/crti.o", "bin/crtbegin.o", "bin/crtend.o", "bin/crtn.o", "-T", buffer);
}
}
#define ADD_DEPENDENCY_FILE(application, _path, _name) \

View File

@ -586,6 +586,14 @@ void OutputC(Entry *root) {
free(buffer);
}
for (int i = 0; i < arrlen(root->children); i++) {
Entry *entry = root->children + i;
if (entry->type == ENTRY_STRUCT) {
FilePrintFormat(output, "struct %s;\n", entry->name);
}
}
for (int i = 0; i < arrlen(root->children); i++) {
Entry *entry = root->children + i;

View File

@ -3,7 +3,7 @@
ECHO 101 TEXT bin\embed.dat > bin\embed.rc
rc /nologo bin\embed.rc
SET CFLAGS=%2 -g -fno-exceptions -Ibin -I. -DARCH_X86_64 -DARCH_X86_COMMON -DARCH_64 -DNO_API_TABLE -DUSE_PLATFORM_HEAP -DUSE_HARFBUZZ -DUSE_FREETYPE -DUSE_STB_SPRINTF -Wall -Wextra -Wno-empty-body -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-unknown-attributes -Wno-c99-designator -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function
SET CFLAGS=%2 -g -fno-exceptions -Ibin -I. -DES_ARCH_X86_64 -DES_BITS_64 -DNO_API_TABLE -DUSE_PLATFORM_HEAP -DUSE_HARFBUZZ -DUSE_FREETYPE -DUSE_STB_SPRINTF -Wall -Wextra -Wno-empty-body -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-unknown-attributes -Wno-c99-designator -Wno-missing-field-initializers -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function
SET LINKFLAGS=/DEBUG /NOLOGO /NODEFAULTLIB /IGNORE:4217 /subsystem:windows /OPT:REF /OPT:ICF /STACK:0x100000,0x100000
SET APPFLAGS=-D_start=_ApplicationStart -DES_FORWARD -DES_EXTERN_FORWARD=ES_EXTERN_C -DES_DIRECT_API