void arch_nvram_put( char *buf ) { int i, size = arch_nvram_size(); for( i=0; i<size; i++ ) OSI_WriteNVRamByte( i, buf[i] ); }
void arch_nvram_get( char *buf ) { int i, size = arch_nvram_size(); /* support for zapping the nvram */ if( get_bool_res("zap_nvram") == 1 ) { memset( buf, 0, size ); return; } for( i=0; i<size; i++ ) buf[i] = OSI_ReadNVRamByte( i ); }
void nvconf_init( void ) { int once=0; /* initialize nvram structure completely */ nvram.config = NULL; nvram.config_size = 0; nvram.size = arch_nvram_size(); nvram.data = malloc( nvram.size ); arch_nvram_get( nvram.data ); bind_func( "update-nvram", update_nvram ); for( ;; ) { nvpart_t *p = NULL; int err; while( (err=next_nvpart(&p)) > 0 ) { if( nvpart_checksum(p) != p->checksum ) { err = -1; break; } if( p->signature == NV_SIG_SYSTEM ) { nvram.config = p; nvram.config_size = nvpart_size(p) - 0x10; if( !once++ ) { PUSH( pointer2cell(p->data) ); PUSH( nvram.config_size ); fword("nvram-load-configs"); } } } if( err || !nvram.config ) { printk("nvram error detected, zapping pram\n"); zap_nvram(); if( !once++ ) fword("set-defaults"); continue; } break; } }