* ========== Copyright Header Begin ==========================================
* Hypervisor Software File: sys-seeprom.c
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* - Do no alter or remove copyright notices
* - Redistribution and use of this software in source and binary forms, with
* or without modification, are permitted provided that the following
* - Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* - Redistribution in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of Sun Microsystems, Inc. or the names of contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* This software is provided "AS IS," without a warranty of any kind.
* ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
* MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
* OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
* FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* You acknowledge that this software is not designed, licensed or
* intended for use in the design, construction, operation or maintenance of
* ========== Copyright Header End ============================================
* id: @(#)sys-seeprom.c 1.7 06/04/27
* copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
* copyright: Use is subject to license terms.
#define SYS_DEFAULT_MAGIC 0x5359
#define MAX_TABLE_SIZE 1000
extern struct fixed_seeprom
*seeprom_data
;
struct fixed_seeprom sys_seeprom_data
[] = {
/* name size type value */
{ "id_magic", 2, NUM
, 0, NULL
},
{ "ro-checksum", 1, NUM
, 0, NULL
},
{ "ro-size", 2, NUM
, 0, NULL
},
{ "id_format", 1, NUM
, 0, NULL
},
{ "pad", 2, NUM
, 0, NULL
},
{ "pad", 8, NUM
, 0, NULL
},
{ "sys_speed_max", 1, NUM
, 0, NULL
},
{ "sys_speed_min", 1, NUM
, 0, NULL
},
{ "upa_speed_max", 1, NUM
, 0, NULL
},
{ "upa_speed_min", 1, NUM
, 0, NULL
},
{ "stick_freq", 1, NUM
, 0, NULL
},
{ "memc", 1, NUM
, 0, NULL
},
{ "num_timing_sets", 1, NUM
, 0, NULL
},
{ "pad", 1, NUM
, 0, NULL
},
struct fixed_seeprom fiesta_sys_data
[] = {
/* name size type value */
{ "id_magic", 2, NUM
, 0, NULL
},
{ "ro-checksum", 1, NUM
, 0, NULL
},
{ "ro-size", 2, NUM
, 0, NULL
},
{ "id_format", 1, NUM
, 0, NULL
},
{ "pad", 2, NUM
, 0, NULL
},
{ "pad", 6, NUM
, 0, NULL
},
{ "sys_ssc", 1, NUM
, 0, NULL
},
{ "pci_ssc", 1, NUM
, 0, NULL
},
{ "sys_speed_max", 1, NUM
, 0, NULL
},
{ "sys_speed_min", 1, NUM
, 0, NULL
},
{ "upa_speed_max", 1, NUM
, 0, NULL
},
{ "upa_speed_min", 1, NUM
, 0, NULL
},
{ "stick_freq", 1, NUM
, 0, NULL
},
static struct timing_table_entry
*timing_table
= NULL
;
static struct timing_table_entry
*cur_timing_table
;
static int processing_timing
= 0;
set_byte(int index
, int data
, unsigned short *byte
)
update_timing_table(char *parameter
, char *line
)
while (strcmp(timing_parameters
[i
].name
, parameter
)) {
offset
+= timing_parameters
[i
++].size
;
if (timing_parameters
[i
].name
== NULL
) {
"%s is not a valid timing parameter\n", parameter
);
if (scan_line(line
, &input_val
) == ERROR
)
write_bytes(input_val
, timing_parameters
[i
].size
, offset
,
cur_timing_table
->timing_data
);
sys_dynamic(char *parameter
, char *line
)
if (strcmp(parameter
, "timing_table_end") == 0) {
temp
= get_seeprom("num_timing_sets");
update_seeprom("num_timing_sets", temp
+1);
retval
= update_timing_table(parameter
, line
);
if (strcmp(parameter
, "timing_table_start") == 0) {
if (timing_table
== NULL
) {
sizeof (struct timing_table_entry
));
timing_table
->next
= NULL
;
cur_timing_table
= timing_table
;
cur_timing_table
->next
= malloc(
sizeof (struct timing_table_entry
));
cur_timing_table
= cur_timing_table
->next
;
cur_timing_table
->next
= NULL
;
} else if (strcmp(parameter
, "timing_table_end") == 0) {
fprintf(stderr
, "Missing timing_table_start\n");
struct timing_table_entry
*table_ptr2
, *tmp2
;
if (timing_table
!= NULL
) {
table_ptr2
= timing_table
;
while (table_ptr2
->next
!= NULL
) {
write_sys(unsigned char **ptr
)
struct timing_table_entry
*table_ptr2
;
while (seeprom_data
[i
].name
!= NULL
) {
size
+= seeprom_data
[i
++].size
;
table_ptr2
= timing_table
;
while (table_ptr2
!= NULL
) {
p
= table_ptr2
->timing_data
;
store_chars(TIMING_ENTRY_SIZE
, p
, ptr
);
table_ptr2
= table_ptr2
->next
;
sys_checksum(unsigned short *checksum
, unsigned int bytes
,
if (get_seeprom("id_magic") != SYS_DEFAULT_MAGIC
) {
"id_magic must be 0x%4x!", SYS_DEFAULT_MAGIC
);
if (system_type
== EXCALIBUR
) {
if (timing_table
== NULL
) {
print_error("Must specify a timing table!\n");
print_error("Missing timing_table_end!\n");
struct timing_table_entry
*table_ptr2
;
while (seeprom_data
[i
].name
!= NULL
) {
if (strcmp(seeprom_data
[i
].name
, "checksum") &&
strcmp(seeprom_data
[i
].name
, "ro-size")) {
(uchar_t
*)&seeprom_data
[i
].value
+
(8-seeprom_data
[i
].size
));
size
+= seeprom_data
[i
].size
;
table_ptr2
= timing_table
;
while (table_ptr2
!= NULL
) {
TIMING_ENTRY_SIZE
, table_ptr2
->timing_data
);
size
+= TIMING_ENTRY_SIZE
;
table_ptr2
= table_ptr2
->next
;
sys_checksum(&checksum
, 2, (unsigned char *)&size
+2);
update_seeprom("ro-size", (unsigned long long)size
);
update_seeprom("ro-checksum", (unsigned long long)checksum
);
reg_sys(char *s1
, data_reg
**reg
)