mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
fixes for alpha.
Note the beginning of moving linuxbios_table.c to src/lib
This commit is contained in:
parent
f11b412d37
commit
4dc3c174db
10 changed files with 804 additions and 24 deletions
|
@ -1 +1,2 @@
|
|||
object boot.o
|
||||
object linuxbios_table.o
|
||||
|
|
281
src/arch/alpha/boot/linuxbios_table.c
Normal file
281
src/arch/alpha/boot/linuxbios_table.c
Normal file
|
@ -0,0 +1,281 @@
|
|||
#include <mem.h>
|
||||
#include <ip_checksum.h>
|
||||
#include <boot/linuxbios_tables.h>
|
||||
#include <boot/linuxbios_table.h>
|
||||
#include <printk.h>
|
||||
#include <string.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
struct lb_header *lb_table_init(unsigned long addr)
|
||||
{
|
||||
struct lb_header *header;
|
||||
|
||||
/* 16 byte align the address */
|
||||
addr += 15;
|
||||
addr &= ~15;
|
||||
|
||||
header = (void *)addr;
|
||||
header->signature[0] = 'L';
|
||||
header->signature[1] = 'B';
|
||||
header->signature[2] = 'I';
|
||||
header->signature[3] = 'O';
|
||||
header->header_bytes = sizeof(*header);
|
||||
header->header_checksum = 0;
|
||||
header->table_bytes = 0;
|
||||
header->table_checksum = 0;
|
||||
header->table_entries = 0;
|
||||
return header;
|
||||
}
|
||||
|
||||
struct lb_record *lb_first_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = (void *)(((char *)header) + sizeof(*header));
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_last_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = (void *)(((char *)header) + sizeof(*header) + header->table_bytes);
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_next_record(struct lb_record *rec)
|
||||
{
|
||||
rec = (void *)(((char *)rec) + rec->size);
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_new_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = lb_last_record(header);
|
||||
if (header->table_entries) {
|
||||
header->table_bytes += rec->size;
|
||||
}
|
||||
rec = lb_last_record(header);
|
||||
header->table_entries++;
|
||||
rec->tag = LB_TAG_UNUSED;
|
||||
rec->size = sizeof(*rec);
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
struct lb_memory *lb_memory(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
struct lb_memory *mem;
|
||||
rec = lb_new_record(header);
|
||||
mem = (struct lb_memory *)rec;
|
||||
mem->tag = LB_TAG_MEMORY;
|
||||
mem->size = sizeof(*mem);
|
||||
return mem;
|
||||
}
|
||||
|
||||
struct lb_mainboard *lb_mainboard(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
struct lb_mainboard *mainboard;
|
||||
rec = lb_new_record(header);
|
||||
mainboard = (struct lb_mainboard *)rec;
|
||||
mainboard->tag = LB_TAG_MAINBOARD;
|
||||
|
||||
mainboard->size = (sizeof(*mainboard) +
|
||||
strlen(mainboard_vendor) + 1 +
|
||||
strlen(mainboard_part_number) + 1 +
|
||||
3) & ~3;
|
||||
|
||||
mainboard->vendor_idx = 0;
|
||||
mainboard->part_number_idx = strlen(mainboard_vendor) + 1;
|
||||
|
||||
memcpy(mainboard->strings + mainboard->vendor_idx,
|
||||
mainboard_vendor, strlen(mainboard_vendor) + 1);
|
||||
memcpy(mainboard->strings + mainboard->part_number_idx,
|
||||
mainboard_part_number, strlen(mainboard_part_number) + 1);
|
||||
|
||||
return mainboard;
|
||||
}
|
||||
|
||||
void lb_strings(struct lb_header *header)
|
||||
{
|
||||
static const struct {
|
||||
uint32_t tag;
|
||||
const uint8_t *string;
|
||||
} strings[] = {
|
||||
{ LB_TAG_VERSION, linuxbios_version, },
|
||||
{ LB_TAG_EXTRA_VERSION, linuxbios_extra_version, },
|
||||
{ LB_TAG_BUILD, linuxbios_build, },
|
||||
{ LB_TAG_COMPILE_TIME, linuxbios_compile_time, },
|
||||
{ LB_TAG_COMPILE_BY, linuxbios_compile_by, },
|
||||
{ LB_TAG_COMPILE_HOST, linuxbios_compile_host, },
|
||||
{ LB_TAG_COMPILE_DOMAIN, linuxbios_compile_domain, },
|
||||
{ LB_TAG_COMPILER, linuxbios_compiler, },
|
||||
{ LB_TAG_LINKER, linuxbios_linker, },
|
||||
{ LB_TAG_ASSEMBLER, linuxbios_assembler, },
|
||||
};
|
||||
int i;
|
||||
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
|
||||
struct lb_string *rec;
|
||||
size_t len;
|
||||
rec = lb_new_record(header);
|
||||
len = strlen(strings[i].string);
|
||||
rec->tag = strings[i].tag;
|
||||
rec->size = (sizeof(*rec) + len + 1 + 3) & ~3;
|
||||
memcpy(rec->string, strings[i].string, len+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Some version of gcc have problems with 64 bit types so
|
||||
* take an unsigned long instead of a uint64_t for now.
|
||||
*/
|
||||
void lb_memory_range(struct lb_memory *mem,
|
||||
uint32_t type, unsigned long start, unsigned long size)
|
||||
{
|
||||
int entries;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
mem->map[entries].start = start;
|
||||
mem->map[entries].size = size;
|
||||
mem->map[entries].type = type;
|
||||
mem->size += sizeof(mem->map[0]);
|
||||
}
|
||||
|
||||
static void lb_memory_rangek(struct lb_memory *mem,
|
||||
uint32_t type, unsigned long startk, unsigned long endk)
|
||||
{
|
||||
int entries;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
mem->map[entries].start = startk;
|
||||
mem->map[entries].start <<= 10;
|
||||
mem->map[entries].size = endk - startk;
|
||||
mem->map[entries].size <<= 10;
|
||||
mem->map[entries].type = type;
|
||||
mem->size += sizeof(mem->map[0]);
|
||||
}
|
||||
|
||||
static void lb_reserve_table_memory(struct lb_header *head)
|
||||
{
|
||||
struct lb_record *last_rec;
|
||||
struct lb_memory *mem;
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
int i, entries;
|
||||
|
||||
last_rec = lb_last_record(head);
|
||||
mem = get_lb_mem();
|
||||
start = (unsigned long)head;
|
||||
end = (unsigned long)last_rec;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
/* Resize the right two memory areas so this table is in
|
||||
* a reserved area of memory. Everything has been carefully
|
||||
* setup so that is all we need to do.
|
||||
*/
|
||||
for(i = 0; i < entries; i++ ) {
|
||||
uint64_t map_start = mem->map[i].start;
|
||||
uint64_t map_end = map_start + mem->map[i].size;
|
||||
/* Does this area need to be expanded? */
|
||||
if (map_end == start) {
|
||||
mem->map[i].size = end - map_start;
|
||||
}
|
||||
/* Does this area need to be contracted? */
|
||||
else if (map_start == start) {
|
||||
mem->map[i].start = end;
|
||||
mem->map[i].size = map_end - end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long lb_table_fini(struct lb_header *head)
|
||||
{
|
||||
struct lb_record *rec, *first_rec;
|
||||
rec = lb_last_record(head);
|
||||
if (head->table_entries) {
|
||||
head->table_bytes += rec->size;
|
||||
}
|
||||
lb_reserve_table_memory(head);
|
||||
first_rec = lb_first_record(head);
|
||||
head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
|
||||
head->header_checksum = 0;
|
||||
head->header_checksum = compute_ip_checksum(head, sizeof(*head));
|
||||
printk_debug("Wrote linuxbios table at: %p - %p checksum %lx\n",
|
||||
head, rec, head->table_checksum);
|
||||
return (unsigned long)rec;
|
||||
}
|
||||
|
||||
|
||||
/* Routines to extract part so the linuxBIOS table or
|
||||
* information from the linuxBIOS table after we have written it.
|
||||
* Currently get_lb_mem relies on a global we can change the
|
||||
* implementaiton.
|
||||
*/
|
||||
static struct lb_memory *mem_ranges = 0;
|
||||
struct lb_memory *get_lb_mem(void)
|
||||
{
|
||||
return mem_ranges;
|
||||
}
|
||||
|
||||
unsigned long write_linuxbios_table(
|
||||
unsigned long *processor_map,
|
||||
struct mem_range *ram,
|
||||
unsigned long low_table_start, unsigned long low_table_end,
|
||||
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
||||
{
|
||||
unsigned long table_size;
|
||||
struct mem_range *ramp;
|
||||
struct lb_header *head;
|
||||
struct lb_memory *mem;
|
||||
struct lb_record *rec_dest, *rec_src;
|
||||
|
||||
head = lb_table_init(low_table_end);
|
||||
low_table_end = (unsigned long)head;
|
||||
#if HAVE_OPTION_TABLE == 1
|
||||
/* Write the option config table... */
|
||||
rec_dest = lb_new_record(head);
|
||||
rec_src = (struct lb_record *)&option_table;
|
||||
memcpy(rec_dest, rec_src, rec_src->size);
|
||||
#endif
|
||||
mem = lb_memory(head);
|
||||
mem_ranges = mem;
|
||||
/* I assume there is always ram at address 0 */
|
||||
/* Reserve our tables in low memory */
|
||||
table_size = (low_table_end - low_table_start);
|
||||
lb_memory_range(mem, LB_MEM_TABLE, 0, table_size);
|
||||
lb_memory_range(mem, LB_MEM_RAM, table_size, (ram[0].sizek << 10) - table_size);
|
||||
/* Reserving pci memory mapped space will keep the kernel from booting seeing
|
||||
* any pci resources.
|
||||
*/
|
||||
for(ramp = &ram[1]; ramp->sizek; ramp++) {
|
||||
unsigned long startk, endk;
|
||||
startk = ramp->basek;
|
||||
endk = startk + ramp->sizek;
|
||||
if ((startk < rom_table_startk) && (endk > rom_table_startk)) {
|
||||
lb_memory_rangek(mem, LB_MEM_RAM, startk, rom_table_startk);
|
||||
startk = rom_table_startk;
|
||||
}
|
||||
if ((startk == rom_table_startk) && (endk > startk)) {
|
||||
unsigned long tend;
|
||||
tend = rom_table_endk;
|
||||
if (tend > endk) {
|
||||
tend = endk;
|
||||
}
|
||||
lb_memory_rangek(mem, LB_MEM_TABLE, rom_table_startk, tend);
|
||||
startk = tend;
|
||||
}
|
||||
if (endk > startk) {
|
||||
lb_memory_rangek(mem, LB_MEM_RAM, startk, endk);
|
||||
}
|
||||
}
|
||||
|
||||
/* Record our motheboard */
|
||||
lb_mainboard(head);
|
||||
/* Record our various random string information */
|
||||
lb_strings(head);
|
||||
|
||||
low_table_end = lb_table_fini(head);
|
||||
|
||||
/* Remember where my valid memory ranges are */
|
||||
return low_table_end;
|
||||
}
|
|
@ -1,35 +1,58 @@
|
|||
/*
|
||||
* Memory map:
|
||||
*
|
||||
* _RAMBASE
|
||||
* : data segment
|
||||
* : bss segment
|
||||
* : heap
|
||||
* : stack
|
||||
* _ROMBASE
|
||||
* : linuxbios text
|
||||
* : readonly text
|
||||
*/
|
||||
|
||||
OUTPUT_FORMAT("elf64-alpha")
|
||||
ENTRY(__start_offset)
|
||||
PHDRS { kernel PT_LOAD AT(0x310000); }
|
||||
__start_offset = start + 0x310000;
|
||||
ENTRY(start)
|
||||
SECTIONS
|
||||
{
|
||||
. = _ROMBASE;
|
||||
. = DEFINED(_ROMBASE)? _ROMBASE : _RAMBASE;
|
||||
|
||||
.rom . : {
|
||||
_rom = .;
|
||||
*(.rom.text);
|
||||
*(.rom.data);
|
||||
. = ALIGN(16);
|
||||
_erom = .;
|
||||
}
|
||||
_lrom = LOADADDR(.rom);
|
||||
_elrom = LOADADDR(.rom) + SIZEOF(.rom);
|
||||
|
||||
/*
|
||||
* First we place the code and read only data (typically const declared).
|
||||
* This get placed in rom.
|
||||
*/
|
||||
.text : {
|
||||
_text = .;
|
||||
*(.text)
|
||||
*(.text);
|
||||
*(.text.*);
|
||||
. = ALIGN(16);
|
||||
_etext = .;
|
||||
} : kernel
|
||||
}
|
||||
|
||||
/* streams starts here */
|
||||
_ltext = LOADADDR(.text);
|
||||
_eltext = LOADADDR(.text) + SIZEOF(.text);
|
||||
.rodata . : AT(_eltext){
|
||||
_rodata = .;
|
||||
. = ALIGN(4);
|
||||
streams = . ;
|
||||
*(.rodata.streams)
|
||||
estreams = .;
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
_erodata = .;
|
||||
}
|
||||
|
||||
/* streams ends here */
|
||||
_ltext = LOADADDR(.text);
|
||||
_eltext = LOADADDR(.text) + SIZEOF(.text);
|
||||
.rodata . : AT(_eltext){
|
||||
_rodata = .;
|
||||
. = ALIGN(4);
|
||||
streams = . ;
|
||||
*(.rodata.streams)
|
||||
estreams = .;
|
||||
*(.rodata)
|
||||
*(.rodata.*)
|
||||
_erodata = .;
|
||||
}
|
||||
_lrodata = LOADADDR(.rodata);
|
||||
_elrodata = LOADADDR(.rodata) + SIZEOF(.rodata);
|
||||
|
||||
|
||||
. = _RAMBASE;
|
||||
|
@ -45,6 +68,27 @@ SECTIONS
|
|||
_ldata = LOADADDR(.data);
|
||||
_eldata = LOADADDR(.data) + SIZEOF(.data);
|
||||
|
||||
/*
|
||||
* After the code we place initialized data (typically initialized
|
||||
* global variables). This gets copied into ram by startup code.
|
||||
* __data_start and __data_end shows where in ram this should be placed,
|
||||
* whereas __data_loadstart and __data_loadend shows where in rom to
|
||||
* copy from.
|
||||
*/
|
||||
.data . : AT(_elrodata) {
|
||||
_data = .;
|
||||
*(.data)
|
||||
_edata = .;
|
||||
}
|
||||
_ldata = LOADADDR(.data);
|
||||
_eldata = LOADADDR(.data) + SIZEOF(.data);
|
||||
/* The initialized data segment.
|
||||
* This is all of the data that we copy from rom into the ram.
|
||||
*/
|
||||
_iseg = _text;
|
||||
_eiseg = _edata;
|
||||
_liseg = _ltext;
|
||||
_eliseg = _eldata;
|
||||
|
||||
/* Important align _bss so bss may be zeroed with quadword access */
|
||||
. = ALIGN(8);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
object hardwaremain.o
|
||||
object params.o
|
||||
|
||||
makedefine OBJECTS-+= __divqu.o __remqu.o __divlu.o __remlu.o
|
||||
makedefine OBJECTS-1+= __divqu.o __remqu.o __divlu.o __remlu.o
|
||||
|
||||
makerule __divqu.o: $(TOP)/src/arch/alpha/lib/divide.S; $(CC) $(CFLAGS) -DDIV -c -o __divqu.o $<
|
||||
makerule __remqu.o: $(TOP)/src/arch/alpha/lib/divide.S; $(CC) $(CFLAGS) -DREM -c -o __remqu.o $<
|
||||
|
|
|
@ -50,6 +50,8 @@ void hardwaremain(unsigned long signature, unsigned long memsize,
|
|||
unsigned long totalram);
|
||||
void prepare_hwrpb(unsigned long totalram);
|
||||
|
||||
post_code(0x55);
|
||||
while(1);
|
||||
|
||||
early_mainboard_init();
|
||||
displayinit();
|
||||
|
|
169
src/arch/alpha/lib/params.c
Normal file
169
src/arch/alpha/lib/params.c
Normal file
|
@ -0,0 +1,169 @@
|
|||
#include <string.h>
|
||||
#include <printk.h>
|
||||
|
||||
/*
|
||||
This software and ancillary information (herein called SOFTWARE )
|
||||
called LinuxBIOS is made available under the terms described
|
||||
here. The SOFTWARE has been approved for release with associated
|
||||
LA-CC Number 00-34 . Unless otherwise indicated, this SOFTWARE has
|
||||
been authored by an employee or employees of the University of
|
||||
California, operator of the Los Alamos National Laboratory under
|
||||
Contract No. W-7405-ENG-36 with the U.S. Department of Energy. The
|
||||
U.S. Government has rights to use, reproduce, and distribute this
|
||||
SOFTWARE. The public may copy, distribute, prepare derivative works
|
||||
and publicly display this SOFTWARE without charge, provided that this
|
||||
Notice and any statement of authorship are reproduced on all copies.
|
||||
Neither the Government nor the University makes any warranty, express
|
||||
or implied, or assumes any liability or responsibility for the use of
|
||||
this SOFTWARE. If SOFTWARE is modified to produce derivative works,
|
||||
such modified SOFTWARE should be clearly marked, so as not to confuse
|
||||
it with the version available from LANL.
|
||||
*/
|
||||
/* Copyright 2000, Ron Minnich, Advanced Computing Lab, LANL
|
||||
* rminnich@lanl.gov
|
||||
*/
|
||||
|
||||
/* this is a file of NO OP functions which have to be fixed. */
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id$";
|
||||
#endif
|
||||
|
||||
struct screen_info {
|
||||
unsigned char orig_x; /* 0x00 */
|
||||
unsigned char orig_y; /* 0x01 */
|
||||
unsigned short dontuse1; /* 0x02 -- EXT_MEM_K sits here */
|
||||
unsigned short orig_video_page; /* 0x04 */
|
||||
unsigned char orig_video_mode; /* 0x06 */
|
||||
unsigned char orig_video_cols; /* 0x07 */
|
||||
unsigned short unused2; /* 0x08 */
|
||||
unsigned short orig_video_ega_bx; /* 0x0a */
|
||||
unsigned short unused3; /* 0x0c */
|
||||
unsigned char orig_video_lines; /* 0x0e */
|
||||
unsigned char orig_video_isVGA; /* 0x0f */
|
||||
unsigned short orig_video_points; /* 0x10 */
|
||||
|
||||
/* VESA graphic mode -- linear frame buffer */
|
||||
unsigned short lfb_width; /* 0x12 */
|
||||
unsigned short lfb_height; /* 0x14 */
|
||||
unsigned short lfb_depth; /* 0x16 */
|
||||
unsigned long lfb_base; /* 0x18 */
|
||||
unsigned long lfb_size; /* 0x1c */
|
||||
unsigned short dontuse2, dontuse3; /* 0x20 -- CL_MAGIC and CL_OFFSET here */
|
||||
unsigned short lfb_linelength; /* 0x24 */
|
||||
unsigned char red_size; /* 0x26 */
|
||||
unsigned char red_pos; /* 0x27 */
|
||||
unsigned char green_size; /* 0x28 */
|
||||
unsigned char green_pos; /* 0x29 */
|
||||
unsigned char blue_size; /* 0x2a */
|
||||
unsigned char blue_pos; /* 0x2b */
|
||||
unsigned char rsvd_size; /* 0x2c */
|
||||
unsigned char rsvd_pos; /* 0x2d */
|
||||
unsigned short vesapm_seg; /* 0x2e */
|
||||
unsigned short vesapm_off; /* 0x30 */
|
||||
unsigned short pages; /* 0x32 */
|
||||
/* 0x34 -- 0x3f reserved for future expansion */
|
||||
};
|
||||
|
||||
#define E820MAP 0x2d0 /* our map */
|
||||
#define E820MAX 32 /* number of entries in E820MAP */
|
||||
#define E820NR 0x1e8 /* # entries in E820MAP */
|
||||
|
||||
/* sigh, this is not a struct or include file thing. */
|
||||
#ifdef i386
|
||||
/* from linux 2.2.13 */
|
||||
/*
|
||||
* This is set up by the setup-routine at boot-time
|
||||
*/
|
||||
#define PARAM ((unsigned char *)empty_zero_page)
|
||||
#define SCREEN_INFO (*(struct screen_info *) (PARAM+0))
|
||||
#define EXT_MEM_K (*(unsigned short *) (PARAM+2))
|
||||
#define ALT_MEM_K (*(unsigned long *) (PARAM+0x1e0))
|
||||
#define E820_MAP_NR (*(char*) (PARAM+E820NR))
|
||||
#define E820_MAP ((unsigned long *) (PARAM+E820MAP))
|
||||
#define APM_BIOS_INFO (*(struct apm_bios_info *) (PARAM+0x40))
|
||||
#define DRIVE_INFO (*(struct drive_info_struct *) (PARAM+0x80))
|
||||
#define SYS_DESC_TABLE (*(struct sys_desc_table_struct*)(PARAM+0xa0))
|
||||
#define MOUNT_ROOT_RDONLY (*(unsigned short *) (PARAM+0x1F2))
|
||||
#define RAMDISK_FLAGS (*(unsigned short *) (PARAM+0x1F8))
|
||||
#define ORIG_ROOT_DEV (*(unsigned short *) (PARAM+0x1FC))
|
||||
#define AUX_DEVICE_INFO (*(unsigned char *) (PARAM+0x1FF))
|
||||
#define LOADER_TYPE (*(unsigned char *) (PARAM+0x210))
|
||||
#define KERNEL_START (*(unsigned long *) (PARAM+0x214))
|
||||
#define INITRD_START (*(unsigned long *) (PARAM+0x218))
|
||||
#define INITRD_SIZE (*(unsigned long *) (PARAM+0x21c))
|
||||
#define COMMAND_LINE ((char *) (PARAM+2048))
|
||||
#define COMMAND_LINE_SIZE 256
|
||||
|
||||
#endif
|
||||
/* this is support for passing parameters to the linux kernel.
|
||||
* you can pass memory size, command lines, and so on.
|
||||
*/
|
||||
|
||||
void
|
||||
init_params(unsigned char *empty_zero_page)
|
||||
{
|
||||
printk_emerg("NOT DOING memset(PARAM, 0, 4096 /*XXXXXXXXXXXXXXXXX */ );\n");
|
||||
}
|
||||
|
||||
void
|
||||
set_memory_size(unsigned char *empty_zero_page, unsigned long ext_memory_size,
|
||||
unsigned long alt_memory_size)
|
||||
{
|
||||
/* for now, we do not have an 820 map (who cares, 8x0 chipsets are dead! */
|
||||
printk_emerg("NOT DOING E820_MAP_NR = 0;\n");
|
||||
printk_emerg("NOT DOING EXT_MEM_K = ext_memory_size;\n");
|
||||
printk_emerg("NOT DOING ALT_MEM_K = alt_memory_size;\n");
|
||||
}
|
||||
|
||||
void
|
||||
set_root_rdonly(unsigned char *empty_zero_page)
|
||||
{
|
||||
printk_emerg("NOT DOING MOUNT_ROOT_RDONLY = 1;\n");
|
||||
}
|
||||
|
||||
/* see the lilo doc */
|
||||
void
|
||||
set_command_line(unsigned char *empty_zero_page, unsigned char *cmdline)
|
||||
{
|
||||
int i;
|
||||
/* no strncpy ...
|
||||
strncpy(COMMAND_LINE, cmdline, COMMAND_LINE_SIZE);
|
||||
*/
|
||||
printk_emerg("NOT DOING for (i = 0; (i < COMMAND_LINE_SIZE) && (cmdline[i]); i++)\n");
|
||||
printk_emerg("NOT DOING COMMAND_LINE[i] = cmdline[i];\n");
|
||||
printk_emerg("NOT DOING *(unsigned short *) 0x90020 = 0xa33f;\n");
|
||||
printk_emerg("NOT DOING *(unsigned short *) 0x90022 = 2048;\n");
|
||||
}
|
||||
|
||||
unsigned char *
|
||||
get_empty_zero_page()
|
||||
{
|
||||
/* gosh, I thought we had to do get at empty_zero_page, and we don't.
|
||||
* silly me. We just have to get to 0x90000
|
||||
*/
|
||||
/* we'll leave this hook in for now. We may need it someday */
|
||||
// unsigned long l = *(unsigned long *) 0xffffc;
|
||||
|
||||
printk_emerg("NOT DOING return (unsigned char *) 0x90000;\n");
|
||||
}
|
||||
|
||||
/* I am pretty sure we only need to set rows and cols for now.
|
||||
* All the rest is BIOS stuff. If it gets worse we'll have to make this a
|
||||
* screen_info * as the param
|
||||
*/
|
||||
void
|
||||
set_display(unsigned char *empty_zero_page, int rows, int cols)
|
||||
{
|
||||
printk_emerg("NOT DOING struct screen_info *sc = &SCREEN_INFO;\n");
|
||||
printk_emerg("NOT DOING sc->orig_video_cols = cols;\n");
|
||||
printk_emerg("NOT DOING sc->orig_video_lines = rows;\n");
|
||||
}
|
||||
|
||||
void
|
||||
set_initrd(unsigned char *empty_zero_page, unsigned long start, unsigned long size)
|
||||
{
|
||||
printk_emerg("NOT DOING INITRD_START = start;\n");
|
||||
printk_emerg("NOT DOING INITRD_SIZE = size;\n");
|
||||
printk_emerg("NOT DOING LOADER_TYPE = 1;\n");
|
||||
}
|
|
@ -67,7 +67,7 @@ int elf_check_arch(Elf_ehdr *ehdr)
|
|||
|
||||
}
|
||||
|
||||
void jmp_to_elf_entry(void *entry, unsigned long buffer)
|
||||
void jmp_to_elf_entry(void *entry, void *buffer)
|
||||
{
|
||||
extern unsigned char _ram_seg, _eram_seg;
|
||||
unsigned long lb_start, lb_size;
|
||||
|
|
281
src/lib/linuxbios_table.c
Normal file
281
src/lib/linuxbios_table.c
Normal file
|
@ -0,0 +1,281 @@
|
|||
#include <mem.h>
|
||||
#include <ip_checksum.h>
|
||||
#include <boot/linuxbios_tables.h>
|
||||
#include <boot/linuxbios_table.h>
|
||||
#include <printk.h>
|
||||
#include <string.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
struct lb_header *lb_table_init(unsigned long addr)
|
||||
{
|
||||
struct lb_header *header;
|
||||
|
||||
/* 16 byte align the address */
|
||||
addr += 15;
|
||||
addr &= ~15;
|
||||
|
||||
header = (void *)addr;
|
||||
header->signature[0] = 'L';
|
||||
header->signature[1] = 'B';
|
||||
header->signature[2] = 'I';
|
||||
header->signature[3] = 'O';
|
||||
header->header_bytes = sizeof(*header);
|
||||
header->header_checksum = 0;
|
||||
header->table_bytes = 0;
|
||||
header->table_checksum = 0;
|
||||
header->table_entries = 0;
|
||||
return header;
|
||||
}
|
||||
|
||||
struct lb_record *lb_first_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = (void *)(((char *)header) + sizeof(*header));
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_last_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = (void *)(((char *)header) + sizeof(*header) + header->table_bytes);
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_next_record(struct lb_record *rec)
|
||||
{
|
||||
rec = (void *)(((char *)rec) + rec->size);
|
||||
return rec;
|
||||
}
|
||||
|
||||
struct lb_record *lb_new_record(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
rec = lb_last_record(header);
|
||||
if (header->table_entries) {
|
||||
header->table_bytes += rec->size;
|
||||
}
|
||||
rec = lb_last_record(header);
|
||||
header->table_entries++;
|
||||
rec->tag = LB_TAG_UNUSED;
|
||||
rec->size = sizeof(*rec);
|
||||
return rec;
|
||||
}
|
||||
|
||||
|
||||
struct lb_memory *lb_memory(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
struct lb_memory *mem;
|
||||
rec = lb_new_record(header);
|
||||
mem = (struct lb_memory *)rec;
|
||||
mem->tag = LB_TAG_MEMORY;
|
||||
mem->size = sizeof(*mem);
|
||||
return mem;
|
||||
}
|
||||
|
||||
struct lb_mainboard *lb_mainboard(struct lb_header *header)
|
||||
{
|
||||
struct lb_record *rec;
|
||||
struct lb_mainboard *mainboard;
|
||||
rec = lb_new_record(header);
|
||||
mainboard = (struct lb_mainboard *)rec;
|
||||
mainboard->tag = LB_TAG_MAINBOARD;
|
||||
|
||||
mainboard->size = (sizeof(*mainboard) +
|
||||
strlen(mainboard_vendor) + 1 +
|
||||
strlen(mainboard_part_number) + 1 +
|
||||
3) & ~3;
|
||||
|
||||
mainboard->vendor_idx = 0;
|
||||
mainboard->part_number_idx = strlen(mainboard_vendor) + 1;
|
||||
|
||||
memcpy(mainboard->strings + mainboard->vendor_idx,
|
||||
mainboard_vendor, strlen(mainboard_vendor) + 1);
|
||||
memcpy(mainboard->strings + mainboard->part_number_idx,
|
||||
mainboard_part_number, strlen(mainboard_part_number) + 1);
|
||||
|
||||
return mainboard;
|
||||
}
|
||||
|
||||
void lb_strings(struct lb_header *header)
|
||||
{
|
||||
static const struct {
|
||||
uint32_t tag;
|
||||
const uint8_t *string;
|
||||
} strings[] = {
|
||||
{ LB_TAG_VERSION, linuxbios_version, },
|
||||
{ LB_TAG_EXTRA_VERSION, linuxbios_extra_version, },
|
||||
{ LB_TAG_BUILD, linuxbios_build, },
|
||||
{ LB_TAG_COMPILE_TIME, linuxbios_compile_time, },
|
||||
{ LB_TAG_COMPILE_BY, linuxbios_compile_by, },
|
||||
{ LB_TAG_COMPILE_HOST, linuxbios_compile_host, },
|
||||
{ LB_TAG_COMPILE_DOMAIN, linuxbios_compile_domain, },
|
||||
{ LB_TAG_COMPILER, linuxbios_compiler, },
|
||||
{ LB_TAG_LINKER, linuxbios_linker, },
|
||||
{ LB_TAG_ASSEMBLER, linuxbios_assembler, },
|
||||
};
|
||||
int i;
|
||||
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
|
||||
struct lb_string *rec;
|
||||
size_t len;
|
||||
rec = lb_new_record(header);
|
||||
len = strlen(strings[i].string);
|
||||
rec->tag = strings[i].tag;
|
||||
rec->size = (sizeof(*rec) + len + 1 + 3) & ~3;
|
||||
memcpy(rec->string, strings[i].string, len+1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Some version of gcc have problems with 64 bit types so
|
||||
* take an unsigned long instead of a uint64_t for now.
|
||||
*/
|
||||
void lb_memory_range(struct lb_memory *mem,
|
||||
uint32_t type, unsigned long start, unsigned long size)
|
||||
{
|
||||
int entries;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
mem->map[entries].start = start;
|
||||
mem->map[entries].size = size;
|
||||
mem->map[entries].type = type;
|
||||
mem->size += sizeof(mem->map[0]);
|
||||
}
|
||||
|
||||
static void lb_memory_rangek(struct lb_memory *mem,
|
||||
uint32_t type, unsigned long startk, unsigned long endk)
|
||||
{
|
||||
int entries;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
mem->map[entries].start = startk;
|
||||
mem->map[entries].start <<= 10;
|
||||
mem->map[entries].size = endk - startk;
|
||||
mem->map[entries].size <<= 10;
|
||||
mem->map[entries].type = type;
|
||||
mem->size += sizeof(mem->map[0]);
|
||||
}
|
||||
|
||||
static void lb_reserve_table_memory(struct lb_header *head)
|
||||
{
|
||||
struct lb_record *last_rec;
|
||||
struct lb_memory *mem;
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
int i, entries;
|
||||
|
||||
last_rec = lb_last_record(head);
|
||||
mem = get_lb_mem();
|
||||
start = (unsigned long)head;
|
||||
end = (unsigned long)last_rec;
|
||||
entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
|
||||
/* Resize the right two memory areas so this table is in
|
||||
* a reserved area of memory. Everything has been carefully
|
||||
* setup so that is all we need to do.
|
||||
*/
|
||||
for(i = 0; i < entries; i++ ) {
|
||||
uint64_t map_start = mem->map[i].start;
|
||||
uint64_t map_end = map_start + mem->map[i].size;
|
||||
/* Does this area need to be expanded? */
|
||||
if (map_end == start) {
|
||||
mem->map[i].size = end - map_start;
|
||||
}
|
||||
/* Does this area need to be contracted? */
|
||||
else if (map_start == start) {
|
||||
mem->map[i].start = end;
|
||||
mem->map[i].size = map_end - end;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
unsigned long lb_table_fini(struct lb_header *head)
|
||||
{
|
||||
struct lb_record *rec, *first_rec;
|
||||
rec = lb_last_record(head);
|
||||
if (head->table_entries) {
|
||||
head->table_bytes += rec->size;
|
||||
}
|
||||
lb_reserve_table_memory(head);
|
||||
first_rec = lb_first_record(head);
|
||||
head->table_checksum = compute_ip_checksum(first_rec, head->table_bytes);
|
||||
head->header_checksum = 0;
|
||||
head->header_checksum = compute_ip_checksum(head, sizeof(*head));
|
||||
printk_debug("Wrote linuxbios table at: %p - %p checksum %lx\n",
|
||||
head, rec, head->table_checksum);
|
||||
return (unsigned long)rec;
|
||||
}
|
||||
|
||||
|
||||
/* Routines to extract part so the linuxBIOS table or
|
||||
* information from the linuxBIOS table after we have written it.
|
||||
* Currently get_lb_mem relies on a global we can change the
|
||||
* implementaiton.
|
||||
*/
|
||||
static struct lb_memory *mem_ranges = 0;
|
||||
struct lb_memory *get_lb_mem(void)
|
||||
{
|
||||
return mem_ranges;
|
||||
}
|
||||
|
||||
unsigned long write_linuxbios_table(
|
||||
unsigned long *processor_map,
|
||||
struct mem_range *ram,
|
||||
unsigned long low_table_start, unsigned long low_table_end,
|
||||
unsigned long rom_table_startk, unsigned long rom_table_endk)
|
||||
{
|
||||
unsigned long table_size;
|
||||
struct mem_range *ramp;
|
||||
struct lb_header *head;
|
||||
struct lb_memory *mem;
|
||||
struct lb_record *rec_dest, *rec_src;
|
||||
|
||||
head = lb_table_init(low_table_end);
|
||||
low_table_end = (unsigned long)head;
|
||||
#if HAVE_OPTION_TABLE == 1
|
||||
/* Write the option config table... */
|
||||
rec_dest = lb_new_record(head);
|
||||
rec_src = (struct lb_record *)&option_table;
|
||||
memcpy(rec_dest, rec_src, rec_src->size);
|
||||
#endif
|
||||
mem = lb_memory(head);
|
||||
mem_ranges = mem;
|
||||
/* I assume there is always ram at address 0 */
|
||||
/* Reserve our tables in low memory */
|
||||
table_size = (low_table_end - low_table_start);
|
||||
lb_memory_range(mem, LB_MEM_TABLE, 0, table_size);
|
||||
lb_memory_range(mem, LB_MEM_RAM, table_size, (ram[0].sizek << 10) - table_size);
|
||||
/* Reserving pci memory mapped space will keep the kernel from booting seeing
|
||||
* any pci resources.
|
||||
*/
|
||||
for(ramp = &ram[1]; ramp->sizek; ramp++) {
|
||||
unsigned long startk, endk;
|
||||
startk = ramp->basek;
|
||||
endk = startk + ramp->sizek;
|
||||
if ((startk < rom_table_startk) && (endk > rom_table_startk)) {
|
||||
lb_memory_rangek(mem, LB_MEM_RAM, startk, rom_table_startk);
|
||||
startk = rom_table_startk;
|
||||
}
|
||||
if ((startk == rom_table_startk) && (endk > startk)) {
|
||||
unsigned long tend;
|
||||
tend = rom_table_endk;
|
||||
if (tend > endk) {
|
||||
tend = endk;
|
||||
}
|
||||
lb_memory_rangek(mem, LB_MEM_TABLE, rom_table_startk, tend);
|
||||
startk = tend;
|
||||
}
|
||||
if (endk > startk) {
|
||||
lb_memory_rangek(mem, LB_MEM_RAM, startk, endk);
|
||||
}
|
||||
}
|
||||
|
||||
/* Record our motheboard */
|
||||
lb_mainboard(head);
|
||||
/* Record our various random string information */
|
||||
lb_strings(head);
|
||||
|
||||
low_table_end = lb_table_fini(head);
|
||||
|
||||
/* Remember where my valid memory ranges are */
|
||||
return low_table_end;
|
||||
}
|
|
@ -185,7 +185,7 @@ int linuxbiosmain(unsigned long base, unsigned long totalram)
|
|||
:: "i" (0x100000));
|
||||
|
||||
#else
|
||||
printk_error("UH OH\n");
|
||||
printk_emerg("UH OH you didn't tell me how to jump to kernel\n");
|
||||
#endif
|
||||
return 0; /* It should not ever return */
|
||||
}
|
||||
|
|
|
@ -6,3 +6,4 @@ southbridge acer/m1543
|
|||
|
||||
|
||||
object mainboard.o
|
||||
option _RAMBASE=0x200000
|
||||
|
|
Loading…
Add table
Reference in a new issue