Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1655 giacomo 1
/*
2
 *
3
 *
4
 */
5
 
6
#include "config.h"
7
 
8
#include <kernel/func.h>
9
#include <kernel/model.h>
10
#include <kernel/const.h>
11
 
12
#include <drivers/glib.h>
13
 
14
#include <stdlib.h>
15
#include <assert.h>
16
 
17
#include "mutex.h"
18
#include "xread.h"
19
 
20
#define PERIOD  250000
21
#define WCET      1000
22
 
23
#ifdef FULLCOLOR
24
 
25
#define BARCOLOR rgb16(255,0,0)
26
#define BARBG    rgb16(0,0,0)
27
 
28
#define TEXTCOLOR rgb16(255,255,255)
29
#define TEXTBG    rgb16(0,0,0)
30
 
31
#else
32
 
33
#define BARCOLOR 128
34
#define BARBG      0
35
 
36
#define TEXTCOLOR 255
37
#define TEXTBG      0
38
 
39
#endif
40
 
41
//#define XC     700
42
//#define YC     400
43
#define LEN    100
44
#define BORDER   8
45
 
46
extern void draw_frame(int x, int y, int dx, int dy);
47
 
48
struct taskinfo{
49
  int XC,YC;
50
  struct xbuffer *ptr;
51
};
52
 
53
static TASK monitorbuffer(void *arg)
54
{
55
  struct taskinfo *p=(struct taskinfo *)arg;
56
  int XC,YC;
57
  int oy,y;
58
  struct xbuffer *ptr;
59
  int sum,old;
60
 
61
  ptr=p->ptr;
62
  XC=p->XC;
63
  YC=p->YC;
64
 
65
  oy=YC+LEN-1;
66
  for (;;) {
67
    sum=freespace(ptr);
68
#ifndef NOGRX
69
    y=YC+LEN*sum/BUFFERMAXSIZE-1;
70
    if (y!=oy) {
71
      grxlock();
72
      if (y<oy) grx_box(XC,y,XC+BORDER-1,oy,BARCOLOR);
73
      else grx_box(XC,oy,XC+BORDER-1,y,BARBG);
74
      grxunlock();
75
      oy=y;
76
    }
77
#else
78
    cprintf("@%i@",sum);
79
#endif
80
    old=sum;
81
    task_endcycle();
82
  }
83
  return 0;
84
}
85
 
86
int gbuffer_init(struct xbuffer *ptr, int group, int XC, int YC)
87
{
88
  struct taskinfo *info;
89
  SOFT_TASK_MODEL model;
90
  PID pid;
91
 
92
#ifdef ACTIVATE
93
  info=(struct taskinfo *)malloc(sizeof(struct taskinfo));
94
  if (info==NULL) sys_abort(912);
95
  info->XC=XC;
96
  info->YC=YC;
97
  info->ptr=ptr;
98
 
99
  soft_task_default_model(model);        
100
  soft_task_def_met(model,WCET);
101
  soft_task_def_wcet(model,WCET);
102
  soft_task_def_period(model,PERIOD);
103
  soft_task_def_periodic(model);
104
  soft_task_def_group(model,group);
105
  soft_task_def_arg(model,(void*)info);
106
  /*soft_task_def_group(model,group);*/
107
 
108
  pid=task_create("bufferload",monitorbuffer,&model,NULL);
109
  if (pid==-1) return -6;
110
 
111
#else
112
  pid=-1;
113
#endif
114
 
115
#ifndef NOGRX
116
  draw_frame(XC,YC,BORDER,LEN);
117
  grxlock();
118
  grx_text("Buffer",XC-18,YC+LEN+BORDER*2,TEXTCOLOR,TEXTBG);
119
  grx_text("100%",XC+BORDER*2+1,YC-4,TEXTCOLOR,TEXTBG);
120
  grx_text(" 75%",XC+BORDER*2+1,YC+LEN/4-4,TEXTCOLOR,TEXTBG);
121
  grx_text(" 50%",XC+BORDER*2+1,YC+LEN/4*2-4,TEXTCOLOR,TEXTBG);
122
  grx_text(" 25%",XC+BORDER*2+1,YC+LEN/4*3-4,TEXTCOLOR,TEXTBG);
123
  grx_text("  0%",XC+BORDER*2+1,YC+LEN-4,TEXTCOLOR,TEXTBG);
124
  grxunlock();
125
#endif
126
 
127
  return pid;
128
}
129