Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- drivers/macio.c | 8 ++++---- include/packages/nvram.h | 4 +++- packages/nvram.c | 32 ++++++++++++++++++++++++++++++-- 3 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/drivers/macio.c b/drivers/macio.c index eb2af04..5a94252 100644 --- a/drivers/macio.c +++ b/drivers/macio.c @@ -91,9 +91,8 @@ void macio_nvram_init(const char *path, phys_addr_t addr) nvram_size = macio_nvram_size();
nvram = (char*)addr + nvram_offset; - snprintf(buf, sizeof(buf), "%s/nvram", path); - nvram_init(buf); - dnode = find_dev(buf); + snprintf(buf, sizeof(buf), "%s", path); + dnode = nvram_init(buf); set_int_property(dnode, "#bytes", arch_nvram_size() ); props[0] = __cpu_to_be32(nvram_offset); props[1] = __cpu_to_be32(nvram_size); @@ -102,6 +101,7 @@ void macio_nvram_init(const char *path, phys_addr_t addr) NEWWORLD(set_property(dnode, "compatible", "nvram,flash", 12));
chosen = find_dev("/chosen"); + snprintf(buf, sizeof(buf), "%s", get_path_from_ph(dnode)); push_str(buf); fword("open-dev"); set_int_property(chosen, "nvram", POP()); @@ -395,7 +395,7 @@ ob_macio_keylargo_init(const char *path, phys_addr_t addr) }
/* The NewWorld NVRAM is not located in the MacIO device */ - macio_nvram_init("", 0); + macio_nvram_init("/", 0); escc_init(path, addr); macio_ide_init(path, addr, 2); openpic_init(path, addr); diff --git a/include/packages/nvram.h b/include/packages/nvram.h index ba1b38b..7803814 100644 --- a/include/packages/nvram.h +++ b/include/packages/nvram.h @@ -17,8 +17,10 @@ #ifndef _H_NVRAM_PACKAGE #define _H_NVRAM_PACKAGE
+#include "kernel/stack.h" + extern void nvconf_init( void ); -extern void nvram_init( const char *path ); +extern phandle_t nvram_init( const char *path ); extern void update_nvram( void );
#endif /* _H_NVRAM_PACKAGE */ diff --git a/packages/nvram.c b/packages/nvram.c index 3182edf..b64a804 100644 --- a/packages/nvram.c +++ b/packages/nvram.c @@ -291,7 +291,20 @@ nvram_size( __attribute__((unused)) nvram_ibuf_t *nd ) PUSH( nvram.size ); }
+static void +nvram_open( __attribute__((unused)) nvram_ibuf_t *nd ) +{ + RET(-1); +} + +static void +nvram_close( __attribute__((unused)) nvram_ibuf_t *nd ) +{ +} + NODE_METHODS( nvram ) = { + { "open", (void*)nvram_open }, + { "close", (void*)nvram_close }, { "size", (void*)nvram_size }, { "read", (void*)nvram_read }, { "write", (void*)nvram_write }, @@ -299,10 +312,25 @@ NODE_METHODS( nvram ) = { };
-void +phandle_t nvram_init( const char *path ) { + phandle_t ph; + + push_str(path); + fword("find-device"); + + fword("new-device"); + nvconf_init();
- REGISTER_NAMED_NODE( nvram, path ); + ph = get_cur_dev(); + + push_str("nvram"); + fword("device-name"); + + BIND_NODE_METHODS(get_cur_dev(), nvram); + fword("finish-device"); + + return ph; }