summaryrefslogtreecommitdiff
path: root/src/kernel/mem/seg.h
blob: 26664dc3de790a1a76324b78220c5f6414fec57b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef DEF_SEG_H
#define DEF_SEG_H

#include "paging.h"

struct segment_map;
struct segment {
	void* seg_data;
	int mappings;

	struct segment_map* (*map)(struct segment* seg, struct page_directory* pagedir, size_t offset);
	void (*unmap)(struct segment_map*);
	void (*delete)(struct segment* seg);
	int (*handle_fault)(struct segment_map* map, size_t addr, int write);	//0 if ok, 1 if segfault
};

struct segment_map {
	struct segment* seg;
	struct page_directory* pagedir;
	size_t start, len;
	struct segment_map *next;
};

//parameter offset in seg_map needs not be used
struct segment_map *seg_map(struct segment* seg, struct page_directory* pagedir, size_t offset);
void seg_unmap(struct segment_map* map);

/// *************************************     SIMPLESEG stuff *****************

struct simpleseg {
	int writable;
	size_t start, len;
};

struct segment* simpleseg_make(size_t start, size_t len, int writable); 
struct segment_map* simpleseg_map(struct segment* seg, struct page_directory* pagedir, size_t offset);
void simpleseg_unmap(struct segment_map*);
void simpleseg_delete(struct segment *seg);
int simpleseg_handleFault(struct segment_map* map, size_t addr, int write);
int simpleseg_resize(struct segment_map *map, size_t len);

#endif