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
20eeaa3a
authored
Nov 29, 2015
by
triazo
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add function to free page
parent
3e9db9e5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletions
src/mem.c
src/mem.h
src/mem.c
View file @
20eeaa3a
...
...
@@ -64,6 +64,18 @@ void* page_allocate()
return
(
void
*
)
&
_kernel_end
+
0x1000
*
page_number
;
}
void
page_free
(
void
*
page_start
)
{
if
(((
uint32_t
)
page_start
&
0xfff
)
!=
0
)
{
serial_writestring
(
"tried to free a non-page as a page"
);
}
uint32_t
page_number
=
(
uint32_t
)(
page_start
-
(
void
*
)
&
_kernel_end
)
/
0x1000
;
uint8_t
*
index
=
(
uint8_t
*
)
&
_kernel_end
+
page_number
/
8
;
*
index
=
~
(
~*
index
|
(
1
<<
(
8
-
(
page_number
%
8
))));
}
// This goes through all available memory, and maps 1 to 1 virtual memory to it.
page_directory_entry
*
mem_init_kern_tables
(
multiboot_memory_map
*
mmap
,
multiboot_memory_map
*
mmap_end
)
{
...
...
src/mem.h
View file @
20eeaa3a
...
...
@@ -32,7 +32,7 @@ extern char _kernel_end[];
// Allocation of pages
void
*
page_allocate
();
void
page_free
(
void
*
page_start
);
// Allocatoion of memory
...
...
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