aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2017-09-03 22:02:48 -0400
committerKevin O'Connor <kevin@koconnor.net>2017-09-03 23:16:38 -0400
commit7083a33ecd1cdcf5402cccbdb53f56cdfaf80f5e (patch)
tree95a1984058658800446ace751b6d0adeee35a415 /src
parent7b7f57e01c87efc74ed0c632b14c1fc7897c5a6e (diff)
downloadkutter-7083a33ecd1cdcf5402cccbdb53f56cdfaf80f5e.tar.gz
kutter-7083a33ecd1cdcf5402cccbdb53f56cdfaf80f5e.tar.xz
kutter-7083a33ecd1cdcf5402cccbdb53f56cdfaf80f5e.zip
pru: Support config_reset command to manually reset mcu
Add support for resetting the MCU via a software only mechanism. This is useful on the PRU. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r--src/basecmd.c19
-rw-r--r--src/basecmd.h1
-rw-r--r--src/pru/main.c3
-rw-r--r--src/sched.c4
-rw-r--r--src/sched.h1
5 files changed, 26 insertions, 2 deletions
diff --git a/src/basecmd.c b/src/basecmd.c
index 831b12e4..b5ff738a 100644
--- a/src/basecmd.c
+++ b/src/basecmd.c
@@ -215,6 +215,25 @@ command_finalize_config(uint32_t *args)
}
DECL_COMMAND(command_finalize_config, "finalize_config crc=%u");
+// Attempt a full manual reset of the config
+void
+config_reset(uint32_t *args)
+{
+ if (! sched_is_shutdown())
+ shutdown("config_reset only available when shutdown");
+ irq_disable();
+ config_crc = 0;
+ oid_count = 0;
+ oids = NULL;
+ move_free_list = NULL;
+ move_list = NULL;
+ move_count = move_item_size = 0;
+ alloc_init();
+ sched_timer_reset();
+ sched_clear_shutdown();
+ irq_enable();
+}
+
/****************************************************************
* Timing and load stats
diff --git a/src/basecmd.h b/src/basecmd.h
index 8787b194..21555bf8 100644
--- a/src/basecmd.h
+++ b/src/basecmd.h
@@ -10,6 +10,7 @@ void *oid_lookup(uint8_t oid, void *type);
void *oid_alloc(uint8_t oid, void *type, uint16_t size);
void *oid_next(uint8_t *i, void *type);
void stats_update(uint32_t start, uint32_t cur);
+void config_reset(uint32_t *args);
#define foreach_oid(pos,data,oidtype) \
for (pos=-1; (data=oid_next(&pos, oidtype)); )
diff --git a/src/pru/main.c b/src/pru/main.c
index 49d929ef..3edce8ec 100644
--- a/src/pru/main.c
+++ b/src/pru/main.c
@@ -212,6 +212,9 @@ struct my_resource_table {
* Startup
****************************************************************/
+// Support config_reset
+DECL_COMMAND_FLAGS(config_reset, HF_IN_SHUTDOWN, "config_reset");
+
// Main entry point
int
main(void)
diff --git a/src/sched.c b/src/sched.c
index 9aa5aea2..e4b51355 100644
--- a/src/sched.c
+++ b/src/sched.c
@@ -165,8 +165,8 @@ sched_timer_dispatch(void)
return next_waketime;
}
-// Remove all user timers on a shutdown
-static void
+// Remove all user timers
+void
sched_timer_reset(void)
{
timer_list = &deleted_timer;
diff --git a/src/sched.h b/src/sched.h
index ffe17e03..0a2bdc4b 100644
--- a/src/sched.h
+++ b/src/sched.h
@@ -29,6 +29,7 @@ struct task_wake {
void sched_add_timer(struct timer*);
void sched_del_timer(struct timer *del);
unsigned int sched_timer_dispatch(void);
+void sched_timer_reset(void);
void sched_wake_tasks(void);
uint8_t sched_tasks_busy(void);
void sched_wake_task(struct task_wake *w);