Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
859 serge 1
 
2
typedef  unsigned short int   u16_t;
3
typedef  unsigned int         u32_t;
4
typedef  unsigned long long   u64_t;
5
6
 
7
{
8
  u8_t val;
9
  if(port < 0x100)
10
    asm volatile ("in %b0, %w1 \n" : "=a" (val) : "dN" (port) );
11
  else
12
    asm volatile ("in %b0, %w1 \n" : "=a" (val) : "d" (port) );
13
	return val;
14
}
15
16
 
17
{
18
  if (port < 0x100) /* GCC can optimize this if constant */
19
    asm volatile ("out %w0, %b1" : :"dN"(port), "a"(val));
20
  else
21
    asm volatile ("out %w0, %b1" : :"d"(port), "a"(val));
22
}
23
24
 
25
 
26
   BASE is equal to 'd', interpret that D is decimal, and if BASE is
27
   equal to 'x', interpret that D is hexadecimal.  */
28
static void itoa (char *buf, int base, int d)
29
{
30
  char *p = buf;
31
  char *p1, *p2;
32
  unsigned long ud = d;
33
  int divisor = 10;
34
35
 
36
  if (base == 'd' && d < 0)
37
    {
38
      *p++ = '-';
39
      buf++;
40
      ud = -d;
41
    }
42
  else if (base == 'x')
43
    divisor = 16;
44
45
 
46
  do
47
    {
48
      int remainder = ud % divisor;
49
50
 
51
    }
52
  while (ud /= divisor);
53
54
 
55
  *p = 0;
56
57
 
58
  p1 = buf;
59
  p2 = p - 1;
60
  while (p1 < p2)
61
    {
62
      char tmp = *p1;
63
      *p1 = *p2;
64
      *p2 = tmp;
65
      p1++;
66
      p2--;
67
    }
68
}
69
70
 
71
{
72
    while (!(inb(0x3f8+5) & 0x60));
73
    outb(0x3f8,c);
74
    if (c == '\n')
75
      putc('\r');
76
}
77
78
 
79
{
80
  char **arg = (char **) &format;
81
  int c;
82
  char buf[20];
83
84
 
85
86
 
87
  {
88
    if (c != '%')
89
      putc(c);
90
    else
91
    {
92
      char *p;
93
94
 
95
      switch (c)
96
      {
97
        case 'd':
98
        case 'u':
99
        case 'x':
100
          itoa (buf, c, *((int *) arg++));
101
          p = buf;
102
          goto string;
103
          break;
104
105
 
106
          p = *arg++;
107
          if (! p)
108
            p = "(null)";
109
110
 
111
          while (*p)
112
          putc(*p++);
113
          break;
114
115
 
116
          putc(*((int *) arg++));
117
          break;
118
	    }
119
    }
120
  }
121
}
122