Commit Graph

48 Commits

Author SHA1 Message Date
467ac6c365 Kernel/LibC: Implement SOCK_CLOEXEC and SOCK_NONBLOCK
This removes the need for fcntl after creating a socket :)
2024-09-11 21:59:11 +03:00
f8261c60c0 Kernel: Rewrite the whole scheduler and re-architecture SMP handling
Change Semaphore -> ThreadBlocker
  This was not a semaphore, I just named it one because I didn't know
  what semaphore was. I have meant to change this sooner, but it was in
  no way urgent :D

Implement SMP events. Processors can now be sent SMP events through
IPIs. SMP events can be sent either to a single processor or broadcasted
to every processor.

PageTable::{map_page,map_range,unmap_page,unmap_range}() now send SMP
event to invalidate TLB caches for the changed pages.

Scheduler no longer uses a global run queue. Each processor has its own
scheduler that keeps track of the load on the processor. Once every
second schedulers do load balancing. Schedulers have no access to other
processors' schedulers, they just see approximate loads. If scheduler
decides that it has too much load, it will send a thread to another
processor through a SMP event.

Schedulers are currently run using the timer interrupt on BSB. This
should be not the case, and each processor should use its LAPIC timer
for interrupts. There is no reason to broadcast SMP event to all
processors when BSB gets timer interrupt.

Old scheduler only achieved 20% idle load on qemu. That was probably a
very inefficient implementation. This new scheduler seems to average
around 1% idle load. This is much closer to what I would expect. On my
own laptop idle load seems to be only around 0.5% on each processor.
2024-07-22 00:33:50 +03:00
48a76426e7 BAN: Add more APIs for Atomic and make compare_exchage take a reference 2024-06-28 21:47:47 +03:00
31568fc5a1 Kernel: Rewrite Sockets to not be TmpInodes
TmpInodes just caused issues because TmpFS kept them alive. There was
really no reason for sockets to even be stored inside a TmpFS...
2024-06-27 00:35:19 +03:00
d7b8458a56 Kernel: Fix TCP sending
TCP send was effectively always waiting for connection to close and then
return a value of 0.
2024-06-25 11:04:03 +03:00
4f0457a268 Kernel: Rewrite a lot of TCP code and implement TCP server sockets
TCP stack is now implemented much closer to spec
2024-06-20 13:26:50 +03:00
bce16cdd6e Kernel: Fix how socket closing works
Sockets are now closed only when they are not referenced any more. This
allows child process to close socket and still keep it open for the
parent.
2024-06-19 10:39:44 +03:00
318ce5dec8 All: Fix a lot of compiler warnings from header files
While reworking build system, header files started to report warnings.
2024-06-18 23:02:10 +03:00
cad55a4da5 Kernel/LibC: Implement getsockname for ipv4 sockets 2024-06-17 20:54:45 +03:00
446220494e Kernel: Unix domain sockets close can now be detected
When a unix domain socket is closed and it has a connection to another
socket, it will make the other socket readable and recv will return 0.

This allows detection of socket closing
2024-06-02 16:48:55 +03:00
e77de1804f Kernel: Fix some race conditions in TCP stack
Remove race condition if two acks are to be sent one after another.

Always unblock semaphore once TCP thread has done something. This
allows better chance of TCP sending to succeed.

