aboutsummaryrefslogtreecommitdiff
path: root/kernel/inc
diff options
context:
space:
mode:
authorMarvin Borner2021-05-23 14:30:07 +0200
committerMarvin Borner2021-05-23 14:34:52 +0200
commit33fd97e19a12535c02b1cf6804cb854a279e040c (patch)
tree0ea00a9b60b35e42830eb3b13887fea2d356d655 /kernel/inc
parent0bf64a113f3d3baa110b362fd6a215ef29182671 (diff)
Cleanup, linting, formatting
Diffstat (limited to 'kernel/inc')
-rw-r--r--kernel/inc/drivers/cpu.h2
-rw-r--r--kernel/inc/drivers/pci.h4
-rw-r--r--kernel/inc/drivers/rtl8139.h36
-rw-r--r--kernel/inc/mm.h2
-rw-r--r--kernel/inc/net.h168
5 files changed, 4 insertions, 208 deletions
diff --git a/kernel/inc/drivers/cpu.h b/kernel/inc/drivers/cpu.h
index 7ac6074..75e0495 100644
--- a/kernel/inc/drivers/cpu.h
+++ b/kernel/inc/drivers/cpu.h
@@ -5,7 +5,7 @@
#include <def.h>
-static inline void spinlock(u32 *ptr)
+UNUSED_FUNC static inline void spinlock(u32 *ptr)
{
u32 prev;
do
diff --git a/kernel/inc/drivers/pci.h b/kernel/inc/drivers/pci.h
index 9429f29..ac288c6 100644
--- a/kernel/inc/drivers/pci.h
+++ b/kernel/inc/drivers/pci.h
@@ -76,14 +76,14 @@ static inline u8 pci_extract_func(u32 device)
return (u8)(device);
}
-static inline u32 pci_get_addr(u32 device, int field)
+UNUSED_FUNC static inline u32 pci_get_addr(u32 device, int field)
{
return 0x80000000 | (u32)(pci_extract_bus(device) << 16) |
(u32)(pci_extract_slot(device) << 11) | (u32)(pci_extract_func(device) << 8) |
((field)&0xFC);
}
-static inline u32 pci_box_device(int bus, int slot, int func)
+UNUSED_FUNC static inline u32 pci_box_device(int bus, int slot, int func)
{
return (u32)((bus << 16) | (slot << 8) | func);
}
diff --git a/kernel/inc/drivers/rtl8139.h b/kernel/inc/drivers/rtl8139.h
deleted file mode 100644
index 0d748af..0000000
--- a/kernel/inc/drivers/rtl8139.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef RTL8139_H
-#define RTL8139_H
-
-#include <def.h>
-
-#define RX_BUF_SIZE 0x2000
-
-#define RTL8139_VENDOR_ID 0x10ec
-#define RTL8139_DEVICE_ID 0x8139
-
-#define RTL_ROK (1 << 0)
-#define RTL_TOK (1 << 2)
-
-#define RTL_PORT_MAC 0x00
-#define RTL_PORT_MAR 0x08
-#define RTL_PORT_TXSTAT 0x10
-#define RTL_PORT_TXBUF 0x20
-#define RTL_PORT_RBSTART 0x30
-#define RTL_PORT_CMD 0x37
-#define RTL_PORT_RXPTR 0x38
-#define RTL_PORT_RXADDR 0x3A
-#define RTL_PORT_IMR 0x3C
-#define RTL_PORT_ISR 0x3E
-#define RTL_PORT_TCR 0x40
-#define RTL_PORT_RCR 0x44
-#define RTL_PORT_RXMISS 0x4C
-#define RTL_PORT_CONFIG 0x52
-
-int rtl8139_install(void);
-int rtl8139_installed(void);
-void rtl8139_send_packet(void *data, u32 len) NONNULL;
-u8 *rtl8139_get_mac(void);
-
-#endif
diff --git a/kernel/inc/mm.h b/kernel/inc/mm.h
index 8f6f06a..0a2bb81 100644
--- a/kernel/inc/mm.h
+++ b/kernel/inc/mm.h
@@ -4,8 +4,8 @@
#define PAGING_H
#include <def.h>
-#include <errno.h>
#include <drivers/interrupts.h>
+#include <errno.h>
struct memory_range {
u32 base;
diff --git a/kernel/inc/net.h b/kernel/inc/net.h
deleted file mode 100644
index 62ff5e5..0000000
--- a/kernel/inc/net.h
+++ /dev/null
@@ -1,168 +0,0 @@
-// MIT License, Copyright (c) 2020 Marvin Borner
-
-#ifndef NET_H
-#define NET_H
-
-#include <def.h>
-#include <socket.h>
-
-#define htonl(l) \
- ((((l)&0xff) << 24) | (((l)&0xff00) << 8) | (((l)&0xff0000) >> 8) | \
- (((l)&0xff000000) >> 24))
-#define htons(s) ((((s)&0xff) << 8) | (((s)&0xff00) >> 8))
-#define ntohl(l) htonl((l))
-#define ntohs(s) htons((s))
-#define ip(a, b, c, d) \
- ((((a)&0xff) << 24) | (((b)&0xff) << 16) | (((c)&0xff) << 8) | (((d)&0xff) << 0))
-
-#define ETHERNET_TYPE_IP4 0x0800
-#define ETHERNET_TYPE_IP6 0x86dd
-#define ETHERNET_TYPE_ARP 0x0806
-
-#define IP_PROT_ICMP 0x01
-#define IP_PROT_TCP 0x06
-#define IP_PROT_UDP 0x11
-
-#define TCP_FLAG_FIN (1 << 0)
-#define TCP_FLAG_SYN (1 << 1)
-#define TCP_FLAG_RST (1 << 2)
-#define TCP_FLAG_PSH (1 << 3)
-#define TCP_FLAG_ACK (1 << 4)
-#define TCP_FLAG_URG (1 << 5)
-#define TCP_FLAG_ECE (1 << 6)
-#define TCP_FLAG_CWR (1 << 7)
-#define TCP_FLAG_NS (1 << 8)
-
-#define ARP_REQUEST 1
-#define ARP_REPLY 2
-
-#define DHCP_REQUEST 1
-#define DHCP_REPLY 2
-#define DHCP_TRANSACTION_IDENTIFIER 0x18122002
-
-#define HARDWARE_TYPE_ETHERNET 0x01
-
-// Hardcoded ports - TODO!
-#define DHCP_PORT 68
-#define DNS_PORT 50053
-
-// Protocol structs
-
-struct ethernet_packet {
- u8 dst[6];
- u8 src[6];
- u16 type;
- u8 data[];
-} PACKED;
-
-struct arp_packet {
- u16 hardware_type;
- u16 protocol;
- u8 hardware_addr_len;
- u8 protocol_addr_len;
- u16 opcode;
- u8 src_mac[6];
- u32 src_protocol_addr;
- u8 dst_mac[6];
- u32 dst_protocol_addr;
-} PACKED;
-
-struct ip_packet {
- u8 version_ihl;
- u8 dscp_ecn;
- u16 length;
- u16 id;
- u16 flags_fragment;
- u8 ttl;
- u8 protocol;
- u16 checksum;
- u32 src;
- u32 dst;
- u8 data[];
-} PACKED;
-
-struct dhcp_packet {
- u8 op;
- u8 hardware_type;
- u8 mac_len;
- u8 hops;
- u32 xid;
- u16 seconds;
- u16 flags;
- u32 client_ip;
- u32 your_ip;
- u32 server_ip;
- u32 gateway_ip;
- u8 client_mac[6];
- u8 reserved[10];
- u8 server_name[64];
- u8 file[128];
- u8 options[64];
-} PACKED;
-
-struct dns_packet {
- u16 qid;
- u16 flags;
- u16 questions;
- u16 answers;
- u16 authorities;
- u16 additional;
- u8 data[];
-} PACKED;
-
-struct udp_packet {
- u16 src_port;
- u16 dst_port;
- u16 length;
- u16 checksum;
- u8 data[];
-} PACKED;
-
-struct tcp_packet {
- u16 src_port;
- u16 dst_port;
- u32 seq_number;
- u32 ack_number;
- u16 flags;
- u16 window_size;
- u16 checksum;
- u16 urgent;
- u8 data[];
-} PACKED;
-
-struct tcp_pseudo_header {
- u32 src;
- u32 dst;
- u8 zeros;
- u8 protocol;
- u16 tcp_len;
- u8 tcp_packet[];
-};
-
-struct icmp_packet {
- u8 type;
- u8 version;
- u16 checksum;
- u16 identifier;
- u16 sequence;
-} PACKED;
-
-// Other structs
-
-struct arp_table_entry {
- u32 ip_addr;
- u64 mac_addr;
-};
-
-void ethernet_handle_packet(struct ethernet_packet *packet, int len) NONNULL;
-
-struct socket *net_open(enum socket_type type);
-int net_close(struct socket *socket) NONNULL;
-int net_connect(struct socket *socket, u32 ip_addr, u16 dst_port) NONNULL;
-void net_send(struct socket *socket, void *data, u32 len) NONNULL;
-int net_receive(struct socket *socket, void *buf, u32 len) NONNULL;
-
-int net_installed(void);
-void net_install(void);
-
-#endif