Commit 23a8664b9e221a30071f25529411f118af351baa
- Diff rendering mode:
- inline
- side by side
kernel/arch/x86/paging.cc
(0 / 1)
|   | |||
| 39 | 39 | return a % (8 * 4); | |
| 40 | 40 | } | |
| 41 | 41 | ||
| 42 | |||
| 43 | 42 | // Paging function prototypes | |
| 44 | 43 | void set_frame(uintptr address); | |
| 45 | 44 | void clear_frame(uintptr address); |
kernel/arch/x86/task.cc
(62 / 0)
|   | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2008 Stephen Gentle | ||
| 3 | * | ||
| 4 | * Permission to use, copy, modify, and distribute this software for any | ||
| 5 | * purpose with or without fee is hereby granted, provided that the above | ||
| 6 | * copyright notice and this permission notice appear in all copies. | ||
| 7 | * | ||
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
| 15 | */ | ||
| 16 | |||
| 17 | // Platform dependant multatasking code | ||
| 18 | |||
| 19 | #include "common.h" | ||
| 20 | #include "paging.h" | ||
| 21 | |||
| 22 | #include "mm/virtual_address_space.h" | ||
| 23 | |||
| 24 | namespace multitasking | ||
| 25 | { | ||
| 26 | // Read the value of the register esp | ||
| 27 | uintptr read_esp() | ||
| 28 | { | ||
| 29 | uintptr temp; | ||
| 30 | |||
| 31 | asm volatile("mov %%esp, %0" : "=r"(temp)); | ||
| 32 | |||
| 33 | return temp; | ||
| 34 | } | ||
| 35 | |||
| 36 | // Read the value of the register ebp | ||
| 37 | uintptr read_ebp() | ||
| 38 | { | ||
| 39 | uintptr temp; | ||
| 40 | |||
| 41 | asm volatile("mov %%ebp, %0" : "=r"(temp)); | ||
| 42 | |||
| 43 | return temp; | ||
| 44 | } | ||
| 45 | |||
| 46 | void switch_tasks(uintptr eip, uintptr esp, uintptr ebp, virtual_address_space * addr) | ||
| 47 | { | ||
| 48 | // Get the page directory from the virtual address space | ||
| 49 | uintptr page_dir_address = addr->get_page_directory()->physicalAddress; | ||
| 50 | |||
| 51 | asm volatile(" \ | ||
| 52 | cli; \ | ||
| 53 | mov %0, %%ecx; \ | ||
| 54 | mov %1, %%esp; \ | ||
| 55 | mov %2, %%ebp; \ | ||
| 56 | mov %3, %%cr3; \ | ||
| 57 | mov $0x12345, %%eax; \ | ||
| 58 | sti; \ | ||
| 59 | jmp *%%ecx" | ||
| 60 | : : "r"(eip), "r"(esp), "r"(ebp), "r"(page_dir_address)); | ||
| 61 | } | ||
| 62 | } |
kernel/fs/initrd.cc
(2 / 2)
|   | |||
| 67 | 67 | ||
| 68 | 68 | struct fs::dirent dirent; | |
| 69 | 69 | ||
| 70 | size_t read(fs::node * node, u32int offset, size_t size, u8int * buffer); | ||
| 70 | size_t read(fs::node * node, uintptr offset, size_t size, u8int * buffer); | ||
| 71 | 71 | struct fs::dirent * readdir(fs::node * dir, u32int index); | |
| 72 | 72 | fs::node * finddir(fs::node * dir, const char * name); | |
| 73 | 73 | ||
| … | … | ||
| 202 | 202 | } | |
| 203 | 203 | ||
| 204 | 204 | // Read a file from the initrd | |
| 205 | size_t read(fs::node * node, u32int offset, size_t size, u8int * buffer) | ||
| 205 | size_t read(fs::node * node, uintptr offset, size_t size, u8int * buffer) | ||
| 206 | 206 | { | |
| 207 | 207 | uintptr address = initrd_start; | |
| 208 | 208 | size_t file_size; |
kernel/fs/vfs.cc
(2 / 2)
|   | |||
| 9 | 9 | { | |
| 10 | 10 | // Read a file - just checks if the node has a read method, and returns | |
| 11 | 11 | // the result of that. Otherwise it just fails and returns 0 | |
| 12 | u32int read(node * file, u32int offset, size_t size, u8int * buffer) | ||
| 12 | size_t read(node * file, uintptr offset, size_t size, u8int * buffer) | ||
| 13 | 13 | { | |
| 14 | 14 | if(file->read != 0) | |
| 15 | 15 | return file->read(file, offset, size, buffer); | |
| … | … | ||
| 18 | 18 | } | |
| 19 | 19 | ||
| 20 | 20 | // Write buffer to the file if the node implements a write command | |
| 21 | u32int write(node * file, u32int offset, size_t size, u8int * buffer) | ||
| 21 | size_t write(node * file, uintptr offset, size_t size, u8int * buffer) | ||
| 22 | 22 | { | |
| 23 | 23 | if(file->write != 0) | |
| 24 | 24 | return file->write(file, offset, size, buffer); |
kernel/fs/vfs.h
(4 / 4)
|   | |||
| 18 | 18 | ||
| 19 | 19 | // Prototypes for the functions for reading, writing etc. a | |
| 20 | 20 | // particular filesystem | |
| 21 | typedef u32int (*read_func)(struct fs_node *, u32int, size_t, u8int *); | ||
| 22 | typedef u32int (*write_func)(struct fs_node *, u32int, size_t, u8int *); | ||
| 21 | typedef size_t (*read_func)(struct fs_node *, uintptr, size_t, u8int *); | ||
| 22 | typedef size_t (*write_func)(struct fs_node *, uintptr, size_t, u8int *); | ||
| 23 | 23 | typedef void (*open_func)(struct fs_node *); | |
| 24 | 24 | typedef void (*close_func)(struct fs_node *); | |
| 25 | 25 | typedef struct dirent * (*readdir_func)(struct fs_node *, u32int); | |
| … | … | ||
| 53 | 53 | }; | |
| 54 | 54 | ||
| 55 | 55 | // Standard read, write, open and close functions. | |
| 56 | u32int read(node * file, u32int offset, size_t size, u8int * buffer); | ||
| 57 | u32int write(node * file, u32int offset, size_t size, u8int * buffer); | ||
| 56 | size_t read(node * file, uintptr offset, size_t size, u8int * buffer); | ||
| 57 | size_t write(node * file, uintptr offset, size_t size, u8int * buffer); | ||
| 58 | 58 | void open(node * file); | |
| 59 | 59 | void close(node * file); | |
| 60 | 60 | struct dirent *readdir(node * dir, u32int index); |
kernel/process/process.cc
(1 / 1)
|   | |||
| 29 | 29 | m_id = scheduler::add_process(this); | |
| 30 | 30 | ||
| 31 | 31 | // Set this process's string to its parent's | |
| 32 | m_desc = parent->m_desc;// + "[F]"; | ||
| 32 | m_desc = parent->m_desc + "[F]"; | ||
| 33 | 33 | } | |
| 34 | 34 | ||
| 35 | 35 | process::~process() |

