1/** 2 * \file 3 * \brief 4 */ 5 6/* 7 * Copyright (c) 2010, 2011, 2016, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group. 13 */ 14 15#ifndef OFFSETS_ARCH_H 16#define OFFSETS_ARCH_H 17 18#include <target/x86_32/offsets_target.h> 19 20#define PADDR_SPACE_SIZE X86_32_PADDR_SPACE_SIZE 21#define PADDR_SPACE_LIMIT X86_32_PADDR_SPACE_LIMIT 22 23#define REAL_MODE_LINEAR_OFFSET X86_32_REAL_MODE_LINEAR_OFFSET 24#define REAL_MODE_SEGMENT X86_32_REAL_MODE_SEGMENT 25#define REAL_MODE_OFFSET X86_32_REAL_MODE_OFFSET 26 27#define REAL_MODE_SEGMENT_TO_REAL_MODE_PAGE(seg) X86_32_REAL_MODE_SEGMENT_TO_REAL_MODE_PAGE(seg) 28#define REAL_MODE_ADDR_TO_REAL_MODE_VECTOR(seg,off) X86_32_REAL_MODE_ADDR_TO_REAL_MODE_VECTOR(seg,off) 29 30#ifndef __ASSEMBLER__ 31 32static inline lvaddr_t local_phys_to_mem(lpaddr_t addr) 33{ 34 if (addr >= PADDR_SPACE_LIMIT) { 35 addr = 0; 36 } 37 assert(addr < PADDR_SPACE_LIMIT); 38 return (lvaddr_t)(addr + (lpaddr_t)X86_32_MEMORY_OFFSET); 39} 40 41/** 42 * Checks whether absolute local physical address `addr` is valid. 43 * \param addr Absolute local physical address 44 * \return True iff addr is a valid local physical address 45 */ 46static inline bool local_phys_is_valid(lpaddr_t addr) 47{ 48 return addr < PADDR_SPACE_LIMIT; 49} 50 51static inline lpaddr_t mem_to_local_phys(lvaddr_t addr) 52{ 53 assert(addr >= X86_32_MEMORY_OFFSET); 54 return (lpaddr_t)(addr - (lvaddr_t)X86_32_MEMORY_OFFSET); 55} 56 57static inline lpaddr_t gen_phys_to_local_phys(genpaddr_t addr) 58{ 59 assert(addr < PADDR_SPACE_SIZE); 60 return (lpaddr_t)addr; 61} 62 63static inline genpaddr_t local_phys_to_gen_phys(lpaddr_t addr) 64{ 65 return (genpaddr_t)addr; 66} 67 68/** 69 * Symbol: Start of kernel image. This symbol points to the start 70 * address of the kernel image. 71 */ 72extern char _start_kernel; 73 74/** 75 * Symbol: End of kernel image. This symbol points to the end address 76 * of the kernel image. 77 */ 78extern char _end_kernel; 79 80/** 81 * The size of the whole kernel image. 82 */ 83#define SIZE_KERNEL_IMAGE \ 84 (size_t)(&_end_kernel - &_start_kernel) 85 86#endif // __ASSEMBLER__ 87 88#endif // OFFSETS_ARCH_H 89