uncompress.h 4.1 KB

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