[7150f00f] | 1 | /*-------------------------------------------------------------------------+ |
---|
| 2 | | exit.c v1.1 - PC386 BSP - 1997/08/07 |
---|
| 3 | +--------------------------------------------------------------------------+ |
---|
| 4 | | Routines to shutdown and reboot the PC. |
---|
| 5 | +--------------------------------------------------------------------------+ |
---|
| 6 | | (C) Copyright 1997 - |
---|
| 7 | | - NavIST Group - Real-Time Distributed Systems and Industrial Automation |
---|
| 8 | | |
---|
| 9 | | http://pandora.ist.utl.pt |
---|
| 10 | | |
---|
| 11 | | Instituto Superior Tecnico * Lisboa * PORTUGAL |
---|
| 12 | +--------------------------------------------------------------------------+ |
---|
| 13 | | Disclaimer: |
---|
| 14 | | |
---|
| 15 | | This file is provided "AS IS" without warranty of any kind, either |
---|
| 16 | | expressed or implied. |
---|
| 17 | +--------------------------------------------------------------------------+ |
---|
| 18 | | This code is based on: |
---|
| 19 | | exit.c,v 1.2 1995/12/19 20:07:36 joel Exp - go32 BSP |
---|
| 20 | | With the following copyright notice: |
---|
| 21 | | ************************************************************************** |
---|
[60b791ad] | 22 | | * COPYRIGHT (c) 1989-1998. |
---|
[6f9c75c3] | 23 | | * On-Line Applications Research Corporation (OAR). |
---|
| 24 | | * Copyright assigned to U.S. Government, 1994. |
---|
| 25 | | * |
---|
| 26 | | * The license and distribution terms for this file may be |
---|
| 27 | | * found in found in the file LICENSE in this distribution or at |
---|
| 28 | | * http://www.OARcorp.com/rtems/license.html. |
---|
[7150f00f] | 29 | | ************************************************************************** |
---|
[6f9c75c3] | 30 | | |
---|
| 31 | | $Id$ |
---|
[7150f00f] | 32 | +--------------------------------------------------------------------------*/ |
---|
| 33 | |
---|
| 34 | |
---|
| 35 | #include <stdio.h> |
---|
| 36 | #include <bsp.h> |
---|
[dbfa3148] | 37 | #include <rtems/libio.h> |
---|
[5d18fb0] | 38 | #include <pc386uart.h> |
---|
| 39 | |
---|
| 40 | /*-------------------------------------------------------------------------+ |
---|
| 41 | | Which console is in use: either (-1) which means normal console or |
---|
| 42 | | uart id if uart was used |
---|
| 43 | +-------------------------------------------------------------------------*/ |
---|
| 44 | extern int PC386ConsolePort; |
---|
[7150f00f] | 45 | |
---|
| 46 | /*-------------------------------------------------------------------------+ |
---|
| 47 | | External Prototypes |
---|
| 48 | +--------------------------------------------------------------------------*/ |
---|
[2efdd08] | 49 | extern rtems_boolean _IBMPC_scankey(char *); /* defined in 'inch.c' */ |
---|
[7150f00f] | 50 | |
---|
| 51 | /*-------------------------------------------------------------------------+ |
---|
| 52 | | Function: _exit |
---|
| 53 | | Description: Shutdown the PC. Called from libc's 'exit'. |
---|
| 54 | | Global Variables: None. |
---|
| 55 | | Arguments: status - exit status (ignored). |
---|
| 56 | | Returns: Nothing. |
---|
| 57 | +--------------------------------------------------------------------------*/ |
---|
| 58 | void _exit(int status) |
---|
| 59 | { |
---|
[5d18fb0] | 60 | unsigned char ch, *cp; |
---|
| 61 | static char line[]="EXECUTIVE SHUTDOWN! Any key to reboot..."; |
---|
| 62 | |
---|
| 63 | if(PC386ConsolePort == PC386_CONSOLE_PORT_CONSOLE) |
---|
| 64 | { |
---|
[7150f00f] | 65 | |
---|
[5d18fb0] | 66 | printk("\n"); |
---|
| 67 | printk(line); |
---|
| 68 | while(!_IBMPC_scankey(&ch)) |
---|
| 69 | ; |
---|
| 70 | printk("\n\n"); |
---|
| 71 | } |
---|
| 72 | else |
---|
| 73 | { |
---|
[dbfa3148] | 74 | /* Close console */ |
---|
| 75 | __rtems_close(2); |
---|
| 76 | __rtems_close(1); |
---|
| 77 | __rtems_close(0); |
---|
| 78 | |
---|
[5d18fb0] | 79 | PC386_uart_intr_ctrl(PC386ConsolePort, PC386_UART_INTR_CTRL_DISABLE); |
---|
| 80 | |
---|
| 81 | PC386_uart_polled_write(PC386ConsolePort, '\r'); |
---|
| 82 | PC386_uart_polled_write(PC386ConsolePort, '\n'); |
---|
| 83 | |
---|
| 84 | for(cp=line; *cp != 0; cp++) |
---|
| 85 | { |
---|
| 86 | PC386_uart_polled_write(PC386ConsolePort, *cp); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | PC386_uart_polled_read(PC386ConsolePort); |
---|
| 90 | |
---|
| 91 | PC386_uart_polled_write(PC386ConsolePort, '\r'); |
---|
| 92 | PC386_uart_polled_write(PC386ConsolePort, '\n'); |
---|
| 93 | PC386_uart_polled_write(PC386ConsolePort, '\r'); |
---|
| 94 | PC386_uart_polled_write(PC386ConsolePort, '\n'); |
---|
| 95 | } |
---|
[7150f00f] | 96 | |
---|
| 97 | rtemsReboot(); |
---|
| 98 | } /* _exit */ |
---|
[5d18fb0] | 99 | |
---|
| 100 | |
---|
| 101 | |
---|
| 102 | |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | |
---|