Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
triazo
/
kernel
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
3
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9006ccf6
authored
Nov 29, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add a symbol pointing to the end of used kernel memory
parent
6c1ebf19
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
5 deletions
src/linker.ld
src/mem.c
src/mem.h
src/linker.ld
View file @
9006ccf6
...
...
@@ -43,4 +43,8 @@ SECTIONS
/* The compiler may produce other sections, by default it will put them in
a segment with the same name. Simply add stuff here as needed. */
.end BLOCK(4K) : ALIGN(4K)
{
_kernel_end = . ;
}
}
src/mem.c
View file @
9006ccf6
...
...
@@ -46,9 +46,6 @@ void populate_page_table(page_table_entry* table, void* start, int num, int offs
}
}
// TODO: put this as a label at the end of the code, so we can take
// its address
#define KERN_END 0x204000
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
)
{
...
...
@@ -56,8 +53,8 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
// Make a page directory structure easily
page_directory_entry
*
kern_page_dir
=
initiate_directory
();
//
This line will change with the above TODO
page_table_entry
*
next_table
=
(
page_table_entry
*
)
KERN_END
;
//
_kern_end is defined in the linker script
page_table_entry
*
next_table
=
(
page_table_entry
*
)
&
_kernel_end
;
int
current_dir_entry
=
0
;
...
...
src/mem.h
View file @
9006ccf6
...
...
@@ -27,6 +27,9 @@ typedef uint32_t page_table_entry;
extern
void
loadPageDirectory
(
page_directory_entry
*
);
extern
void
enablePaging
();
// Defined in linker.ld
extern
char
_kernel_end
[];
// Defined in the file mem.c
page_directory_entry
*
initiate_directory
();
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
);
...
...
@@ -38,4 +41,30 @@ void* memory_mark;
void
*
malloc
(
uint32_t
bytes
);
// Required for elf loading - virtual memory and stuff
#endif
// TODO:
/*
Two stage memory thing.
Ensure kernel is paged.
Ensure that a space equal to <remaining_memory> / (4096 * 8) is paged. This is for the following struct
Create binary array specifying which pages are used (abstract ownership a bit maybe to pid, or just use bit array)
Place in allocated space
Write allocor for pages. This should be the only way to get ownership of pages.
- takes a page directory and a new address as an argument.
- Sholud be called by the other malloc function, or by construction of page tables
- flips a bit in a binary array
- Also write corresponding free, flip bit and remove entry in page dir/table
Write more versatile malloc/free
- Use struct{void* next, size_t size} before every hunk. Walk list to find total size, use this to determine if more pages are needed. Or something
Problems - how to determine when new pages are needed
- how to load in elf stuff at arbitrary locations
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment