# HG changeset patch # User Paul Boddie # Date 1475440687 -7200 # Node ID 62eec209b04febbec5fa3fb039d191a62b863374 # Parent 8647b2eb5c4d70b6d914d2fd97abfeab1c5e5920 Changed the task stack virtual address, introducing also a GPIO address base. Renamed various memory-related definitions. Introduced GPIO details for potential GPIO region mapping in user tasks. Added GPIO details for device keyboards. diff -r 8647b2eb5c4d -r 62eec209b04f include/minipc.h --- a/include/minipc.h Sun Oct 02 22:34:32 2016 +0200 +++ b/include/minipc.h Sun Oct 02 22:38:07 2016 +0200 @@ -31,7 +31,12 @@ #define GPIO_POWER 97 #define GPIO_KEYIN_BASE 0 /* if jz_keypad.c is understood correctly */ +#define GPIO_KEYOUT_BASE (3 * 32 + 0) +#define GPIO_KEYIN_COUNT 8 +#define GPIO_KEYOUT_COUNT 17 #define GPIO_IRQ IRQ_GPIO0 +#define GPIO_REGION_SIZE 0x10000 + #endif /* __MINIPC_H__ */ diff -r 8647b2eb5c4d -r 62eec209b04f include/nanonote.h --- a/include/nanonote.h Sun Oct 02 22:34:32 2016 +0200 +++ b/include/nanonote.h Sun Oct 02 22:38:07 2016 +0200 @@ -42,6 +42,9 @@ #define GPIO_KEYIN_BASE (3 * 32 + 18) #define GPIO_KEYIN_8 (3 * 32 + 26) +#define GPIO_KEYIN_COUNT 7 +#define GPIO_KEYOUT_COUNT 8 + #define GPIO_POWER (3 * 32 + 29) #define GPIO_SD_CD_N GPIO_SD_DETECT /* SD Card insert detect */ @@ -55,4 +58,6 @@ #define GPIO_IRQ IRQ_GPIO3 +#define GPIO_REGION_SIZE 0x10000 + #endif /* __NANONOTE_H__ */ diff -r 8647b2eb5c4d -r 62eec209b04f stage2/board-minipc.c --- a/stage2/board-minipc.c Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/board-minipc.c Sun Oct 02 22:38:07 2016 +0200 @@ -27,7 +27,8 @@ void gpio_init2() { - /* LED enable */ + /* LED enable. */ + __gpio_as_output(GPIO_LED_EN); __gpio_set_pin(GPIO_LED_EN); @@ -35,15 +36,27 @@ __gpio_as_emc(); __gpio_as_dma(); - /* - * Initialize LCD pins - */ + /* Initialise LCD pins. */ + __gpio_as_lcd_master(); - /* - * Initialize MSC pins - */ + /* Initialise MSC pins. */ + __gpio_as_msc(); + + /* Initialise other pins. */ + + unsigned short i; + + for (i = 0; i < GPIO_KEYIN_COUNT; i++) { + __gpio_as_input(GPIO_KEYIN_BASE + i); + __gpio_enable_pull(GPIO_KEYIN_BASE + i); + } + + for (i = 0; i < GPIO_KEYOUT_COUNT; i++) { + __gpio_as_output(GPIO_KEYOUT_BASE + i); + __gpio_clear_pin(GPIO_KEYOUT_BASE + i); + } } void cpm_init() @@ -99,12 +112,6 @@ void gpio_init_irq() { - unsigned short i; - - for (i = 0; i < 7; i++) { - __gpio_as_irq_low_level(GPIO_KEYIN_BASE + i); - } - __gpio_as_irq_low_level(GPIO_POWER); __intc_unmask_irq(GPIO_IRQ); } diff -r 8647b2eb5c4d -r 62eec209b04f stage2/board-nanonote.c --- a/stage2/board-nanonote.c Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/board-nanonote.c Sun Oct 02 22:38:07 2016 +0200 @@ -27,31 +27,30 @@ void gpio_init2() { - /* - * Initialize LCD pins - */ + /* Initialise LCD pins. */ + __gpio_as_slcd_8bit(); - /* - * Initialize MSC pins - */ + /* Initialise MSC pins. */ + __gpio_as_msc(); - /* - * Initialize Other pins - */ + /* Initialise other pins. */ + unsigned int i; - for (i = 0; i < 7; i++){ + + for (i = 0; i < GPIO_KEYIN_COUNT; i++){ __gpio_as_input(GPIO_KEYIN_BASE + i); __gpio_enable_pull(GPIO_KEYIN_BASE + i); } - for (i = 0; i < 8; i++) { + for (i = 0; i < GPIO_KEYOUT_COUNT; i++) { __gpio_as_output(GPIO_KEYOUT_BASE + i); __gpio_clear_pin(GPIO_KEYOUT_BASE + i); } - /* enable the TP4, TP5 as UART0 */ + /* Enable TP4, TP5 as UART0. */ + __gpio_jtag_to_uart0(); __gpio_as_input(GPIO_KEYIN_8); @@ -157,12 +156,6 @@ void gpio_init_irq() { - unsigned short i; - - for (i = 0; i < 7; i++) { - __gpio_as_irq_low_level(GPIO_KEYIN_BASE + i); - } - __gpio_as_irq_low_level(GPIO_POWER); __intc_unmask_irq(GPIO_IRQ); } diff -r 8647b2eb5c4d -r 62eec209b04f stage2/memory.h --- a/stage2/memory.h Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/memory.h Sun Oct 02 22:38:07 2016 +0200 @@ -9,10 +9,12 @@ #define STAGE2_PAGE_TABLE 0x81400000 #define STAGE2_PAGE_TABLE_TASK 0x00008000 -/* User mode addresses. */ +/* User mode and physical addresses. */ -#define STAGE2_TASK_STACK 0x01c00000 -#define STAGE2_TASK_STACK_SIZE 0x00002000 +#define TASK_GPIO_BASE 0x7fff0000 +#define TASK_STACK_TOP 0x7fff0000 +#define TASK_STACK_PHYSICAL 0x01c00000 +#define TASK_STACK_SIZE 0x00002000 /* Common configuration. */ diff -r 8647b2eb5c4d -r 62eec209b04f stage2/paging.c --- a/stage2/paging.c Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/paging.c Sun Oct 02 22:38:07 2016 +0200 @@ -34,3 +34,8 @@ { return addr + pagesize * 2; } + +inline u32 page_size(u32 size) +{ + return size / 2; +} diff -r 8647b2eb5c4d -r 62eec209b04f stage2/paging.h --- a/stage2/paging.h Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/paging.h Sun Oct 02 22:38:07 2016 +0200 @@ -10,6 +10,7 @@ u32 user_address(u32 addr); u32 previous_page(u32 addr, u32 pagesize); u32 next_page(u32 addr, u32 pagesize); +u32 page_size(u32 size); #endif /* __ASSEMBLER__ */ diff -r 8647b2eb5c4d -r 62eec209b04f stage2/tasks.c --- a/stage2/tasks.c Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/tasks.c Sun Oct 02 22:38:07 2016 +0200 @@ -75,8 +75,11 @@ is never started. */ - virtual = STAGE2_TASK_STACK; - physical = STAGE2_TASK_STACK - STAGE2_TASK_STACK_SIZE * task; + virtual = TASK_STACK_TOP; + + /* NOTE: Should allocate pages generally, not according to this simple calculation. */ + + physical = TASK_STACK_PHYSICAL - TASK_STACK_SIZE * task; init_page_table(STAGE2_PAGE_TABLE, previous_page(virtual, STAGE2_PAGESIZE), diff -r 8647b2eb5c4d -r 62eec209b04f stage2/tasks.h --- a/stage2/tasks.h Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/tasks.h Sun Oct 02 22:38:07 2016 +0200 @@ -3,6 +3,8 @@ #include "xburst_types.h" +/* Provide a limit to the number of tasks (in a way that employs a constant). */ + enum { max_tasks = 3 }; /* Task management functions. */ diff -r 8647b2eb5c4d -r 62eec209b04f stage2/tasks/manifest.c --- a/stage2/tasks/manifest.c Sun Oct 02 22:34:32 2016 +0200 +++ b/stage2/tasks/manifest.c Sun Oct 02 22:38:07 2016 +0200 @@ -25,6 +25,12 @@ void (*initial_task_array[])(unsigned short) = { start_plot_pattern, start_plot_pattern, + + /* + Employ a zero terminator, and make sure that max_tasks is not exceeded + above. + */ + 0 };