Changed camelCase to snake_case

This commit is contained in:
2025-04-27 19:18:33 +02:00
parent 7b5efc1837
commit 1bc758f3c1
24 changed files with 272 additions and 213 deletions
+5 -6
View File
@@ -57,8 +57,8 @@ should not be placed after/before unary operators or member access operators.
Naming
------
_The hardest thing in programming_
Identifiers should use camelCase (starting with lowercase). And may have a
short prefix separated with an underscore (e.g. 'sys_malloc').
Identifiers should use snake_case (starting with lowercase). And should have a
short prefix to indicate what system they're from (e.g. 'vmm_alloc' & 'pmm_alloc').
Global variables (that should be sparse) and global functions need good,
descriptive names. A disk reading function shouldn't be called 'dskrd()'.
@@ -69,15 +69,14 @@ should be named 'i' and not loopCounter.
Some good naming examples:
```c
// Random good function names
int32_t disk_findFreeBlock(uint32_t count);
int32_t disk_find_free_block(uint32_t count);
int32_t tty_write(const void* buf, size_t len);
uint8_t getRtcRegister(uint8_t reg);
uint8_t get_rtc_register(uint8_t reg);
// Serial functions all start with 'serial_'
int serial_init();
void serial_write(uint8_t byte);
uint8_t serial_read();
```
Labels, for 'goto' statements or assembly, should be snake_case.
@@ -212,5 +211,5 @@ For example `drivers/fat32.h would have this guard:
Hex literals
************
Hexadecimal literals are preffered over binary and should be written in uppercase.
Example: 0xA1B2
Example: 0xA1B2C0DE
+34 -4
View File
@@ -3,18 +3,48 @@ Memory Management
Memory management is split into three layers: physical, virtual & the heap.
pmm.h
-----
The **physical memory manager** (PMM) is responsible for allocating physical
memory. It gives `pmm_*` functions. The `pmm_allocPage()` function allocates a
4kB page frame and retuns its **physical address**.
vmm.h
-----
The **virtual memory manager** (VMM) is responsible for allocating virtual
memory. It provides `vmm_*` functions. The `vmm_alloc()` function takes in a
number of 4kB pages to allocate and returns the **virtual address** of the
first page. Userspace can interface with the VMM using the `mmap()` and
`munmap()` syscalls.
**The heap** is an area of memory that both kernel and user space have.
Kernel space uses the `kalloc()` and it's derivative functions for the heap.
User space may use the `brk()` and `sbrk()` syscalls to grow and shrink the
heap.
kmalloc.h
---------
The `kmalloc.h` header provides memory management functions for kernel memory.
`void* kmalloc(size_t size)`
****************************
**Parameters**
* `size_t size` - Number of bytes to allocate
**Descriptions**
This function allocates `size` bytes of contiguous memory.
**Returns**
A pointer to allocated memory or NULL.
`void* kzalloc(size_t size)`
****************************
**Parameters**
* `size_t size` - Number of bytes to allocate
**Description**
This function allocates `size` bytes of contiguous, zeroed-out memory.
**Returns**
A pointer to allocated memory or NULL.
`void* kcalloc(size_t count, size_t size)`
******************************************
**Parameters**
* `size_t count` -