/ payloads / linuxcheck / i386.c
i386.c
 1  /*
 2   *
 3   * Copyright (C) 2018 Google Inc.
 4   *
 5   * This program is free software; you can redistribute it and/or modify
 6   * it under the terms of the GNU General Public License as published by
 7   * the Free Software Foundation; version 2 of the License.
 8   *
 9   * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   */
14  
15  #include <libpayload-config.h>
16  #include <libpayload.h>
17  #include "linuxcheck.h"
18  
19  void buts(char *s)
20  {
21  	int i;
22  	for (i = 0; i < strlen(s); i++)
23  		outb(s[i], 0x3f8);
24  }
25  
26  void hex4(u8 c)
27  {
28  	static char *hex = "0123456789abcdef";
29  	outb(hex[c & 0xf], 0x3f8);
30  }
31  
32  void hex8(u8 c)
33  {
34  	hex4(c >> 4);
35  	hex4(c);
36  }
37  
38  void hex16(u16 c)
39  {
40  	hex8((u8)(c >> 8));
41  	hex8((u8)c);
42  }
43  void hex32(u32 c)
44  {
45  	hex16((u16)(c >> 16));
46  	hex16((u16)c);
47  }