paul@189 | 1 | /* |
paul@189 | 2 | * Paging utilities. |
paul@189 | 3 | * |
paul@189 | 4 | * Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk> |
paul@189 | 5 | * |
paul@189 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@189 | 7 | * it under the terms of the GNU General Public License as published by |
paul@189 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@189 | 9 | * (at your option) any later version. |
paul@189 | 10 | * |
paul@189 | 11 | * This program is distributed in the hope that it will be useful, |
paul@189 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@189 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@189 | 14 | * GNU General Public License for more details. |
paul@189 | 15 | * |
paul@189 | 16 | * You should have received a copy of the GNU General Public License |
paul@189 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@189 | 18 | */ |
paul@189 | 19 | |
paul@189 | 20 | #include "paging.h" |
paul@200 | 21 | #include "memory.h" |
paul@189 | 22 | |
paul@189 | 23 | inline u32 user_address(u32 addr) |
paul@189 | 24 | { |
paul@189 | 25 | return addr & USER_ADDRESS_MASK; |
paul@189 | 26 | } |
paul@200 | 27 | |
paul@200 | 28 | inline u32 previous_page(u32 addr, u32 pagesize) |
paul@200 | 29 | { |
paul@200 | 30 | return addr - pagesize * 2; |
paul@200 | 31 | } |
paul@200 | 32 | |
paul@200 | 33 | inline u32 next_page(u32 addr, u32 pagesize) |
paul@200 | 34 | { |
paul@200 | 35 | return addr + pagesize * 2; |
paul@200 | 36 | } |
paul@204 | 37 | |
paul@204 | 38 | inline u32 page_size(u32 size) |
paul@204 | 39 | { |
paul@204 | 40 | return size / 2; |
paul@204 | 41 | } |