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