18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * arch/arm/mach-rpc/include/mach/uncompress.h 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 1996 Russell King 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci#define VIDMEM ((char *)SCREEN_START) 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#include <linux/io.h> 108c2ecf20Sopenharmony_ci#include <mach/hardware.h> 118c2ecf20Sopenharmony_ci#include <asm/setup.h> 128c2ecf20Sopenharmony_ci#include <asm/page.h> 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ciint video_size_row; 158c2ecf20Sopenharmony_ciunsigned char bytes_per_char_h; 168c2ecf20Sopenharmony_ciextern unsigned long con_charconvtable[256]; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct param_struct { 198c2ecf20Sopenharmony_ci unsigned long page_size; 208c2ecf20Sopenharmony_ci unsigned long nr_pages; 218c2ecf20Sopenharmony_ci unsigned long ramdisk_size; 228c2ecf20Sopenharmony_ci unsigned long mountrootrdonly; 238c2ecf20Sopenharmony_ci unsigned long rootdev; 248c2ecf20Sopenharmony_ci unsigned long video_num_cols; 258c2ecf20Sopenharmony_ci unsigned long video_num_rows; 268c2ecf20Sopenharmony_ci unsigned long video_x; 278c2ecf20Sopenharmony_ci unsigned long video_y; 288c2ecf20Sopenharmony_ci unsigned long memc_control_reg; 298c2ecf20Sopenharmony_ci unsigned char sounddefault; 308c2ecf20Sopenharmony_ci unsigned char adfsdrives; 318c2ecf20Sopenharmony_ci unsigned char bytes_per_char_h; 328c2ecf20Sopenharmony_ci unsigned char bytes_per_char_v; 338c2ecf20Sopenharmony_ci unsigned long unused[256/4-11]; 348c2ecf20Sopenharmony_ci}; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_cistatic const unsigned long palette_4[16] = { 378c2ecf20Sopenharmony_ci 0x00000000, 388c2ecf20Sopenharmony_ci 0x000000cc, 398c2ecf20Sopenharmony_ci 0x0000cc00, /* Green */ 408c2ecf20Sopenharmony_ci 0x0000cccc, /* Yellow */ 418c2ecf20Sopenharmony_ci 0x00cc0000, /* Blue */ 428c2ecf20Sopenharmony_ci 0x00cc00cc, /* Magenta */ 438c2ecf20Sopenharmony_ci 0x00cccc00, /* Cyan */ 448c2ecf20Sopenharmony_ci 0x00cccccc, /* White */ 458c2ecf20Sopenharmony_ci 0x00000000, 468c2ecf20Sopenharmony_ci 0x000000ff, 478c2ecf20Sopenharmony_ci 0x0000ff00, 488c2ecf20Sopenharmony_ci 0x0000ffff, 498c2ecf20Sopenharmony_ci 0x00ff0000, 508c2ecf20Sopenharmony_ci 0x00ff00ff, 518c2ecf20Sopenharmony_ci 0x00ffff00, 528c2ecf20Sopenharmony_ci 0x00ffffff 538c2ecf20Sopenharmony_ci}; 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci#define palette_setpixel(p) *(unsigned long *)(IO_START+0x00400000) = 0x10000000|((p) & 255) 568c2ecf20Sopenharmony_ci#define palette_write(v) *(unsigned long *)(IO_START+0x00400000) = 0x00000000|((v) & 0x00ffffff) 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* 598c2ecf20Sopenharmony_ci * params_phys is a linker defined symbol - see 608c2ecf20Sopenharmony_ci * arch/arm/boot/compressed/Makefile 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ciextern __attribute__((pure)) struct param_struct *params(void); 638c2ecf20Sopenharmony_ci#define params (params()) 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci#ifndef STANDALONE_DEBUG 668c2ecf20Sopenharmony_ciunsigned long video_num_cols; 678c2ecf20Sopenharmony_ciunsigned long video_num_rows; 688c2ecf20Sopenharmony_ciunsigned long video_x; 698c2ecf20Sopenharmony_ciunsigned long video_y; 708c2ecf20Sopenharmony_ciunsigned char bytes_per_char_v; 718c2ecf20Sopenharmony_ciint white; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* 748c2ecf20Sopenharmony_ci * This does not append a newline 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistatic inline void putc(int c) 778c2ecf20Sopenharmony_ci{ 788c2ecf20Sopenharmony_ci extern void ll_write_char(char *, char c, char white); 798c2ecf20Sopenharmony_ci int x,y; 808c2ecf20Sopenharmony_ci char *ptr; 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci x = video_x; 838c2ecf20Sopenharmony_ci y = video_y; 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci if (c == '\n') { 868c2ecf20Sopenharmony_ci if (++y >= video_num_rows) 878c2ecf20Sopenharmony_ci y--; 888c2ecf20Sopenharmony_ci } else if (c == '\r') { 898c2ecf20Sopenharmony_ci x = 0; 908c2ecf20Sopenharmony_ci } else { 918c2ecf20Sopenharmony_ci ptr = VIDMEM + ((y*video_num_cols*bytes_per_char_v+x)*bytes_per_char_h); 928c2ecf20Sopenharmony_ci ll_write_char(ptr, c, white); 938c2ecf20Sopenharmony_ci if (++x >= video_num_cols) { 948c2ecf20Sopenharmony_ci x = 0; 958c2ecf20Sopenharmony_ci if ( ++y >= video_num_rows ) { 968c2ecf20Sopenharmony_ci y--; 978c2ecf20Sopenharmony_ci } 988c2ecf20Sopenharmony_ci } 998c2ecf20Sopenharmony_ci } 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci video_x = x; 1028c2ecf20Sopenharmony_ci video_y = y; 1038c2ecf20Sopenharmony_ci} 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_cistatic inline void flush(void) 1068c2ecf20Sopenharmony_ci{ 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci/* 1108c2ecf20Sopenharmony_ci * Setup for decompression 1118c2ecf20Sopenharmony_ci */ 1128c2ecf20Sopenharmony_cistatic void arch_decomp_setup(void) 1138c2ecf20Sopenharmony_ci{ 1148c2ecf20Sopenharmony_ci int i; 1158c2ecf20Sopenharmony_ci struct tag *t = (struct tag *)params; 1168c2ecf20Sopenharmony_ci unsigned int nr_pages = 0, page_size = PAGE_SIZE; 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci if (t->hdr.tag == ATAG_CORE) { 1198c2ecf20Sopenharmony_ci for (; t->hdr.size; t = tag_next(t)) { 1208c2ecf20Sopenharmony_ci if (t->hdr.tag == ATAG_VIDEOTEXT) { 1218c2ecf20Sopenharmony_ci video_num_rows = t->u.videotext.video_lines; 1228c2ecf20Sopenharmony_ci video_num_cols = t->u.videotext.video_cols; 1238c2ecf20Sopenharmony_ci video_x = t->u.videotext.x; 1248c2ecf20Sopenharmony_ci video_y = t->u.videotext.y; 1258c2ecf20Sopenharmony_ci } else if (t->hdr.tag == ATAG_VIDEOLFB) { 1268c2ecf20Sopenharmony_ci bytes_per_char_h = t->u.videolfb.lfb_depth; 1278c2ecf20Sopenharmony_ci bytes_per_char_v = 8; 1288c2ecf20Sopenharmony_ci } else if (t->hdr.tag == ATAG_MEM) { 1298c2ecf20Sopenharmony_ci page_size = PAGE_SIZE; 1308c2ecf20Sopenharmony_ci nr_pages += (t->u.mem.size / PAGE_SIZE); 1318c2ecf20Sopenharmony_ci } 1328c2ecf20Sopenharmony_ci } 1338c2ecf20Sopenharmony_ci } else { 1348c2ecf20Sopenharmony_ci nr_pages = params->nr_pages; 1358c2ecf20Sopenharmony_ci page_size = params->page_size; 1368c2ecf20Sopenharmony_ci video_num_rows = params->video_num_rows; 1378c2ecf20Sopenharmony_ci video_num_cols = params->video_num_cols; 1388c2ecf20Sopenharmony_ci video_x = params->video_x; 1398c2ecf20Sopenharmony_ci video_y = params->video_y; 1408c2ecf20Sopenharmony_ci bytes_per_char_h = params->bytes_per_char_h; 1418c2ecf20Sopenharmony_ci bytes_per_char_v = params->bytes_per_char_v; 1428c2ecf20Sopenharmony_ci } 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci video_size_row = video_num_cols * bytes_per_char_h; 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci if (bytes_per_char_h == 4) 1478c2ecf20Sopenharmony_ci for (i = 0; i < 256; i++) 1488c2ecf20Sopenharmony_ci con_charconvtable[i] = 1498c2ecf20Sopenharmony_ci (i & 128 ? 1 << 0 : 0) | 1508c2ecf20Sopenharmony_ci (i & 64 ? 1 << 4 : 0) | 1518c2ecf20Sopenharmony_ci (i & 32 ? 1 << 8 : 0) | 1528c2ecf20Sopenharmony_ci (i & 16 ? 1 << 12 : 0) | 1538c2ecf20Sopenharmony_ci (i & 8 ? 1 << 16 : 0) | 1548c2ecf20Sopenharmony_ci (i & 4 ? 1 << 20 : 0) | 1558c2ecf20Sopenharmony_ci (i & 2 ? 1 << 24 : 0) | 1568c2ecf20Sopenharmony_ci (i & 1 ? 1 << 28 : 0); 1578c2ecf20Sopenharmony_ci else 1588c2ecf20Sopenharmony_ci for (i = 0; i < 16; i++) 1598c2ecf20Sopenharmony_ci con_charconvtable[i] = 1608c2ecf20Sopenharmony_ci (i & 8 ? 1 << 0 : 0) | 1618c2ecf20Sopenharmony_ci (i & 4 ? 1 << 8 : 0) | 1628c2ecf20Sopenharmony_ci (i & 2 ? 1 << 16 : 0) | 1638c2ecf20Sopenharmony_ci (i & 1 ? 1 << 24 : 0); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci 1668c2ecf20Sopenharmony_ci palette_setpixel(0); 1678c2ecf20Sopenharmony_ci if (bytes_per_char_h == 1) { 1688c2ecf20Sopenharmony_ci palette_write (0); 1698c2ecf20Sopenharmony_ci palette_write (0x00ffffff); 1708c2ecf20Sopenharmony_ci for (i = 2; i < 256; i++) 1718c2ecf20Sopenharmony_ci palette_write (0); 1728c2ecf20Sopenharmony_ci white = 1; 1738c2ecf20Sopenharmony_ci } else { 1748c2ecf20Sopenharmony_ci for (i = 0; i < 256; i++) 1758c2ecf20Sopenharmony_ci palette_write (i < 16 ? palette_4[i] : 0); 1768c2ecf20Sopenharmony_ci white = 7; 1778c2ecf20Sopenharmony_ci } 1788c2ecf20Sopenharmony_ci 1798c2ecf20Sopenharmony_ci if (nr_pages * page_size < 4096*1024) error("<4M of mem\n"); 1808c2ecf20Sopenharmony_ci} 1818c2ecf20Sopenharmony_ci#endif 182