There are multiple places in the networking code that would require
thread-safe entering to blocking mode. I should add some API for this
so that a lot of race conditions could be removed.
2024-05-21 01:53:45 +03:00
e00b92225d Kernel: Fix E1000 interrupt handling condition
I had written the ICR register check backwards which lead to interrupt
handling only when it was not needed, and no handling when it was
needed. This somehow still worked, just much slower often requiring tcp
resends from the server.
2024-05-21 01:52:19 +03:00
5050047cef Kernel: Rewrite whole scheduler
Current context saving was very hacky and dependant on compiler
behaviour that was not consistent. Now we always use iret for
context saving. This makes everything more clean.
2024-03-29 18:02:12 +02:00
aa2e53c4f8 Kernel: E1000 fix physical address on 32 bit target 2024-03-22 12:35:38 +02:00
9c36d7c338 BAN/Kernel: Rework assertion/panic system
BAN/Assert.h does not need any includes meaning it can be included
anywhere without problems.
2024-03-04 11:41:54 +02:00
90878a7c2b Kernel: Replace CriticalScopes with SpinLocks in networking code 2024-02-29 19:17:28 +02:00
d94f6388b7 Kernel: Fix all broken locks from new mutexes 2024-02-28 22:45:34 +02:00
efdc4817bb Kernel: Print to debug log ICMP unreachable messages
These messages should be forwarded to underlying sockets
2024-02-28 13:19:18 +02:00
9594ee8e47 Kernel: Start making device numbers unique for each device 2024-02-22 15:53:48 +02:00
2ab3eb4109 Kernel: Fix bugs in select
Unix domain socket is now select readable when it has pending
connection
2024-02-12 23:46:27 +02:00
3fc1edede0 Kernel/LibC: Implement super basic select
This does not really even block but it works... :D
2024-02-12 17:26:33 +02:00
f50b4be162 Kernel: Cleanup TCP code 2024-02-12 15:44:40 +02:00
435636a655 Kernel: Implement super simple TCP stack
No SACK support and windows are fixed size
2024-02-12 04:45:42 +02:00
ba06269b14 Kernel: Move on_close_impl from network socket to udp socket 2024-02-12 04:45:42 +02:00
ff49d8b84f Kernel: Cleanup OSI layer overlapping 2024-02-09 17:05:07 +02:00
ed0b1a86aa Kernel: Semaphores and Threads can now be blocked with timeout 2024-02-09 15:28:15 +02:00
534b3e6a9a Kernel: Add LockFreeGuard to LockGuard.h 2024-02-09 15:13:54 +02:00
acf79570ef Kernel: Cleanup network APIs and error messages 2024-02-08 18:33:49 +02:00
9bc7a72a25 Kernel: Implement unix domain sockets with SOCK_DGRAM
Also unbind sockets on close
2024-02-08 13:18:54 +02:00
e7dd03e551 Kernel: Implement basic connection-mode unix domain sockets 2024-02-08 02:28:19 +02:00
41cad88d6e Kernel/LibC: Implement dummy syscalls for accept, connect, listen 2024-02-07 15:57:45 +02:00
5da59c9151 Kernel: Make better abstractions for networking 2024-02-06 16:45:39 +02:00
f804e87f7d Kernel: Implement basic gateway for network interfaces 2024-02-05 18:18:56 +02:00
dd3641f054 Kernel: Cleanup ARPTable code
Packet process is now killed if ARPTable dies.

ARP wait loop now just reschecules so timeout actually works.
2024-02-05 18:18:56 +02:00
b2291ce162 Kernel/BAN: Fix network strucute endianness 2024-02-05 18:18:56 +02:00
d15cbb2d6a Kernel: Fix IPv4 header checksum calculation 2024-02-05 18:18:56 +02:00
649e9f4500 Kernel: ARP now replies to requests 2024-02-03 18:04:12 +02:00
5cfe249945 Kernel: Cleanup network code and implement basic ARP request 2024-02-03 02:39:26 +02:00
a0138955cd Kernel: Implement barebones arp table 2024-02-03 01:50:10 +02:00
e1ffbb710b Kernel/LibC: Implement basic ioctl for network addresses 2024-02-03 01:50:10 +02:00
0f154c3173 Kernel: Implement basic recvfrom 2024-02-02 13:50:00 +02:00
ec2f21bb9f Kernel/LibC: Implement SYS_SENDTO 2024-02-02 03:16:01 +02:00
ab150b458a Kernel/LibC: Implement basic socket binding 2024-02-02 01:31:58 +02:00
99eed9c37a Kernel: Start work on network stack 2024-02-01 23:38:06 +02:00
f4e86028d0 Kernel: Write simple working E1000 and E1000E drivers 2024-02-01 22:08:59 +02:00
1312a9dad2 Kernel: PCI checks if ethernet device is E1000 before initialization
I used to treat all ethernet deivices as E1000 but now it is actually
verified before initialization
2023-10-16 01:44:54 +03:00
Bananymous
11717f90c1 Kernel: PCI devices can now create region for BAR
This creates either MEM or IO region for read/write access to PCI
device.
2023-09-22 17:20:35 +03:00
Bananymous
a740bf8df4 1000th COMMIT: Kernel: Add basic E1000 driver
This driver is only capable to read mac address and enable and read
link status
2023-09-22 17:20:28 +03:00