# HG changeset patch # User Paul Boddie # Date 1475415058 -7200 # Node ID 949a23b4b98ab86f7a64c4c0c89670fa4119fd15 # Parent c2fc5c9301931b7b2739e27a306955b8a6313640 Moved example tasks into a separate directory. Tidied up the stage2 Makefile, grouping different source and object files. diff -r c2fc5c930193 -r 949a23b4b98a stage2/Makefile --- a/stage2/Makefile Sun Oct 02 14:58:04 2016 +0200 +++ b/stage2/Makefile Sun Oct 02 15:30:58 2016 +0200 @@ -44,9 +44,9 @@ # Configure target-specific objects. NANONOTE_SRC = board-nanonote.c nanonote_gpm940b0.c -NANONOTE_OBJ = board-nanonote.o nanonote_gpm940b0.o +NANONOTE_OBJ = $(NANONOTE_SRC:.c=.o) MINIPC_SRC = board-minipc.c minipc_claa070vc01.c -MINIPC_OBJ = board-minipc.o minipc_claa070vc01.o +MINIPC_OBJ = $(MINIPC_SRC:.c=.o) ifdef MINIPC BOARD_SRC = $(MINIPC_SRC) @@ -58,23 +58,40 @@ BOARD_DEFS = endif +# Configure generic objects. + +CORE_SRC = stage2.c cpu.c lcd.c jzlcd.c board.c irq.c paging.c tasks.c +CORE_OBJ = $(CORE_SRC:.c=.o) + +# Add tasks. + +TASKS_SRC = $(wildcard tasks/*.c) +TASKS_OBJ = $(TASKS_SRC:.c=.o) + +# Resulting definitions. + DEFS = $(BOARD_DEFS) # Ordering of objects is important and cannot be left to replacement rules. # In particular the head2 file must appear first. -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) -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) +SRC = head2.S entry.S handlers.S cpu_op.S $(CORE_SRC) $(BOARD_SRC) +OBJ = head2.o entry.o handlers.o cpu_op.o $(CORE_OBJ) $(BOARD_OBJ) -.PHONY: all clean distclean +.PHONY: all clean distclean tasks -all: $(PAYLOAD) $(UIMAGE) +all: $(PAYLOAD) $(UIMAGE) tasks clean: rm -f $(OBJ) $(TARGET) $(PAYLOAD) $(UIMAGE) $(DUMP) *.map + make -C tasks clean distclean: clean echo "Nothing else to clean." + make -C tasks distclean + +tasks: + make -C tasks $(UIMAGE): $(PAYLOAD) $(MKIMAGE) -A mips -O linux -T kernel -C none -a 0x81c00000 -e 0x81c00000 -n NanoPayload -d $(PAYLOAD) $(UIMAGE) @@ -87,8 +104,8 @@ chmod -x $@+ mv -f $@+ $@ -stage2.elf: $(OBJ) - $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) -o $@ +$(TARGET): $(OBJ) tasks + $(LD) $(LDFLAGS) -T $(@:.elf=.ld) $(OBJ) $(TASKS_OBJ) -o $@ .c.o: $(CC) -c $(CFLAGS) $(DEFS) $< -o $@ diff -r c2fc5c930193 -r 949a23b4b98a stage2/example.c --- a/stage2/example.c Sun Oct 02 14:58:04 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* - * Example tasks. - * - * Copyright (C) 2015, 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 "board.h" -#include "lcd.h" -#include "jzlcd.h" -#include "tasks.h" - -extern vidinfo_t panel_info; - -void next_pixel(unsigned short *x, unsigned short *y) -{ - (*x)++; - if (*x >= panel_info.vl_col) { - *x = 0; - (*y)++; - if (*y >= panel_info.vl_row) - *y = 0; - } -} - -void plot_value(u32 value) -{ - unsigned short x, y; - - while (1) - { - for (y = 0; y < panel_info.vl_row; y++) - { - for (x = 0; x < panel_info.vl_col; x++) - { - set_pixel(x, y, get_bitmap_value(x, value)); - } - } - } -} - -/* Tasks. */ - -void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y) -{ - int i; - - while (1) { - test_pixel(x, y, pixel_type); - next_pixel(&x, &y); - for (i = 0; i < 10000; i++); - } -} - -void start_plot_pattern(unsigned short task) -{ - u32 args[] = {task, 0, (task * (panel_info.vl_row / 4)) % panel_info.vl_row}; - - start_task(task, (void (*)()) plot_pattern, args, 3); -} diff -r c2fc5c930193 -r 949a23b4b98a stage2/example.h --- a/stage2/example.h Sun Oct 02 14:58:04 2016 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ -#ifndef __EXAMPLE_H__ -#define __EXAMPLE_H__ - -/* Example task functions. */ - -void plot_pattern(unsigned short, unsigned short, unsigned short); -void plot_value(u32); -void start_plot_pattern(unsigned short); - -#endif /* __EXAMPLE_H__ */ diff -r c2fc5c930193 -r 949a23b4b98a stage2/stage2.c --- a/stage2/stage2.c Sun Oct 02 14:58:04 2016 +0200 +++ b/stage2/stage2.c Sun Oct 02 15:30:58 2016 +0200 @@ -24,7 +24,7 @@ #include "cpu.h" #include "cpu_op.h" #include "tasks.h" -#include "example.h" +#include "tasks/example.h" void c_main() { diff -r c2fc5c930193 -r 949a23b4b98a stage2/tasks/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/tasks/Makefile Sun Oct 02 15:30:58 2016 +0200 @@ -0,0 +1,53 @@ +# Makefile - Build the bundled tasks +# +# Copyright (C) 2015, 2016 Paul Boddie +# Copyright (C) Xiangfu Liu +# +# 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 . + +ARCH = mipsel-linux-gnu +CC = $(ARCH)-gcc + +# NOTE: -O2 is actually needed to prevent memcpy references, whereas probably +# NOTE: one of the -f{freestanding, no-hosted, no-builtin} options should work. +# NOTE: See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56888 + +CFLAGS = -O2 -Wall \ + -fno-unit-at-a-time -fno-zero-initialized-in-bss \ + -ffreestanding -fno-hosted -fno-builtin -fPIC \ + -march=mips32 \ + -I../../include -I.. +LDFLAGS = -nostdlib -EL + +# Configure task objects. + +DEFS = +SRC = example.c +OBJ = $(SRC:.c=.o) + +.PHONY: all clean distclean + +all: $(OBJ) + +clean: + rm -f $(OBJ) + +distclean: clean + echo "Nothing else to clean." + +.c.o: + $(CC) -c $(CFLAGS) $(DEFS) $< -o $@ + +.S.o: + $(CC) -c $(CFLAGS) $(DEFS) $< -o $@ diff -r c2fc5c930193 -r 949a23b4b98a stage2/tasks/example.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/tasks/example.c Sun Oct 02 15:30:58 2016 +0200 @@ -0,0 +1,72 @@ +/* + * Example tasks. + * + * Copyright (C) 2015, 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 "board.h" +#include "lcd.h" +#include "jzlcd.h" +#include "tasks.h" + +extern vidinfo_t panel_info; + +void next_pixel(unsigned short *x, unsigned short *y) +{ + (*x)++; + if (*x >= panel_info.vl_col) { + *x = 0; + (*y)++; + if (*y >= panel_info.vl_row) + *y = 0; + } +} + +void plot_value(u32 value) +{ + unsigned short x, y; + + while (1) + { + for (y = 0; y < panel_info.vl_row; y++) + { + for (x = 0; x < panel_info.vl_col; x++) + { + set_pixel(x, y, get_bitmap_value(x, value)); + } + } + } +} + +/* Tasks. */ + +void plot_pattern(unsigned short pixel_type, unsigned short x, unsigned short y) +{ + int i; + + while (1) { + test_pixel(x, y, pixel_type); + next_pixel(&x, &y); + for (i = 0; i < 10000; i++); + } +} + +void start_plot_pattern(unsigned short task) +{ + u32 args[] = {task, 0, (task * (panel_info.vl_row / 4)) % panel_info.vl_row}; + + start_task(task, (void (*)()) plot_pattern, args, 3); +} diff -r c2fc5c930193 -r 949a23b4b98a stage2/tasks/example.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stage2/tasks/example.h Sun Oct 02 15:30:58 2016 +0200 @@ -0,0 +1,10 @@ +#ifndef __EXAMPLE_H__ +#define __EXAMPLE_H__ + +/* Example task functions. */ + +void plot_pattern(unsigned short, unsigned short, unsigned short); +void plot_value(u32); +void start_plot_pattern(unsigned short); + +#endif /* __EXAMPLE_H__ */