fix(baremetal,net): fix bare-metal boot freezes and implement real internet stack
- Zero user PML4 and allocated page tables in VMM to prevent dirty RAM crash on real hardware - Probe UART existence and add timeout to prevent infinite freeze on motherboards without COM1 - Clamp SMP AP boot to MAX_CPUS to prevent GDT/TSS corruption on multi-core CPUs - Add kernel early framebuffer console (FbConsole) with 8x16 font for direct HDMI/DP screen output - Configure Limine resolution and dynamic 4K draw buffers in gui_server to fix 1080p black screen - Implement RFC 793 TCP pseudo-header checksum and full TCP 3-way handshake - Implement DHCP client (UDP 67/68) and DNS client (UDP 53) - Add dns, dhcp commands to shell and update web browser with live URL loading
This commit is contained in:
+44
-21
@@ -317,32 +317,51 @@ static void cmd_modules() {
|
||||
}
|
||||
|
||||
static void cmd_curl(const char *target) {
|
||||
char body[1024];
|
||||
memset(body, 0, sizeof(body));
|
||||
uint32_t ip = g_net_cfg.gateway;
|
||||
uint16_t port = 80;
|
||||
const char *path = "/";
|
||||
|
||||
if (target && *target) {
|
||||
if (strncmp(target, "http://", 7) == 0) target += 7;
|
||||
char host[64] = {0};
|
||||
int hi = 0;
|
||||
while (*target && *target != '/' && *target != ':' && hi < 63) {
|
||||
host[hi++] = *target++;
|
||||
}
|
||||
if (*host) ip = parse_ip(host);
|
||||
if (*target == '/') path = target;
|
||||
if (!target || !*target) {
|
||||
puts("Usage: curl <http://domain-or-ip/path>");
|
||||
return;
|
||||
}
|
||||
char body[2048];
|
||||
memset(body, 0, sizeof(body));
|
||||
|
||||
char ip_str[32];
|
||||
format_ip(ip, ip_str);
|
||||
printf("[curl] Connecting to %s:%u (Path: %s) via TCP/IPv4...\n", ip_str, port, path);
|
||||
int status = net_http_get(ip, port, path, body, sizeof(body));
|
||||
printf("[curl] Fetching '%s' over TCP/IPv4...\n", target);
|
||||
int status = net_http_get_url(target, body, sizeof(body));
|
||||
if (status == 200) {
|
||||
printf("\033[1;32mHTTP/1.1 200 OK\033[0m (TCP Connected)\n\n");
|
||||
printf("\033[1;32mHTTP/1.1 200 OK\033[0m (Bytes read: %d)\n\n", (int)strlen(body));
|
||||
puts(body);
|
||||
} else {
|
||||
printf("[curl] Connection to %s:%u failed.\n", ip_str, port);
|
||||
printf("[curl] HTTP request returned status %d\n", status);
|
||||
if (*body) puts(body);
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_dns(const char *domain) {
|
||||
if (!domain || !*domain) {
|
||||
puts("Usage: dns <hostname> (e.g. dns httpbin.org)");
|
||||
return;
|
||||
}
|
||||
printf("[dns] Querying DNS nameserver for '%s' (UDP port 53)...\n", domain);
|
||||
uint32_t ip = 0;
|
||||
if (net_dns_resolve(domain, &ip) == 0) {
|
||||
char ip_str[32];
|
||||
format_ip(ip, ip_str);
|
||||
printf(" \033[1;32m%s\033[0m has address \033[1;36m%s\033[0m\n", domain, ip_str);
|
||||
} else {
|
||||
printf("[dns] Host '%s' not found (NXDOMAIN / timeout)\n", domain);
|
||||
}
|
||||
}
|
||||
|
||||
static void cmd_dhcp() {
|
||||
puts("[dhcp] Broadcasting DHCPDISCOVER (UDP 68 -> 67)...");
|
||||
if (net_dhcp_discover() == 0) {
|
||||
char ip[32], gw[32], dns[32];
|
||||
format_ip(g_net_cfg.ip, ip);
|
||||
format_ip(g_net_cfg.gateway, gw);
|
||||
format_ip(g_net_cfg.dns_server, dns);
|
||||
printf("\033[1;32m[dhcp] Lease acquired successfully!\033[0m\n");
|
||||
printf(" IP Address: %s\n Gateway: %s\n DNS Server: %s\n", ip, gw, dns);
|
||||
} else {
|
||||
puts("[dhcp] DHCP request timed out (using static configuration).");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -839,6 +858,10 @@ static void handle_command(char *cmd) {
|
||||
cmd_curl(cmd + 5);
|
||||
} else if (strncmp(cmd, "fetch ", 6) == 0) {
|
||||
cmd_curl(cmd + 6);
|
||||
} else if (strncmp(cmd, "dns ", 4) == 0) {
|
||||
cmd_dns(cmd + 4);
|
||||
} else if (strcmp(cmd, "dhcp") == 0) {
|
||||
cmd_dhcp();
|
||||
} else if (strcmp(cmd, "fastfetch") == 0 || strcmp(cmd, "neofetch") == 0) {
|
||||
print_fastfetch();
|
||||
} else if (strcmp(cmd, "clear") == 0) {
|
||||
|
||||
Reference in New Issue
Block a user