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

Subversion Repositories c0or1k

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

Go to most recent revision | 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_UART0_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
 
40
                ++str;
41
        }
42
}
43
 
44
void printhex8(unsigned int val)
45
{
46
        char hexbuf[16];
47
        char *temp = hexbuf + 15;
48
        int v;
49
 
50
        /* put end of string */
51
        *(temp--) = '\0';
52
 
53
        if (!val) {
54
                *temp = '0';
55
        }
56
        else {
57
                while (val) {
58
                        v = val & 0xf;
59
                        val = val >> 4;
60
                        --temp;
61
 
62
                        /* convert decimal value to ascii */
63
                        if (v >= 10)
64
                                v += ('a' - 10);
65
                        else
66
                                v = v + '0';
67
 
68
                        *temp = *((char *)&v);
69
                }
70
        }
71
 
72
        *(--temp) = 'x';
73
        *(--temp) = '0';
74
        print_early(temp);
75
}

powered by: WebSVN 2.1.0

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