diff --git a/Doxyfile b/Doxyfile index 430a677..134b4bc 100644 --- a/Doxyfile +++ b/Doxyfile @@ -829,8 +829,11 @@ WARN_LOGFILE = # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING # Note: If this tag is empty the current directory is searched. -INPUT = ./kernel ./kernel/device ./kernel/lib ./kernel/core \ - ./kernel/proc ./kernel/fs ./kernel/test +INPUT = ./kernel ./kernel/device/display \ + ./kernel/device/keyboard ./kernel/device/storage \ + ./kernel/base ./kernel/sys \ + ./kernel/proc ./kernel/fs ./kernel/mm \ + ./libc ./userspace # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses diff --git a/kernel/base/hash.c b/kernel/base/hash.c index 86347f5..b79cd29 100644 --- a/kernel/base/hash.c +++ b/kernel/base/hash.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file hash.c + @brief Implementation of a simple hash table + @details + @verbatim + + This file contains the implementation of a simple hash table used within + the HanOS kernel. It includes functions for initializing the hash table, + searching for a key, inserting a key-value pair, and deleting a key. + The hash table uses open addressing for collision resolution. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/kernel/base/hash.h b/kernel/base/hash.h index c233a7e..0280b09 100644 --- a/kernel/base/hash.h +++ b/kernel/base/hash.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file hash.h + @brief Hash table definitions + @details + @verbatim + + This file contains the type definitions and function declarations for the + hash table implementation used within the HanOS kernel. It includes the + structure definitions for hash table items and the hash table itself, + as well as the function prototypes for initializing, searching, inserting, + and deleting entries in the hash table. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define HT_DEFAULT_ARRAY_SIZE 128 diff --git a/kernel/base/image.c b/kernel/base/image.c index a1346be..65bed76 100644 --- a/kernel/base/image.c +++ b/kernel/base/image.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file image.c + @brief Implementation of image handling functions + @details + @verbatim + + This file contains the implementation of functions for handling images within + the HanOS kernel. It includes the function for loading BMP images from a file + into an image structure. The BMP loading function reads the file, parses the + BMP header, and extracts the image data for use within the kernel. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/kernel/base/image.h b/kernel/base/image.h index be47647..98eaeeb 100644 --- a/kernel/base/image.h +++ b/kernel/base/image.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file image.h + @brief Image handling definitions + @details + @verbatim + + This file contains the type definitions and function declarations for image + handling within the HanOS kernel. It includes the structure definition for + representing an image and a function prototype for loading a BMP image from + a file. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/base/klib.h b/kernel/base/klib.h index 1a6f6f6..aa94848 100644 --- a/kernel/base/klib.h +++ b/kernel/base/klib.h @@ -1,8 +1,7 @@ /**----------------------------------------------------------------------------- @file klib.h - @brief Definition of fundamental data structures, macros and functions for - the kernel + @brief Definition of fundamental data structures, macros and functions @details @verbatim diff --git a/kernel/device/display/edid.h b/kernel/device/display/edid.h index 0f8fe5d..b687176 100644 --- a/kernel/device/display/edid.h +++ b/kernel/device/display/edid.h @@ -1,3 +1,22 @@ +/**----------------------------------------------------------------------------- + + @file edid.h + @brief EDID (Extended Display Identification Data) definitions + @details + @verbatim + + This file contains the type definitions related to EDID (Extended Display + Identification Data) used within the HanOS kernel. The EDID data structure + provides detailed information about a display device's capabilities. This + includes the manufacturer ID, serial number, week and year of manufacture, + EDID version and revision, video input type, display size, gamma factor, + power management features, chromaticity coordinates, established timings, + standard timings, and detailed timings. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once typedef struct [[gnu::packed]] { diff --git a/kernel/device/display/gfx.c b/kernel/device/display/gfx.c index fd7126b..3c16827 100644 --- a/kernel/device/display/gfx.c +++ b/kernel/device/display/gfx.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file gfx.c + @brief Implementation of graphics device handling + @details + @verbatim + + This file contains the implementation of functions for handling graphics + devices within the HanOS kernel. It includes functions for initializing PCI + graphics devices, configuring graphics translation tables (GTT), managing + graphics memory, and enabling specific graphics features. It also includes + functions for entering and exiting force wake states and for allocating + graphics memory objects. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include <3rd-party/boot/limine.h> #include #include diff --git a/kernel/device/display/gfx.h b/kernel/device/display/gfx.h index 5757e0c..9a93d6b 100644 --- a/kernel/device/display/gfx.h +++ b/kernel/device/display/gfx.h @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file gfx.h + @brief Graphics device handling definitions + @details + @verbatim + + This file contains the type definitions and function declarations for handling + graphics devices within the HanOS kernel. It includes structures for + representing PCI graphics devices, graphics translation tables (GTT), graphics + objects, and memory ranges. Additionally, it provides function prototypes for + initializing and starting the graphics system, as well as macros for + interacting with memory-mapped I/O registers of the graphics device. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once typedef struct { diff --git a/kernel/device/display/gfx_reg.h b/kernel/device/display/gfx_reg.h index eacb4bd..783a758 100644 --- a/kernel/device/display/gfx_reg.h +++ b/kernel/device/display/gfx_reg.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file gfx_reg.h + @brief Graphics device register definitions + @details + @verbatim + + This file contains the definitions of various registers and constants used + for handling graphics devices within the HanOS kernel. It includes bit masks + and shifts for manipulating register values, as well as addresses for memory + mapped I/O registers related to graphics memory management, GTT (Graphics + Translation Table), and display control. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define MASKED_ENABLE(x) (((x) << 16) | (x)) diff --git a/kernel/device/keyboard/keycode.h b/kernel/device/keyboard/keycode.h index 9c60736..26e6e50 100644 --- a/kernel/device/keyboard/keycode.h +++ b/kernel/device/keyboard/keycode.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file keycode.h + @brief Keycode definitions for keyboard driver + @details + @verbatim + + This file contains the keycode definitions and function declarations used in + the HanOS keyboard driver. It defines constants for common keyboard keys such + as arrow keys, backspace, caps lock, enter, control, shift, and tab. It also + declares a function for converting scancode inputs into ASCII characters + considering the shift and caps lock states. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define KB_ARROW_UP 72 diff --git a/kernel/device/storage/ata.c b/kernel/device/storage/ata.c index f8fad1a..4a0e884 100644 --- a/kernel/device/storage/ata.c +++ b/kernel/device/storage/ata.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file ata.c + @brief Implementation of ATA (Advanced Technology Attachment) device handling + @details + @verbatim + + This file contains the implementation of functions for handling ATA devices + within the HanOS kernel. It includes functions for initializing and detecting + ATA and ATAPI devices, performing PIO read and write operations, and reading + partition maps. Additionally, it provides utility functions for interacting + with ATA registers and handling device-specific operations such as soft + resets and polling for device status. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/kernel/device/storage/ata.h b/kernel/device/storage/ata.h index 757d407..403e59d 100644 --- a/kernel/device/storage/ata.h +++ b/kernel/device/storage/ata.h @@ -1,3 +1,22 @@ +/**----------------------------------------------------------------------------- + + @file ata.h + @brief ATA (Advanced Technology Attachment) definitions + @details + @verbatim + + This file contains the type definitions, constants, and function declarations + for handling ATA devices within the HanOS kernel. It includes definitions for + ATA status and error codes, command codes, identification fields, and + register addresses. It also defines structures for representing IDE channels, + devices, partitions, and ATA identity information, as well as function + prototypes for initializing ATA devices and performing PIO read and write + operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define ATA_SR_BSY 0x80 diff --git a/kernel/fs/filebase.c b/kernel/fs/filebase.c index 3228011..1c8f379 100644 --- a/kernel/fs/filebase.c +++ b/kernel/fs/filebase.c @@ -76,8 +76,8 @@ vfs_node_desc_t *vfs_handle_to_fd(vfs_handle_t handle, const char *func) { task_t *t = sched_get_current_task(); if (t != NULL) { - vfs_node_desc_t* nd = (vfs_node_desc_t*)ht_search(&(t->open_files_table), handle); - if (nd != NULL) return nd; + vfs_node_desc_t* fd = (vfs_node_desc_t*)ht_search(&(t->open_files_table), handle); + if (fd != NULL) return fd; klogw("VFS: %s() cannot locate %d (0x%x) in file list of task %d\n", func, handle, handle, t->tid); } diff --git a/kernel/fs/pipefs.c b/kernel/fs/pipefs.c index 61dc3f1..50f99a3 100644 --- a/kernel/fs/pipefs.c +++ b/kernel/fs/pipefs.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file pipefs.c + @brief Implementation of PipeFS functions + @details + @verbatim + + This file contains the implementation of the PipeFS, a simple filesystem for + handling pipe files within the HanOS Kernel. It provides functions for + mounting, creating, removing, opening, reading, and writing pipe files. The + PipeFS is designed to facilitate inter-process communication by using pipes + as a means to transfer data between processes. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/fs/pipefs.h b/kernel/fs/pipefs.h index 1dc0e0e..d78669f 100644 --- a/kernel/fs/pipefs.h +++ b/kernel/fs/pipefs.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file pipefs.h + @brief Definition of PipeFS related data structures and functions + @details + @verbatim + + PipeFS is a simple file system designed to handle pipe files within the HanOS + Kernel. It provides basic file system operations such as mounting, creating, + removing, opening, reading, and writing pipe files. This file defines the + necessary data structures and function prototypes used by PipeFS. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/fs/ramfs.c b/kernel/fs/ramfs.c index 96dc2f9..8cdcf27 100644 --- a/kernel/fs/ramfs.c +++ b/kernel/fs/ramfs.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file ramfs.c + @brief Implementation of RAMFS functions + @details + @verbatim + + This file contains the implementation of the RAMFS, a simple filesystem that + resides entirely in memory. It provides functions for mounting, creating, + removing, opening, reading, writing, and syncing files. The RAMFS is designed + to facilitate fast in-memory file operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/kernel/fs/ramfs.h b/kernel/fs/ramfs.h index 21e2890..7a109c5 100644 --- a/kernel/fs/ramfs.h +++ b/kernel/fs/ramfs.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file ramfs.h + @brief Definition of RAMFS related data structures and functions + @details + @verbatim + + RAMFS is a simple filesystem that resides entirely in memory. It provides + basic file system operations such as mounting, creating, removing, opening, + reading, writing, and syncing files. This file defines the necessary data + structures and function prototypes used by RAMFS. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/fs/ttyfs.c b/kernel/fs/ttyfs.c index 9e886f2..940f9ba 100644 --- a/kernel/fs/ttyfs.c +++ b/kernel/fs/ttyfs.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file ttyfs.c + @brief Implementation of TTYFS functions + @details + @verbatim + + This file contains the implementation of the TTYFS (Teletypewriter Filesystem), + a simple filesystem designed to handle TTY files within the HanOS Kernel. It + provides functions for mounting, creating, opening, reading, writing, and + syncing TTY files, as well as handling IO control operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/fs/ttyfs.h b/kernel/fs/ttyfs.h index f1cf0fc..bfc0831 100644 --- a/kernel/fs/ttyfs.h +++ b/kernel/fs/ttyfs.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file ttyfs.h + @brief Definition of TTYFS related data structures and functions + @details + @verbatim + + TTYFS is a simple filesystem designed to handle TTY (teletypewriter) files + within the HanOS Kernel. It provides basic file system operations such as + mounting, creating, opening, reading, writing, and syncing TTY files. This + file defines the necessary data structures and function prototypes used by + TTYFS. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/fs/vfs.c b/kernel/fs/vfs.c index 3153d1f..af3c52d 100644 --- a/kernel/fs/vfs.c +++ b/kernel/fs/vfs.c @@ -352,35 +352,35 @@ int64_t vfs_unlink(char *path) /* Write specified number of bytes to file */ int64_t vfs_write(vfs_handle_t handle, uint64_t len, const void *buff) { - vfs_node_desc_t *nd = vfs_handle_to_fd(handle, __func__); - if (!nd) + vfs_node_desc_t *fd = vfs_handle_to_fd(handle, __func__); + if (!fd) return 0; /* Cannot write to read-only files */ - if (nd->mode == VFS_MODE_READ) { - kloge("File handle %d is read only, nd = 0x%x\n", handle, nd); + if (fd->mode == VFS_MODE_READ) { + kloge("File handle %d is read only, nd = 0x%x\n", handle, fd); return 0; } lock_lock(&vfs_lock); - vfs_inode_t* inode = nd->inode; + vfs_inode_t* inode = fd->inode; /* Expand file if writing more data than its size */ - if (nd->seek_pos + len > inode->size) { - inode->size = nd->seek_pos + len; + if (fd->seek_pos + len > inode->size) { + inode->size = fd->seek_pos + len; if (inode->fs->sync != NULL) inode->fs->sync(inode); } - int64_t status = inode->fs->write(inode, nd->seek_pos, len, buff); + int64_t status = inode->fs->write(inode, fd->seek_pos, len, buff); if (status == -1) { len = 0; } else { /* Move seek position to the tail of writing area */ - nd->seek_pos += len; + fd->seek_pos += len; } /* Set file size to stat data structure */ - nd->tnode->st.st_size = nd->inode->size; + fd->tnode->st.st_size = fd->inode->size; lock_release(&vfs_lock); return (int64_t)len; @@ -512,18 +512,18 @@ vfs_handle_t vfs_open(char *path, vfs_openmode_t mode) req->inode->refcount++; /* Create node descriptor */ - vfs_node_desc_t* nd = (vfs_node_desc_t*)kmalloc(sizeof(vfs_node_desc_t)); - memset(nd, 0, sizeof(vfs_node_desc_t)); + vfs_node_desc_t* fd = (vfs_node_desc_t*)kmalloc(sizeof(vfs_node_desc_t)); + memset(fd, 0, sizeof(vfs_node_desc_t)); - strcpy(nd->path, path); - nd->tnode = req; - nd->inode = req->inode; - nd->seek_pos = 0; - nd->mode = mode; + strcpy(fd->path, path); + fd->tnode = req; + fd->inode = req->inode; + fd->seek_pos = 0; + fd->mode = mode; /* If this is a symlink, we should set the real file size */ /* TODO: Need to consider in the future */ - nd->tnode->st.st_size = req->inode->size; + fd->tnode->st.st_size = req->inode->size; /* Return the handle */ vfs_handle_t fh = vfs_next_handle++; @@ -531,7 +531,7 @@ vfs_handle_t vfs_open(char *path, vfs_openmode_t mode) /* Add to current task */ task_t *t = sched_get_current_task(); if (t != NULL) { - ht_insert(&(t->open_files_table), fh, nd); + ht_insert(&(t->open_files_table), fh, fd); } else { kloge("VFS: cannot insert \"%s\" because of invalid task\n", path); } @@ -540,10 +540,10 @@ vfs_handle_t vfs_open(char *path, vfs_openmode_t mode) if (strcmp(path, "/dev/tty") != 0) { klogd("VFS: Open %s with mode 0x%x and return handle %d, " - "nd = 0x%x, inode = 0x%x\n", path, mode, fh, nd, nd->inode); + "nd = 0x%x, inode = 0x%x\n", path, mode, fh, fd, fd->inode); } else { klogv("VFS: Open %s with mode 0x%x and return handle %d, " - "nd = 0x%x, inode = 0x%x\n", path, mode, fh, nd, nd->inode); + "nd = 0x%x, inode = 0x%x\n", path, mode, fh, fd, fd->inode); } return fh; @@ -559,21 +559,21 @@ int64_t vfs_close(vfs_handle_t handle) lock_lock(&vfs_lock); - vfs_node_desc_t *nd = vfs_handle_to_fd(handle, __func__); - if (!nd) + vfs_node_desc_t *fd = vfs_handle_to_fd(handle, __func__); + if (!fd) goto fail; - if (strcmp(nd->path, "/dev/tty") == 0) istty = true; - if (strncmp(nd->path, "/dev/pipe", 9) == 0) { - if ((nd->mode & VFS_MODE_WRITE) && nd->seek_pos > 0) { + if (strcmp(fd->path, "/dev/tty") == 0) istty = true; + if (strncmp(fd->path, "/dev/pipe", 9) == 0) { + if ((fd->mode & VFS_MODE_WRITE) && fd->seek_pos > 0) { klogi("VFS: write EOF to %s with seek position %d\n", - nd->path, nd->seek_pos); + fd->path, fd->seek_pos); lock_release(&vfs_lock); vfs_write(handle, 4, pipe_eof_magic_word); lock_lock(&vfs_lock); } } - nd->inode->refcount--; + fd->inode->refcount--; task_t *t = sched_get_current_task(); if (t != NULL) { @@ -583,14 +583,14 @@ int64_t vfs_close(vfs_handle_t handle) } /* Remove this file if needed */ - if (nd->inode->refcount == 0 && nd->tnode->st.st_nlink == 0) { - if (nd->inode->fs->rmnode != NULL) { - klogd("VFS: close \"%s\" and remove tnode\n", nd->path); - nd->inode->fs->rmnode(nd->tnode); + if (fd->inode->refcount == 0 && fd->tnode->st.st_nlink == 0) { + if (fd->inode->fs->rmnode != NULL) { + klogd("VFS: close \"%s\" and remove tnode\n", fd->path); + fd->inode->fs->rmnode(fd->tnode); } } - kmfree(nd); + kmfree(fd); lock_release(&vfs_lock); @@ -605,18 +605,18 @@ int64_t vfs_close(vfs_handle_t handle) int64_t vfs_refresh(vfs_handle_t handle) { - vfs_node_desc_t *nd = vfs_handle_to_fd(handle, __func__); - if (!nd) + vfs_node_desc_t *fd = vfs_handle_to_fd(handle, __func__); + if (!fd) return -1; lock_lock(&vfs_lock); - nd->inode->fs->refresh(nd->inode); + fd->inode->fs->refresh(fd->inode); for (uint64_t i = 0; ; i++) { vfs_dirent_t de; - if (nd->inode->fs->getdent(nd->inode, i, &de)) break; + if (fd->inode->fs->getdent(fd->inode, i, &de)) break; char path[VFS_MAX_PATH_LEN] = {0}; - strcpy(path, nd->path); + strcpy(path, fd->path); strcat(path, "/"); strcat(path, de.name); vfs_tnode_t* tn = vfs_path_to_node(path, CREATE, de.type); @@ -631,14 +631,14 @@ int64_t vfs_refresh(vfs_handle_t handle) /* Get next directory entry */ int64_t vfs_getdent(vfs_handle_t handle, vfs_dirent_t* dirent) { int64_t status; - vfs_node_desc_t *nd = vfs_handle_to_fd(handle, __func__); - if (!nd) + vfs_node_desc_t *fd = vfs_handle_to_fd(handle, __func__); + if (!fd) return -1; lock_lock(&vfs_lock); /* Can only traverse folders */ - if (!IS_TRAVERSABLE(nd->inode)) { + if (!IS_TRAVERSABLE(fd->inode)) { kloge("Node not traversable\n"); status = -1; goto done; @@ -647,20 +647,20 @@ int64_t vfs_getdent(vfs_handle_t handle, vfs_dirent_t* dirent) { /* Need to make sure that we alreay load all children here */ /* We've reached the end */ - if (nd->seek_pos >= nd->inode->child.len) { + if (fd->seek_pos >= fd->inode->child.len) { status = 0; goto done; } /* Initialize the dirent */ - vfs_tnode_t* entry = vec_at(&(nd->inode->child), nd->seek_pos); + vfs_tnode_t* entry = vec_at(&(fd->inode->child), fd->seek_pos); dirent->type = entry->inode->type; memcpy(dirent->name, entry->name, sizeof(entry->name)); memcpy(&dirent->tm, &entry->inode->tm, sizeof(tm_t)); /* We're done here, advance the offset */ status = 1; - nd->seek_pos++; + fd->seek_pos++; done: lock_release(&vfs_lock); diff --git a/kernel/kconfig.h b/kernel/kconfig.h index 30f9a9d..011e2a3 100644 --- a/kernel/kconfig.h +++ b/kernel/kconfig.h @@ -1,3 +1,18 @@ +/**----------------------------------------------------------------------------- + + @file kconfig.h + @brief Kernel configuration header + @details + @verbatim + + This header file contains configuration macros and type definitions used in + the HanOS kernel. It includes standard headers and defines various + configuration options and default values for the kernel. + +@endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/mm/alloc.c b/kernel/mm/alloc.c index 7bdc608..1789564 100644 --- a/kernel/mm/alloc.c +++ b/kernel/mm/alloc.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file alloc.c + @brief Implementation of memory allocation functions + @details + @verbatim + + This file contains the implementation of memory allocation functions for the + HanOS kernel. The allocator uses a slab allocation mechanism to manage memory + with different cache sizes. Functions for initializing the allocator, as well + as allocating, reallocating, and freeing memory are provided. Each allocation + includes metadata for capacity and size, and optionally a poison value for + debugging purposes. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/mm/alloc.h b/kernel/mm/alloc.h index 5a93407..22ec3d9 100644 --- a/kernel/mm/alloc.h +++ b/kernel/mm/alloc.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file alloc.h + @brief Memory allocation definitions + @details + @verbatim + + This file contains the function declarations and constants used for memory + allocation within the HanOS kernel. It includes the initialization function + for the allocator, and functions for allocating, reallocating, and freeing + memory. It also defines the maximum size of memory that can be allocated. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/mm/slab.c b/kernel/mm/slab.c index 5888915..417b986 100644 --- a/kernel/mm/slab.c +++ b/kernel/mm/slab.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file slab.c + @brief Implementation of slab allocator + @details + @verbatim + + This file contains the implementation of a slab allocator for managing + memory allocation in the HanOS kernel. It defines functions for creating and + managing slab caches, allocating and freeing memory from these caches, and + initializing and destructing objects within slabs. The slab allocator + optimizes memory usage by dividing memory into small, fixed-size chunks and + reusing them efficiently. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/mm/slab.h b/kernel/mm/slab.h index 33b6991..41dc042 100644 --- a/kernel/mm/slab.h +++ b/kernel/mm/slab.h @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file slab.h + @brief Slab allocator definitions + @details + @verbatim + + This file contains the type definitions and function declarations for the + slab allocator used in the HanOS kernel. It defines structures for representing + slabs and slab caches, and provides function prototypes for allocating and + freeing memory from these caches. Additionally, it includes functions for + creating and destroying slab caches, each with customizable constructors and + destructors for initializing and cleaning up objects. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/proc/elf.c b/kernel/proc/elf.c index cff0dcd..045f0ad 100644 --- a/kernel/proc/elf.c +++ b/kernel/proc/elf.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file elf.c + @brief Implementation of ELF file loading and handling functions + @details + @verbatim + + This file contains the implementation of functions required to load and handle + ELF (Executable and Linkable Format) files within the HanOS Kernel. It includes + functions to read ELF headers, program headers, section headers, and symbols. + It also handles memory mapping and dynamic linking where necessary. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/kernel/proc/elf.h b/kernel/proc/elf.h index 3ad23fc..9e0251a 100644 --- a/kernel/proc/elf.h +++ b/kernel/proc/elf.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file elf.h + @brief Definitions for ELF file format structures and constants + @details + @verbatim + + This file contains definitions for the structures and constants used to + interpret and manipulate ELF (Executable and Linkable Format) files within + the HanOS Kernel. It includes definitions for ELF headers, program headers, + section headers, and other related data structures. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/kernel/proc/eventbus.c b/kernel/proc/eventbus.c index a8023b5..1613d37 100644 --- a/kernel/proc/eventbus.c +++ b/kernel/proc/eventbus.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file eventbus.c + @brief Implementation of the event bus system + @details + @verbatim + + This file contains the implementation of the event bus system used in the HanOS + kernel. The event bus allows tasks to publish and subscribe to events, enabling + inter-task communication and event-driven execution. The functions provided + facilitate publishing events, subscribing to events, and dispatching events to + their respective handlers. The event bus is designed to handle specific types of + events, such as key press events. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/proc/eventbus.h b/kernel/proc/eventbus.h index 7f058bf..ad3b7c9 100644 --- a/kernel/proc/eventbus.h +++ b/kernel/proc/eventbus.h @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file eventbus.h + @brief Definitions for the event bus system + @details + @verbatim + + This file contains the definitions for the event bus system used in the HanOS + kernel. The event bus allows tasks to publish and subscribe to events, +enabling + inter-task communication and event-driven execution. The functions provided + facilitate publishing events, subscribing to events, and dispatching events to + their respective handlers. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once /* Event related data structures are defined in task.h */ diff --git a/kernel/proc/signal.c b/kernel/proc/signal.c index 6834906..d008259 100644 --- a/kernel/proc/signal.c +++ b/kernel/proc/signal.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file signal.c + @brief Implementation of signal handling functions + @details + @verbatim + + This file contains the implementation of functions required to handle signals + within the HanOS kernel. It includes functions to set signal actions, change + signal masks, and manage the default actions for various signals. The signal + handling mechanism allows tasks to handle asynchronous events such as interrupts, + exceptions, and inter-process communication. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/proc/signal.h b/kernel/proc/signal.h index 28ea161..4c2818c 100644 --- a/kernel/proc/signal.h +++ b/kernel/proc/signal.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file signal.h + @brief Definitions for signal handling + @details + @verbatim + + This file contains the definitions and structures used for signal handling + within the HanOS kernel. It includes definitions for signal sets, signal + actions, and various signal-related constants. The functions provided allow + for setting signal actions, changing signal masks, and managing signals + within tasks. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include @@ -152,7 +169,7 @@ typedef struct { #define SIG_ACTION_STOP 3 #define SIG_ACTION_CONT 4 -typedef struct _task_t task_t; /* Definition in task.h */ +typedef struct task_t task_t; /* Definition in task.h */ void signal_action(task_t *t, int64_t signal, sigaction_t *new, sigaction_t *old); void signal_changemask(task_t *t, int64_t how, sigset_t *new, sigset_t *old); diff --git a/kernel/proc/syscall.c b/kernel/proc/syscall.c index a212756..78ec9de 100644 --- a/kernel/proc/syscall.c +++ b/kernel/proc/syscall.c @@ -1,5 +1,21 @@ -/* Ref: Page 2994 in Intel® 64 and IA-32 Architectures Software Developer’s - * Manual Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4 +/**----------------------------------------------------------------------------- + + @file syscall.c + @brief Implementation of system calls + @details + @verbatim + + This file contains the implementation of system calls within the HanOS kernel. + System calls provide an interface for user space applications to request services + from the kernel. This file defines various system call handlers, including those + for file operations, process management, memory management, and signal handling. + + Ref: Page 2994 in Intel® 64 and IA-32 Architectures Software Developer’s Manual + Combined Volumes: 1, 2A, 2B, 2C, 2D, 3A, 3B, 3C, 3D, and 4 + + @endverbatim + + **----------------------------------------------------------------------------- */ #include #include diff --git a/kernel/proc/syscall.h b/kernel/proc/syscall.h index 28bdd14..80922c6 100644 --- a/kernel/proc/syscall.h +++ b/kernel/proc/syscall.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file syscall.h + @brief Definitions and declarations for system calls + @details + @verbatim + + This file contains the definitions and declarations for system calls within + the HanOS kernel. System calls provide an interface for user space applications + to request services from the operating system kernel. The file includes + syscall numbers, macros, and function prototypes necessary for implementing + and handling system calls. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define SYSCALL_DEBUGLOG 0 diff --git a/kernel/proc/task.h b/kernel/proc/task.h index 9c095c7..600be70 100644 --- a/kernel/proc/task.h +++ b/kernel/proc/task.h @@ -204,7 +204,7 @@ typedef struct { vfs_handle_t newfh; } file_dup_t; -typedef struct _task_t { +typedef struct task_t { void *tstack_top; void *tstack_limit; diff --git a/kernel/proc/wait.h b/kernel/proc/wait.h index e44b835..bc1f689 100644 --- a/kernel/proc/wait.h +++ b/kernel/proc/wait.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file wait.h + @brief Definitions for process wait options and macros + @details + @verbatim + + This file contains definitions and macros used for process waiting options + within the HanOS kernel. The macros provided are used to determine the status + of a process that has been waited on, including whether it has exited, was + stopped, continued, or terminated by a signal. These definitions are essential + for handling process synchronization and management in the kernel. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define WCONTINUED 1 diff --git a/kernel/sys/cpu.h b/kernel/sys/cpu.h index 617d83a..f74c60f 100644 --- a/kernel/sys/cpu.h +++ b/kernel/sys/cpu.h @@ -1,4 +1,5 @@ /**----------------------------------------------------------------------------- + @file cpu.h @brief Definition of CPU related data structures and macros @details @@ -8,6 +9,7 @@ specific registers and port input & output. @endverbatim + **----------------------------------------------------------------------------- */ #pragma once diff --git a/kernel/sys/mtrr.h b/kernel/sys/mtrr.h index 19e0c6a..b7fe0cc 100644 --- a/kernel/sys/mtrr.h +++ b/kernel/sys/mtrr.h @@ -1,4 +1,5 @@ /**----------------------------------------------------------------------------- + @file mtrr.h @brief Definition of MTRR macros and save/restore functions @details @@ -8,6 +9,7 @@ modified values. @endverbatim + **----------------------------------------------------------------------------- */ #pragma once diff --git a/kernel/sys/serial.c b/kernel/sys/serial.c index 5f3e59b..c4b37e2 100644 --- a/kernel/sys/serial.c +++ b/kernel/sys/serial.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file serial.c + @brief Implementation of serial port communication functions + @details + @verbatim + + This file contains the implementation of functions to initialize and use the + serial port for communication in the HanOS kernel. It sets up the serial port + with the specified baud rate and configuration, and provides functions to + write individual characters and strings to the serial port. The initialization + function ensures the serial port is properly configured before any data is sent. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/kernel/sys/serial.h b/kernel/sys/serial.h index 12ffa18..00e8dfe 100644 --- a/kernel/sys/serial.h +++ b/kernel/sys/serial.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file serial.h + @brief Definitions for serial port communication + @details + @verbatim + + This file contains the function declarations and constants used for serial + port communication within the HanOS kernel. It includes the initialization + function for the serial port, and functions for writing individual characters + and strings to the serial port. The serial port base address is also defined. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define SERIAL_PORT 0x3F8 diff --git a/kernel/version.h b/kernel/version.h index 8c2b7d9..76d46ed 100644 --- a/kernel/version.h +++ b/kernel/version.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file version.h + @brief Definition of version information + @details + @verbatim + + This file defines the version information for the HanOS Kernel. The version + information is broken down into major, minor, and patch levels. These values + are combined to form a version string that can be used to identify the + specific version of the kernel. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define major 0 diff --git a/libc/ctype.c b/libc/ctype.c index d876b35..bcbca79 100644 --- a/libc/ctype.c +++ b/libc/ctype.c @@ -1,3 +1,22 @@ +/**----------------------------------------------------------------------------- + + @file ctype.c + @brief Implementation of character type and conversion functions + @details + @verbatim + + This file contains the implementation of functions for character type checking + and conversion in the HanOS standard library. The functions include checks for + alphanumeric characters, alphabetic characters, blank characters, control + characters, digits, graphical characters, lowercase characters, printable + characters, punctuation, whitespace characters, uppercase characters, and + hexadecimal digits. Additionally, it provides functions to convert characters + to lowercase and uppercase. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include int isalnum(int c) diff --git a/libc/ctype.h b/libc/ctype.h index 495b002..15e1b28 100644 --- a/libc/ctype.h +++ b/libc/ctype.h @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file ctype.h + @brief Character type and conversion functions for HanOS standard library + @details + @verbatim + + This file contains the declarations of functions used for character type + checking and conversion in the HanOS standard library. It includes functions + to check if a character is alphanumeric, alphabetic, blank, control, digit, + graphical, lowercase, printable, punctuation, whitespace, uppercase, or + hexadecimal digit. Additionally, it provides functions to convert characters + to lowercase and uppercase. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/libc/errno.h b/libc/errno.h index b0b44bf..b92eb81 100644 --- a/libc/errno.h +++ b/libc/errno.h @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file errno.h + @brief Error number definitions for HanOS standard library + @details + @verbatim + + This file defines a set of error numbers (errno) used in the HanOS standard + library. These error numbers represent various error conditions that might + be encountered during system and library calls. Each error number is + associated with a specific type of error, such as file not found, permission + denied, or out of memory. These definitions help standardize error handling + across the operating system and its libraries. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #define EDOM 1 /* Math argument out of domain of func */ diff --git a/libc/numeric.c b/libc/numeric.c index b61753e..cdbe972 100644 --- a/libc/numeric.c +++ b/libc/numeric.c @@ -1,3 +1,21 @@ +/**----------------------------------------------------------------------------- + + @file numeric.c + @brief Implementation of numeric utility functions + @details + @verbatim + + This file contains the implementation of utility functions for numeric + operations in the HanOS standard library. It includes the implementation of + the function to convert an integer to a string representation (itoa), a + helper function to reverse a string, and a function to generate a random + integer within a specified range based on a seed value using a linear + congruential generator (rand). + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include /* Below code is generated by Baidu Wenxin */ diff --git a/libc/numeric.h b/libc/numeric.h index afd02a5..5461288 100644 --- a/libc/numeric.h +++ b/libc/numeric.h @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file numeric.h + @brief Numeric utility functions for HanOS standard library + @details + @verbatim + + This file contains the declarations of utility functions for numeric + operations in the HanOS standard library. It includes the function to + convert an integer to a string representation (itoa) and a function to + generate a random integer within a specified range based on a seed value. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/libc/printf.h b/libc/printf.h index 9af06b5..78478dd 100644 --- a/libc/printf.h +++ b/libc/printf.h @@ -1,3 +1,10 @@ +/**----------------------------------------------------------------------------- + + @file printf.h + @brief printf, sprintf and snprintf implementation for HanOS standard library + + **----------------------------------------------------------------------------- + */ /////////////////////////////////////////////////////////////////////////////// // \author (c) Marco Paland (info@paland.com) // 2014-2019, PALANDesign Hannover, Germany diff --git a/libc/stdio.h b/libc/stdio.h index 1a9953e..4bda58b 100644 --- a/libc/stdio.h +++ b/libc/stdio.h @@ -1,3 +1,23 @@ +/**----------------------------------------------------------------------------- + + @file stdio.h + @brief Standard I/O definitions and declarations for HanOS standard library + @details + @verbatim + + This file provides the declarations for standard input/output functions and + definitions for file system structures and constants used in HanOS. It +includes + definitions for standard file descriptors (STDIN, STDOUT, STDERR), the +end-of-file + marker (EOF), and file system structures such as timespec_t, dirent_t, and +stat_t. + Additionally, it defines various file types and modes. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/libc/sysfunc.c b/libc/sysfunc.c index 59096af..2f35f6c 100644 --- a/libc/sysfunc.c +++ b/libc/sysfunc.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file sysfunc.c + @brief Implementation of system call functions + @details + @verbatim + + This file contains the implementation of system call functions for HanOS. + It includes various system call wrappers that provide interfaces for common + operations such as file handling, process management, memory allocation, + and logging. These functions utilize inline assembly to perform the actual + system calls. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include #include diff --git a/libc/sysfunc.h b/libc/sysfunc.h index 16f4323..880d791 100644 --- a/libc/sysfunc.h +++ b/libc/sysfunc.h @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file sysfunc.h + @brief System call function declarations and related macros + @details + @verbatim + + This file contains the declarations of system call functions and related + macros used in the HanOS operating system. It includes definitions for + various file descriptor constants, access modes, and flags. The system call + functions provide interfaces for common operations such as file handling, + process management, and memory allocation. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #pragma once #include diff --git a/userspace/cat.c b/userspace/cat.c index ddb0a28..388dcbf 100644 --- a/userspace/cat.c +++ b/userspace/cat.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file cat.c + @brief Implementation of the 'cat' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'cat' command which is used to + concatenate and display files on the standard output. It includes the main + function to handle command-line arguments and the cat function for reading + from a file descriptor and writing to standard output. Error handling is + included for read and write operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/echo.c b/userspace/echo.c index dba2587..4c165f4 100644 --- a/userspace/echo.c +++ b/userspace/echo.c @@ -1,3 +1,22 @@ +/**----------------------------------------------------------------------------- + + @file echo.c + @brief Implementation of the 'echo' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'echo' command which is used to + display a specified string. It includes the main function to handle +command-line + arguments and output them to the standard output, separated by spaces and +followed + by a newline. This command is useful for displaying messages or concatenating + command-line arguments. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/hansh.c b/userspace/hansh.c index 09006b9..63592a1 100644 --- a/userspace/hansh.c +++ b/userspace/hansh.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file hansh.c + @brief Implementation of the HanOS shell (hansh) for userspace + @details + @verbatim + + This file provides the implementation of the HanOS shell (hansh) which is used + to execute user commands in the HanOS operating system. It includes functions + for parsing and executing commands, handling input and output redirection, + and managing processes. The shell supports command execution, piping, background + processes, and command lists. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/init.c b/userspace/init.c index 0a3e1bb..35ecf91 100644 --- a/userspace/init.c +++ b/userspace/init.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file init.c + @brief Initialization process for HanOS userspace + @details + @verbatim + + This file provides the implementation of the initialization process for the + HanOS userspace. It includes the main function that continuously starts the + shell (hansh) by forking and executing the shell program. The init process is + responsible for ensuring that the shell is always running and handles the + necessary process management. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/ls.c b/userspace/ls.c index 1921065..73e4a0a 100644 --- a/userspace/ls.c +++ b/userspace/ls.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file ls.c + @brief Implementation of the 'ls' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'ls' command which is used to + list the contents of a specified directory. It includes functions for formatting + directory names and reading directory entries. The command displays file names, + types, inode numbers, and sizes. Error handling is included for directory + operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/pwd.c b/userspace/pwd.c index 3a63b43..3367fae 100644 --- a/userspace/pwd.c +++ b/userspace/pwd.c @@ -1,3 +1,19 @@ +/**----------------------------------------------------------------------------- + + @file pwd.c + @brief Implementation of the 'pwd' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'pwd' command which is used to + print the current working directory. It includes the main function that calls + sys_getcwd to retrieve the current directory path and then prints it to the + standard output. Error handling is included for the getcwd operation. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/rm.c b/userspace/rm.c index 6bbe08a..140659e 100644 --- a/userspace/rm.c +++ b/userspace/rm.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file rm.c + @brief Implementation of the 'rm' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'rm' command which is used to + remove files or directories in the HanOS operating system. It includes the + main function that processes command-line arguments and calls the sys_unlink + system function to delete specified files. Error handling is included for + file deletion operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include diff --git a/userspace/wc.c b/userspace/wc.c index 85126ec..210d594 100644 --- a/userspace/wc.c +++ b/userspace/wc.c @@ -1,3 +1,20 @@ +/**----------------------------------------------------------------------------- + + @file wc.c + @brief Implementation of the 'wc' command for HanOS userspace + @details + @verbatim + + This file provides the implementation of the 'wc' command which is used to + print newline, word, and byte counts for files or standard input in the + HanOS operating system. It includes functions for reading and counting + characters, words, and lines. The command processes input and outputs the + counts to the standard output. Error handling is included for file operations. + + @endverbatim + + **----------------------------------------------------------------------------- + */ #include #include