This commit is contained in:
Greg Watson 2003-04-15 19:32:35 +00:00
parent 89f71da2cf
commit d17a78e726
3 changed files with 159 additions and 0 deletions

View file

@ -0,0 +1,36 @@
/* $Id$ */
/* Copyright 2000 AG Electronics Ltd. */
/* This code is distributed without warranty under the GPL v2 (see COPYING) */
#ifndef _FLASH_H
#define _FLASH_H
struct flash_device;
typedef struct flash_fn
{
const char *(* identify)(struct flash_device *flash);
void *(* ptr)(void *data);
int (* erase_all)(void *data);
int (* erase)(void *data, unsigned offset, unsigned length);
int (* program)(void *data, unsigned offset, const void *source, unsigned length);
u8 ( *read_byte)(void *data, unsigned offset);
} flash_fn;
typedef struct flash_device
{
const flash_fn *fn;
char *tag;
void *data;
unsigned long base;
unsigned size;
unsigned erase_size;
unsigned store_size;
struct flash_device *next;
} flash_device;
int register_flash_device(const flash_fn *fn, char *tag, void *data);
flash_device *find_flash_device(const char *tag);
int init_flash_amd800(char *tag, unsigned base, unsigned spacing);
#endif

View file

@ -0,0 +1,37 @@
/* $Id$ */
/* Copyright 2000 AG Electronics Ltd. */
/* This code is distributed without warranty under the GPL v2 (see COPYING) */
/* Definitions for nvram devices - these are flash or eeprom devices used to
store information across power cycles and resets. Though they are byte
addressable, writes must be committed to allow flash devices to write
complete sectors. */
#ifndef _NVRAM_H
#define _NVRAM_H
typedef struct nvram_device
{
unsigned (*size)(struct nvram_device *data);
int (*read_block)(struct nvram_device *dev, unsigned offset,
unsigned char *data, unsigned length);
int (*write_byte)(struct nvram_device *dev, unsigned offset, unsigned char byte);
void (*commit)(struct nvram_device *data);
void *data;
} nvram_device;
int nvram_init (nvram_device *dev);
void nvram_clear(void);
extern nvram_device pcrtc_nvram;
extern void nvram_putenv(const char *name, const char *value);
extern int nvram_getenv(const char *name, char *buffer, unsigned size);
typedef const struct nvram_constant
{
const char *name;
const char *value;
} nvram_constant;
extern nvram_constant hardcoded_environment[];
#endif

View file

@ -0,0 +1,86 @@
/* $Id$ */
/* Copyright 2000 AG Electronics Ltd. */
/* This code is distributed without warranty under the GPL v2 (see COPYING) */
#include <ppc.h>
#include <bsp.h>
#include <ppcreg.h>
#include <types.h>
#include <string.h>
#include <printk.h>
#include <pci.h>
#include "nvram.h"
#define ONEMEG 0x00100000
#define HALFMEG 0x00080000
int memory_has_failed = 0;
//extern char __heap_end[];
extern nvram_device bsp_nvram;
extern int init_flash_amd800(char *, unsigned, unsigned);
#if 0
void bsp_relocate(void)
{
extern unsigned _iseg[];
extern unsigned _liseg[];
extern unsigned _eiseg[];
unsigned *to;
unsigned *from;
from = _liseg;
to = _iseg;
while ( from < _eiseg )
*to++ = *from++;
}
void bsp_init_post_reloc(unsigned memory)
{
extern char __stack_end[];
physical_memory_size = memory;
memory_top = memory - ONEMEG;
memory_base = 0;
/* Use tiny default heap */
malloc_add_pool(__stack_end, __heap_end - __stack_end);
}
void bsp_init_post_hello(void)
{
init_flash_amd800("BOOT", 0xff000000, 1);
init_flash_amd800("BOOT", 0xff800000, 1);
pci_configure();
printk_info("Memory from 0x%08lx to 0x%08lx\n", memory_base, memory_top);
nvram_init(&bsp_nvram);
if (!memory_has_failed)
{
printk_info("Clearing memory...");
//memset(0, 0, memory_top); trashes dink
//block_add_pool(0, memory_top);
printk_info("Done\n");
}
}
void bsp_indicate_dead(void)
{
for(;;)
{
}
}
void bsp_identify(void)
{
printk_info("Sandpoint BSP\n");
ppc_identify();
//net_init();
}
#endif
unsigned bsp_clock_speed(void)
{
return 100000000 / 4;
}