Subversion Repositories shark

Rev

Rev 2 | 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
  CVS :        $Id: phdsk.c,v 1.1.1.1 2002-03-29 14:12:49 pj Exp $
24
 
25
  Revision:    $Revision: 1.1.1.1 $
26
 
27
  Last update: $Date: 2002-03-29 14:12:49 $
28
 
29
  This module register every physical disk into the system
30
  (actually only for informational purpose).
31
 
32
***************************************/
33
 
34
/*
35
 * Copyright (C) 1999 Massimiliano Giorgi
36
 *
37
 * This program is free software; you can redistribute it and/or modify
38
 * it under the terms of the GNU General Public License as published by
39
 * the Free Software Foundation; either version 2 of the License, or
40
 * (at your option) any later version.
41
 *
42
 * This program is distributed in the hope that it will be useful,
43
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
44
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
45
 * GNU General Public License for more details.
46
 *
47
 * You should have received a copy of the GNU General Public License
48
 * along with this program; if not, write to the Free Software
49
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
50
 *
51
 */
52
 
53
#include "glue.h"
54
#include <fs/magic.h>
55
 
56
#include "phdsk.h"
57
 
58
/*+ an entry for every hard disk into the system +*/
59
static struct phdskinfo phdsk[MAXPHDSK];
60
 
61
/*++++++++++++++++++++++++++++++++++++++
62
 
63
  Initialize the interal data structures. Must be called prior of every
64
  routine in this module.
65
 
66
  ++++++++++++++++++++++++++++++++++++++*/
67
 
68
void phdsk_init(void)
69
{
70
  int i;
71
  for (i=0;i<MAXPHDSK;i++) {
72
 
73
#ifdef _PARANOIA
74
    phdsk[i].magic=PHDSK_MAGIC;
75
#endif
76
 
77
    memcpy(phdsk[i].pd_name,"noname",7);
78
 
79
    phdsk[i].pd_device=0;
80
    phdsk[i].pd_size=0;
81
    phdsk[i].pd_sectsize=0;
82
 
83
#ifdef IDE_BLOCK_DEVICE    
84
    phdsk[i].pd_ide_check_geom=0;
85
#endif
86
 
87
    phdsk[i].pd_phgeom.cyls=0;
88
    phdsk[i].pd_phgeom.heads=0;
89
    phdsk[i].pd_phgeom.sectors=0;
90
 
91
    phdsk[i].pd_logeom.cyls=0;
92
    phdsk[i].pd_logeom.heads=0;
93
    phdsk[i].pd_logeom.sectors=0;
94
  }
95
}
96
 
97
/*++++++++++++++++++++++++++++++++++++++
98
 
99
  Every block device module shall call this function to inform
100
  the system that a physical hard-disk in available to the system.
101
 
102
  struct phdskinfo *phdsk_register
103
    return a pointer to a phdskinfo structure that hold hard disk information
104
    or NULL in case of error
105
 
106
  struct phdskinfo *disk
107
    information on the physical hard disk
108
  ++++++++++++++++++++++++++++++++++++++*/
109
 
110
struct phdskinfo *phdsk_register(struct phdskinfo *disk)
111
{
112
  int i;
113
 
114
  for (i=0;i<MAXPHDSK;i++)
115
    if (phdsk[i].pd_device==0) break;
116
  if (i==MAXPHDSK||disk->pd_device==0) return NULL;
117
 
118
  //cprintf("pdisk dev %i\n",disk->pd_device);
119
  memcpy(phdsk+i,disk,sizeof(struct phdskinfo));
120
  //cprintf("pdisk dev %i\n",(phdsk+i)->pd_device);
121
 
122
  return phdsk+i;
123
}