Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
20
 
21
 
22
/***************************************
23
 
24
  CVS :        $Id: ideglue.c,v 1.1.1.1 2002-03-29 14:12:49 pj Exp $
25
 
26
  Revision:    $Revision: 1.1.1.1 $
27
 
28
  Last update: $Date: 2002-03-29 14:12:49 $
29
 
30
  This module is used to link the low-level IDE module with
31
  some kernel specific and particular functionality (it is included
32
  into idelow.c).
33
 
34
***************************************/
35
 
36
/*
37
 * Copyright (C) 1999,2000 Massimiliano Giorgi
38
 *
39
 * This program is free software; you can redistribute it and/or modify
40
 * it under the terms of the GNU General Public License as published by
41
 * the Free Software Foundation; either version 2 of the License, or
42
 * (at your option) any later version.
43
 *
44
 * This program is distributed in the hope that it will be useful,
45
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
46
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47
 * GNU General Public License for more details.
48
 *
49
 * You should have received a copy of the GNU General Public License
50
 * along with this program; if not, write to the Free Software
51
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
52
 *
53
 */
54
 
55
#include <ll/ll.h>
56
#include <kernel/func.h>
57
#include <kernel/model.h>
58
 
59
#include "glue.h"
60
#include "ide.h"
61
 
62
/* --- */
63
 
64
/*+ the default values for the server task +*/
65
#define DEFAULT_WCET     200
66
//#define DEFAULT_MIT      1000
67
#define DEFAULT_DL       7000 
68
//#define DEFAULT_WCET     200
69
////#define DEFAULT_MIT      1000
70
//#define DEFAULT_DL       2000 
71
 
72
/* --- */
73
 
74
void ide_service_request(int ideif);
75
 
76
/*++++++++++++++++++++++++++++++++++++++
77
 
78
  This is the ide server (a task is created for every interface)
79
 
80
  TASK ide_server
81
    never return
82
 
83
  int ideif
84
    interface number (index into ide[])
85
  ++++++++++++++++++++++++++++++++++++++*/
86
 
87
TASK ide_server(int ideif)
88
{
89
  for (;;) {
90
    task_endcycle();
91
    ide_service_request(ideif);
92
  }
93
  return NULL;
94
}
95
 
96
/*++++++++++++++++++++++++++++++++++++++
97
 
98
  A request is made to the server (the server is activated).
99
 
100
  int ideif
101
    interface that own the server
102
  ++++++++++++++++++++++++++++++++++++++*/
103
 
104
void ide_glue_send_request(int ideif)
105
{
106
  task_activate(ide[ideif].server);
107
}
108
 
109
/*++++++++++++++++++++++++++++++++++++++
110
 
111
  This function activate an interface: create a server task and set the
112
  irq handler to wake up this server.
113
 
114
  int ide_glue_activate_interface
115
    return 0 on success, other value on error
116
 
117
  int ideif
118
    interface to activate
119
  ++++++++++++++++++++++++++++++++++++++*/
120
 
121
 
122
TASK ide_dummy(int x)
123
{
124
  for (;;) {
125
    cprintf("²");
126
    task_endcycle();
127
  }
128
  return NULL;
129
}
130
 
131
 
132
 
133
int ide_glue_activate_interface(int ideif)
134
{
135
  struct ide_server_model *parms=
136
    (struct ide_server_model *)ide_parm_initserver;
137
  char name[32];
138
  SOFT_TASK_MODEL model;
139
  TIME dl=DEFAULT_DL;
140
  //TIME mit=DEFAULT_MIT;
141
  TIME wcet=DEFAULT_WCET;
142
 
143
  soft_task_default_model(model);    
144
  if (parms!=NULL) {
145
    dl=parms->dl;
146
    //mit=parms->mit;
147
    wcet=parms->wcet;
148
  }
149
  soft_task_def_system(model);
150
  //hard_task_def_mit(model,mit);
151
  //hard_task_def_drel(model,dl);
152
  //hard_task_def_wcet(model,wcet);
153
  soft_task_def_met(model,wcet);
154
  soft_task_def_wcet(model,wcet);
155
  soft_task_def_period(model,dl);
156
  soft_task_def_system(model);
157
  soft_task_def_nokill(model);
158
 
159
  soft_task_def_arg(model,(void*)ideif);
160
  soft_task_def_aperiodic(model);
161
  /* forse un NO_PREEMPT e' meglio */
162
 
163
  sprintf(name,"ide%i-server",ideif);
164
  ide[ideif].server=task_create(name,ide_server,&model,NULL);
165
 
166
  if (ide[ideif].server==NIL) {
167
    if (ide_showinfo_flag)
168
      printk(IDELOG "ide glue: can't create task");
169
    return -1;
170
  }
171
 
172
  /* activate */
173
  task_activate(ide[ideif].server);
174
 
175
  /* associate an IRQ handler */
176
  handler_set(ide[ideif].irq,NULL,ide[ideif].server);
177
 
178
  return 0;
179
}
180
 
181
 
182
/*++++++++++++++++++++++++++++++++++++++
183
 
184
  This function unactivate??? an interface: release the irq and
185
  kill the server task.
186
 
187
  int ideif
188
    interface to release
189
  ++++++++++++++++++++++++++++++++++++++*/
190
 
191
void __inline__ ide_glue_unactivate_interface(int ideif)
192
{
193
  handler_remove(ide[ideif].irq);
194
  task_kill(ide[ideif].server);
195
}
196