Skip to content
Merged

Vfs #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
320a9ab
Make an InitRD driver. Add new command line options. Add a script to …
oberrow Aug 15, 2024
d051306
Remove tests for InitRD driver. Add get_linked_desc to the driver's f…
oberrow Aug 15, 2024
fcfdc6a
Add various VFS structs and defines. Add a dirent search helper. Add …
oberrow Aug 15, 2024
666c214
Fix bugs with dirent lookup. Utilize the namecache on dirent lookup. …
oberrow Aug 15, 2024
1f89bbd
Implement Vfs_Mount. Fix bugs.
oberrow Aug 16, 2024
b806488
Add a struct fd. Implement Vfs_FdOpen. Fix mounting bugs. Add GIDs an…
oberrow Aug 16, 2024
9835143
Implement all functions in fd.h, but Vfs_FdWrite. Fix bugs in the ini…
oberrow Aug 16, 2024
6a11290
Fix bug.
oberrow Aug 16, 2024
b6f1184
Fix build instruction mistake.
oberrow Aug 16, 2024
a0f4ef4
Fix the page cache. Implement Vfs_FdWrite
oberrow Aug 16, 2024
797de06
Implement ASync IO. Fix a bug with writing. Fix a bug in the VMA.
oberrow Aug 17, 2024
abd41f4
On mount, add the newly created mount point to the mount list.
oberrow Aug 17, 2024
e63c0ca
Make PMM arch-independant. Implement CoW. Implement file mapping (bot…
oberrow Aug 19, 2024
563193a
Bug fixes in the UART driver. Fix bugs regarding special files. Fix o…
oberrow Aug 19, 2024
6cbfc79
Add APIs for drivers so that they can add their devices into /dev/ (o…
oberrow Aug 19, 2024
c6c14ce
Implement IO from block devices within file descriptors. Note: Requir…
oberrow Aug 19, 2024
4cf1795
Add a method to open directory entries directly.
oberrow Aug 19, 2024
6685e85
Implement unmounting. Fix bugs.
oberrow Aug 19, 2024
e0517fb
Add a function (largly unimplemented as of now) to finalize VFS initi…
oberrow Aug 19, 2024
6f87ce7
Remove lock tests from entry.c
oberrow Aug 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
/dependencies/include/
/dependencies/needs_download.cmake
/qemu_log.txt
/tar
/src/oboskrnl/inc/*
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,20 @@ add_compile_definitions(
set_property(GLOBAL PROPERTY C_STANDARD 17
PROPERTY C_STANDARD_REQUIRED true)

if (OBOS_ENABLE_WERROR)
if (DEFINED OBOS_ENABLE_WERROR AND NOT DEFINED OBOS_ENABLE_FANALYZER)
add_compile_options("-Werror")
endif()
if (DEFINED OBOS_ENABLE_FANALYZER)
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fanalyzer>)
endif()
if (DEFINED OBOS_ENABLE_FANALYZER AND DEFINED OBOS_ENABLE_WERROR)
message(WARNING "OBOS_ENABLE_FANALYZER and OBOS_ENABLE_WERROR are mutually exclusive. Preferring OBOS_ENABLE_FANALYZER.")
endif()

if (NOT DEFINED OBOS_DEV_PREFIX)
set(OBOS_DEV_PREFIX "/dev/")
endif()
configure_file(${CMAKE_SOURCE_DIR}/src/inc/dev_prefix.h.in ${CMAKE_SOURCE_DIR}/src/oboskrnl/inc/dev_prefix.h @ONLY)

# Include the kernel
add_subdirectory("src/oboskrnl")
Expand All @@ -119,9 +129,10 @@ get_target_property(uacpi_INCLUDES uacpi INCLUDE_DIRECTORIES)
include_directories(${uacpi_INCLUDES})
if (OBOS_ARCHITECTURE STREQUAL "x86_64")
add_subdirectory("src/drivers/x86_64/uart")
endif()
add_subdirectory("src/isogen")
endif()
add_subdirectory("src/drivers/generic/initrd")
add_subdirectory("src/drivers/test_driver")
add_subdirectory("src/isogen")
if (OBOS_ARCHITECTURE STREQUAL "m68k")
add_subdirectory("src/oboskrnl/arch/m68k/loader")
endif()
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ git clone https://github.com/OBOS-dev/obos.git
3. Run cmake to build the OS
(x86_64)
```sh
mkdir build
alias rem=eval
cmake -GNinja -DCMAKE_BUILD_TYPE=Release --toolchain=src/build/x86_64/toolchain.cmake -B build .
rem chmod +x dependencies/hyper/hyper_install-linux-x86_64
cmake --build build
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug --toolchain=src/build/x86_64/toolchain.cmake -B build/x86_64 .
chmod +x dependencies/hyper/hyper_install-linux-x86_64
cmake --build build/x86_64
scripts/generate_initrd-x86_64.sh
cmake --build build/x86_64
```
4. To run the kernel, run the script under scripts/launch_qemu.\[bat,sh\]

Expand Down
10 changes: 7 additions & 3 deletions config/hyper.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ protocol=ultra
higher-half-exclusive=true
kernel-as-module=true
video-mode=auto
cmdline=''
cmdline='-initrd-module=initrd -initrd-driver-module=initrd_driver --root-fs-partid initrd'

binary:
path="/obos/oboskrnl"
Expand All @@ -22,5 +22,9 @@ module:
name="INITIAL_SWAP_BUFFER"
module:
type="file"
path="/uart"
name="uart_driver"
path="/obos/initrd.tar"
name="initrd"
module:
type="file"
path="/obos/initrd"
name="initrd_driver"
Binary file added config/initrd.tar
Binary file not shown.
14 changes: 14 additions & 0 deletions scripts/generate_initrd-x86_64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export old_pwd=$PWD
if [[ ! -d tar ]]
then
mkdir tar
fi
cd $(git rev-parse --show-toplevel)
cp out/uart tar
if [[ ! -d tar/dev ]]
then
mkdir tar/dev
fi
cd tar
tar -H ustar -cf ../config/initrd.tar *
cd $old_pwd
4 changes: 3 additions & 1 deletion scripts/launch_qemu-m68k.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ qemu-system-m68k \
-m 512M \
-d int \
-D qemu_log.txt \
-serial file:/dev/stdout
-serial file:/dev/stdout \
-append "--root-fs-uuid=initrd" \
-initrd "config/initrd.tar"

cd scripts
5 changes: 3 additions & 2 deletions src/build/m68k/driver_link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ PHDRS
interp PT_INTERP ;
text PT_LOAD FILEHDR PHDRS ;
data PT_LOAD ;
pageable_text PT_LOAD FLAGS(PF_R|PF_X|0x00010000);
pageable_data PT_LOAD FLAGS(PF_R|PF_W|0x00010000);
pageable_text PT_LOAD FLAGS(PF_X|PF_R|0x00010000);
pageable_data PT_LOAD FLAGS(PF_W|PF_R|0x00010000);
dynamic PT_DYNAMIC ;
}
SECTIONS
Expand Down Expand Up @@ -194,6 +194,7 @@ SECTIONS
pad the .data section. */
. = ALIGN(. != 0 ? 32 / 8 : 1);
} :pageable_data
. = ALIGN(32 / 8);
_end = .; PROVIDE (end = .);
. = DATA_SEGMENT_END (.);
/* Stabs debugging sections. */
Expand Down
1 change: 1 addition & 0 deletions src/build/m68k/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ add_compile_definitions(
OBOS_USER_ADDRESS_SPACE_BASE=0x1000 OBOS_USER_ADDRESS_SPACE_LIMIT=0x80000000
OBOS_TIMER_IS_DEADLINE=
OBOS_ARCH_USES_SOFT_FLOAT=1
OBOS_ARCH_EMULATED_IRQL=1
)
add_compile_options($<$<CONFIG:Debug>:-g>)

Expand Down
1 change: 1 addition & 0 deletions src/build/x86_64/toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ add_compile_definitions(
OBOS_KERNEL_ADDRESS_SPACE_BASE=0xffffff0000000000 OBOS_KERNEL_ADDRESS_SPACE_LIMIT=0xfffffffffffff000
OBOS_USER_ADDRESS_SPACE_BASE=0x1000 OBOS_USER_ADDRESS_SPACE_LIMIT=0x7FFFFFFFFFFF
OBOS_ARCH_USES_SOFT_FLOAT=0
OBOS_ARCH_EMULATED_IRQL=0
)
add_compile_options($<$<CONFIG:Debug>:-g>)

Expand Down
32 changes: 32 additions & 0 deletions src/drivers/generic/initrd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# drivers/generic/initrd/CMakeLists.txt
#
# Copyright (c) 2024 Omar Berrow

add_executable(initrd "main.c" "parse.c")

target_compile_options(initrd
PRIVATE $<$<COMPILE_LANGUAGE:C>:${TARGET_DRIVER_COMPILE_OPTIONS_C}>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-ffreestanding>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wall>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wextra>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-fstack-protector-all>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-fno-builtin-memset>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-fvisibility=hidden>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-fPIC>
)

set_property(TARGET initrd PROPERTY link_depends ${DRIVER_LINKER_SCRIPT})

target_include_directories(initrd
PRIVATE "${CMAKE_SOURCE_DIR}/src/oboskrnl"
PRIVATE ${OBOSKRNL_EXTERNAL_INCLUDES})

target_link_options(initrd
PRIVATE "-nostdlib"
PRIVATE "-Wl,-pic"
PRIVATE "-T${DRIVER_LINKER_SCRIPT}"
PRIVATE "-Wl,-shared"
# PRIVATE "-Wl,--allow-shlib-undefined"
PRIVATE ${TARGET_DRIVER_LINKER_OPTIONS}
)
target_compile_definitions(initrd PRIVATE OBOS_DRIVER=1)
Loading