mirror of
https://gitlab.com/qemu-project/openbios.git
synced 2024-02-13 08:34:06 +08:00
Access to nvram must left shifted by 4.
Initialize device tree (used by PCI patch, to follow). Signed-off-by: Laurent Vivier <Laurent@lvivier.info> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://coreboot.org/openbios/openbios-devel@255 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
committed by
Stefan Reinauer
parent
c619e7c4a1
commit
bee6afbc60
@@ -100,13 +100,12 @@ arch_of_init( void )
|
||||
int autoboot;
|
||||
|
||||
devtree_init();
|
||||
nvram_init();
|
||||
modules_init();
|
||||
setup_timers();
|
||||
#ifdef CONFIG_DRIVER_PCI
|
||||
ob_pci_init();
|
||||
#endif
|
||||
#ifdef CONFIG_DRIVER_IDE
|
||||
setup_timers();
|
||||
ob_ide_init();
|
||||
#endif
|
||||
#ifdef CONFIG_DRIVER_ADB
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "openbios/nvram.h"
|
||||
#include "libc/vsprintf.h"
|
||||
#include "libc/string.h"
|
||||
#include "libc/byteorder.h"
|
||||
#include "qemu/qemu.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
// FIXME
|
||||
unsigned long virt_offset = 0;
|
||||
|
||||
//#define DUMP_NVRAM
|
||||
|
||||
void
|
||||
exit( int status )
|
||||
@@ -150,57 +152,84 @@ putchar( int c )
|
||||
/* briQ specific stuff */
|
||||
/************************************************************************/
|
||||
|
||||
#define IO_NVRAM_PA_START 0x80860000
|
||||
#define IO_NVRAM_PA_END 0x80880000
|
||||
#define IO_NVRAM_SIZE 0x00020000
|
||||
#define IO_NVRAM_OFFSET 0x00060000
|
||||
|
||||
static char *nvram=(char *)IO_NVRAM_PA_START;
|
||||
static char *nvram;
|
||||
|
||||
void macio_nvram_init(char *path, uint32_t addr)
|
||||
{
|
||||
phandle_t chosen, aliases;
|
||||
phandle_t dnode;
|
||||
int props[2];
|
||||
char buf[64];
|
||||
|
||||
nvram = (char*)addr + IO_NVRAM_OFFSET;
|
||||
sprintf(buf, "%s/nvram", path);
|
||||
nvram_init(buf);
|
||||
dnode = find_dev(buf);
|
||||
set_int_property(dnode, "#bytes", IO_NVRAM_SIZE >> 4);
|
||||
set_property(dnode, "compatible", "nvram,flash", 12);
|
||||
props[0] = __cpu_to_be32(IO_NVRAM_OFFSET);
|
||||
props[1] = __cpu_to_be32(IO_NVRAM_SIZE);
|
||||
set_property(dnode, "reg", &props, sizeof(props));
|
||||
set_property(dnode, "device_type", "nvram", 6);
|
||||
|
||||
chosen = find_dev("/chosen");
|
||||
set_int_property(chosen, "nvram", dnode);
|
||||
|
||||
aliases = find_dev("/aliases");
|
||||
set_property(aliases, "nvram", buf, strlen(buf) + 1);
|
||||
}
|
||||
|
||||
#ifdef DUMP_NVRAM
|
||||
void
|
||||
dump_nvram(void)
|
||||
{
|
||||
static char hexdigit[] = "0123456789abcdef";
|
||||
int i;
|
||||
for (i = 0; i < 16*4; i++)
|
||||
int i, j;
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
printk ("%c", hexdigit[nvram[i<<4] >> 4]);
|
||||
printk ("%c", hexdigit[nvram[i<<4] % 16]);
|
||||
if (!((i + 1) % 16))
|
||||
{
|
||||
printk ("\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printk (" ");
|
||||
}
|
||||
}
|
||||
for (j = 0; j < 16; j++)
|
||||
printk ("%02x ", nvram[(i*16+j)<<4]);
|
||||
printk (" ");
|
||||
for (j = 0; j < 16; j++)
|
||||
if (isprint(nvram[(i*16+j)<<4]))
|
||||
printk("%c", nvram[(i*16+j)<<4]);
|
||||
else
|
||||
printk(".");
|
||||
printk ("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
arch_nvram_size( void )
|
||||
{
|
||||
return (IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4;
|
||||
return IO_NVRAM_SIZE>>4;
|
||||
}
|
||||
|
||||
void
|
||||
arch_nvram_put( char *buf )
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
|
||||
for (i=0; i<IO_NVRAM_SIZE>>4; i++)
|
||||
nvram[i<<4]=buf[i];
|
||||
// memcpy(nvram, buf, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
|
||||
#ifdef DUMP_NVRAM
|
||||
printk("new nvram:\n");
|
||||
dump_nvram();
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
arch_nvram_get( char *buf )
|
||||
{
|
||||
int i;
|
||||
for (i=0; i<(IO_NVRAM_PA_END-IO_NVRAM_PA_START)>>4; i++)
|
||||
for (i=0; i<IO_NVRAM_SIZE>>4; i++)
|
||||
buf[i]=nvram[i<<4];
|
||||
|
||||
//memcpy(buf, nvram, IO_NVRAM_PA_END-IO_NVRAM_PA_START);
|
||||
#ifdef DUMP_NVRAM
|
||||
printk("current nvram:\n");
|
||||
dump_nvram();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ extern int arch_nvram_size( void );
|
||||
extern void arch_nvram_get( char *buf );
|
||||
extern void arch_nvram_put( char *buf );
|
||||
|
||||
extern void nvram_init( void );
|
||||
extern void nvram_init( char *path );
|
||||
extern void update_nvram( void );
|
||||
|
||||
#endif /* _H_NVRAM */
|
||||
|
||||
@@ -18,6 +18,13 @@
|
||||
#include "openbios/bindings.h"
|
||||
#include "openbios/nvram.h"
|
||||
|
||||
#ifdef CONFIG_DEBUG_NVRAM
|
||||
#define DPRINTF(fmt, args...) \
|
||||
do { printk("NVRAM: " fmt , ##args); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, args...) do {} while(0)
|
||||
#endif
|
||||
|
||||
#define DEF_SYSTEM_SIZE 0xc10
|
||||
|
||||
#define NV_SIG_SYSTEM 0x70
|
||||
@@ -77,10 +84,12 @@ next_nvpart( nvpart_t **p )
|
||||
return 1;
|
||||
}
|
||||
|
||||
if( !(len=nvpart_size(*p)) ) {
|
||||
len=nvpart_size(*p);
|
||||
if( len == 0) {
|
||||
printk("invalid nvram partition length\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
*p = (nvpart_t*)((char*)*p + len);
|
||||
if( *p < end )
|
||||
return 1;
|
||||
@@ -219,7 +228,7 @@ typedef struct {
|
||||
uint mark_lo;
|
||||
} nvram_ibuf_t;
|
||||
|
||||
DECLARE_NODE( nvram, INSTALL_OPEN, sizeof(nvram_ibuf_t), "Tnvram" );
|
||||
DECLARE_UNNAMED_NODE( nvram, INSTALL_OPEN, sizeof(nvram_ibuf_t ));
|
||||
|
||||
/* ( pos_lo pos_hi -- status ) */
|
||||
static void
|
||||
@@ -228,7 +237,7 @@ nvram_seek( nvram_ibuf_t *nd )
|
||||
int pos_hi = POP();
|
||||
int pos_lo = POP();
|
||||
|
||||
/* printk("NVRAM: seek %08x %08x\n", pos_hi, pos_lo ); */
|
||||
DPRINTF("seek %08x %08x\n", pos_hi, pos_lo );
|
||||
nd->mark_lo = pos_lo;
|
||||
nd->mark_hi = pos_hi;
|
||||
|
||||
@@ -254,7 +263,7 @@ nvram_read( nvram_ibuf_t *nd )
|
||||
n++;
|
||||
}
|
||||
PUSH(n);
|
||||
/* printk("NVRAM: read %08x %x -- %x\n", (int)p, len, n); */
|
||||
DPRINTF("read %08x %x -- %x\n", (int)p, len, n);
|
||||
}
|
||||
|
||||
/* ( addr len -- actual ) */
|
||||
@@ -270,13 +279,14 @@ nvram_write( nvram_ibuf_t *nd )
|
||||
n++;
|
||||
}
|
||||
PUSH(n);
|
||||
/* printk("NVRAM: write %08x %x -- %x\n", (int)p, len, n ); */
|
||||
DPRINTF("write %08x %x -- %x\n", (int)p, len, n );
|
||||
}
|
||||
|
||||
/* ( -- size ) */
|
||||
static void
|
||||
nvram_size( __attribute__((unused)) nvram_ibuf_t *nd )
|
||||
{
|
||||
DPRINTF("nvram_size %d\n", nvram.size);
|
||||
PUSH( nvram.size );
|
||||
}
|
||||
|
||||
@@ -289,9 +299,9 @@ NODE_METHODS( nvram ) = {
|
||||
|
||||
|
||||
void
|
||||
nvram_init( void )
|
||||
nvram_init( char *path )
|
||||
{
|
||||
nvconf_init();
|
||||
|
||||
REGISTER_NODE( nvram );
|
||||
REGISTER_NAMED_NODE( nvram, path );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user