summaryrefslogtreecommitdiff
path: root/compressed/include/mach/uncompress.h
blob: 5d83ec6f2703d32d4aac6825f2d9be55dd1addbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*++
linux/include/asm-arm/arch-wmt/uncompress.h

Copyright (c) 2008  WonderMedia Technologies, Inc.

This program is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software Foundation,
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program.  If not, see <http://www.gnu.org/licenses/>.

WonderMedia Technologies, Inc.
10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
--*/

#include "hardware.h"

/*
 * The following code assumes the serial port has already been
 * initialized by the bootloader.  We search for the first enabled
 * port in the most probable order.  If you didn't setup a port in
 * your bootloader then nothing will appear (which might be desired).
 */

/*
 * Macros to manipulate UART port.
 */
#define UART(x)         (*(volatile unsigned long *)(serial_port + (x)))
/*
 * This one is unique bacause UART TX FIFO access is 8-bit write.
 */
#define UART_URTXF      (*(volatile unsigned char *)(serial_port + URTXF))

static void putstr(const char *s)
{
#if 1
	unsigned long serial_port;

	do {
		/*
		 * If UART0 ready, do puts().
		 */
		serial_port = UART0_PHY_BASE_ADDR;

		if (UART(URLCR) & URLCR_TXEN)
			break;

		/*
		 * Else if UART2 ready, do puts().
		 */
		serial_port = UART1_PHY_BASE_ADDR;

		if (UART(URLCR) & URLCR_TXEN)
			break;

		/*
		 * Return if there is no UART ready.
		 */
		return;

	} while (0);

	/*
	 * Force to use register mode.
	 */
	UART(URFCR) &= ~URFCR_FIFOEN;

	for (; *s; s++) {
		/*
		 * wait for space in the UART's transmiter
		 */
		while (UART(URUSR) & URUSR_TXDBSY)
			;

		/*
		 * Send the character out.
		 */
		UART(URTDR) = *s;

		/*
		 * if there comes a LF, also do CR...
		 *
		 * Line Feed == '\n' == 10
		 */
		if (*s == 10) {
			while (UART(URUSR) & URUSR_TXDBSY)
				;
			/*
			 * CR = Carriage Return == '\r' == 13
			 */
			UART(URTDR) = 13;
		}
	}
#endif
}

/*
 * Nothing to do for these
 */
#define arch_decomp_setup()
#define arch_decomp_wdog()