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. 11 HtifRegs* volatile gHtifRegs = (HtifRegs* volatile)0x40008000; 12 13 14 uint64_t 15 HtifCmd(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 26 void 27 HtifShutdown() 28 { 29 HtifCmd(0, 0, 1); 30 } 31 32 33 void 34 HtifOutChar(char ch) 35 { 36 HtifCmd(1, 1, ch); 37 } 38 39 40 void 41 HtifOutString(const char* str) 42 { 43 for (; *str != '\0'; str++) HtifOutChar(*str); 44 } 45 46 47 void 48 HtifOutString(const char* str, size_t len) 49 { 50 for (; len > 0; str++, len--) HtifOutChar(*str); 51 } 52