ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / asm-arm / arch-rpc / uncompress.h
1 /*
2  *  linux/include/asm-arm/arch-rpc/uncompress.h
3  *
4  *  Copyright (C) 1996 Russell King
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10 #define VIDMEM ((char *)SCREEN_START)
11  
12 #include <asm/hardware.h>
13 #include <asm/io.h>
14
15 int video_num_columns, video_num_lines, video_size_row;
16 int white, bytes_per_char_h;
17 extern unsigned long con_charconvtable[256];
18
19 struct param_struct {
20         unsigned long page_size;
21         unsigned long nr_pages;
22         unsigned long ramdisk_size;
23         unsigned long mountrootrdonly;
24         unsigned long rootdev;
25         unsigned long video_num_cols;
26         unsigned long video_num_rows;
27         unsigned long video_x;
28         unsigned long video_y;
29         unsigned long memc_control_reg;
30         unsigned char sounddefault;
31         unsigned char adfsdrives;
32         unsigned char bytes_per_char_h;
33         unsigned char bytes_per_char_v;
34         unsigned long unused[256/4-11];
35 };
36
37 static const unsigned long palette_4[16] = {
38         0x00000000,
39         0x000000cc,
40         0x0000cc00,             /* Green   */
41         0x0000cccc,             /* Yellow  */
42         0x00cc0000,             /* Blue    */
43         0x00cc00cc,             /* Magenta */
44         0x00cccc00,             /* Cyan    */
45         0x00cccccc,             /* White   */
46         0x00000000,
47         0x000000ff,
48         0x0000ff00,
49         0x0000ffff,
50         0x00ff0000,
51         0x00ff00ff,
52         0x00ffff00,
53         0x00ffffff
54 };
55
56 #define palette_setpixel(p)     *(unsigned long *)(IO_START+0x00400000) = 0x10000000|((p) & 255)
57 #define palette_write(v)        *(unsigned long *)(IO_START+0x00400000) = 0x00000000|((v) & 0x00ffffff)
58
59 static struct param_struct *params = (struct param_struct *)PARAMS_PHYS;
60
61 #ifndef STANDALONE_DEBUG 
62 /*
63  * This does not append a newline
64  */
65 static void puts(const char *s)
66 {
67         extern void ll_write_char(char *, char c, char white);
68         int x,y;
69         unsigned char c;
70         char *ptr;
71
72         x = params->video_x;
73         y = params->video_y;
74
75         while ( ( c = *(unsigned char *)s++ ) != '\0' ) {
76                 if ( c == '\n' ) {
77                         x = 0;
78                         if ( ++y >= video_num_lines ) {
79                                 y--;
80                         }
81                 } else {
82                         ptr = VIDMEM + ((y*video_num_columns*params->bytes_per_char_v+x)*bytes_per_char_h);
83                         ll_write_char(ptr, c, white);
84                         if ( ++x >= video_num_columns ) {
85                                 x = 0;
86                                 if ( ++y >= video_num_lines ) {
87                                         y--;
88                                 }
89                         }
90                 }
91         }
92
93         params->video_x = x;
94         params->video_y = y;
95 }
96
97 static void error(char *x);
98
99 /*
100  * Setup for decompression
101  */
102 static void arch_decomp_setup(void)
103 {
104         int i;
105         
106         video_num_lines = params->video_num_rows;
107         video_num_columns = params->video_num_cols;
108         bytes_per_char_h = params->bytes_per_char_h;
109         video_size_row = video_num_columns * bytes_per_char_h;
110         if (bytes_per_char_h == 4)
111                 for (i = 0; i < 256; i++)
112                         con_charconvtable[i] =
113                                 (i & 128 ? 1 << 0  : 0) |
114                                 (i & 64  ? 1 << 4  : 0) |
115                                 (i & 32  ? 1 << 8  : 0) |
116                                 (i & 16  ? 1 << 12 : 0) |
117                                 (i & 8   ? 1 << 16 : 0) |
118                                 (i & 4   ? 1 << 20 : 0) |
119                                 (i & 2   ? 1 << 24 : 0) |
120                                 (i & 1   ? 1 << 28 : 0);
121         else
122                 for (i = 0; i < 16; i++)
123                         con_charconvtable[i] =
124                                 (i & 8   ? 1 << 0  : 0) |
125                                 (i & 4   ? 1 << 8  : 0) |
126                                 (i & 2   ? 1 << 16 : 0) |
127                                 (i & 1   ? 1 << 24 : 0);
128
129
130         palette_setpixel(0);
131         if (bytes_per_char_h == 1) {
132                 palette_write (0);
133                 palette_write (0x00ffffff);
134                 for (i = 2; i < 256; i++)
135                         palette_write (0);
136                 white = 1;
137         } else {
138                 for (i = 0; i < 256; i++)
139                         palette_write (i < 16 ? palette_4[i] : 0);
140                 white = 7;
141         }
142
143         if (params->nr_pages * params->page_size < 4096*1024) error("<4M of mem\n");
144 }
145 #endif
146
147 /*
148  * nothing to do
149  */
150 #define arch_decomp_wdog()