1 /* *********************************************************************
2 * Broadcom Common Firmware Environment (CFE)
4 * P5064-specific commands File: P5064_COMMANDS.C
6 * This module contains special command extensions for the
7 * Algorithmics P5064 port of CFE.
9 * NOTE: Some of the routines in this module were borrowed
12 * Author: Mitch Lichtenberg (mpl@broadcom.com)
14 *********************************************************************
16 * Copyright 2000,2001,2002,2003
17 * Broadcom Corporation. All rights reserved.
19 * This software is furnished under license and may be used and
20 * copied only in accordance with the following terms and
21 * conditions. Subject to these conditions, you may download,
22 * copy, install, use, modify and distribute modified or unmodified
23 * copies of this software in source and/or binary form. No title
24 * or ownership is transferred hereby.
26 * 1) Any source code used, modified or distributed must reproduce
27 * and retain this copyright notice and list of conditions
28 * as they appear in the source file.
30 * 2) No right is granted to use any trade name, trademark, or
31 * logo of Broadcom Corporation. The "Broadcom Corporation"
32 * name may not be used to endorse or promote products derived
33 * from this software without the prior written permission of
34 * Broadcom Corporation.
36 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR
37 * IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED
38 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 * PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT
40 * SHALL BROADCOM BE LIABLE FOR ANY DAMAGES WHATSOEVER, AND IN
41 * PARTICULAR, BROADCOM SHALL NOT BE LIABLE FOR DIRECT, INDIRECT,
42 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
44 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
45 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
46 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
47 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE), EVEN IF ADVISED OF
48 * THE POSSIBILITY OF SUCH DAMAGE.
49 ********************************************************************* */
53 #include "lib_types.h"
54 #include "lib_string.h"
55 #include "lib_queue.h"
56 #include "lib_malloc.h"
57 #include "lib_printf.h"
60 #include "cfe_device.h"
61 #include "cfe_console.h"
62 #include "cfe_devfuncs.h"
63 #include "cfe_timer.h"
65 #include "cfe_error.h"
67 #include "ui_command.h"
77 #if !defined(__MIPSEB) && !defined(__MIPSEL)
78 #error "You must define either __MIPSEB or __MIPSEL"
81 /* #define POWEROFF */
84 int ui_init_p6064cmds(void);
87 static int ui_cmd_poweroff(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
91 static int ui_cmd_vgadump(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
92 static int ui_cmd_vgainit(ui_cmdline_t
*cmd
,int argc
,char *argv
[]);
93 extern int vga_biosinit(void);
94 extern void vgaraw_dump(char *tail
);
101 #define OUTB(x,y) outb(x,y)
102 #define OUTW(x,y) outw(x,y)
103 #define OUTL(x,y) outl(x,y)
106 int ui_init_p6064cmds(void)
110 cmd_addcmd("power off",
113 "Power off the system.",
115 "This command turns off the power for systems that support it.",
120 cmd_addcmd("vga init",
123 "Initialize the VGA adapter.",
127 cmd_addcmd("vga dumpbios",
130 "Dump the VGA BIOS to the console",
140 unsigned int apc_bis (int reg
, unsigned int val
);
143 apc_bis (int reg
, unsigned int val
)
145 unsigned int rtcsa
, o
, n
;
147 if (BOARD_REVISION
< 'C')
150 OUTB(RTC_ADDR_PORT
, RTC_STATUSA
);
151 rtcsa
= INB(RTC_DATA_PORT
);
152 if ((rtcsa
& RTCSA_DVMASK
) != RTC_DV2_OSC_ON
)
153 OUTB(RTC_DATA_PORT
, (rtcsa
& ~RTCSA_DVMASK
) | RTC_DV2_OSC_ON
);
155 OUTB(RTC_ADDR_PORT
, reg
);
156 o
= INB(RTC_DATA_PORT
);
159 OUTB(RTC_DATA_PORT
, n
);
162 /* paranoia - switch back to bank 0 */
163 OUTB(RTC_ADDR_PORT
, RTC_STATUSA
);
164 OUTB(RTC_DATA_PORT
, (rtcsa
& ~RTCSA_DVMASK
) | RTC_DV0_OSC_ON
);
172 static int ui_cmd_vgainit(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
176 res
= vga_biosinit();
178 xprintf("vgaraw_init returns %d\n",res
);
183 static int ui_cmd_vgadump(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
187 x
= cmd_getarg(cmd
,0);
198 static int ui_cmd_poweroff(ui_cmdline_t
*cmd
,int argc
,char *argv
[])
200 xprintf("Power off.\n");
201 apc_bis(RTC_BANK2_APCR1
, APCR1_SOC
);