feat: userspace overhaul, Intel GPU driver, and more
This commit is contained in:
@@ -463,6 +463,7 @@ extern "C" void _start() {
|
||||
newCfg.ipAddress = offer.offeredIp;
|
||||
newCfg.subnetMask = offer.subnetMask;
|
||||
newCfg.gateway = offer.router;
|
||||
newCfg.dnsServer = offer.dns;
|
||||
zenith::set_netcfg(&newCfg);
|
||||
|
||||
// 9. Print results
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Makefile for fetch (HTTP/HTTPS client) on ZenithOS
|
||||
# Copyright (c) 2025-2026 Daniel Hammer
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
.SUFFIXES:
|
||||
|
||||
# ---- Toolchain ----
|
||||
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
else
|
||||
CXX := g++
|
||||
endif
|
||||
|
||||
# ---- Paths ----
|
||||
|
||||
BEARSSL := ../../lib/bearssl
|
||||
LIBC_LIB := ../../lib/libc
|
||||
LIBC_INC := ../../include/libc
|
||||
PROG_INC := ../../include
|
||||
LINK_LD := ../../link.ld
|
||||
BINDIR := ../../bin
|
||||
OBJDIR := obj
|
||||
|
||||
# ---- Compiler flags ----
|
||||
|
||||
CXXFLAGS := \
|
||||
-std=gnu++20 \
|
||||
-g -O2 -pipe \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-nostdinc \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fno-PIC \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=small \
|
||||
-I $(PROG_INC) \
|
||||
-isystem $(LIBC_INC) \
|
||||
-I $(BEARSSL)/inc \
|
||||
-isystem ../../../kernel/freestnd-c-hdrs/x86_64/include \
|
||||
-isystem ../../../kernel/freestnd-cxx-hdrs/x86_64/include
|
||||
|
||||
# ---- Linker flags ----
|
||||
|
||||
LDFLAGS := \
|
||||
-nostdlib \
|
||||
-static \
|
||||
-Wl,--build-id=none \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-m,elf_x86_64 \
|
||||
-z max-page-size=0x1000 \
|
||||
-T $(LINK_LD)
|
||||
|
||||
# ---- Libraries ----
|
||||
|
||||
LIBS := $(BEARSSL)/libbearssl.a $(LIBC_LIB)/liblibc.a
|
||||
|
||||
# ---- Target ----
|
||||
|
||||
TARGET := $(BINDIR)/os/fetch.elf
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJDIR)/main.o $(LIBS) $(LINK_LD) Makefile
|
||||
mkdir -p $(BINDIR)/os
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJDIR)/main.o $(LIBS) -o $@
|
||||
|
||||
$(OBJDIR)/main.o: main.cpp Makefile
|
||||
mkdir -p $(OBJDIR)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR) $(TARGET)
|
||||
+705
-219
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* main.cpp
|
||||
* fontscale - Change terminal font scale
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#include <zenith/syscall.h>
|
||||
#include <zenith/string.h>
|
||||
|
||||
static int atoi(const char* s) {
|
||||
int n = 0;
|
||||
while (*s >= '0' && *s <= '9') {
|
||||
n = n * 10 + (*s - '0');
|
||||
s++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
static void print_int(int n) {
|
||||
char buf[16];
|
||||
int i = 0;
|
||||
if (n == 0) {
|
||||
zenith::putchar('0');
|
||||
return;
|
||||
}
|
||||
while (n > 0 && i < 15) {
|
||||
buf[i++] = '0' + (n % 10);
|
||||
n /= 10;
|
||||
}
|
||||
while (i > 0) zenith::putchar(buf[--i]);
|
||||
}
|
||||
|
||||
extern "C" void _start() {
|
||||
char args[128];
|
||||
int len = zenith::getargs(args, sizeof(args));
|
||||
|
||||
if (len <= 0 || args[0] == '\0') {
|
||||
// No args: show current scale
|
||||
int sx, sy;
|
||||
zenith::get_termscale(&sx, &sy);
|
||||
int cols, rows;
|
||||
zenith::termsize(&cols, &rows);
|
||||
|
||||
zenith::print("Font scale: ");
|
||||
print_int(sx);
|
||||
zenith::print("x");
|
||||
print_int(sy);
|
||||
zenith::print(" Terminal: ");
|
||||
print_int(cols);
|
||||
zenith::print("x");
|
||||
print_int(rows);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(0);
|
||||
}
|
||||
|
||||
// Parse arguments
|
||||
const char* p = zenith::skip_spaces(args);
|
||||
int scale_x = atoi(p);
|
||||
|
||||
// Skip past first number to find optional second
|
||||
while (*p >= '0' && *p <= '9') p++;
|
||||
p = zenith::skip_spaces(p);
|
||||
int scale_y = (*p >= '1' && *p <= '8') ? atoi(p) : scale_x;
|
||||
|
||||
if (scale_x < 1 || scale_x > 8 || scale_y < 1 || scale_y > 8) {
|
||||
zenith::print("fontscale: scale must be 1-8\n");
|
||||
zenith::exit(1);
|
||||
}
|
||||
|
||||
zenith::termscale(scale_x, scale_y);
|
||||
|
||||
// Clear and show result
|
||||
zenith::print("\033[2J\033[H");
|
||||
|
||||
int cols, rows;
|
||||
zenith::termsize(&cols, &rows);
|
||||
zenith::print("Font scale set to ");
|
||||
print_int(scale_x);
|
||||
zenith::print("x");
|
||||
print_int(scale_y);
|
||||
zenith::print(" (");
|
||||
print_int(cols);
|
||||
zenith::print("x");
|
||||
print_int(rows);
|
||||
zenith::print(")\n");
|
||||
|
||||
zenith::exit(0);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* main.cpp
|
||||
* HTTP/1.0 server for ZenithOS
|
||||
* Usage: run httpd.elf [port] (default: 80)
|
||||
* Usage: httpd [port] (default: 80)
|
||||
* Serves a built-in index page and files from the VFS
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
@@ -81,6 +81,9 @@ extern "C" void _start() {
|
||||
zenith::print(" Gateway: ");
|
||||
print_ip(cfg.gateway);
|
||||
zenith::putchar('\n');
|
||||
zenith::print(" DNS Server: ");
|
||||
print_ip(cfg.dnsServer);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(0);
|
||||
}
|
||||
|
||||
|
||||
+15
-12
@@ -836,23 +836,26 @@ extern "C" void _start() {
|
||||
const char* arg = skip_spaces(argbuf);
|
||||
|
||||
if (*arg == '\0') {
|
||||
zenith::print("Usage: irc.elf <server_ip> <port> <nickname> [#channel]\n");
|
||||
zenith::print("Example: run irc.elf 10.0.68.1 6667 ZenithUser #general\n");
|
||||
zenith::print("Usage: irc <server> <port> <nickname> [#channel]\n");
|
||||
zenith::print("Example: irc irc.libera.chat 6667 ZenithUser #general\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// Parse IP
|
||||
char ipStr[32];
|
||||
// Parse host (IP or hostname)
|
||||
char hostStr[128];
|
||||
int i = 0;
|
||||
while (arg[i] && arg[i] != ' ' && i < 31) { ipStr[i] = arg[i]; i++; }
|
||||
ipStr[i] = '\0';
|
||||
while (arg[i] && arg[i] != ' ' && i < 127) { hostStr[i] = arg[i]; i++; }
|
||||
hostStr[i] = '\0';
|
||||
arg = skip_spaces(arg + i);
|
||||
|
||||
if (!parse_ip(ipStr, &irc.serverIp)) {
|
||||
zenith::print("Invalid IP address: ");
|
||||
zenith::print(ipStr);
|
||||
zenith::putchar('\n');
|
||||
return;
|
||||
if (!parse_ip(hostStr, &irc.serverIp)) {
|
||||
irc.serverIp = zenith::resolve(hostStr);
|
||||
if (irc.serverIp == 0) {
|
||||
zenith::print("Could not resolve: ");
|
||||
zenith::print(hostStr);
|
||||
zenith::putchar('\n');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Parse port
|
||||
@@ -910,7 +913,7 @@ extern "C" void _start() {
|
||||
|
||||
// Initial draw
|
||||
msg_add("\033[1m*** ZenithOS IRC Client\033[0m");
|
||||
msg_add_fmt("*** Connecting to %s:%d as %s...", ipStr, (int)irc.serverPort, irc.nick);
|
||||
msg_add_fmt("*** Connecting to %s:%d as %s...", hostStr, (int)irc.serverPort, irc.nick);
|
||||
ui_render();
|
||||
|
||||
// Create socket and connect
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* main.cpp
|
||||
* DNS lookup utility for ZenithOS
|
||||
* Usage: nslookup <hostname>
|
||||
* Copyright (c) 2025-2026 Daniel Hammer
|
||||
*/
|
||||
|
||||
#include <zenith/syscall.h>
|
||||
#include <zenith/string.h>
|
||||
|
||||
using zenith::skip_spaces;
|
||||
|
||||
static void print_ip(uint32_t ip) {
|
||||
auto print_int = [](uint32_t n) {
|
||||
if (n == 0) { zenith::putchar('0'); return; }
|
||||
char buf[4];
|
||||
int i = 0;
|
||||
while (n > 0) { buf[i++] = '0' + (n % 10); n /= 10; }
|
||||
for (int j = i - 1; j >= 0; j--) zenith::putchar(buf[j]);
|
||||
};
|
||||
|
||||
print_int(ip & 0xFF);
|
||||
zenith::putchar('.');
|
||||
print_int((ip >> 8) & 0xFF);
|
||||
zenith::putchar('.');
|
||||
print_int((ip >> 16) & 0xFF);
|
||||
zenith::putchar('.');
|
||||
print_int((ip >> 24) & 0xFF);
|
||||
}
|
||||
|
||||
extern "C" void _start() {
|
||||
char args[256];
|
||||
int len = zenith::getargs(args, sizeof(args));
|
||||
|
||||
const char* hostname = skip_spaces(args);
|
||||
if (len <= 0 || hostname[0] == '\0') {
|
||||
zenith::print("Usage: nslookup <hostname>\n");
|
||||
zenith::print("Example: nslookup example.com\n");
|
||||
zenith::exit(0);
|
||||
}
|
||||
|
||||
// Show DNS server
|
||||
Zenith::NetCfg cfg;
|
||||
zenith::get_netcfg(&cfg);
|
||||
|
||||
zenith::print("Server: ");
|
||||
print_ip(cfg.dnsServer);
|
||||
zenith::putchar('\n');
|
||||
|
||||
zenith::print("Querying ");
|
||||
zenith::print(hostname);
|
||||
zenith::print("...\n");
|
||||
|
||||
uint64_t start = zenith::get_milliseconds();
|
||||
uint32_t ip = zenith::resolve(hostname);
|
||||
uint64_t elapsed = zenith::get_milliseconds() - start;
|
||||
|
||||
if (ip == 0) {
|
||||
zenith::print("Error: could not resolve ");
|
||||
zenith::print(hostname);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(1);
|
||||
}
|
||||
|
||||
zenith::print("Name: ");
|
||||
zenith::print(hostname);
|
||||
zenith::putchar('\n');
|
||||
zenith::print("Address: ");
|
||||
print_ip(ip);
|
||||
zenith::putchar('\n');
|
||||
|
||||
// Print timing
|
||||
zenith::print("Time: ");
|
||||
char buf[20];
|
||||
int i = 0;
|
||||
uint64_t ms = elapsed;
|
||||
if (ms == 0) { buf[i++] = '0'; }
|
||||
else { while (ms > 0) { buf[i++] = '0' + (ms % 10); ms /= 10; } }
|
||||
for (int j = i - 1; j >= 0; j--) zenith::putchar(buf[j]);
|
||||
zenith::print(" ms\n");
|
||||
|
||||
zenith::exit(0);
|
||||
}
|
||||
@@ -65,21 +65,26 @@ extern "C" void _start() {
|
||||
int len = zenith::getargs(args, sizeof(args));
|
||||
|
||||
if (len <= 0 || args[0] == '\0') {
|
||||
zenith::print("Usage: ping <ip address>\n");
|
||||
zenith::print("Usage: ping <host>\n");
|
||||
zenith::exit(1);
|
||||
}
|
||||
|
||||
uint32_t ip;
|
||||
if (!parse_ip(args, &ip)) {
|
||||
zenith::print("Invalid IP address: ");
|
||||
zenith::print(args);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(1);
|
||||
ip = zenith::resolve(args);
|
||||
if (ip == 0) {
|
||||
zenith::print("Could not resolve: ");
|
||||
zenith::print(args);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
zenith::print("PING ");
|
||||
zenith::print(args);
|
||||
zenith::print(" (");
|
||||
print_ip(ip);
|
||||
zenith::putchar('\n');
|
||||
zenith::print(")\n");
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int32_t rtt = zenith::ping(ip, 3000);
|
||||
|
||||
@@ -118,11 +118,13 @@ static void cmd_help() {
|
||||
zenith::print(" date Show current date and time\n");
|
||||
zenith::print(" uptime Show uptime\n");
|
||||
zenith::print(" clear Clear the screen\n");
|
||||
zenith::print(" fontscale [n] Set terminal font scale (1-8)\n");
|
||||
zenith::print(" reset Reboot the system\n");
|
||||
zenith::print(" shutdown Shut down the system\n");
|
||||
zenith::print("\n");
|
||||
zenith::print("Network commands:\n");
|
||||
zenith::print(" ping <ip> Send ICMP echo requests\n");
|
||||
zenith::print(" nslookup DNS lookup\n");
|
||||
zenith::print(" ifconfig Show/set network configuration\n");
|
||||
zenith::print(" tcpconnect Connect to a TCP server\n");
|
||||
zenith::print(" irc IRC client\n");
|
||||
|
||||
@@ -81,25 +81,28 @@ extern "C" void _start() {
|
||||
int len = zenith::getargs(args, sizeof(args));
|
||||
|
||||
if (len <= 0 || args[0] == '\0') {
|
||||
zenith::print("Usage: tcpconnect <ip> <port>\n");
|
||||
zenith::print("Usage: tcpconnect <host> <port>\n");
|
||||
zenith::exit(1);
|
||||
}
|
||||
|
||||
// Parse IP address (up to first space)
|
||||
char ipStr[32];
|
||||
// Parse host (IP or hostname)
|
||||
char hostStr[128];
|
||||
int i = 0;
|
||||
while (args[i] && args[i] != ' ' && i < 31) {
|
||||
ipStr[i] = args[i];
|
||||
while (args[i] && args[i] != ' ' && i < 127) {
|
||||
hostStr[i] = args[i];
|
||||
i++;
|
||||
}
|
||||
ipStr[i] = '\0';
|
||||
hostStr[i] = '\0';
|
||||
|
||||
uint32_t ip;
|
||||
if (!parse_ip(ipStr, &ip)) {
|
||||
zenith::print("Invalid IP address: ");
|
||||
zenith::print(ipStr);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(1);
|
||||
if (!parse_ip(hostStr, &ip)) {
|
||||
ip = zenith::resolve(hostStr);
|
||||
if (ip == 0) {
|
||||
zenith::print("Could not resolve: ");
|
||||
zenith::print(hostStr);
|
||||
zenith::putchar('\n');
|
||||
zenith::exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse port
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Makefile for wiki (Wikipedia client) on ZenithOS
|
||||
# Copyright (c) 2025-2026 Daniel Hammer
|
||||
|
||||
MAKEFLAGS += -rR
|
||||
.SUFFIXES:
|
||||
|
||||
# ---- Toolchain ----
|
||||
|
||||
TOOLCHAIN_PREFIX := $(shell cd ../../.. && pwd)/toolchain/local/bin/x86_64-elf-
|
||||
ifneq ($(wildcard $(TOOLCHAIN_PREFIX)gcc),)
|
||||
CXX := $(TOOLCHAIN_PREFIX)g++
|
||||
else
|
||||
CXX := g++
|
||||
endif
|
||||
|
||||
# ---- Paths ----
|
||||
|
||||
BEARSSL := ../../lib/bearssl
|
||||
LIBC_LIB := ../../lib/libc
|
||||
LIBC_INC := ../../include/libc
|
||||
PROG_INC := ../../include
|
||||
LINK_LD := ../../link.ld
|
||||
BINDIR := ../../bin
|
||||
OBJDIR := obj
|
||||
|
||||
# ---- Compiler flags ----
|
||||
|
||||
CXXFLAGS := \
|
||||
-std=gnu++20 \
|
||||
-g -O2 -pipe \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wno-unused-parameter \
|
||||
-nostdinc \
|
||||
-ffreestanding \
|
||||
-fno-stack-protector \
|
||||
-fno-stack-check \
|
||||
-fno-PIC \
|
||||
-fno-rtti \
|
||||
-fno-exceptions \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
-m64 \
|
||||
-march=x86-64 \
|
||||
-mno-80387 \
|
||||
-mno-mmx \
|
||||
-mno-sse \
|
||||
-mno-sse2 \
|
||||
-mno-red-zone \
|
||||
-mcmodel=small \
|
||||
-I $(PROG_INC) \
|
||||
-isystem $(LIBC_INC) \
|
||||
-I $(BEARSSL)/inc \
|
||||
-isystem ../../../kernel/freestnd-c-hdrs/x86_64/include \
|
||||
-isystem ../../../kernel/freestnd-cxx-hdrs/x86_64/include
|
||||
|
||||
# ---- Linker flags ----
|
||||
|
||||
LDFLAGS := \
|
||||
-nostdlib \
|
||||
-static \
|
||||
-Wl,--build-id=none \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-m,elf_x86_64 \
|
||||
-z max-page-size=0x1000 \
|
||||
-T $(LINK_LD)
|
||||
|
||||
# ---- Libraries ----
|
||||
|
||||
LIBS := $(BEARSSL)/libbearssl.a $(LIBC_LIB)/liblibc.a
|
||||
|
||||
# ---- Target ----
|
||||
|
||||
TARGET := $(BINDIR)/os/wiki.elf
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJDIR)/main.o $(LIBS) $(LINK_LD) Makefile
|
||||
mkdir -p $(BINDIR)/os
|
||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJDIR)/main.o $(LIBS) -o $@
|
||||
|
||||
$(OBJDIR)/main.o: main.cpp Makefile
|
||||
mkdir -p $(OBJDIR)
|
||||
$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
rm -rf $(OBJDIR) $(TARGET)
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user