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

Subversion Repositories c0or1k

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

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

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

powered by: WebSVN 2.1.0

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