Subversion Repositories shark

Rev

Rev 3 | Go to most recent revision | Details | Compare with Previous | 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
 
496 giacomo 24
  CVS :        $Id: ideglue.c,v 1.2 2004-03-09 08:49:12 giacomo Exp $
2 pj 25
 
496 giacomo 26
  Revision:    $Revision: 1.2 $
2 pj 27
 
496 giacomo 28
  Last update: $Date: 2004-03-09 08:49:12 $
2 pj 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
    task_endcycle();
126
  }
127
  return NULL;
128
}
129
 
130
 
131
 
132
int ide_glue_activate_interface(int ideif)
133
{
134
  struct ide_server_model *parms=
135
    (struct ide_server_model *)ide_parm_initserver;
136
  char name[32];
137
  SOFT_TASK_MODEL model;
138
  TIME dl=DEFAULT_DL;
139
  //TIME mit=DEFAULT_MIT;
140
  TIME wcet=DEFAULT_WCET;
141
 
142
  soft_task_default_model(model);    
143
  if (parms!=NULL) {
144
    dl=parms->dl;
145
    //mit=parms->mit;
146
    wcet=parms->wcet;
147
  }
148
  soft_task_def_system(model);
149
  //hard_task_def_mit(model,mit);
150
  //hard_task_def_drel(model,dl);
151
  //hard_task_def_wcet(model,wcet);
152
  soft_task_def_met(model,wcet);
153
  soft_task_def_wcet(model,wcet);
154
  soft_task_def_period(model,dl);
155
  soft_task_def_system(model);
156
  soft_task_def_nokill(model);
157
 
158
  soft_task_def_arg(model,(void*)ideif);
159
  soft_task_def_aperiodic(model);
160
  /* forse un NO_PREEMPT e' meglio */
161
 
162
  sprintf(name,"ide%i-server",ideif);
163
  ide[ideif].server=task_create(name,ide_server,&model,NULL);
164
 
165
  if (ide[ideif].server==NIL) {
166
    if (ide_showinfo_flag)
167
      printk(IDELOG "ide glue: can't create task");
168
    return -1;
169
  }
170
 
171
  /* activate */
172
  task_activate(ide[ideif].server);
173
 
174
  /* associate an IRQ handler */
496 giacomo 175
  handler_set(ide[ideif].irq,NULL,ide[ideif].server, FALSE);
2 pj 176
 
177
  return 0;
178
}
179
 
180
 
181
/*++++++++++++++++++++++++++++++++++++++
182
 
183
  This function unactivate??? an interface: release the irq and
184
  kill the server task.
185
 
186
  int ideif
187
    interface to release
188
  ++++++++++++++++++++++++++++++++++++++*/
189
 
190
void __inline__ ide_glue_unactivate_interface(int ideif)
191
{
192
  handler_remove(ide[ideif].irq);
193
  task_kill(ide[ideif].server);
194
}
195