1/* 2 * Copyright 2021, Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7#include <Htif.h> 8 9 10// This address is used by TinyEMU and it is not present in FDT. 11HtifRegs* volatile gHtifRegs = (HtifRegs* volatile)0x40008000; 12 13 14uint64_t 15HtifCmd(uint32_t device, uint8_t cmd, uint32_t arg) 16{ 17 uint64_t htifTohost = ((uint64_t)device << 56) 18 + ((uint64_t)cmd << 48) + arg; 19 gHtifRegs->toHostLo = htifTohost % ((uint64_t)1 << 32); 20 gHtifRegs->toHostHi = htifTohost / ((uint64_t)1 << 32); 21 return (uint64_t)gHtifRegs->fromHostLo 22 + ((uint64_t)gHtifRegs->fromHostHi << 32); 23} 24 25 26void 27HtifShutdown() 28{ 29 HtifCmd(0, 0, 1); 30} 31 32 33void 34HtifOutChar(char ch) 35{ 36 HtifCmd(1, 1, ch); 37} 38 39 40void 41HtifOutString(const char* str) 42{ 43 for (; *str != '\0'; str++) HtifOutChar(*str); 44} 45 46 47void 48HtifOutString(const char* str, size_t len) 49{ 50 for (; len > 0; str++, len--) HtifOutChar(*str); 51} 52