OpenCores
URL https://opencores.org/ocsvn/plasma/plasma/trunk

Subversion Repositories plasma

[/] [plasma/] [trunk/] [tools/] [no_os.c] - Blame information for rev 356

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 137 rhoads
#include "plasma.h"
2
 
3
#define MemoryRead(A) (*(volatile unsigned int*)(A))
4
#define MemoryWrite(A,V) *(volatile unsigned int*)(A)=(V)
5
 
6 336 rhoads
int putchar(int value)
7 137 rhoads
{
8
   while((MemoryRead(IRQ_STATUS) & IRQ_UART_WRITE_AVAILABLE) == 0)
9
      ;
10
   MemoryWrite(UART_WRITE, value);
11 336 rhoads
   return 0;
12 137 rhoads
}
13
 
14
int puts(const char *string)
15
{
16
   while(*string)
17
   {
18
      if(*string == '\n')
19
         putchar('\r');
20
      putchar(*string++);
21
   }
22
   return 0;
23
}
24
 
25 270 rhoads
void print_hex(unsigned long num)
26
{
27
   long i;
28
   unsigned long j;
29
   for(i = 28; i >= 0; i -= 4)
30
   {
31
      j = (num >> i) & 0xf;
32
      if(j < 10)
33
         putchar('0' + j);
34
      else
35
         putchar('a' - 10 + j);
36
   }
37
}
38
 
39 137 rhoads
void OS_InterruptServiceRoutine(unsigned int status)
40
{
41
   (void)status;
42
   putchar('I');
43
}
44
 
45
int kbhit(void)
46
{
47
   return MemoryRead(IRQ_STATUS) & IRQ_UART_READ_AVAILABLE;
48
}
49
 
50
int getch(void)
51
{
52
   while(!kbhit()) ;
53
   return MemoryRead(UART_READ);
54
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.