2012-03-21 12:19:26 -04:00
|
|
|
/*******************************************************************************
|
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
This file is part of Sortix.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Sortix is free software: you can redistribute it and/or modify it under the
|
|
|
|
terms of the GNU General Public License as published by the Free Software
|
|
|
|
Foundation, either version 3 of the License, or (at your option) any later
|
|
|
|
version.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
Sortix is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
|
|
details.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
You should have received a copy of the GNU General Public License along with
|
|
|
|
Sortix. If not, see <http://www.gnu.org/licenses/>.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
2013-07-10 09:26:01 -04:00
|
|
|
memorymanagement.cpp
|
|
|
|
Functions that allow modification of virtual memory.
|
2012-03-21 12:19:26 -04:00
|
|
|
|
|
|
|
*******************************************************************************/
|
|
|
|
|
|
|
|
#include <sortix/kernel/platform.h>
|
|
|
|
#include <sortix/kernel/memorymanagement.h>
|
2013-01-08 18:41:35 -05:00
|
|
|
#include <sortix/kernel/syscall.h>
|
2012-03-21 12:19:26 -04:00
|
|
|
|
|
|
|
namespace Sortix {
|
|
|
|
namespace Memory {
|
|
|
|
|
2013-01-14 08:40:04 -05:00
|
|
|
static int sys_memstat(size_t* memused, size_t* memtotal)
|
2012-03-21 12:19:26 -04:00
|
|
|
{
|
|
|
|
size_t used;
|
|
|
|
size_t total;
|
|
|
|
Statistics(&used, &total);
|
|
|
|
// TODO: Check if legal user-space buffers!
|
2013-01-14 08:40:04 -05:00
|
|
|
if ( memused )
|
|
|
|
*memused = used;
|
|
|
|
if ( memtotal )
|
|
|
|
*memtotal = total;
|
2012-03-21 12:19:26 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InitCPU(multiboot_info_t* bootinfo);
|
|
|
|
|
|
|
|
void Init(multiboot_info_t* bootinfo)
|
|
|
|
{
|
|
|
|
InitCPU(bootinfo);
|
|
|
|
|
2013-01-14 08:40:04 -05:00
|
|
|
Syscall::Register(SYSCALL_MEMSTAT, (void*) sys_memstat);
|
2012-03-21 12:19:26 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Memory
|
|
|
|
} // namespace Sortix
|