Root/
| 1 | #pypp 0 |
| 2 | // Iris: micro-kernel for a capability-based operating system. |
| 3 | // mips/trendtac/board.ccp: trendtac-specific functions. |
| 4 | // Copyright 2009 Bas Wijnen <wijnen@debian.org> |
| 5 | // |
| 6 | // This program is free software: you can redistribute it and/or modify |
| 7 | // it under the terms of the GNU General Public License as published by |
| 8 | // the Free Software Foundation, either version 3 of the License, or |
| 9 | // (at your option) any later version. |
| 10 | // |
| 11 | // This program is distributed in the hope that it will be useful, |
| 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | // GNU General Public License for more details. |
| 15 | // |
| 16 | // You should have received a copy of the GNU General Public License |
| 17 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | |
| 19 | #define ARCH |
| 20 | #define INIT |
| 21 | #include "kernel.hh" |
| 22 | |
| 23 | void board_init (): |
| 24 | // Disable all gpio interrupts and alternate functions initially. |
| 25 | for unsigned i = 0; i < 4; ++i: |
| 26 | GPIO_GPIER (i) = 0 |
| 27 | GPIO_GPALR (i) = 0 |
| 28 | GPIO_GPAUR (i) = 0 |
| 29 | // Set up the rest of the hardware (copied from Linux). |
| 30 | cpm_idle_mode () |
| 31 | cpm_enable_cko1 () |
| 32 | cpm_start_all () |
| 33 | harb_set_priority (0x08) |
| 34 | dmac_enable_all_channels () |
| 35 | harb_usb0_uhc () |
| 36 | gpio_as_emc () |
| 37 | gpio_as_uart0 () |
| 38 | gpio_as_dma () |
| 39 | gpio_as_eth () |
| 40 | gpio_as_usb () |
| 41 | gpio_as_lcd_master () |
| 42 | gpio_as_ssi() |
| 43 | gpio_as_msc () |
| 44 | |
| 45 | gpio_as_gpio (GPIO_CAPS_PORT, GPIO_CAPS) |
| 46 | gpio_as_gpio (GPIO_SCROLL_PORT, GPIO_SCROLL) |
| 47 | gpio_as_gpio (GPIO_NUM_PORT, GPIO_NUM) |
| 48 | gpio_as_gpio (GPIO_TP_LEFT_PORT, GPIO_TP_LEFT) |
| 49 | gpio_as_gpio (GPIO_TP_RIGHT_PORT, GPIO_TP_RIGHT) |
| 50 | |
| 51 | // Start the operating system timer, and set it to give an interrupt immediately. |
| 52 | // This is better, because the kernel starts with jumping into the idle task and |
| 53 | // waiting for the first interrupt. |
| 54 | unsigned latch = (JZ_EXTAL + (HZ >> 1)) / HZ |
| 55 | ost_disable_all () |
| 56 | ost_set_mode (0, OST_TCSR_UIE | OST_TCSR_CKS_EXTAL) |
| 57 | ost_set_reload (0, latch) |
| 58 | ost_set_count (0, 1) |
| 59 | ost_set_mode (0, OST_TCSR_UIE | OST_TCSR_CKS_EXTAL) |
| 60 | ost_enable_channel (0) |
| 61 | |
| 62 | void arch_reboot (): |
| 63 | // Wait for serial port to be done. |
| 64 | while !(UART0_LSR & UARTLSR_TEMT): |
| 65 | // Reboot. |
| 66 | wdt_set_count (~0) |
| 67 | wdt_start () |
| 68 | // Wait for wdt to trigger reboot. |
| 69 | while true: |
| 70 |
Branches:
master
