fix: Cross-compilation & build tools script, IoPort fix

This commit is contained in:
2026-02-17 11:15:43 +01:00
parent e8e89b27a7
commit e2f059bf90
5 changed files with 199 additions and 14 deletions
+13 -3
View File
@@ -17,17 +17,27 @@ ifeq ($(filter $(ARCH),aarch64 loongarch64 riscv64 x86_64),)
$(error Architecture $(ARCH) not supported)
endif
# Auto-detect x86_64-elf cross compiler from toolchain/local/.
ifeq ($(ARCH),x86_64)
TOOLCHAIN_PREFIX := $(shell cd .. && pwd)/toolchain/local/bin/x86_64-elf-
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
CC := $(TOOLCHAIN_PREFIX)gcc
CXX := $(TOOLCHAIN_PREFIX)g++
AR := $(TOOLCHAIN_PREFIX)ar
endif
endif
# User controllable C compiler command.
CC := cc
CC ?= cc
# User controllable C++ compiler command.
CXX := c++
CXX ?= c++
# User controllable Objective C compiler command.
OBJC := g++
# User controllable archiver command.
AR := ar
AR ?= ar
# User controllable C flags.
CFLAGS := -g -O2 -pipe
+16 -11
View File
@@ -23,20 +23,25 @@ namespace Io {
asm ("outl %0, %1" : : "a"(value), "Nd"(port) : "memory");
}
/* TODO fix */
// inline uint8_t In8(uint16_t port) {
// asm ("inb %0" : : "Nd"(port) : "memory");
// }
inline uint8_t In8(uint16_t port) {
uint8_t result;
asm volatile("inb %1, %0" : "=a"(result) : "Nd"(port) : "memory");
return result;
}
// inline uint16_t In16(uint16_t port) {
// asm ("inw %0" : : "Nd"(port) : "memory");
// }
inline uint16_t In16(uint16_t port) {
uint16_t result;
asm volatile("inw %1, %0" : "=a"(result) : "Nd"(port) : "memory");
return result;
}
// inline uint32_t In32(uint16_t port) {
// asm ("inl %0" : : "Nd"(port) : "memory");
// }
inline uint32_t In32(uint16_t port) {
uint32_t result;
asm volatile("inl %1, %0" : "=a"(result) : "Nd"(port) : "memory");
return result;
}
inline void IoPortWait() {
Out8(0x80, 0);
Out8(0, 0x80);
}
};