Add newline at the end of the files. Use built in keywords properly.

This commit is contained in:
Enrico Fraccaroli
2022-12-13 14:31:27 -05:00
parent 0965669f4b
commit 3f73b8d8a0
26 changed files with 46 additions and 48 deletions
+1 -1
View File
@@ -60,4 +60,4 @@ void tss_init(uint8_t idx, uint32_t ss0);
void tss_set_stack(uint32_t kss, uint32_t kesp);
/// @}
/// @}
/// @}
+1 -1
View File
@@ -290,4 +290,4 @@ palette_entry_t ansi_256_palette[256] = {
{ 218, 218, 218 }, // Grey85
{ 228, 228, 228 }, // Grey89
{ 238, 238, 238 }, // Grey93
};
};
+2 -3
View File
@@ -41,9 +41,8 @@
#pragma once
/// @brief Assign the value to the given variable.
#define WRITE_ONCE(var, val) (*((volatile typeof(val) *)(&(var))) = (val))
#define WRITE_ONCE(var, val) (*((__volatile__ __typeof__(val) *)(&(var))) = (val))
/// @brief Read the value from the given variable.
#define READ_ONCE(var) (*((volatile typeof(var) *)(&(var))))
#define READ_ONCE(var) (*((__volatile__ __typeof__(var) *)(&(var))))
+2 -2
View File
@@ -12,6 +12,6 @@
/// @brief Moves the pointer up.
#define __MOVE_PTR_UP(type, ptr) ((ptr) += sizeof(type))
/// @brief First, it moves the pointer down, and then it pushes the value at that memory location.
#define PUSH_VALUE_ON_STACK(ptr, value) (__ACCESS_PTR(typeof(value), __MOVE_PTR_DOWN(typeof(value), ptr)) = (value))
#define PUSH_VALUE_ON_STACK(ptr, value) (__ACCESS_PTR(__typeof__(value), __MOVE_PTR_DOWN(__typeof__(value), ptr)) = (value))
/// @brief First, it access the value at the given memory location, and then it moves the pointer up.
#define POP_VALUE_FROM_STACK(value, ptr) ({value = __ACCESS_PTR(typeof(value), ptr); __MOVE_PTR_UP(typeof(value), ptr); })
#define POP_VALUE_FROM_STACK(value, ptr) ({value = __ACCESS_PTR(__typeof__(value), ptr); __MOVE_PTR_UP(__typeof__(value), ptr); })
+1 -1
View File
@@ -192,4 +192,4 @@ void gdt_set_gate(uint8_t index, uint32_t base, uint32_t limit, uint8_t access,
// and the data selectors ds, ss, ..., should store 35 (0x23):
// | 0000000000100| 0| 11|
// | index 4 (data) | GDT| non-privileged|
//
//
+11 -11
View File
@@ -29,23 +29,23 @@ uint8_t saves[512] __attribute__((aligned(16)));
/// @param cw What to set the control word to.
static inline void __set_fpu_cw(const uint16_t cw)
{
asm volatile("fldcw %0" ::"m"(cw));
__asm__ __volatile__("fldcw %0" ::"m"(cw));
}
/// @brief Enable the FPU and SSE.
static inline void __enable_fpu()
{
asm volatile("clts");
__asm__ __volatile__("clts");
size_t t;
asm volatile("mov %%cr0, %0"
__asm__ __volatile__("mov %%cr0, %0"
: "=r"(t));
t &= ~(1U << 2U);
t |= (1U << 1U);
asm volatile("mov %0, %%cr0" ::"r"(t));
asm volatile("mov %%cr4, %0"
__asm__ __volatile__("mov %0, %%cr0" ::"r"(t));
__asm__ __volatile__("mov %%cr4, %0"
: "=r"(t));
t |= 3U << 9U;
asm volatile("mov %0, %%cr4" ::"r"(t));
__asm__ __volatile__("mov %0, %%cr4" ::"r"(t));
}
/// Disable FPU and SSE so it traps to the kernel.
@@ -53,12 +53,12 @@ static inline void __disable_fpu()
{
size_t t;
asm volatile("mov %%cr0, %0"
__asm__ __volatile__("mov %%cr0, %0"
: "=r"(t));
t |= 1U << 3U;
asm volatile("mov %0, %%cr0" ::"r"(t));
__asm__ __volatile__("mov %0, %%cr0" ::"r"(t));
}
/// @brief Restore the FPU for a process.
@@ -68,7 +68,7 @@ static inline void __restore_fpu(task_struct *proc)
memcpy(&saves, (uint8_t *)&proc->thread.fpu_register, 512);
asm volatile("fxrstor (%0)" ::"r"(saves));
__asm__ __volatile__("fxrstor (%0)" ::"r"(saves));
}
/// Save the FPU for a process.
@@ -76,7 +76,7 @@ static inline void __save_fpu(task_struct *proc)
{
assert(proc && "Trying to save FPU of NULL process.");
asm volatile("fxsave (%0)" ::"r"(saves));
__asm__ __volatile__("fxsave (%0)" ::"r"(saves));
memcpy((uint8_t *)&proc->thread.fpu_register, &saves, 512);
}
@@ -84,7 +84,7 @@ static inline void __save_fpu(task_struct *proc)
/// Initialize the FPU.
static inline void __init_fpu()
{
asm volatile("fninit");
__asm__ __volatile__("fninit");
}
/// Kernel trap for FPU usage when FPU is disabled.
+1 -1
View File
@@ -453,4 +453,4 @@ const char *elf_symbol_bind_to_string(int bind)
if (bind == STB_WEAK)
return "WEAK";
return "-1";
}
}
+1 -1
View File
@@ -57,7 +57,7 @@ inline void outports(uint16_t port, uint16_t data)
void outportsm(uint16_t port, uint8_t *data, uint16_t size)
{
asm volatile("rep outsw"
__asm__ __volatile__("rep outsw"
: "+S"(data), "+c"(size)
: "d"(port));
}
+1 -1
View File
@@ -202,4 +202,4 @@ static ssize_t procs_do_meminfo(char *buffer, size_t bufsize)
static ssize_t procs_do_stat(char *buffer, size_t bufsize)
{
return 0;
}
}
+1 -1
View File
@@ -241,4 +241,4 @@ int procv_module_init()
video->sys_operations = &procv_sys_operations;
video->fs_operations = &procv_fs_operations;
return 0;
}
}
+1 -1
View File
@@ -890,4 +890,4 @@ void vga_update()
void vga_set_color(unsigned int color)
{
_color = color;
}
}
+1 -1
View File
@@ -428,4 +428,4 @@ void video_scroll_down()
stored_y = 0;
}
#endif
#endif
+1 -1
View File
@@ -31,4 +31,4 @@ long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf)
return 0;
}
///! @endcond
///! @endcond
+1 -1
View File
@@ -25,4 +25,4 @@ long sys_semctl(int semid, int semnum, int cmd, unsigned long arg)
return 0;
}
///! @endcond
///! @endcond
+1 -1
View File
@@ -137,4 +137,4 @@ char *realpath(const char *path, char *resolved)
else
resolved[1] = '\0';
return resolved;
}
}
+6 -6
View File
@@ -14,12 +14,12 @@ void mutex_lock(mutex_t *mutex, uint32_t owner)
while (mutex->state == 0 || failure || mutex->owner != owner) {
failure = 1;
if (mutex->state == 0) {
asm("movl $0x01,%%eax\n\t" // move 1 to eax
"xchg %%eax,%0\n\t" // try to set the lock bit
"mov %%eax,%1\n\t" // export our result to a test var
: "=m"(mutex->state), "=r"(failure)
: "m"(mutex->state)
: "%eax");
__asm__ __volatile__("movl $0x01,%%eax\n\t" // move 1 to eax
"xchg %%eax,%0\n\t" // try to set the lock bit
"mov %%eax,%1\n\t" // export our result to a test var
: "=m"(mutex->state), "=r"(failure)
: "m"(mutex->state)
: "%eax");
}
if (failure == 0) {
mutex->owner = owner; //test to see if we got the lock bit
+1 -1
View File
@@ -374,4 +374,4 @@ void ndtree_tree_visitor(ndtree_t *tree, ndtree_tree_node_f enter_fun, ndtree_tr
{
if (tree && tree->root)
__ndtree_tree_visitor_iter(tree, tree->root, enter_fun, exit_fun);
}
}
+1 -1
View File
@@ -111,4 +111,4 @@ tm_t *localtime(const time_t *time)
// Calculate day of week.
date.tm_wday = day_of_week(date.tm_year, date.tm_mon, date.tm_mday);
return &date;
}
}
+3 -3
View File
@@ -221,7 +221,7 @@ static inline void __set_pg_table_flags(page_table_entry_t *table, uint32_t flag
/// @param addr The faulting address.
static void __page_fault_panic(pt_regs *f, uint32_t addr)
{
asm volatile("cli");
__asm__ __volatile__("cli");
// Gather fault info and print to screen
pr_err("Faulting address (cr2): 0x%p\n", addr);
@@ -250,7 +250,7 @@ static void __page_fault_panic(pt_regs *f, uint32_t addr)
// main_mm->pgd->entries[addr/(1024*4096)].user = 1;
// main_directory->entries[addr/(1024*4096)]. = 1;
asm volatile("cli");
__asm__ __volatile__("cli");
}
static void __page_handle_cow(page_table_entry_t *entry)
@@ -327,7 +327,7 @@ void page_fault_handler(pt_regs *f)
// When the exception occurs, the CPU control unit stores that
// value in the cr2 control register.
uint32_t faulting_addr;
asm volatile("mov %%cr2, %0"
__asm__ __volatile__("mov %%cr2, %0"
: "=r"(faulting_addr));
// Get the physical address of the current page directory.
uint32_t phy_dir = (uint32_t)paging_get_current_directory();
+1 -1
View File
@@ -479,4 +479,4 @@ unsigned long get_zone_cached_space(gfp_t gfp_mask)
zone_t *zone = get_zone_from_flags(gfp_mask);
assert(zone && "Cannot retrieve the correct zone.");
return buddy_system_get_cached_space(&zone->buddy_system);
}
}
+1 -1
View File
@@ -738,4 +738,4 @@ int sys_waitperiod()
// Tell the scheduler that we have executed the periodic process.
current->se.executed = true;
return 0;
}
}
+1 -1
View File
@@ -247,4 +247,4 @@ static void __update_task_statistics(task_struct *task)
task->se.vruntime += /* ... */;
}
#endif
}
}
+1 -1
View File
@@ -42,4 +42,4 @@ void remove_wait_queue(wait_queue_head_t *head, wait_queue_entry_t *wq)
spinlock_lock(&head->lock);
__remove_wait_queue(head, wq);
spinlock_unlock(&head->lock);
}
}
+2 -2
View File
@@ -10,6 +10,6 @@ void kernel_panic(const char *msg)
{
pr_emerg("\nPANIC:\n%s\n\nWelcome to Kernel Debugging Land...\n\n", msg);
pr_emerg("\n");
asm("cli"); // Disable interrupts
for (;;) asm("hlt"); // Decrease power consumption with hlt
__asm__ __volatile__("cli"); // Disable interrupts
for (;;) __asm__ __volatile__("hlt"); // Decrease power consumption with hlt
}