Add ENABLE_NET and ENABLE_UNIX options
This commit is contained in:
+4
-9
@@ -100,15 +100,7 @@ set(SRC arch/amd64/kernel.c
|
||||
drivers/usb/driver.c
|
||||
drivers/usb/device.c
|
||||
drivers/usb/usbkbd.c
|
||||
drivers/usb/hub.c
|
||||
|
||||
net/net.c
|
||||
net/if.c
|
||||
net/socket.c
|
||||
net/util.c
|
||||
net/ports.c
|
||||
net/unix.c
|
||||
sys/sys_net.c)
|
||||
drivers/usb/hub.c)
|
||||
|
||||
#### CFLAGS and LDFLAGS
|
||||
execute_process(COMMAND git describe --always
|
||||
@@ -152,6 +144,9 @@ set(CMAKE_ASM_FLAGS "${CFLAGS} -D__ASM__")
|
||||
#### Options
|
||||
# ...
|
||||
|
||||
include(etc/cmake/Options.cmake NO_POLICY_SCOPE)
|
||||
set(SRC ${SRC} ${OPT_SRC})
|
||||
|
||||
#### Dependencies
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "user/syscall.h"
|
||||
#include "user/errno.h"
|
||||
#include "user/time.h"
|
||||
@@ -9,7 +11,9 @@
|
||||
#include "sys/sys_file.h"
|
||||
#include "sys/sys_sys.h"
|
||||
#include "sys/sys_proc.h"
|
||||
#if defined(ENABLE_NET)
|
||||
#include "sys/sys_net.h"
|
||||
#endif
|
||||
#include "sys/mod.h"
|
||||
|
||||
#define MSR_IA32_STAR 0xC0000081
|
||||
@@ -90,6 +94,7 @@ void *syscall_table[256] = {
|
||||
[SYSCALL_NRX_MODULE_LOAD] = sys_module_load,
|
||||
[SYSCALL_NRX_MODULE_UNLOAD] = sys_module_unload,
|
||||
|
||||
#if defined(ENABLE_NET)
|
||||
// Network
|
||||
[SYSCALL_NR_SOCKET] = sys_socket,
|
||||
[SYSCALL_NR_CONNECT] = sys_connect,
|
||||
@@ -99,6 +104,7 @@ void *syscall_table[256] = {
|
||||
[SYSCALL_NR_BIND] = sys_bind,
|
||||
[SYSCALL_NR_SETSOCKOPT] = sys_setsockopt,
|
||||
[SYSCALL_NRX_NETCTL] = sys_netctl,
|
||||
#endif
|
||||
|
||||
// Extension
|
||||
[SYSCALL_NRX_TRACE] = sys_debug_trace,
|
||||
|
||||
@@ -2,3 +2,6 @@
|
||||
|
||||
#define AMD64_KERNEL_STACK 32768
|
||||
#define AMD64_MAX_SMP 1
|
||||
|
||||
#cmakedefine ENABLE_NET
|
||||
#cmakedefine ENABLE_UNIX
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
option(ENABLE_UNIX "Enable support for Unix domain sockets" ON)
|
||||
option(ENABLE_NET "Enable networking support" ON)
|
||||
|
||||
function(require what whom)
|
||||
if (NOT ${what})
|
||||
message(FATAL_ERROR "${what} is required by ${whom}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
set(OPT_SRC "")
|
||||
|
||||
if (ENABLE_NET)
|
||||
set(OPT_SRC ${OPT_SRC}
|
||||
net/net.c
|
||||
net/if.c
|
||||
net/socket.c
|
||||
net/util.c
|
||||
net/ports.c
|
||||
sys/sys_net.c)
|
||||
endif()
|
||||
|
||||
if (ENABLE_UNIX)
|
||||
require(ENABLE_NET ENABLE_UNIX)
|
||||
|
||||
set(OPT_SRC ${OPT_SRC} net/unix.c)
|
||||
endif(ENABLE_UNIX)
|
||||
+5
-1
@@ -1,3 +1,4 @@
|
||||
#include <config.h>
|
||||
#include "sys/mem/slab.h"
|
||||
#include "sys/assert.h"
|
||||
#include "fs/ofile.h"
|
||||
@@ -28,9 +29,12 @@ void ofile_close(struct vfs_ioctx *ioctx, struct ofile *of) {
|
||||
_assert(of->refcount > 0);
|
||||
--of->refcount;
|
||||
if (of->refcount == 0) {
|
||||
#if defined(ENABLE_NET)
|
||||
if (of->flags & OF_SOCKET) {
|
||||
net_close(ioctx, of);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
vfs_close(ioctx, of);
|
||||
}
|
||||
ofile_destroy(of);
|
||||
|
||||
+6
-3
@@ -1,3 +1,4 @@
|
||||
#include <config.h>
|
||||
#include "arch/amd64/syscall.h"
|
||||
#include "drivers/pci/pci.h"
|
||||
#include "drivers/usb/usb.h"
|
||||
@@ -18,8 +19,8 @@ void _init(void) {
|
||||
init_func_t *init_array = (init_func_t *) &_init_start;
|
||||
|
||||
// Sanity checks
|
||||
_assert(((uintptr_t) init_array & 0xF) == 0);
|
||||
_assert(((uintptr_t) (&_init_end) & 0xF) == 0);
|
||||
_assert(((uintptr_t) init_array & 0x7) == 0);
|
||||
_assert(((uintptr_t) (&_init_end) & 0x7) == 0);
|
||||
size_t count = ((uintptr_t) &_init_end - (uintptr_t) &_init_start) / sizeof(init_func_t);
|
||||
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
@@ -39,9 +40,11 @@ void main(void) {
|
||||
syscall_init();
|
||||
sched_init();
|
||||
|
||||
#if defined(ENABLE_NET)
|
||||
net_init();
|
||||
usb_daemon_start();
|
||||
net_daemon_start();
|
||||
#endif
|
||||
usb_daemon_start();
|
||||
user_init_start();
|
||||
|
||||
sched_enter();
|
||||
|
||||
+5
-1
@@ -1,3 +1,4 @@
|
||||
#include <config.h>
|
||||
#include "user/errno.h"
|
||||
#include "arch/amd64/hw/timer.h"
|
||||
#include "arch/amd64/cpu.h"
|
||||
@@ -346,9 +347,12 @@ int sys_mknod(const char *filename, int mode, unsigned int dev) {
|
||||
}
|
||||
|
||||
static int sys_select_get_ready(struct ofile *fd) {
|
||||
#if defined(ENABLE_NET)
|
||||
if (fd->flags & OF_SOCKET) {
|
||||
return socket_has_data(&fd->socket);
|
||||
} else {
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
struct vnode *vn = fd->file.vnode;
|
||||
_assert(vn);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user