| Index: emcore/trunk/init.c |
| — | — | @@ -54,6 +54,11 @@ |
| 55 | 55 | #endif
|
| 56 | 56 |
|
| 57 | 57 |
|
| | 58 | +#ifndef BATTERY_BOOT_LOCKOUT_THRESHOLD
|
| | 59 | +#define BATTERY_BOOT_LOCKOUT_THRESHOLD 0
|
| | 60 | +#endif
|
| | 61 | +
|
| | 62 | +
|
| 58 | 63 | extern int _poolstart; // Not an int at all, but gcc complains about void types being
|
| 59 | 64 | // used here, and we only need the address, so just make it happy...
|
| 60 | 65 |
|
| — | — | @@ -119,25 +124,35 @@ |
| 120 | 125 | void storageinitthread(void* arg0, void* arg1, void* arg2, void* arg3)
|
| 121 | 126 | {
|
| 122 | 127 | struct initbss* ib = (struct initbss*)arg0;
|
| 123 | | - int threshold = 0;
|
| 124 | | - DEBUGF("Battery state: %d mV, %d mAh", read_battery_voltage(0), read_battery_mwh_current(0));
|
| 125 | | - if (read_battery_mwh_current(0) <= threshold)
|
| | 128 | + DEBUGF("Battery state: %d, %d mV, %d mAh", read_battery_state(0),
|
| | 129 | + read_battery_voltage(0), read_battery_mwh_current(0));
|
| | 130 | + switch (read_battery_state(0))
|
| 126 | 131 | {
|
| 127 | | - backlight_set_brightness(50);
|
| 128 | | - cputs(CONSOLE_BOOT, "The battery is discharged.\n"
|
| 129 | | - "Please connect to a power supply\n"
|
| 130 | | - "and wait a few minutes.\n");
|
| 131 | | - while (read_battery_mwh_current(0) <= threshold)
|
| | 132 | + case BATTERY_STATE_NONPRESENT:
|
| | 133 | + cputs(CONSOLE_BOOT, "No battery connected.\n");
|
| | 134 | + break;
|
| | 135 | + case BATTERY_STATE_IDLE:
|
| | 136 | + case BATTERY_STATE_CHARGING:
|
| | 137 | + case BATTERY_STATE_DISCHARGING:
|
| | 138 | + if (read_battery_mwh_current(0) <= BATTERY_BOOT_LOCKOUT_THRESHOLD)
|
| 132 | 139 | {
|
| 133 | | - DEBUGF("Battery state: %d mV, %d mAh", read_battery_voltage(0), read_battery_mwh_current(0));
|
| 134 | | - sleep(10000000);
|
| 135 | | - if (read_input_state(0) != INPUT_STATE_ACTIVE)
|
| | 140 | + backlight_set_brightness(50);
|
| | 141 | + cputs(CONSOLE_BOOT, "The battery is discharged.\n"
|
| | 142 | + "Please connect to a power supply\n"
|
| | 143 | + "and wait a few minutes.\n");
|
| | 144 | + while (read_battery_mwh_current(0) <= BATTERY_BOOT_LOCKOUT_THRESHOLD)
|
| 136 | 145 | {
|
| 137 | | - shutdown(true);
|
| 138 | | - power_off();
|
| | 146 | + DEBUGF("Battery state: %d, %d mV, %d mAh", read_battery_state(0),
|
| | 147 | + read_battery_voltage(0), read_battery_mwh_current(0));
|
| | 148 | + sleep(10000000);
|
| | 149 | + if (read_battery_state(0) != BATTERY_STATE_CHARGING)
|
| | 150 | + {
|
| | 151 | + shutdown(true);
|
| | 152 | + power_off();
|
| | 153 | + }
|
| 139 | 154 | }
|
| | 155 | + backlight_set_brightness(100);
|
| 140 | 156 | }
|
| 141 | | - backlight_set_brightness(100);
|
| 142 | 157 | }
|
| 143 | 158 | DEBUGF("Initializing storage drivers...");
|
| 144 | 159 | int rc = storage_init();
|
| — | — | @@ -148,10 +163,13 @@ |
| 149 | 164 | }
|
| 150 | 165 | DEBUGF("Initializing storage subsystem...");
|
| 151 | 166 | disk_init_subsystem();
|
| 152 | | - DEBUGF("Reading partition tables...");
|
| 153 | | - disk_init();
|
| 154 | 167 | DEBUGF("Mounting partitions...");
|
| 155 | | - disk_mount_all();
|
| | 168 | + rc = disk_mount_all();
|
| | 169 | + if (IS_ERR(rc))
|
| | 170 | + {
|
| | 171 | + DEBUGF("FS mount error: %08X\n", rc);
|
| | 172 | + cprintf(CONSOLE_BOOT, "FS mount error: %08X\n", rc);
|
| | 173 | + }
|
| 156 | 174 | DEBUGF("Storage init finished.");
|
| 157 | 175 | wakeup_signal(&(ib->storagewakeup));
|
| 158 | 176 | }
|