Commit b6b11840 authored by hudson@kremvax.wan's avatar hudson@kremvax.wan
Browse files

Writing the bootflags->diskboot flag works.

- Created bootflags.c with parser for bootflags structure
- Added Boot menu
- Moved power save into bootflags.c
- Added power save menu item
- Use call() to enable/disable the boot flag
- Tested!
parent e71b937b80a0
......@@ -239,7 +239,6 @@ call_init_funcs( void * priv )
init_funcs_done = 1;
}
CONFIG_INT( "disable-powersave", disable_powersave, 1 );
/** Initial task setup.
......@@ -311,15 +310,6 @@ my_init_task(void)
msleep( 500 );
if( disable_powersave )
{
DebugMsg( DM_MAGIC, 3,
"%s: Disabling powersave",
__func__
);
prop_request_icu_auto_poweroff( EM_PROHIBIT );
}
init_funcs_done = 0;
//task_create( "init_func", 0x1f, 0x1000, call_init_funcs, 0 );
//while( !init_funcs_done )
......
......@@ -167,6 +167,7 @@ ML_OBJS-y = \
spotmeter.o \
hotplug.o \
config.o \
bootflags.o \
ptp.o \
bmp.o \
bracket.o \
......
/** \file
* Autoboot flag control
*/
#include "dryos.h"
#include "bmp.h"
#include "menu.h"
#include "config.h"
/** Shadow copy of the NVRAM boot flags stored at 0xF8000000 */
#define NVRAM_BOOTFLAGS ((void*) 0xF8000000)
struct boot_flags
{
uint32_t firmware; // 0x00
uint32_t bootdisk; // 0x04
uint32_t ram_exe; // 0x08
uint32_t update; // 0x0c
uint32_t flag_0x10;
uint32_t flag_0x14;
uint32_t flag_0x18;
uint32_t flag_0x1c;
};
static struct boot_flags * const boot_flags = NVRAM_BOOTFLAGS;;
/** Write the auto-boot flags to the CF card and to the flash memory */
static void
bootflag_toggle( void * priv )
{
if( boot_flags->bootdisk )
call( "DisableBootDisk" );
else
call( "EnableBootDisk" );
}
void
bootflag_display(
void * priv,
int x,
int y,
int selected
)
{
bmp_printf(
selected ? MENU_FONT_SEL : MENU_FONT,
x, y,
//23456789012
"Autoboot %s",
boot_flags->bootdisk != 0 ? "ON " : "OFF"
);
}
void
bootflag_write_bootblock( void )
{
gui_stop_menu();
//bmp_printf( FONT_LARGE, 0, 30, "Not yet" );
bmp_hexdump( FONT_MED, 0, 30, boot_flags, sizeof(*boot_flags) );
}
#if 0
void
bootflag_display_all(
void * priv,
int x,
int y,
int selected
)
{
bmp_printf( selected ? MENU_FONT_SEL : MENU_FONT,
x,
y,
//23456789012
"Firmware %s\n"
"Bootdisk %s\n"
"RAM_EXE %s\n"
"Update %s\n",
boot_flags->firmware == 0 ? "ON" : "OFF",
boot_flags->bootdisk == 0 ? "ON" : "OFF",
boot_flags->ram_exe == 0 ? "ON" : "OFF",
boot_flags->update == 0 ? "ON" : "OFF"
);
}
#endif
CONFIG_INT( "disable-powersave", disable_powersave, 1 );
static void
powersave_display(
void * priv,
int x,
int y,
int selected
)
{
bmp_printf(
selected ? MENU_FONT_SEL : MENU_FONT,
x,
y,
//23456789012
"Powersave %s\n",
!disable_powersave ? "ON " : "OFF"
);
}
static void
powersave_toggle( void )
{
disable_powersave = !disable_powersave;
prop_request_icu_auto_poweroff(
disable_powersave ? EM_PROHIBIT : EM_ALLOW
);
}
struct menu_entry boot_menus[] = {
{
.display = menu_print,
.priv = "Show flags",
.select = bootflag_write_bootblock,
},
{
.display = bootflag_display,
.select = bootflag_toggle,
},
{
.display = powersave_display,
.select = powersave_toggle,
},
#if 0
{
.display = bootflag_display_all,
},
#endif
};
static void
bootflags_init( void )
{
menu_add( "Boot", boot_menus, COUNT(boot_menus) );
if( disable_powersave )
{
DebugMsg( DM_MAGIC, 3,
"%s: Disabling powersave",
__func__
);
prop_request_icu_auto_poweroff( EM_PROHIBIT );
}
}
INIT_FUNC( __FILE__, bootflags_init );
......@@ -640,6 +640,7 @@ strftime(
extern void powersave_disable( void );
extern void powersave_enable( void );
#define EM_ALLOW 1
#define EM_PROHIBIT 2
extern void prop_request_icu_auto_poweroff( int mode );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment