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
55d156d8
authored
Nov 30, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add function to ensure a given page is mapped
parent
37f5b7d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
src/mem.c
src/mem.h
src/mem.c
View file @
55d156d8
...
@@ -144,6 +144,21 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
...
@@ -144,6 +144,21 @@ page_directory_entry* mem_init_kern_tables(multiboot_memory_map* mmap, multiboot
return
kern_page_dir
;
return
kern_page_dir
;
}
}
// page_map takes in a virtual address and a directory, and ensures
// that that address points to valid memory
void
page_map
(
page_directory_entry
[]
pgdir
,
void
*
page_start
)
{
if
(
pgdir
[
page_start
>>
22
]
&
0xfffff
==
0
)
{
pgdir
[
page_start
>>
22
]
|=
page_new_table
();
}
if
(
pgdir
[
page_start
>>
22
][(
page_start
>>
12
)
%
1024
]
&
0xfffff
==
0
)
{
pgdir
[
page_start
>>
22
][(
page_start
>>
12
)
%
1024
]
|=
page_allocate
();
}
}
page_directory_entry
*
page_new_directory
()
page_directory_entry
*
page_new_directory
()
{
{
page_directory_entry
*
pgdir
=
(
page_directory_entry
*
)
page_allocate
();
page_directory_entry
*
pgdir
=
(
page_directory_entry
*
)
page_allocate
();
...
...
src/mem.h
View file @
55d156d8
...
@@ -33,6 +33,7 @@ extern char _kernel_end[];
...
@@ -33,6 +33,7 @@ extern char _kernel_end[];
// Allocation of pages
// Allocation of pages
void
*
page_allocate
();
void
*
page_allocate
();
void
page_free
(
void
*
page_start
);
void
page_free
(
void
*
page_start
);
void
page_map
(
page_directory_entry
[]
pgdir
,
void
*
page_start
);
// Initilization
// Initilization
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
);
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
);
...
...
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