~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/SLOF/llfw/io_generic/io_generic.S

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * Copyright (c) 2004, 2008 IBM Corporation
 
3
 * All rights reserved.
 
4
 * This program and the accompanying materials
 
5
 * are made available under the terms of the BSD License
 
6
 * which accompanies this distribution, and is available at
 
7
 * http://www.opensource.org/licenses/bsd-license.php
 
8
 *
 
9
 * Contributors:
 
10
 *     IBM Corporation - initial implementation
 
11
 *****************************************************************************/
 
12
#include "macros.h"
 
13
 
 
14
        .text
 
15
 
 
16
/****************************************************************************
 
17
 * prints a 0-terminated string to serial console
 
18
 *
 
19
 * Input:
 
20
 * R3 - pointer to string in memory
 
21
 *
 
22
 * Returns: -
 
23
 *
 
24
 * Modifies Registers:
 
25
 * R3, R4, R5, R6, R7, R8, R9
 
26
 ****************************************************************************/
 
27
ASM_ENTRY(io_print)
 
28
        mflr    r8
 
29
        mr      r9, r3
 
30
 
 
31
0:
 
32
        lbz     r3, 0(r9)
 
33
        cmpwi   r3, 0
 
34
        beq     1f
 
35
        bl      io_putchar
 
36
        addi    r9, r9, 1
 
37
        b               0b
 
38
1:
 
39
        mtlr    r8
 
40
        blr
 
41
 
 
42
/****************************************************************************
 
43
 * prints Hex integer to the UART and the NVRAM (using board io_putchar)
 
44
 *
 
45
 * Input:
 
46
 * R3 - integer to print
 
47
 *
 
48
 * Returns: -
 
49
 *
 
50
 * Modifies Registers:
 
51
 * R3, R4, R5, R6, R7, R8, R9
 
52
 ****************************************************************************/
 
53
#define _io_gen_print_nib(reg, src, shift)      \
 
54
        srdi    reg, src, shift;                \
 
55
        andi.   reg, reg, 0x0F;                 \
 
56
        cmpwi   reg, 0x0A;                      \
 
57
        blt     0f;                             \
 
58
        addi    reg, reg, ('A'-'0'-10);         \
 
59
0:;                                             \
 
60
        addi    reg, reg, '0';                  \
 
61
        bl      io_putchar
 
62
 
 
63
ASM_ENTRY(io_printhex64)
 
64
        mflr    r8
 
65
        mr      r9, r3
 
66
 
 
67
_io_printhex64:
 
68
        _io_gen_print_nib(r3, r9, 60)
 
69
        _io_gen_print_nib(r3, r9, 56)
 
70
        _io_gen_print_nib(r3, r9, 52)
 
71
        _io_gen_print_nib(r3, r9, 48)
 
72
        _io_gen_print_nib(r3, r9, 44)
 
73
        _io_gen_print_nib(r3, r9, 40)
 
74
        _io_gen_print_nib(r3, r9, 36)
 
75
        _io_gen_print_nib(r3, r9, 32)
 
76
_io_printhex32:
 
77
        _io_gen_print_nib(r3, r9, 28)
 
78
        _io_gen_print_nib(r3, r9, 24)
 
79
        _io_gen_print_nib(r3, r9, 20)
 
80
        _io_gen_print_nib(r3, r9, 16)
 
81
_io_printhex16:
 
82
        _io_gen_print_nib(r3, r9, 12)
 
83
        _io_gen_print_nib(r3, r9,  8)
 
84
_io_printhex8:
 
85
        _io_gen_print_nib(r3, r9,  4)
 
86
        _io_gen_print_nib(r3, r9,  0)
 
87
 
 
88
        mtlr    r8
 
89
        blr
 
90
 
 
91
ASM_ENTRY(io_printhex32)
 
92
        mflr    r8
 
93
        mr      r9, r3
 
94
        b       _io_printhex32
 
95
 
 
96
ASM_ENTRY(io_printhex16)
 
97
        mflr    r8
 
98
        mr      r9, r3
 
99
        b       _io_printhex16
 
100
 
 
101
ASM_ENTRY(io_printhex8)
 
102
        mflr    r8
 
103
        mr      r9, r3
 
104
        b       _io_printhex8
 
105
 
 
106
 
 
107
/****************************************************************************
 
108
 * print the address and its contents as 64-bit hex values
 
109
 *
 
110
 * Input:
 
111
 * R3 - Address to read from
 
112
 *
 
113
 * Returns: -
 
114
 *
 
115
 * Modifies Registers:
 
116
 * R3, R4, R5, R6, R7, R8, R9, R10
 
117
 ****************************************************************************/
 
118
#if 0   /* currently unused */
 
119
ASM_ENTRY(io_dump)
 
120
        mflr    r10
 
121
        bl      io_printhex64
 
122
        li      r3,':'
 
123
        bl      io_putchar
 
124
        ld      r9,0(r9)
 
125
        mr      r8,r10
 
126
        b       _io_printhex64
 
127
#endif