mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
changes from smg
This commit is contained in:
parent
8224daf61a
commit
05f5dde560
2 changed files with 63 additions and 13 deletions
|
@ -4,7 +4,7 @@
|
|||
* $Source$
|
||||
*
|
||||
* load a splash image from a pcx file
|
||||
* the pcs file is stored in flash at a know address.
|
||||
* the pcs file is stored in flash at a known address.
|
||||
* VGA must be in gmode prior to entering this routine.
|
||||
* There are some assumptions made about the pcx image
|
||||
* and the color table. See the code.
|
||||
|
@ -12,6 +12,10 @@
|
|||
* by
|
||||
* Steve M. Gehlbach <steve@kesa.com>
|
||||
*
|
||||
* References:
|
||||
* PCX file spec:
|
||||
* http://www.whisqu.se/per/docs/graphics57.htm
|
||||
*
|
||||
* pcx row decode function modified from the netpbm project
|
||||
* http://download.sourceforge.net/netpbm/
|
||||
*
|
||||
|
@ -28,9 +32,11 @@ u8 *vga = (u8 *) VGA_GRAFIX_BASE;
|
|||
static void GetPCXRow(unsigned char * pcx_file, unsigned char * const pcxrow, int const bytesperline, int * file_index);
|
||||
void writeVga(u8 *pcxrow);
|
||||
|
||||
// globals
|
||||
static int rowsRead = 0;
|
||||
static int xsize = 0;
|
||||
static int ysize = 0;
|
||||
static u8 p_offset;
|
||||
|
||||
struct pcx_header {
|
||||
u8 manufacturer;
|
||||
|
@ -58,6 +64,31 @@ int vga_load_pcx (char * pcx_file, int size) {
|
|||
u8 vgarow[650];
|
||||
struct pcx_header *pcx;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Image must be 1 plane, 8 bits per pixel, run length encoding,
|
||||
// 256 colors with only 16 colors of the 256 used. The file is
|
||||
// assumed to be a version 5 type file with the 256
|
||||
// color palette at the file end. Only 4 bit planes
|
||||
// are used, however, so the image must be generated with
|
||||
// 16 colors, so that the palette uses only 16
|
||||
// entries. The image can use either the bottom or
|
||||
// top of the palette (the code checks the
|
||||
// bottom then the top of 256 entry palette).
|
||||
// Gimp puts the 16 entry palette at the beginning of the 256 color
|
||||
// palette, and PhotoShop puts the 16 colors at the end of the palette.
|
||||
// Both are supported. To generate a compatible pcx file in gimp,
|
||||
// right click on the image and select image->mode->indexed,
|
||||
// change #colors to 16, and make sure "Generate Optimal Palette"
|
||||
// and appropriate dithering is selected (Floyd Steinberg Normal
|
||||
// is the default and seems to work). Click Okay, then right
|
||||
// click and select File->Save As and select PCX as the File
|
||||
// Type and save the file with a pcx extension.
|
||||
// This routine supports variable width and height but the default
|
||||
// for linuxbios is 640 x 400 pixels.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
pcx = (struct pcx_header *) pcx_file;
|
||||
if ( ! (pcx->manufacturer == 0x0a && pcx->version == 0x05 && pcx->encoding == 0x01) ) {
|
||||
printk_info("vga_load_pcx: not a compatible .pcx file.\n");
|
||||
|
@ -83,22 +114,35 @@ int vga_load_pcx (char * pcx_file, int size) {
|
|||
total_bytes_per_line*ysize
|
||||
);
|
||||
|
||||
// read the color table at the end of the file
|
||||
// skip first 240 colors
|
||||
// we only use last 16 colors
|
||||
// Read the color table at the end of the file.
|
||||
// Check the beginning of the palette to see if it
|
||||
// is non-zero. Default to the end of the palette
|
||||
// if beginning is zero. We only use 16 colors.
|
||||
|
||||
file_index = size-769;
|
||||
// check palette signature
|
||||
if (pcx_file[file_index++] != PCX_256_COLORS) {
|
||||
// palette no good, bail out
|
||||
printk_info("vga_load_pcx: invalid color table signature at file_index %d: 0x%x\n",
|
||||
file_index-1,pcx_file[file_index-1]);
|
||||
return -1;
|
||||
}
|
||||
file_index += 240*3;
|
||||
|
||||
// add up 2 3-tuples at beginning of palette and see if the result == 0; if so,
|
||||
// then use top 16 entries. If not, then use 16 entries at beginning of palette.
|
||||
p_offset = 0;
|
||||
for (i = 0; i<6; i++) p_offset += pcx_file[file_index + i];
|
||||
if (p_offset == 0) p_offset = 240;
|
||||
else p_offset = 0;
|
||||
|
||||
file_index += p_offset*3;
|
||||
i = 0;
|
||||
outb_p(240, PEL_IW);
|
||||
do {
|
||||
// put the 16 3-tuple color table at the top of the PEL
|
||||
// scale 0-255 -> 0-63
|
||||
// put the 16 3-tuple color table at the upper end of the PEL
|
||||
// this avoids conflicting with standard palette at lower end
|
||||
// since the upper end is not used in this legacy mode
|
||||
// scale 0-255 -> 0-63 (6 bit DAC)
|
||||
outb_p(pcx_file[file_index++]>>2, PEL_D);
|
||||
outb_p(pcx_file[file_index++]>>2, PEL_D);
|
||||
outb_p(pcx_file[file_index++]>>2, PEL_D);
|
||||
|
@ -110,6 +154,7 @@ int vga_load_pcx (char * pcx_file, int size) {
|
|||
printk_debug("vga_load_pcx: %d colors read into colortable.\n",i);
|
||||
|
||||
// set the color select to set b7-4 to 1111 to use high end of PEL
|
||||
// this avoids conflicting with standard palette at lower end
|
||||
write_att(read_att_b(ATC_MODE)|0x80,ATC_MODE);
|
||||
write_att(0x0f,ATC_COLOR_PAGE);
|
||||
|
||||
|
@ -211,8 +256,9 @@ void writeVga(u8 *pcxrow) {
|
|||
}
|
||||
if (i >= xsize) return;
|
||||
}
|
||||
// pixel value is at high end so subtract 240
|
||||
s_pixel = pcxrow[i] - 240;
|
||||
// if we are using upper end of palette, then
|
||||
// subtract 240 to scale value to 0-15
|
||||
s_pixel = pcxrow[i] - p_offset;
|
||||
mask = 0x80 >> (i % 8);
|
||||
for (j=0;j<4;j++)
|
||||
if (s_pixel & (1<<j) )
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
# by Steve M. Gehlbach <steve@kesa.com>
|
||||
#
|
||||
|
||||
# This will dump files in directory of /usr/src/pcchips
|
||||
# This will dump files in directory of /usr/src/pcchips787
|
||||
target /usr/src/pcchips787
|
||||
|
||||
|
||||
|
@ -84,10 +84,14 @@ commandline root=/dev/hda1 ro reboot=h
|
|||
# these actions put the pcx image file on the front of the bios.
|
||||
# the image size is placed in the first 4 bytes then the pcx file
|
||||
# important that ROM_IMAGE_SIZE be set to 128K or larger.
|
||||
# The logo file is called linuxbioslogo.pcx and should be copied to the build directory
|
||||
# The logo file is called linuxbioslogo.pcx and is by default located at
|
||||
# src/pc80/linuxbioslogo.pcx.
|
||||
# Change the variable LOGOFILE below if you want to use your own file.
|
||||
# See the file src/pc80/vga_load_pcx.c for details on the file format.
|
||||
#
|
||||
addaction linuxbios.rom dd if=$(TOP)/src/pc80/linuxbioslogo.pcx of=linuxbios.rom bs=1 seek=4 conv=notrunc;
|
||||
addaction linuxbios.rom perl -e '@a=stat "$(TOP)/src/pc80/linuxbioslogo.pcx";$$a=pack("L",$$a[7]); print $$a' | dd of=linuxbios.rom bs=1 conv=notrunc
|
||||
option LOGOFILE=$(TOP)/src/pc80/linuxbioslogo.pcx
|
||||
addaction linuxbios.rom dd if=$(LOGOFILE) of=linuxbios.rom bs=1 seek=4 conv=notrunc;
|
||||
addaction linuxbios.rom perl -e '@a=stat "$(LOGOFILE)";$$a=pack("L",$$a[7]); print $$a' | dd of=linuxbios.rom bs=1 conv=notrunc
|
||||
|
||||
# copy to home dir where flash programmer can reach.
|
||||
addaction linuxbios.rom /bin/cp -f linuxbios.rom $(HOME)/linuxbios_787.bin
|
||||
|
|
Loading…
Add table
Reference in a new issue