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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [dhrystone/] [port/] [dhry_utils.c] - Blame information for rev 280

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 280 hellwig
/*
2
 * dhry_utils.c -- utility functions
3
 */
4
 
5
#include "dhry_utils.h"
6
 
7
/**************************************************************/
8
 
9
clock_t times(struct tms *buf) {
10
  static int firstCall = 1;
11
  volatile unsigned int *timerDivisor;
12
  volatile unsigned int *timerCounter;
13
 
14
  if (firstCall) {
15
    firstCall = 0;
16
    timerDivisor = (unsigned int *) 0xF0000004;
17
    *timerDivisor = 0xFFFFFFFF;
18
    buf->tms_utime = 0;
19
    buf->tms_stime = 0;
20
    buf->tms_cutime = 0;
21
    buf->tms_cstime = 0;
22
  } else {
23
    timerCounter = (unsigned int *) 0xF0000008;
24
    /* the counter counts in units of 20 nsec */
25
    /* but we want to count in units of 1 msec */
26
    buf->tms_utime = (0xFFFFFFFF - *timerCounter) / 50000;
27
    buf->tms_stime = 0;
28
    buf->tms_cutime = 0;
29
    buf->tms_cstime = 0;
30
  }
31
  return 0;
32
}
33
 
34
/**************************************************************/
35
 
36
#define MAX_MALLOC      100
37
 
38
static unsigned int a[MAX_MALLOC];
39
static unsigned int *p = a;
40
 
41
void *malloc(unsigned size) {
42
  void *q;
43
 
44
  size = (size + sizeof(unsigned) - 1) / sizeof(unsigned);
45
  if (p + size > &a[MAX_MALLOC]) {
46
    return 0;
47
  }
48
  q = p;
49
  p += size;
50
  return q;
51
}

powered by: WebSVN 2.1.0

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