]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
refactor: move lwIP port headers from src/net/lwip_port/ to include/net/
authorTulio A M Mendes <[email protected]>
Thu, 12 Feb 2026 06:46:40 +0000 (03:46 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 02:44:55 +0000 (23:44 -0300)
Moved lwipopts.h and arch/cc.h to include/net/ where they belong
alongside other public headers. Updated Makefile include path from
-Isrc/net/lwip_port to -Iinclude/net.

Also fixed cc.h to use arch-conditional BYTE_ORDER instead of
hardcoding x86 little-endian, supporting ARM, RISC-V, and MIPS
targets.

Makefile
include/net/arch/cc.h [new file with mode: 0644]
include/net/lwipopts.h [new file with mode: 0644]
src/net/lwip_port/arch/cc.h [deleted file]
src/net/lwip_port/lwipopts.h [deleted file]

index a12f42c13324dd7b260e5cfee79ee19179e425fc..76d1edcfab36e46c1bb1fbf2534e3c4cf8077629 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -45,7 +45,7 @@ ifeq ($(ARCH),x86)
     C_SOURCES += $(NET_SOURCES)
 
     # Mandatory Architecture Flags
-    ARCH_CFLAGS := -m32 -ffreestanding -fno-builtin -U_FORTIFY_SOURCE -Iinclude -Isrc/net/lwip_port -Ithird_party/lwip/src/include
+    ARCH_CFLAGS := -m32 -ffreestanding -fno-builtin -U_FORTIFY_SOURCE -Iinclude -Iinclude/net -Ithird_party/lwip/src/include
     ARCH_LDFLAGS := -m elf_i386 -T $(SRC_DIR)/arch/x86/linker.ld
     ARCH_ASFLAGS := --32
 
diff --git a/include/net/arch/cc.h b/include/net/arch/cc.h
new file mode 100644 (file)
index 0000000..26cea98
--- /dev/null
@@ -0,0 +1,44 @@
+#ifndef LWIP_ARCH_CC_H
+#define LWIP_ARCH_CC_H
+
+#include <stdint.h>
+#include <stddef.h>
+
+/* Define byte order based on target architecture */
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv)
+#define BYTE_ORDER LITTLE_ENDIAN
+#elif defined(__MIPSEB__) || defined(__ARMEB__)
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+/* Use GCC-style struct packing */
+#define PACK_STRUCT_FIELD(x) x
+#define PACK_STRUCT_STRUCT __attribute__((packed))
+#define PACK_STRUCT_BEGIN
+#define PACK_STRUCT_END
+
+/* Compiler hints */
+#define LWIP_PLATFORM_DIAG(x)   do { } while(0)
+#define LWIP_PLATFORM_ASSERT(x) do { } while(0)
+
+/* Use our own printf-less approach; lwIP only needs these types */
+typedef uint8_t  u8_t;
+typedef int8_t   s8_t;
+typedef uint16_t u16_t;
+typedef int16_t  s16_t;
+typedef uint32_t u32_t;
+typedef int32_t  s32_t;
+typedef uintptr_t mem_ptr_t;
+
+/* Provide format macros for lwIP debug prints (unused with NO_SYS + no debug) */
+#define U16_F "u"
+#define S16_F "d"
+#define X16_F "x"
+#define U32_F "u"
+#define S32_F "d"
+#define X32_F "x"
+#define SZT_F "u"
+
+#endif /* LWIP_ARCH_CC_H */
diff --git a/include/net/lwipopts.h b/include/net/lwipopts.h
new file mode 100644 (file)
index 0000000..662be29
--- /dev/null
@@ -0,0 +1,73 @@
+#ifndef LWIPOPTS_H
+#define LWIPOPTS_H
+
+/* ---- NO_SYS mode (raw API, no threads) ---- */
+#define NO_SYS                  1
+#define LWIP_SOCKET             0
+#define LWIP_NETCONN            0
+#define LWIP_NETIF_API          0
+
+/* ---- Memory settings ---- */
+#define MEM_ALIGNMENT           4
+#define MEM_SIZE                (64 * 1024)     /* 64 KB heap for lwIP */
+#define MEMP_NUM_PBUF           32
+#define MEMP_NUM_UDP_PCB        8
+#define MEMP_NUM_TCP_PCB        8
+#define MEMP_NUM_TCP_PCB_LISTEN 4
+#define MEMP_NUM_TCP_SEG        32
+#define MEMP_NUM_ARP_QUEUE      8
+#define PBUF_POOL_SIZE          32
+#define PBUF_POOL_BUFSIZE       1536
+
+/* ---- IPv4 ---- */
+#define LWIP_IPV4               1
+#define LWIP_IPV6               0
+#define LWIP_ARP                1
+#define LWIP_ICMP               1
+#define LWIP_UDP                1
+#define LWIP_TCP                1
+#define LWIP_DHCP               0
+#define LWIP_AUTOIP             0
+#define LWIP_DNS                1
+#define LWIP_NO_CTYPE_H         1
+#define LWIP_IGMP               0
+
+/* ---- TCP tuning ---- */
+#define TCP_MSS                 1460
+#define TCP_WND                 (4 * TCP_MSS)
+#define TCP_SND_BUF             (4 * TCP_MSS)
+#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF / TCP_MSS)
+#define TCP_QUEUE_OOSEQ         1
+
+/* ---- Checksum ---- */
+#define CHECKSUM_GEN_IP         1
+#define CHECKSUM_GEN_UDP        1
+#define CHECKSUM_GEN_TCP        1
+#define CHECKSUM_GEN_ICMP       1
+#define CHECKSUM_CHECK_IP       1
+#define CHECKSUM_CHECK_UDP      1
+#define CHECKSUM_CHECK_TCP      1
+#define CHECKSUM_CHECK_ICMP     1
+
+/* ---- ARP ---- */
+#define ARP_TABLE_SIZE          10
+#define ARP_QUEUEING            1
+#define ETHARP_SUPPORT_STATIC_ENTRIES 1
+
+/* ---- Debug (all off) ---- */
+#define LWIP_DEBUG              0
+#define LWIP_DBG_TYPES_ON       0
+
+/* ---- Misc ---- */
+#define LWIP_STATS              0
+#define LWIP_PROVIDE_ERRNO      0
+#define LWIP_RAND()             ((u32_t)0x12345678)  /* TODO: proper RNG */
+#define LWIP_TIMERS             1
+#define SYS_LIGHTWEIGHT_PROT    0
+#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1
+
+/* ---- Raw API callbacks ---- */
+#define LWIP_RAW                1
+#define MEMP_NUM_RAW_PCB        4
+
+#endif /* LWIPOPTS_H */
diff --git a/src/net/lwip_port/arch/cc.h b/src/net/lwip_port/arch/cc.h
deleted file mode 100644 (file)
index 3b5070a..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#ifndef LWIP_ARCH_CC_H
-#define LWIP_ARCH_CC_H
-
-#include <stdint.h>
-#include <stddef.h>
-
-/* Define byte order for x86 (little-endian) */
-#define BYTE_ORDER LITTLE_ENDIAN
-
-/* Use GCC-style struct packing */
-#define PACK_STRUCT_FIELD(x) x
-#define PACK_STRUCT_STRUCT __attribute__((packed))
-#define PACK_STRUCT_BEGIN
-#define PACK_STRUCT_END
-
-/* Compiler hints */
-#define LWIP_PLATFORM_DIAG(x)   do { } while(0)
-#define LWIP_PLATFORM_ASSERT(x) do { } while(0)
-
-/* Use our own printf-less approach; lwIP only needs these types */
-typedef uint8_t  u8_t;
-typedef int8_t   s8_t;
-typedef uint16_t u16_t;
-typedef int16_t  s16_t;
-typedef uint32_t u32_t;
-typedef int32_t  s32_t;
-typedef uintptr_t mem_ptr_t;
-
-/* Provide format macros for lwIP debug prints (unused with NO_SYS + no debug) */
-#define U16_F "u"
-#define S16_F "d"
-#define X16_F "x"
-#define U32_F "u"
-#define S32_F "d"
-#define X32_F "x"
-#define SZT_F "u"
-
-#endif /* LWIP_ARCH_CC_H */
diff --git a/src/net/lwip_port/lwipopts.h b/src/net/lwip_port/lwipopts.h
deleted file mode 100644 (file)
index 662be29..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef LWIPOPTS_H
-#define LWIPOPTS_H
-
-/* ---- NO_SYS mode (raw API, no threads) ---- */
-#define NO_SYS                  1
-#define LWIP_SOCKET             0
-#define LWIP_NETCONN            0
-#define LWIP_NETIF_API          0
-
-/* ---- Memory settings ---- */
-#define MEM_ALIGNMENT           4
-#define MEM_SIZE                (64 * 1024)     /* 64 KB heap for lwIP */
-#define MEMP_NUM_PBUF           32
-#define MEMP_NUM_UDP_PCB        8
-#define MEMP_NUM_TCP_PCB        8
-#define MEMP_NUM_TCP_PCB_LISTEN 4
-#define MEMP_NUM_TCP_SEG        32
-#define MEMP_NUM_ARP_QUEUE      8
-#define PBUF_POOL_SIZE          32
-#define PBUF_POOL_BUFSIZE       1536
-
-/* ---- IPv4 ---- */
-#define LWIP_IPV4               1
-#define LWIP_IPV6               0
-#define LWIP_ARP                1
-#define LWIP_ICMP               1
-#define LWIP_UDP                1
-#define LWIP_TCP                1
-#define LWIP_DHCP               0
-#define LWIP_AUTOIP             0
-#define LWIP_DNS                1
-#define LWIP_NO_CTYPE_H         1
-#define LWIP_IGMP               0
-
-/* ---- TCP tuning ---- */
-#define TCP_MSS                 1460
-#define TCP_WND                 (4 * TCP_MSS)
-#define TCP_SND_BUF             (4 * TCP_MSS)
-#define TCP_SND_QUEUELEN        (4 * TCP_SND_BUF / TCP_MSS)
-#define TCP_QUEUE_OOSEQ         1
-
-/* ---- Checksum ---- */
-#define CHECKSUM_GEN_IP         1
-#define CHECKSUM_GEN_UDP        1
-#define CHECKSUM_GEN_TCP        1
-#define CHECKSUM_GEN_ICMP       1
-#define CHECKSUM_CHECK_IP       1
-#define CHECKSUM_CHECK_UDP      1
-#define CHECKSUM_CHECK_TCP      1
-#define CHECKSUM_CHECK_ICMP     1
-
-/* ---- ARP ---- */
-#define ARP_TABLE_SIZE          10
-#define ARP_QUEUEING            1
-#define ETHARP_SUPPORT_STATIC_ENTRIES 1
-
-/* ---- Debug (all off) ---- */
-#define LWIP_DEBUG              0
-#define LWIP_DBG_TYPES_ON       0
-
-/* ---- Misc ---- */
-#define LWIP_STATS              0
-#define LWIP_PROVIDE_ERRNO      0
-#define LWIP_RAND()             ((u32_t)0x12345678)  /* TODO: proper RNG */
-#define LWIP_TIMERS             1
-#define SYS_LIGHTWEIGHT_PROT    0
-#define LWIP_DONT_PROVIDE_BYTEORDER_FUNCTIONS 1
-
-/* ---- Raw API callbacks ---- */
-#define LWIP_RAW                1
-#define MEMP_NUM_RAW_PCB        4
-
-#endif /* LWIPOPTS_H */