OpenCores
URL https://opencores.org/ocsvn/light52/light52/trunk

Subversion Repositories light52

[/] [light52/] [trunk/] [test/] [dhrystone/] [src/] [estubs.c] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 ja_rd
/*******************************************************************************
2
 * Copyright (c) 2004 by Graham Davies, ECROS Technology.  This work is        *
3
 * released into the Public Domain on condition that the forgoing copyright    *
4
 * notice is preserved in this and all derived files.                          *
5
 ******************************************************************************/
6
 
7
/*******************************************************************************
8
 * File: estubs.c - embedded stubs used to adapt the Dhrystone benchmark for
9
 * small (4 Kbyte RAM) microcontrollers.
10
 *
11
 * Last edited on $Date: Wednesday, June 09, 2004 1:05:22 PM $ by
12
 * $Author: Graham $ saved as $Revision: 1.5 $ $Version: NONE $
13
 ******************************************************************************/
14
 
15
#include <stdio.h>
16
#include <stdarg.h>
17
#include "dhry.h"
18
 
19
#if defined(__LIGHT52__)
20
#include "../../common/soc.h"
21
#endif
22
 
23
/*******************************************************************************
24
 * Function emalloc() - provides a dynamic memory allocation service sufficient
25
 * for two allocations of 50 bytes each or less.
26
 */
27
void * emalloc( size_t nbytes )
28
{
29
   static char   space[100];
30
   static char * ptr = space;
31
   static char * result;
32
 
33
   result = ptr;
34
   nbytes = (nbytes & 0xFFFC) + 4;
35
   ptr += nbytes;
36
 
37
   return ( result );
38
 
39
} /* end of function emalloc() */
40
 
41
#if defined(__LIGHT52__)
42
 
43
int exit(int v){
44
    return 0;
45
}
46
 
47
#endif
48
 
49
/*******************************************************************************
50
 * Function fopen() - initialize an output port bit.
51
 */
52
FILE * fopen( const char * filename, const char * mode )
53
{
54
#if defined(__LIGHT52__)
55
   /* We don't use the ports to time the loop */
56
#elif defined( __AVR_ARCH__ )
57
   DDRB = 0x01;    /* bit 0 output */
58
   PORTB = 0x00;   /* start low (zero) */
59
#elif defined( __ENCORE__ )
60
   PAADDR = 4;
61
   PACTL  = 0x01;  /* bit 0 high drive */
62
   PAADDR = 1;
63
   PACTL  = 0xFE;  /* bit 0 output */
64
   PAADDR = 0;
65
   PAOUT  = 0x00;  /* start low (zero) */
66
#endif
67
 
68
   return ( (FILE *)1 );
69
 
70
} /* end of function fopen() */
71
 
72
/*******************************************************************************
73
 * Function fclose() - stub; does nothing.
74
 */
75
int fclose( FILE * stream )
76
{
77
   return ( 0 );
78
 
79
} /* end of function fclose() */
80
 
81
/*******************************************************************************
82
 * Function scanf() - fake a value typed by the user.
83
 */
84
int scanf( const char * format, ... )
85
{
86
   va_list args;
87
   int *   ptr;
88
 
89
   va_start( args, format );
90
   ptr = va_arg( args, int * );
91
   *ptr = 30000;
92
   va_end( args );
93
 
94
   return ( 0 );
95
 
96
} /* end of function scanf() */
97
 
98
/* end of file estubs.c */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.