13 #include <linux/compiler.h>
14 #include <asm/serial-regs.h>
17 #ifndef CONFIG_GDBSTUB_ON_TTYSx
20 #define CYG_DEV_BASE 0xA6FB0000
22 #define CYG_DEV_BASE 0xA6FC0000
25 #define CYG_DEV_THR (*((volatile __u8*)(CYG_DEV_BASE + 0x00)))
26 #define CYG_DEV_MCR (*((volatile __u8*)(CYG_DEV_BASE + 0x10)))
27 #define SIO_MCR_DTR 0x01
28 #define SIO_MCR_RTS 0x02
29 #define CYG_DEV_LSR (*((volatile __u8*)(CYG_DEV_BASE + 0x14)))
30 #define SIO_LSR_THRE 0x20
31 #define SIO_LSR_TEMT 0x40
32 #define CYG_DEV_MSR (*((volatile __u8*)(CYG_DEV_BASE + 0x18)))
33 #define SIO_MSR_CTS 0x10
34 #define SIO_MSR_DSR 0x20
36 #define LSR_WAIT_FOR(STATE) \
37 do { while (!(CYG_DEV_LSR & SIO_LSR_##STATE)) {} } while (0)
38 #define FLOWCTL_QUERY(LINE) \
39 ({ CYG_DEV_MSR & SIO_MSR_##LINE; })
40 #define FLOWCTL_WAIT_FOR(LINE) \
41 do { while (!(CYG_DEV_MSR & SIO_MSR_##LINE)) {} } while (0)
42 #define FLOWCTL_CLEAR(LINE) \
43 do { CYG_DEV_MCR &= ~SIO_MCR_##LINE; } while (0)
44 #define FLOWCTL_SET(LINE) \
45 do { CYG_DEV_MCR |= SIO_MCR_##LINE; } while (0)
58 static inline void *
memset(
const void *
s,
int c,
size_t n)
61 char *
ss = (
char *) s;
63 for (i = 0; i <
n; i++)
68 #define memzero(s, n) memset((s), 0, (n))
70 static inline void *
memcpy(
void *__dest,
const void *__src,
size_t __n)
73 const char *
s = __src;
76 for (i = 0; i < __n; i++)
81 typedef unsigned char uch;
82 typedef unsigned short ush;
83 typedef unsigned long ulg;
91 static unsigned insize;
92 static unsigned inptr;
93 static unsigned outcnt;
96 #define ASCII_FLAG 0x01
97 #define CONTINUATION 0x02
98 #define EXTRA_FIELD 0x04
99 #define ORIG_NAME 0x08
101 #define ENCRYPTED 0x20
102 #define RESERVED 0xC0
106 # define Assert(cond, msg) { if (!(cond)) error(msg); }
107 # define Trace(x) fprintf x
108 # define Tracev(x) { if (verbose) fprintf x ; }
109 # define Tracevv(x) { if (verbose > 1) fprintf x ; }
110 # define Tracec(c, x) { if (verbose && (c)) fprintf x ; }
111 # define Tracecv(c, x) { if (verbose > 1 && (c)) fprintf x ; }
113 # define Assert(cond, msg)
117 # define Tracec(c, x)
118 # define Tracecv(c, x)
121 static int fill_inbuf(
void);
124 static
void kputs(
const char *);
126 static
inline unsigned char get_byte(
void)
132 hex[0] = ((ch & 0x0f) > 9) ?
133 ((ch & 0x0f) +
'A' - 0xa) : ((ch & 0x0f) +
'0');
134 hex[1] = ((ch >> 4) > 9) ?
135 ((ch >> 4) +
'A' - 0xa) : ((ch >> 4) +
'0');
145 #define EXT_MEM_K (*(unsigned short *)0x90002)
146 #ifndef STANDARD_MEMORY_BIOS_CALL
147 #define ALT_MEM_K (*(unsigned long *) 0x901e0)
149 #define SCREEN_INFO (*(struct screen_info *)0x90000)
151 static long bytes_out;
159 #define INPLACE_MOVE_ROUTINE 0x1000
160 #define LOW_BUFFER_START 0x2000
161 #define LOW_BUFFER_END 0x90000
162 #define LOW_BUFFER_SIZE (LOW_BUFFER_END - LOW_BUFFER_START)
163 #define HEAP_SIZE 0x3000
164 static int high_loaded;
165 static uch *high_buffer_start ;
167 static char *vidmem = (
char *)0xb8000;
168 static int lines,
cols;
170 #define BOOTLOADER_INFLATE
171 #include "../../../../lib/inflate.c"
173 static inline void scroll(
void)
178 for (i = (lines - 1) *
cols * 2; i < lines *
cols * 2; i += 2)
182 static inline void kputchar(
unsigned char ch)
184 #ifdef CONFIG_MN10300_UNIT_ASB2305
185 while (SC0STR & SC01STR_TBF)
190 while (SC0STR & SC01STR_TBF)
197 while (SC1STR & SC01STR_TBF)
202 while (SC1STR & SC01STR_TBF)
211 static void kputs(
const char *
s)
213 #ifdef CONFIG_DEBUG_DECOMPRESS_KERNEL
214 #ifndef CONFIG_GDBSTUB_ON_TTYSx
244 static int fill_inbuf()
247 error(
"ran out of input data\n");
259 static void flush_window_low(
void)
267 for (n = 0; n < outcnt; n++) {
269 c = crc_32_tab[((
int)c ^ ch) & 0xff] ^ (c >> 8);
272 bytes_out += (
ulg)outcnt;
277 static void flush_window_high(
void)
283 for (n = 0; n < outcnt; n++) {
287 c = crc_32_tab[((
int)c ^ ch) & 0xff] ^ (c >> 8);
290 bytes_out += (
ulg)outcnt;
302 static void error(
const char *
x)
306 kputs(
"\n\n -- System halted");
312 #define STACK_SIZE (4096)
323 #ifdef STANDARD_MEMORY_BIOS_CALL
325 error(
"Less than 2MB of memory.\n");
328 error(
"Less than 2MB of memory.\n");
343 #ifdef STANDARD_MEMORY_BIOS_CALL
345 error(
"Less than 4MB of memory.\n");
348 error(
"Less than 4MB of memory.\n");
389 kputs(
"Uncompressing Linux... ");
391 kputs(
"Ok, booting the kernel.\n");