85 lines
2 KiB
C
85 lines
2 KiB
C
/*
|
|
* Copyright 2010 Stefan Lankes, Chair for Operating Systems,
|
|
* RWTH Aachen University
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*
|
|
* This file is part of MetalSVM.
|
|
*/
|
|
|
|
/**
|
|
* @author Stefan Lankes
|
|
* @file include/metalsvm/mmu.h
|
|
* @brief Memory management related
|
|
*
|
|
* This file contains memory management related
|
|
* functions for use in kernel space
|
|
*/
|
|
|
|
#ifndef __MMU_H__
|
|
#define __MMU_H__
|
|
|
|
#include <metalsvm/stddef.h>
|
|
#include <asm/atomic.h>
|
|
//#include <asm/mmu.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern atomic_int32_t total_pages;
|
|
extern atomic_int32_t total_allocated_pages;
|
|
extern atomic_int32_t total_available_pages;
|
|
|
|
/** @brief Initialize MMU subsystem
|
|
*
|
|
* This function finds out which pageframes are
|
|
* used by the kernel already before the paging
|
|
* was initialized, marks it as used and starts
|
|
* the paging subsystem.
|
|
*/
|
|
int mmu_init(void);
|
|
|
|
/** @brief get continuous pages
|
|
*
|
|
* This function finds a continuous page region (first fit algorithm)
|
|
*
|
|
* @param no_pages Desired number of pages
|
|
*
|
|
* @return
|
|
* - physical address on success
|
|
* - 0 on failure
|
|
*/
|
|
size_t get_pages(uint32_t no_pages);
|
|
|
|
/** @brief get a single page
|
|
*
|
|
* Convenience function: uses get_pages(1);
|
|
*/
|
|
static inline size_t get_page(void) { return get_pages(1); }
|
|
|
|
/** @brief Put back a page after use
|
|
*
|
|
* @param phyaddr Physical address to put back
|
|
*
|
|
* @return
|
|
* - 0 on success
|
|
* - -EINVAL (-22) on failure
|
|
*/
|
|
int put_page(size_t phyaddr);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|