Compare commits
No commits in common. "98da473fdc7eced1a8efad47320f559b60c012f7" and "327b60566c182f23809b4b15b7e92abfe212f526" have entirely different histories.
98da473fdc
...
327b60566c
@ -1,26 +1,26 @@
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int fd = open("/dev/fb0", O_WRONLY | O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
if(fd < 0)
|
||||
{
|
||||
perror("open");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fb_width = ioctl(fd, FB_GET_WIDTH);
|
||||
if (fb_width < 0)
|
||||
if(fb_width < 0)
|
||||
{
|
||||
perror("ioctl(FB_GET_WIDTH)");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fb_height = ioctl(fd, FB_GET_HEIGHT);
|
||||
if (fb_height < 0)
|
||||
if(fb_height < 0)
|
||||
{
|
||||
perror("ioctl(FB_GET_HEIGHT)");
|
||||
return 1;
|
||||
|
@ -35,6 +35,5 @@ namespace MemoryManager
|
||||
|
||||
void protect(void* page, uint64_t count, int flags);
|
||||
|
||||
void map_several_pages(uint64_t physicalAddress, uint64_t virtualAddress, uint64_t count,
|
||||
int flags = MAP_READ_WRITE);
|
||||
void map_several_pages(uint64_t physicalAddress, uint64_t virtualAddress, uint64_t count, int flags = MAP_READ_WRITE);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
#include "fs/devices/DeviceFS.h"
|
||||
#include "fs/devices/Console.h"
|
||||
#include "fs/devices/Framebuffer.h"
|
||||
#include "fs/devices/Keyboard.h"
|
||||
#include "fs/devices/NullDevice.h"
|
||||
#include "fs/devices/Framebuffer.h"
|
||||
#include "fs/devices/Random.h"
|
||||
#include "fs/devices/Serial.h"
|
||||
#include "fs/devices/Version.h"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "memory/PMM.h"
|
||||
#include "memory/VMM.h"
|
||||
#include "misc/MSR.h"
|
||||
#include "misc/hang.h"
|
||||
#include "rand/Init.h"
|
||||
#include "rand/Mersenne.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "std/assert.h"
|
||||
#include "std/string.h"
|
||||
#include "utils/Time.h"
|
||||
#include "misc/MSR.h"
|
||||
|
||||
extern BOOTBOOT bootboot;
|
||||
extern "C" char environment[4096];
|
||||
@ -46,8 +46,7 @@ extern void panic_prepare_keyboard_triple_fault();
|
||||
|
||||
static void check_and_enable_nx()
|
||||
{
|
||||
if (!CPU::has_nx())
|
||||
{
|
||||
if(!CPU::has_nx()) {
|
||||
kerrorln("This machine does not support the NX feature, which is required to continue booting.");
|
||||
kerrorln("On most cases, this means your machine is too old and not supported.");
|
||||
|
||||
@ -55,7 +54,7 @@ static void check_and_enable_nx()
|
||||
|
||||
panic_prepare_keyboard_triple_fault();
|
||||
|
||||
while (1) halt();
|
||||
while(1) halt();
|
||||
}
|
||||
|
||||
kdbgln("nx supported");
|
||||
@ -64,7 +63,7 @@ static void check_and_enable_nx()
|
||||
|
||||
uint64_t value = efer.read();
|
||||
|
||||
if (value & NO_EXECUTE_ENABLED)
|
||||
if(value & NO_EXECUTE_ENABLED)
|
||||
{
|
||||
kdbgln("nx already enabled");
|
||||
return;
|
||||
|
@ -1,8 +1,8 @@
|
||||
#define MODULE "irq"
|
||||
|
||||
#include "interrupts/IRQ.h"
|
||||
#include "fs/devices/Console.h"
|
||||
#include "fs/devices/Keyboard.h"
|
||||
#include "fs/devices/Console.h"
|
||||
#include "io/IO.h"
|
||||
#include "io/PIC.h"
|
||||
#include "log/Log.h"
|
||||
|
@ -26,8 +26,7 @@ void AddressSpace::destroy()
|
||||
if (!pdp_pde.present) continue;
|
||||
if (pdp_pde.larger_pages)
|
||||
{
|
||||
if (pdp_pde.owned_by_task)
|
||||
{
|
||||
if(pdp_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pdp_pde.get_address());
|
||||
}
|
||||
@ -40,8 +39,7 @@ void AddressSpace::destroy()
|
||||
if (!pd_pde.present) continue;
|
||||
if (pd_pde.larger_pages)
|
||||
{
|
||||
if (pd_pde.owned_by_task)
|
||||
{
|
||||
if(pd_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pd_pde.get_address());
|
||||
}
|
||||
@ -54,8 +52,7 @@ void AddressSpace::destroy()
|
||||
if (!pt_pde.present) continue;
|
||||
if (pt_pde.larger_pages)
|
||||
{
|
||||
if (pt_pde.owned_by_task)
|
||||
{
|
||||
if(pt_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pt_pde.get_address());
|
||||
}
|
||||
@ -94,8 +91,7 @@ void AddressSpace::clear()
|
||||
if (!pdp_pde.present) continue;
|
||||
if (pdp_pde.larger_pages)
|
||||
{
|
||||
if (pdp_pde.owned_by_task)
|
||||
{
|
||||
if(pdp_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pdp_pde.get_address());
|
||||
}
|
||||
@ -108,8 +104,7 @@ void AddressSpace::clear()
|
||||
if (!pd_pde.present) continue;
|
||||
if (pd_pde.larger_pages)
|
||||
{
|
||||
if (pd_pde.owned_by_task)
|
||||
{
|
||||
if(pd_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pd_pde.get_address());
|
||||
}
|
||||
@ -122,8 +117,7 @@ void AddressSpace::clear()
|
||||
if (!pt_pde.present) continue;
|
||||
if (pt_pde.larger_pages)
|
||||
{
|
||||
if (pt_pde.owned_by_task)
|
||||
{
|
||||
if(pt_pde.owned_by_task) {
|
||||
pages_freed++;
|
||||
PMM::free_page((void*)pt_pde.get_address());
|
||||
}
|
||||
@ -174,7 +168,7 @@ AddressSpace AddressSpace::clone() // FIXME: Add out-of-memory checks to this fu
|
||||
if (!pdp_pde.present) continue;
|
||||
if (pdp_pde.larger_pages)
|
||||
{
|
||||
if (!pdp_pde.owned_by_task)
|
||||
if(!pdp_pde.owned_by_task)
|
||||
{
|
||||
memcpy(&cloned_pdp_pde, &pdp_pde, sizeof(PageDirectoryEntry));
|
||||
continue;
|
||||
@ -203,7 +197,7 @@ AddressSpace AddressSpace::clone() // FIXME: Add out-of-memory checks to this fu
|
||||
if (!pd_pde.present) continue;
|
||||
if (pd_pde.larger_pages)
|
||||
{
|
||||
if (!pd_pde.owned_by_task)
|
||||
if(!pd_pde.owned_by_task)
|
||||
{
|
||||
memcpy(&cloned_pd_pde, &pd_pde, sizeof(PageDirectoryEntry));
|
||||
continue;
|
||||
@ -232,7 +226,7 @@ AddressSpace AddressSpace::clone() // FIXME: Add out-of-memory checks to this fu
|
||||
if (!pt_pde.present) continue;
|
||||
if (pt_pde.larger_pages)
|
||||
{
|
||||
if (!pt_pde.owned_by_task)
|
||||
if(!pt_pde.owned_by_task)
|
||||
{
|
||||
memcpy(&cloned_pt_pde, &pt_pde, sizeof(PageDirectoryEntry));
|
||||
continue;
|
||||
@ -258,7 +252,7 @@ AddressSpace AddressSpace::clone() // FIXME: Add out-of-memory checks to this fu
|
||||
{
|
||||
PageDirectoryEntry& pde = pt->entries[l];
|
||||
PageDirectoryEntry& cloned_pde = cloned_pt->entries[l];
|
||||
if (!pde.owned_by_task)
|
||||
if(!pde.owned_by_task)
|
||||
{
|
||||
memcpy(&cloned_pde, &pde, sizeof(PageDirectoryEntry));
|
||||
continue;
|
||||
|
@ -7,8 +7,8 @@
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "memory/PMM.h"
|
||||
#include "memory/VMM.h"
|
||||
#include "misc/utils.h"
|
||||
#include "std/assert.h"
|
||||
#include "misc/utils.h"
|
||||
|
||||
void MemoryManager::init()
|
||||
{
|
||||
@ -25,10 +25,8 @@ extern char end_of_kernel_data[1];
|
||||
|
||||
void MemoryManager::protect_kernel_sections()
|
||||
{
|
||||
protect(start_of_kernel_rodata,
|
||||
Utilities::get_blocks_from_size(PAGE_SIZE, end_of_kernel_rodata - start_of_kernel_rodata), 0);
|
||||
protect(start_of_kernel_data, Utilities::get_blocks_from_size(PAGE_SIZE, end_of_kernel_data - start_of_kernel_data),
|
||||
MAP_READ_WRITE);
|
||||
protect(start_of_kernel_rodata, Utilities::get_blocks_from_size(PAGE_SIZE, end_of_kernel_rodata - start_of_kernel_rodata), 0);
|
||||
protect(start_of_kernel_data, Utilities::get_blocks_from_size(PAGE_SIZE, end_of_kernel_data - start_of_kernel_data), MAP_READ_WRITE);
|
||||
}
|
||||
|
||||
void* MemoryManager::get_mapping(void* physicalAddress, int flags)
|
||||
|
@ -16,9 +16,7 @@ void Syscall::entry(Context* context)
|
||||
case SYS_sleep: sys_sleep(context, context->rdi); break;
|
||||
case SYS_write: sys_write(context, (int)context->rdi, context->rsi, (const char*)context->rdx); break;
|
||||
case SYS_getprocid: sys_getprocid(context, (int)context->rdi); break;
|
||||
case SYS_mmap:
|
||||
sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx, (int)context->r10, (off_t)context->r8);
|
||||
break;
|
||||
case SYS_mmap: sys_mmap(context, (void*)context->rdi, context->rsi, (int)context->rdx, (int)context->r10, (off_t)context->r8); break;
|
||||
case SYS_munmap: sys_munmap(context, (void*)context->rdi, context->rsi); break;
|
||||
case SYS_open: sys_open(context, (const char*)context->rdi, (int)context->rsi, (mode_t)context->rdx); break;
|
||||
case SYS_read: sys_read(context, (int)context->rdi, context->rsi, (char*)context->rdx); break;
|
||||
|
@ -119,8 +119,7 @@ ELFImage* ELFLoader::load_elf_from_vfs(VFS::Node* node)
|
||||
|
||||
int new_flags = MAP_USER | MAP_AS_OWNED_BY_TASK;
|
||||
if (can_write_segment(phdr.p_flags)) new_flags |= MAP_READ_WRITE;
|
||||
else if (can_execute_segment(phdr.p_flags))
|
||||
new_flags |= MAP_EXEC;
|
||||
else if (can_execute_segment(phdr.p_flags)) new_flags |= MAP_EXEC;
|
||||
|
||||
MemoryManager::protect(buffer, pages, new_flags);
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#include <luna/syscall.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -7,8 +7,7 @@ extern "C"
|
||||
// FIXME: Implement a POSIX-compliant mmap.
|
||||
void* mmap(void* addr, size_t len, int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
long result = __luna_syscall5(SYS_mmap, (sysarg_t)addr, (sysarg_t)len, (sysarg_t)prot,
|
||||
flags & MAP_ANONYMOUS ? (sysarg_t)-1 : (sysarg_t)fd, (sysarg_t)offset);
|
||||
long result = __luna_syscall5(SYS_mmap, (sysarg_t)addr, (sysarg_t)len, (sysarg_t)prot, flags & MAP_ANONYMOUS ? (sysarg_t)-1 : (sysarg_t)fd, (sysarg_t)offset);
|
||||
_RETURN_WITH_MEMORY_ERRNO(result, void*);
|
||||
}
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
source $(dirname $0)/env.sh
|
||||
|
||||
cd $LUNA_ROOT
|
||||
|
||||
SOURCES=($(find kernel/src -type f | grep "\.c") $(find kernel/include -type f))
|
||||
SOURCES+=($(find libs/libc/src -type f | grep "\.c") $(find libs/libc/include -type f))
|
||||
SOURCES+=($(find apps/src -type f))
|
||||
|
||||
for f in ${SOURCES[@]}
|
||||
do
|
||||
clang-format $f -i
|
||||
done
|
Loading…
Reference in New Issue
Block a user