metalsvm/include/metalsvm/vma.h
2011-08-16 03:29:54 -07:00

85 lines
2.1 KiB
C

/*
* Copyright 2011 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/vma.h
* @brief VMA related sructure and functions
*/
#ifndef __VMA_H__
#define __VMA_H__
#include <metalsvm/stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#define VMA_READ (1 << 0)
#define VMA_WRITE (1 << 1)
#define VMA_EXECUTE (1 << 2)
#define VMA_CACHEABLE (1 << 3)
#define VMA_NOACCESS (1 << 4)
struct vma;
/** @brief VMA structure definition */
typedef struct vma {
/// Start address of the memory area
size_t start;
/// End address of the memory area
size_t end;
/// Type flags field
uint32_t type;
/// Pointer of next VMA element in the list
struct vma* next;
/// Pointer to previous VMA element in the list
struct vma* prev;
} vma_t;
/** @brief Add a new virtual memory region to the list of VMAs
*
* @param task Pointer to the task_t structure of the task
* @param start Start address of the new region
* @param end End address of the new region
* @param type Type flags the new region shall have
*
* @return
* - 0 on success
* - -EINVAL (-22) or -EINVAL (-12) on failure
*/
int vma_add(struct task* task, size_t start, size_t end, uint32_t type);
/** @brief Dump information about this task's VMAs into the terminal.
*
* This will print out Start, end and flags for each VMA in the task's list
*
* @param task The task's task_t structure
* @return
* - 0 on success
* - -EINVAL (-22) on failure
*/
int vma_dump(struct task* task);
#ifdef __cplusplus
}
#endif
#endif