uncompress.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*
  2. * arch/arm/mach-rpc/include/mach/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. #include <linux/io.h>
  12. #include <mach/hardware.h>
  13. #include <asm/setup.h>
  14. #include <asm/page.h>
  15. int video_size_row;
  16. unsigned char bytes_per_char_h;
  17. extern unsigned long con_charconvtable[256];
  18. struct param_struct {
  19. unsigned long page_size;
  20. unsigned long nr_pages;
  21. unsigned long ramdisk_size;
  22. unsigned long mountrootrdonly;
  23. unsigned long rootdev;
  24. unsigned long video_num_cols;
  25. unsigned long video_num_rows;
  26. unsigned long video_x;
  27. unsigned long video_y;
  28. unsigned long memc_control_reg;
  29. unsigned char sounddefault;
  30. unsigned char adfsdrives;
  31. unsigned char bytes_per_char_h;
  32. unsigned char bytes_per_char_v;
  33. unsigned long unused[256/4-11];
  34. };
  35. static const unsigned long palette_4[16] = {
  36. 0x00000000,
  37. 0x000000cc,
  38. 0x0000cc00, /* Green */
  39. 0x0000cccc, /* Yellow */
  40. 0x00cc0000, /* Blue */
  41. 0x00cc00cc, /* Magenta */
  42. 0x00cccc00, /* Cyan */
  43. 0x00cccccc, /* White */
  44. 0x00000000,
  45. 0x000000ff,
  46. 0x0000ff00,
  47. 0x0000ffff,
  48. 0x00ff0000,
  49. 0x00ff00ff,
  50. 0x00ffff00,
  51. 0x00ffffff
  52. };
  53. #define palette_setpixel(p) *(unsigned long *)(IO_START+0x00400000) = 0x10000000|((p) & 255)
  54. #define palette_write(v) *(unsigned long *)(IO_START+0x00400000) = 0x00000000|((v) & 0x00ffffff)
  55. /*
  56. * params_phys is a linker defined symbol - see
  57. * arch/arm/boot/compressed/Makefile
  58. */
  59. extern __attribute__((pure)) struct param_struct *params(void);
  60. #define params (params())
  61. #ifndef STANDALONE_DEBUG
  62. static unsigned long video_num_cols;
  63. static unsigned long video_num_rows;
  64. static unsigned long video_x;
  65. static unsigned long video_y;
  66. static unsigned char bytes_per_char_v;
  67. static int white;
  68. /*
  69. * This does not append a newline
  70. */
  71. static void putc(int c)
  72. {
  73. extern void ll_write_char(char *, char c, char white);
  74. int x,y;
  75. char *ptr;
  76. x = video_x;
  77. y = video_y;
  78. if (c == '\n') {
  79. if (++y >= video_num_rows)
  80. y--;
  81. } else if (c == '\r') {
  82. x = 0;
  83. } else {
  84. ptr = VIDMEM + ((y*video_num_cols*bytes_per_char_v+x)*bytes_per_char_h);
  85. ll_write_char(ptr, c, white);
  86. if (++x >= video_num_cols) {
  87. x = 0;
  88. if ( ++y >= video_num_rows ) {
  89. y--;
  90. }
  91. }
  92. }
  93. video_x = x;
  94. video_y = y;
  95. }
  96. static inline void flush(void)
  97. {
  98. }
  99. static void error(char *x);
  100. /*
  101. * Setup for decompression
  102. */
  103. static void arch_decomp_setup(void)
  104. {
  105. int i;
  106. struct tag *t = (struct tag *)params;
  107. unsigned int nr_pages = 0, page_size = PAGE_SIZE;
  108. if (t->hdr.tag == ATAG_CORE)
  109. {
  110. for (; t->hdr.size; t = tag_next(t))
  111. {
  112. if (t->hdr.tag == ATAG_VIDEOTEXT)
  113. {
  114. video_num_rows = t->u.videotext.video_lines;
  115. video_num_cols = t->u.videotext.video_cols;
  116. bytes_per_char_h = t->u.videotext.video_points;
  117. bytes_per_char_v = t->u.videotext.video_points;
  118. video_x = t->u.videotext.x;
  119. video_y = t->u.videotext.y;
  120. }
  121. if (t->hdr.tag == ATAG_MEM)
  122. {
  123. page_size = PAGE_SIZE;
  124. nr_pages += (t->u.mem.size / PAGE_SIZE);
  125. }
  126. }
  127. }
  128. else
  129. {
  130. nr_pages = params->nr_pages;
  131. page_size = params->page_size;
  132. video_num_rows = params->video_num_rows;
  133. video_num_cols = params->video_num_cols;
  134. video_x = params->video_x;
  135. video_y = params->video_y;
  136. bytes_per_char_h = params->bytes_per_char_h;
  137. bytes_per_char_v = params->bytes_per_char_v;
  138. }
  139. video_size_row = video_num_cols * bytes_per_char_h;
  140. if (bytes_per_char_h == 4)
  141. for (i = 0; i < 256; i++)
  142. con_charconvtable[i] =
  143. (i & 128 ? 1 << 0 : 0) |
  144. (i & 64 ? 1 << 4 : 0) |
  145. (i & 32 ? 1 << 8 : 0) |
  146. (i & 16 ? 1 << 12 : 0) |
  147. (i & 8 ? 1 << 16 : 0) |
  148. (i & 4 ? 1 << 20 : 0) |
  149. (i & 2 ? 1 << 24 : 0) |
  150. (i & 1 ? 1 << 28 : 0);
  151. else
  152. for (i = 0; i < 16; i++)
  153. con_charconvtable[i] =
  154. (i & 8 ? 1 << 0 : 0) |
  155. (i & 4 ? 1 << 8 : 0) |
  156. (i & 2 ? 1 << 16 : 0) |
  157. (i & 1 ? 1 << 24 : 0);
  158. palette_setpixel(0);
  159. if (bytes_per_char_h == 1) {
  160. palette_write (0);
  161. palette_write (0x00ffffff);
  162. for (i = 2; i < 256; i++)
  163. palette_write (0);
  164. white = 1;
  165. } else {
  166. for (i = 0; i < 256; i++)
  167. palette_write (i < 16 ? palette_4[i] : 0);
  168. white = 7;
  169. }
  170. if (nr_pages * page_size < 4096*1024) error("<4M of mem\n");
  171. }
  172. #endif
  173. /*
  174. * nothing to do
  175. */
  176. #define arch_decomp_wdog()