feat(phase-6): implement TCP/IP network stack, PCI bus driver & native AiraLang VM
- Implement PCI Bus Controller (drivers/pci.c, include/airlys/pci.h) with Type 1 config mechanism (0xCF8/0xCFC) - Implement IPv4 packet framing, checksum calculation, and protocol routing (net/ipv4.c) - Implement ICMP Echo Request/Reply ping engine (net/icmp.c) - Implement UDP transmission and reception (net/udp.c) - Implement TCP SYN handshake connection initiator (net/tcp.c) - Implement DHCPDISCOVER client broadcasting (net/dhcp.c) - Implement native embedded AiraLang bytecode VM & runtime v1.4.0 (kernel/airalang.c, include/airlys/airalang.h) - Add /home/user/demo.aira sample script to RamFS initramfs - Wire commands to airlys-sh shell: pci, ping, dhcp, airalang, airarun - Zero-warning freestanding verification with clang & ld.lld (bin/airlys.elf: 814 KB) Co-Authored-By: Er. Adam Eehan <adameehanairagroup@gmail.com> Co-Authored-By: Sovereign AI Aira 3 Ultra (Engine v3.6)
This commit is contained in:
committed
1 parent
aa1c82f81e
commit
b083b7ff6e
17 files changed
+1146
-27
No files matched your search
@@ -0,0 +1,39 @@
|
||||
#ifndef AIRLYS_AIRALANG_H
|
||||
#define AIRLYS_AIRALANG_H
|
||||
|
||||
/*
|
||||
* Airlys Operating System Kernel - Native Embedded AiraLang Engine (Phase 6)
|
||||
* Language Architect: Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
|
||||
* Co-Pilot: Sovereign AI Aira 3 Ultra (Engine v3.6)
|
||||
*/
|
||||
|
||||
#include <airlys/types.h>
|
||||
|
||||
#define AIRALANG_VERSION "v1.4.0 (Kernel Native Edition)"
|
||||
#define MAX_AIRA_VARS 32
|
||||
#define MAX_VAR_NAME 32
|
||||
#define MAX_VAR_STR 128
|
||||
|
||||
typedef enum {
|
||||
VAL_NULL = 0,
|
||||
VAL_NUM,
|
||||
VAL_STR,
|
||||
VAL_BOOL
|
||||
} val_type_t;
|
||||
|
||||
typedef struct {
|
||||
char name[MAX_VAR_NAME];
|
||||
val_type_t type;
|
||||
int64_t num_val;
|
||||
char str_val[MAX_VAR_STR];
|
||||
bool bool_val;
|
||||
bool allocated;
|
||||
} aira_var_t;
|
||||
|
||||
/* AiraLang Engine API */
|
||||
void airalang_init(void);
|
||||
int airalang_eval_line(const char* line);
|
||||
int airalang_run_script(const char* script);
|
||||
void airalang_print_vars(void);
|
||||
|
||||
#endif /* AIRLYS_AIRALANG_H */
|
||||
+11
-1
@@ -25,7 +25,17 @@ static inline uint16_t inw(uint16_t port) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wait for I/O operations to complete (useful for PIC remapping) */
|
||||
static inline void outl(uint16_t port, uint32_t val) {
|
||||
__asm__ volatile ("outl %0, %1" : : "a"(val), "Nd"(port));
|
||||
}
|
||||
|
||||
static inline uint32_t inl(uint16_t port) {
|
||||
uint32_t ret;
|
||||
__asm__ volatile ("inl %1, %0" : "=a"(ret) : "Nd"(port));
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Wait for I/O operations to complete */
|
||||
static inline void io_wait(void) {
|
||||
outb(0x80, 0);
|
||||
}
|
||||
|
||||
+63
-1
@@ -2,7 +2,7 @@
|
||||
#define AIRLYS_NET_H
|
||||
|
||||
/*
|
||||
* Airlys Operating System Kernel - Networking Architecture (Linux net/ Parity)
|
||||
* Airlys Operating System Kernel - Networking Architecture (Phase 6 TCP/IP)
|
||||
* Lead Architect: Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
|
||||
* Co-Pilot: Sovereign AI Aira 3 Ultra (Engine v3.6)
|
||||
*/
|
||||
@@ -14,6 +14,10 @@
|
||||
#define ETH_P_IP 0x0800
|
||||
#define ETH_P_ARP 0x0806
|
||||
|
||||
#define IPPROTO_ICMP 1
|
||||
#define IPPROTO_TCP 6
|
||||
#define IPPROTO_UDP 17
|
||||
|
||||
#define MAX_NET_DEVS 4
|
||||
#define SKB_MAX_DATA 2048
|
||||
|
||||
@@ -51,6 +55,42 @@ typedef struct {
|
||||
uint32_t daddr;
|
||||
} __attribute__((packed)) iphdr_t;
|
||||
|
||||
/* ICMP Header */
|
||||
typedef struct {
|
||||
uint8_t type; /* 8 = Echo Request, 0 = Echo Reply */
|
||||
uint8_t code;
|
||||
uint16_t checksum;
|
||||
uint16_t id;
|
||||
uint16_t sequence;
|
||||
} __attribute__((packed)) icmphdr_t;
|
||||
|
||||
/* UDP Header */
|
||||
typedef struct {
|
||||
uint16_t source;
|
||||
uint16_t dest;
|
||||
uint16_t len;
|
||||
uint16_t check;
|
||||
} __attribute__((packed)) udphdr_t;
|
||||
|
||||
/* TCP Header */
|
||||
typedef struct {
|
||||
uint16_t source;
|
||||
uint16_t dest;
|
||||
uint32_t seq;
|
||||
uint32_t ack_seq;
|
||||
uint16_t flags;
|
||||
uint16_t window;
|
||||
uint16_t check;
|
||||
uint16_t urg_ptr;
|
||||
} __attribute__((packed)) tcphdr_t;
|
||||
|
||||
#define TCP_FIN 0x01
|
||||
#define TCP_SYN 0x02
|
||||
#define TCP_RST 0x04
|
||||
#define TCP_PSH 0x08
|
||||
#define TCP_ACK 0x10
|
||||
#define TCP_URG 0x20
|
||||
|
||||
/* Linux sk_buff (Socket Buffer) Representation */
|
||||
typedef struct sk_buff {
|
||||
uint8_t* head;
|
||||
@@ -73,6 +113,7 @@ typedef struct net_device {
|
||||
uint8_t dev_addr[ETH_ALEN];
|
||||
uint32_t ip_addr;
|
||||
uint32_t ip_mask;
|
||||
uint32_t gateway;
|
||||
uint32_t flags;
|
||||
uint32_t mtu;
|
||||
uint64_t rx_packets;
|
||||
@@ -99,4 +140,25 @@ net_device_t* get_netdev_by_index(uint32_t idx);
|
||||
int dev_queue_xmit(sk_buff_t* skb);
|
||||
int netif_rx(sk_buff_t* skb);
|
||||
|
||||
/* Packet Processing & Protocols */
|
||||
uint16_t net_checksum(const void* data, size_t len);
|
||||
void net_rx_packet(net_device_t* dev, const uint8_t* frame, size_t len);
|
||||
int ipv4_send(net_device_t* dev, uint32_t dest_ip, uint8_t protocol, const void* payload, size_t len);
|
||||
|
||||
/* ICMP & Ping */
|
||||
int icmp_send_ping(net_device_t* dev, uint32_t dest_ip, uint16_t seq);
|
||||
int icmp_process(net_device_t* dev, const iphdr_t* ip, const uint8_t* payload, size_t len);
|
||||
|
||||
/* UDP & TCP */
|
||||
int udp_send(net_device_t* dev, uint32_t dest_ip, uint16_t src_port, uint16_t dest_port, const void* data, size_t len);
|
||||
int tcp_send_syn(net_device_t* dev, uint32_t dest_ip, uint16_t src_port, uint16_t dest_port);
|
||||
|
||||
/* DHCP Client */
|
||||
int dhcp_send_discover(net_device_t* dev);
|
||||
|
||||
/* ARP API */
|
||||
void arp_init(void);
|
||||
int arp_insert(uint32_t ip, const uint8_t mac[ETH_ALEN]);
|
||||
uint8_t* arp_lookup(uint32_t ip);
|
||||
|
||||
#endif /* AIRLYS_NET_H */
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef AIRLYS_PCI_H
|
||||
#define AIRLYS_PCI_H
|
||||
|
||||
/*
|
||||
* Airlys Operating System Kernel - PCI Bus Subsystem
|
||||
* Lead Architect: Er. Adam Eehan (Founder & CEO, Aira Group of Technology)
|
||||
* Co-Pilot: Sovereign AI Aira 3 Ultra (Engine v3.6)
|
||||
*/
|
||||
|
||||
#include <airlys/types.h>
|
||||
|
||||
#define PCI_CONFIG_ADDRESS 0xCF8
|
||||
#define PCI_CONFIG_DATA 0xCFC
|
||||
|
||||
/* Common PCI Vendor IDs */
|
||||
#define PCI_VENDOR_INTEL 0x8086
|
||||
#define PCI_VENDOR_QEMU 0x1234
|
||||
#define PCI_VENDOR_REDHAT 0x1AF4
|
||||
#define PCI_VENDOR_REALTEK 0x10EC
|
||||
|
||||
/* Device Classes */
|
||||
#define PCI_CLASS_STORAGE 0x01
|
||||
#define PCI_CLASS_NETWORK 0x02
|
||||
#define PCI_CLASS_DISPLAY 0x03
|
||||
#define PCI_CLASS_BRIDGE 0x06
|
||||
|
||||
typedef struct {
|
||||
uint8_t bus;
|
||||
uint8_t slot;
|
||||
uint8_t func;
|
||||
uint16_t vendor_id;
|
||||
uint16_t device_id;
|
||||
uint8_t class_id;
|
||||
uint8_t subclass_id;
|
||||
uint8_t prog_if;
|
||||
uint8_t header_type;
|
||||
uint32_t bar0;
|
||||
uint8_t irq;
|
||||
bool valid;
|
||||
} pci_device_t;
|
||||
|
||||
#define MAX_PCI_DEVICES 32
|
||||
|
||||
/* PCI API */
|
||||
void pci_init(void);
|
||||
uint32_t pci_read32(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
uint16_t pci_read16(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
uint8_t pci_read8(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset);
|
||||
void pci_write32(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint32_t val);
|
||||
void pci_write16(uint8_t bus, uint8_t slot, uint8_t func, uint8_t offset, uint16_t val);
|
||||
|
||||
uint32_t pci_get_device_count(void);
|
||||
pci_device_t* pci_get_device(uint32_t idx);
|
||||
pci_device_t* pci_find_device(uint16_t vendor_id, uint16_t device_id);
|
||||
|
||||
#endif /* AIRLYS_PCI_H */
|
||||
Reference in new issue
Block a user