42 lines
1.1 KiB
C

/**
* HAL implementation for aarch64 of asagiri
* Copyright (C) 2023 Furkan Mudanyali
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <bits/alltypes.h>
#include <hal.h>
void hcf() {
asm("wfi");
}
void delay(int32_t count) {
asm("__delay_%=: subs %[count], %[count], #1; bne __delay_%=\n"
: "=r"(count): [count]"0"(count) : "cc");
}
uint32_t mmio_read(uint64_t reg) {
uint64_t *p_reg = (uint64_t*)reg;
return *p_reg;
}
void mmio_write(uint64_t reg, uint32_t data) {
uint32_t *p_reg = (uint32_t*)reg;
*p_reg = data;
}