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

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [src/] [platform/] [beagle/] [print-early.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
 
2
#include INC_PLAT(uart.h)
3
#include INC_PLAT(offsets.h)
4
#include INC_ARCH(io.h)
5
 
6
void print_early(char *str)
7
{
8
        unsigned int reg = 0;
9
        unsigned long uart_base;
10
 
11
        /* Check if mmu is on */
12
        __asm__ __volatile__ (
13
                "mrc     p15, 0, %0, c1, c0"
14
                : "=r" (reg)
15
                : "r" (reg)
16
        );
17
 
18
        /*
19
         * Get uart phys/virt base based on mmu on/off
20
         * Also strings are linked at virtual address, so if
21
         * we are running with mmu off we should translate
22
         * string address to physical
23
         */
24
        if (reg & 1) {
25
                uart_base = PLATFORM_CONSOLE_VBASE;
26
        }
27
        else {
28
                uart_base = PLATFORM_UART2_BASE;
29
                str = (char *)(((unsigned long)str & ~KERNEL_AREA_START) |
30
                               PLATFORM_PHYS_MEM_START);
31
        }
32
 
33
        /* call uart tx function */
34
        while (*str != '\0') {
35
                uart_tx_char(uart_base, *str);
36
 
37
                if (*str == '\n')
38
                        uart_tx_char(uart_base, '\r');
39
                ++str;
40
        }
41
}
42
 
43
void printhex8(unsigned int val)
44
{
45
        char hexbuf[16];
46
        char *temp = hexbuf + 15;
47
        int v;
48
 
49
        /* put end of string */
50
        *(temp--) = '\0';
51
 
52
        if (!val) {
53
                *temp = '0';
54
        }
55
        else {
56
                while (val) {
57
                        v = val & 0xf;
58
                        val = val >> 4;
59
                        --temp;
60
 
61
                        /* convert decimal value to ascii */
62
                        if (v >= 10)
63
                                v += ('a' - 10);
64
                        else
65
                                v = v + '0';
66
 
67
                        *temp = *((char *)&v);
68
                }
69
        }
70
 
71
        *(--temp) = 'x';
72
        *(--temp) = '0';
73
        print_early(temp);
74
}
75
 

powered by: WebSVN 2.1.0

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