source: trunk/libs/newlib/src/libgloss/mips/cfe.c @ 474

Last change on this file since 474 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 3.0 KB
RevLine 
[444]1/* cfe.c -- I/O code for the MIPS boards running CFE.  */
2
3/*
4 * Copyright 2001, 2002, 2003
5 * Broadcom Corporation. All rights reserved.
6 *
7 * This software is furnished under license and may be used and copied only
8 * in accordance with the following terms and conditions.  Subject to these
9 * conditions, you may download, copy, install, use, modify and distribute
10 * modified or unmodified copies of this software in source and/or binary
11 * form. No title or ownership is transferred hereby.
12 *
13 * 1) Any source code used, modified or distributed must reproduce and
14 *    retain this copyright notice and list of conditions as they appear in
15 *    the source file.
16 *
17 * 2) No right is granted to use any trade name, trademark, or logo of
18 *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
19 *    used to endorse or promote products derived from this software
20 *    without the prior written permission of Broadcom Corporation.
21 *
22 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
23 *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
24 *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
25 *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
26 *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
27 *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
30 *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31 */
32
33#include "cfe_api.h"
34
35void *__libcfe_init (long handle, long a1, long cfe_entrypoint, long a3);
36void __libcfe_exit (long status);
37
38char inbyte (void);
39int outbyte (char c);
40
41/* Echo input characters?  */
42int     __libcfe_echo_input = 0;
43
44/* CFE handle used to access console device.  */
45static int cfe_conshandle;
46
47
48/* Initialize firmware callbacks.  Called from crt0_cfe.  Returns desired
49   stack pointer.  */
50void *
51__libcfe_init (long handle, long a1, long entrypoint, long a3)
52{
53  cfe_init (handle, entrypoint);
54  cfe_conshandle = cfe_getstdhandle (CFE_STDHANDLE_CONSOLE);
55
56  __libcfe_meminit ();
57  return __libcfe_stack_top ();
58}
59
60/* Exit back to monitor, with the given status code.  */
61void
62__libcfe_exit (long status)
63{
64  outbyte ('\r');
65  outbyte ('\n');
66  cfe_exit (CFE_FLG_WARMSTART, status);
67}
68
69char
70inbyte (void)
71{
72  unsigned char c;
73  int rv;
74
75  while (cfe_read (cfe_conshandle, &c, 1) != 1)
76    ;
77  if (c == '\r')
78    c = '\n';
79  if (__libcfe_echo_input)
80    outbyte (c);
81  return c;
82}
83
84int
85outbyte (char c)
86{
87  int res;
88
89  do
90    {
91      res = cfe_write (cfe_conshandle, &c, 1);
92    }
93  while (res == 0);
94  if (c == '\n')
95    outbyte ('\r');
96  return 0;
97}
98
99/* This is the MIPS cache flush function call.  No defines are provided
100   by libgloss for 'cache', and CFE doesn't let you flush ranges, so
101   we just flush all I & D for every call.  */
102int
103_flush_cache (char *addr, int nbytes, int cache)
104{
105  cfe_flushcache (0);
106  return 0;
107}
Note: See TracBrowser for help on using the repository browser.