kernel: add RISC-V HTIF code
Change-Id: I83251bb4586b4f752c97741f62a96d2f6f842377 Reviewed-on: https://review.haiku-os.org/c/haiku/+/4055 Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
This commit is contained in:
parent
e013897fcf
commit
d6a257bbe9
52
src/system/kernel/arch/riscv64/Htif.cpp
Normal file
52
src/system/kernel/arch/riscv64/Htif.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2021, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include <Htif.h>
|
||||
|
||||
|
||||
uint64
|
||||
HtifCmd(uint32 device, uint8 cmd, uint32 arg)
|
||||
{
|
||||
if (gHtifRegs == 0)
|
||||
return 0;
|
||||
|
||||
uint64 htifTohost = ((uint64)device << 56)
|
||||
+ ((uint64)cmd << 48) + arg;
|
||||
gHtifRegs->toHostLo = htifTohost % ((uint64)1 << 32);
|
||||
gHtifRegs->toHostHi = htifTohost / ((uint64)1 << 32);
|
||||
return (uint64)gHtifRegs->fromHostLo
|
||||
+ ((uint64)gHtifRegs->fromHostHi << 32);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HtifShutdown()
|
||||
{
|
||||
HtifCmd(0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HtifOutChar(char ch)
|
||||
{
|
||||
HtifCmd(1, 1, ch);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HtifOutString(const char *str)
|
||||
{
|
||||
for (; *str != '\0'; str++)
|
||||
HtifOutChar(*str);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HtifOutString(const char *str, size_t len)
|
||||
{
|
||||
for (; len > 0; str++, len--)
|
||||
HtifOutChar(*str);
|
||||
}
|
@ -21,6 +21,7 @@ KernelMergeObject kernel_arch_riscv64.o :
|
||||
arch_vm.cpp
|
||||
arch_vm_translation_map.cpp
|
||||
RISCV64VMTranslationMap.cpp
|
||||
Htif.cpp
|
||||
:
|
||||
$(TARGET_KERNEL_PIC_CCFLAGS) -Wno-unused
|
||||
:
|
||||
|
Loading…
x
Reference in New Issue
Block a user