Commit 23a8664b9e221a30071f25529411f118af351baa

Add missing multitasking file. Fix some non-portable types in VFS
  
3939 return a % (8 * 4);
4040 }
4141
42
4342 // Paging function prototypes
4443 void set_frame(uintptr address);
4544 void clear_frame(uintptr address);
  
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
24namespace 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}
  
6767
6868 struct fs::dirent dirent;
6969
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);
7171 struct fs::dirent * readdir(fs::node * dir, u32int index);
7272 fs::node * finddir(fs::node * dir, const char * name);
7373
202202 }
203203
204204 // 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)
206206 {
207207 uintptr address = initrd_start;
208208 size_t file_size;
  
99{
1010 // Read a file - just checks if the node has a read method, and returns
1111 // 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)
1313 {
1414 if(file->read != 0)
1515 return file->read(file, offset, size, buffer);
1818 }
1919
2020 // 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)
2222 {
2323 if(file->write != 0)
2424 return file->write(file, offset, size, buffer);
  
1818
1919 // Prototypes for the functions for reading, writing etc. a
2020 // 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 *);
2323 typedef void (*open_func)(struct fs_node *);
2424 typedef void (*close_func)(struct fs_node *);
2525 typedef struct dirent * (*readdir_func)(struct fs_node *, u32int);
5353 };
5454
5555 // 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);
5858 void open(node * file);
5959 void close(node * file);
6060 struct dirent *readdir(node * dir, u32int index);
  
2929 m_id = scheduler::add_process(this);
3030
3131 // Set this process's string to its parent's
32 m_desc = parent->m_desc;// + "[F]";
32 m_desc = parent->m_desc + "[F]";
3333}
3434
3535process::~process()