paul@93 | 1 | /* |
paul@93 | 2 | * Memory quantity calculation utilities. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@0 | 22 | #pragma once |
paul@0 | 23 | |
paul@30 | 24 | #include <systypes/base.h> |
paul@0 | 25 | |
paul@0 | 26 | #define PAGE_SIZE 4096 |
paul@0 | 27 | |
paul@0 | 28 | |
paul@0 | 29 | |
paul@0 | 30 | /* Address arithmetic. */ |
paul@0 | 31 | |
paul@0 | 32 | offset_t page(unsigned int n); |
paul@0 | 33 | |
paul@0 | 34 | unsigned int page_order(offset_t size); |
paul@0 | 35 | |
paul@0 | 36 | offset_t round(offset_t value, offset_t increment); |
paul@0 | 37 | |
paul@0 | 38 | offset_t round_multiple(offset_t value, offset_t increment); |
paul@0 | 39 | |
paul@0 | 40 | offset_t trunc(offset_t value, offset_t increment); |
paul@0 | 41 | |
paul@0 | 42 | offset_t trunc_multiple(offset_t value, offset_t increment); |
paul@0 | 43 | |
paul@0 | 44 | offset_t max_multiple(offset_t start, offset_t end, offset_t increment); |
paul@0 | 45 | |
paul@0 | 46 | // vim: tabstop=4 expandtab shiftwidth=4 |