# HG changeset patch # User Paul Boddie # Date 1475417732 -7200 # Node ID 934658b3556d52ae0b75a3028ff5e1a12c96e98d # Parent 949a23b4b98ab86f7a64c4c0c89670fa4119fd15 Introduced a separate initial tasks manifest. diff -r 949a23b4b98a -r 934658b3556d stage2/stage2.c --- a/stage2/stage2.c Sun Oct 02 15:30:58 2016 +0200 +++ b/stage2/stage2.c Sun Oct 02 16:15:32 2016 +0200 @@ -24,7 +24,6 @@ #include "cpu.h" #include "cpu_op.h" #include "tasks.h" -#include "tasks/example.h" void c_main() { @@ -51,8 +50,7 @@ /* Start the tasks. */ init_tasks(); - start_plot_pattern(1); - start_plot_pattern(2); + start_tasks(); /* Now, wait for the tasks to be selected as interrupts occur. */ diff -r 949a23b4b98a -r 934658b3556d stage2/tasks.c --- a/stage2/tasks.c Sun Oct 02 15:30:58 2016 +0200 +++ b/stage2/tasks.c Sun Oct 02 16:15:32 2016 +0200 @@ -23,6 +23,7 @@ #include "mips.h" #include "paging.h" #include "tasks.h" +#include "tasks/manifest.h" /* Task tables and data. */ @@ -55,6 +56,15 @@ current_registers = registers[current_task]; } +void start_tasks() +{ + void (**starter)(unsigned short); + int i; + + for (i = 1, starter = initial_tasks; *starter; i++, starter++) + (*starter)(i); +} + void start_task(unsigned short task, void (*function)(), u32 args[], u8 nargs) { u32 virtual, physical, address; diff -r 949a23b4b98a -r 934658b3556d stage2/tasks.h --- a/stage2/tasks.h Sun Oct 02 15:30:58 2016 +0200 +++ b/stage2/tasks.h Sun Oct 02 16:15:32 2016 +0200 @@ -9,6 +9,7 @@ void init_tasks(); void init_task(); +void start_tasks(); void start_task(unsigned short, void (*)(), u32[], u8); void start_task_now(); void switch_task(); diff -r 949a23b4b98a -r 934658b3556d stage2/tasks/Makefile --- a/stage2/tasks/Makefile Sun Oct 02 15:30:58 2016 +0200 +++ b/stage2/tasks/Makefile Sun Oct 02 16:15:32 2016 +0200 @@ -33,7 +33,7 @@ # Configure task objects. DEFS = -SRC = example.c +SRC = $(wildcard *.c) OBJ = $(SRC:.c=.o) .PHONY: all clean distclean diff -r 949a23b4b98a -r 934658b3556d stage2/tasks/example.h --- a/stage2/tasks/example.h Sun Oct 02 15:30:58 2016 +0200 +++ b/stage2/tasks/example.h Sun Oct 02 16:15:32 2016 +0200 @@ -1,6 +1,8 @@ #ifndef __EXAMPLE_H__ #define __EXAMPLE_H__ +#include "xburst_types.h" + /* Example task functions. */ void plot_pattern(unsigned short, unsigned short, unsigned short); diff -r 949a23b4b98a -r 934658b3556d stage2/tasks/manifest.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/tasks/manifest.c Sun Oct 02 16:15:32 2016 +0200 @@ -0,0 +1,31 @@ +/* + * Task manifest. + * + * Copyright (C) 2016 Paul Boddie + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "manifest.h" +#include "example.h" + +/* A list of task-starting functions accepting their task identifier. */ + +void (*initial_task_array[])(unsigned short) = { + start_plot_pattern, + start_plot_pattern, + 0 + }; + +void (**initial_tasks)(unsigned short) = initial_task_array; diff -r 949a23b4b98a -r 934658b3556d stage2/tasks/manifest.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/tasks/manifest.h Sun Oct 02 16:15:32 2016 +0200 @@ -0,0 +1,6 @@ +#ifndef __TASKS_MANIFEST_H__ +#define __TASKS_MANIFEST_H__ + +void (**initial_tasks)(unsigned short); + +#endif /* __TASKS_MANIFEST_H__ */