1.1 --- a/stage2/Makefile Sun Oct 02 14:58:04 2016 +0200
1.2 +++ b/stage2/Makefile Sun Oct 02 15:30:58 2016 +0200
1.3 @@ -44,9 +44,9 @@
1.4 # Configure target-specific objects.
1.5
1.6 NANONOTE_SRC = board-nanonote.c nanonote_gpm940b0.c
1.7 -NANONOTE_OBJ = board-nanonote.o nanonote_gpm940b0.o
1.8 +NANONOTE_OBJ = $(NANONOTE_SRC:.c=.o)
1.9 MINIPC_SRC = board-minipc.c minipc_claa070vc01.c
1.10 -MINIPC_OBJ = board-minipc.o minipc_claa070vc01.o
1.11 +MINIPC_OBJ = $(MINIPC_SRC:.c=.o)
1.12
1.13 ifdef MINIPC
1.14 BOARD_SRC = $(MINIPC_SRC)
1.15 @@ -58,23 +58,40 @@
1.16 BOARD_DEFS =
1.17 endif
1.18
1.19 +# Configure generic objects.
1.20 +
1.21 +CORE_SRC = stage2.c cpu.c lcd.c jzlcd.c board.c irq.c paging.c tasks.c
1.22 +CORE_OBJ = $(CORE_SRC:.c=.o)
1.23 +
1.24 +# Add tasks.
1.25 +
1.26 +TASKS_SRC = $(wildcard tasks/*.c)
1.27 +TASKS_OBJ = $(TASKS_SRC:.c=.o)
1.28 +
1.29 +# Resulting definitions.
1.30 +
1.31 DEFS = $(BOARD_DEFS)
1.32
1.33 # Ordering of objects is important and cannot be left to replacement rules.
1.34 # In particular the head2 file must appear first.
1.35
1.36 -SRC = head2.S entry.S handlers.S stage2.c cpu.c cpu_op.S lcd.c jzlcd.c board.c irq.c paging.c tasks.c example.c $(BOARD_SRC)
1.37 -OBJ = head2.o entry.o handlers.o stage2.o cpu.o cpu_op.o lcd.o jzlcd.o board.o irq.o paging.o tasks.o example.o $(BOARD_OBJ)
1.38 +SRC = head2.S entry.S handlers.S cpu_op.S $(CORE_SRC) $(BOARD_SRC)
1.39 +OBJ = head2.o entry.o handlers.o cpu_op.o $(CORE_OBJ) $(BOARD_OBJ)
1.40
1.41 -.PHONY: all clean distclean
1.42 +.PHONY: all clean distclean tasks
1.43
1.44 -all: $(PAYLOAD) $(UIMAGE)
1.45 +all: $(PAYLOAD) $(UIMAGE) tasks
1.46
1.47 clean:
1.48 rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(UIMAGE) $(DUMP) *.map
1.49 + make -C tasks clean
1.50
1.51 distclean: clean
1.52 echo "Nothing else to clean."
1.53 + make -C tasks distclean
1.54 +
1.55 +tasks:
1.56 + make -C tasks
1.57
1.58 $(UIMAGE): $(PAYLOAD)
1.59 $(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x81c00000 -e 0x81c00000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE)
1.60 @@ -87,8 +104,8 @@
1.61 chmod -x $@+
1.62 mv -f $@+ $@
1.63
1.64 -stage2.elf: $(OBJ)
1.65 - $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) -o $@
1.66 +$(TARGET): $(OBJ) tasks
1.67 + $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) $(TASKS_OBJ) -o $@
1.68
1.69 .c.o:
1.70 $(CC) -c $(CFLAGS) $(DEFS) $< -o $@
2.1 --- a/stage2/example.c Sun Oct 02 14:58:04 2016 +0200
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,72 +0,0 @@
2.4 -/*
2.5 - * Example tasks.
2.6 - *
2.7 - * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
2.8 - *
2.9 - * This program is free software: you can redistribute it and/or modify
2.10 - * it under the terms of the GNU General Public License as published by
2.11 - * the Free Software Foundation, either version 3 of the License, or
2.12 - * (at your option) any later version.
2.13 - *
2.14 - * This program is distributed in the hope that it will be useful,
2.15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
2.16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2.17 - * GNU General Public License for more details.
2.18 - *
2.19 - * You should have received a copy of the GNU General Public License
2.20 - * along with this program. If not, see <http://www.gnu.org/licenses/>.
2.21 - */
2.22 -
2.23 -#include "board.h"
2.24 -#include "lcd.h"
2.25 -#include "jzlcd.h"
2.26 -#include "tasks.h"
2.27 -
2.28 -extern vidinfo_t panel_info;
2.29 -
2.30 -void next_pixel(unsigned short *x, unsigned short *y)
2.31 -{
2.32 - (*x)++;
2.33 - if (*x >= panel_info.vl_col) {
2.34 - *x = 0;
2.35 - (*y)++;
2.36 - if (*y >= panel_info.vl_row)
2.37 - *y = 0;
2.38 - }
2.39 -}
2.40 -
2.41 -void plot_value(u32 value)
2.42 -{
2.43 - unsigned short x, y;
2.44 -
2.45 - while (1)
2.46 - {
2.47 - for (y = 0; y < panel_info.vl_row; y++)
2.48 - {
2.49 - for (x = 0; x < panel_info.vl_col; x++)
2.50 - {
2.51 - set_pixel(x, y, get_bitmap_value(x, value));
2.52 - }
2.53 - }
2.54 - }
2.55 -}
2.56 -
2.57 -/* Tasks. */
2.58 -
2.59 -void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y)
2.60 -{
2.61 - int i;
2.62 -
2.63 - while (1) {
2.64 - test_pixel(x, y, pixel_type);
2.65 - next_pixel(&x, &y);
2.66 - for (i = 0; i < 10000; i++);
2.67 - }
2.68 -}
2.69 -
2.70 -void start_plot_pattern(unsigned short task)
2.71 -{
2.72 - u32 args[] = {task, 0, (task * (panel_info.vl_row / 4)) % panel_info.vl_row};
2.73 -
2.74 - start_task(task, (void (*)()) plot_pattern, args, 3);
2.75 -}
3.1 --- a/stage2/example.h Sun Oct 02 14:58:04 2016 +0200
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,10 +0,0 @@
3.4 -#ifndef __EXAMPLE_H__
3.5 -#define __EXAMPLE_H__
3.6 -
3.7 -/* Example task functions. */
3.8 -
3.9 -void plot_pattern(unsigned short, unsigned short, unsigned short);
3.10 -void plot_value(u32);
3.11 -void start_plot_pattern(unsigned short);
3.12 -
3.13 -#endif /* __EXAMPLE_H__ */
4.1 --- a/stage2/stage2.c Sun Oct 02 14:58:04 2016 +0200
4.2 +++ b/stage2/stage2.c Sun Oct 02 15:30:58 2016 +0200
4.3 @@ -24,7 +24,7 @@
4.4 #include "cpu.h"
4.5 #include "cpu_op.h"
4.6 #include "tasks.h"
4.7 -#include "example.h"
4.8 +#include "tasks/example.h"
4.9
4.10 void c_main()
4.11 {
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/stage2/tasks/Makefile Sun Oct 02 15:30:58 2016 +0200
5.3 @@ -0,0 +1,53 @@
5.4 +# Makefile - Build the bundled tasks
5.5 +#
5.6 +# Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
5.7 +# Copyright (C) Xiangfu Liu <xiangfu@sharism.cc>
5.8 +#
5.9 +# This program is free software: you can redistribute it and/or modify
5.10 +# it under the terms of the GNU General Public License as published by
5.11 +# the Free Software Foundation, either version 3 of the License, or
5.12 +# (at your option) any later version.
5.13 +#
5.14 +# This program is distributed in the hope that it will be useful,
5.15 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
5.16 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5.17 +# GNU General Public License for more details.
5.18 +#
5.19 +# You should have received a copy of the GNU General Public License
5.20 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
5.21 +
5.22 +ARCH = mipsel-linux-gnu
5.23 +CC = $(ARCH)-gcc
5.24 +
5.25 +# NOTE: -O2 is actually needed to prevent memcpy references, whereas probably
5.26 +# NOTE: one of the -f{freestanding, no-hosted, no-builtin} options should work.
5.27 +# NOTE: See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888
5.28 +
5.29 +CFLAGS = -O2 -Wall \
5.30 + -fno-unit-at-a-time -fno-zero-initialized-in-bss \
5.31 + -ffreestanding -fno-hosted -fno-builtin -fPIC \
5.32 + -march=mips32 \
5.33 + -I../../include -I..
5.34 +LDFLAGS = -nostdlib -EL
5.35 +
5.36 +# Configure task objects.
5.37 +
5.38 +DEFS =
5.39 +SRC = example.c
5.40 +OBJ = $(SRC:.c=.o)
5.41 +
5.42 +.PHONY: all clean distclean
5.43 +
5.44 +all: $(OBJ)
5.45 +
5.46 +clean:
5.47 + rm -f $(OBJ)
5.48 +
5.49 +distclean: clean
5.50 + echo "Nothing else to clean."
5.51 +
5.52 +.c.o:
5.53 + $(CC) -c $(CFLAGS) $(DEFS) $< -o $@
5.54 +
5.55 +.S.o:
5.56 + $(CC) -c $(CFLAGS) $(DEFS) $< -o $@
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/stage2/tasks/example.c Sun Oct 02 15:30:58 2016 +0200
6.3 @@ -0,0 +1,72 @@
6.4 +/*
6.5 + * Example tasks.
6.6 + *
6.7 + * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk>
6.8 + *
6.9 + * This program is free software: you can redistribute it and/or modify
6.10 + * it under the terms of the GNU General Public License as published by
6.11 + * the Free Software Foundation, either version 3 of the License, or
6.12 + * (at your option) any later version.
6.13 + *
6.14 + * This program is distributed in the hope that it will be useful,
6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.17 + * GNU General Public License for more details.
6.18 + *
6.19 + * You should have received a copy of the GNU General Public License
6.20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
6.21 + */
6.22 +
6.23 +#include "board.h"
6.24 +#include "lcd.h"
6.25 +#include "jzlcd.h"
6.26 +#include "tasks.h"
6.27 +
6.28 +extern vidinfo_t panel_info;
6.29 +
6.30 +void next_pixel(unsigned short *x, unsigned short *y)
6.31 +{
6.32 + (*x)++;
6.33 + if (*x >= panel_info.vl_col) {
6.34 + *x = 0;
6.35 + (*y)++;
6.36 + if (*y >= panel_info.vl_row)
6.37 + *y = 0;
6.38 + }
6.39 +}
6.40 +
6.41 +void plot_value(u32 value)
6.42 +{
6.43 + unsigned short x, y;
6.44 +
6.45 + while (1)
6.46 + {
6.47 + for (y = 0; y < panel_info.vl_row; y++)
6.48 + {
6.49 + for (x = 0; x < panel_info.vl_col; x++)
6.50 + {
6.51 + set_pixel(x, y, get_bitmap_value(x, value));
6.52 + }
6.53 + }
6.54 + }
6.55 +}
6.56 +
6.57 +/* Tasks. */
6.58 +
6.59 +void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y)
6.60 +{
6.61 + int i;
6.62 +
6.63 + while (1) {
6.64 + test_pixel(x, y, pixel_type);
6.65 + next_pixel(&x, &y);
6.66 + for (i = 0; i < 10000; i++);
6.67 + }
6.68 +}
6.69 +
6.70 +void start_plot_pattern(unsigned short task)
6.71 +{
6.72 + u32 args[] = {task, 0, (task * (panel_info.vl_row / 4)) % panel_info.vl_row};
6.73 +
6.74 + start_task(task, (void (*)()) plot_pattern, args, 3);
6.75 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/stage2/tasks/example.h Sun Oct 02 15:30:58 2016 +0200
7.3 @@ -0,0 +1,10 @@
7.4 +#ifndef __EXAMPLE_H__
7.5 +#define __EXAMPLE_H__
7.6 +
7.7 +/* Example task functions. */
7.8 +
7.9 +void plot_pattern(unsigned short, unsigned short, unsigned short);
7.10 +void plot_value(u32);
7.11 +void start_plot_pattern(unsigned short);
7.12 +
7.13 +#endif /* __EXAMPLE_H__ */