+FSCTL_DISMOUNT_VOLUME define
[reactos.git] / hal / halx86 / mca.c
1 /*
2  *  ReactOS kernel
3  *  Copyright (C) 2002 ReactOS Team
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 /* $Id$
20  *
21  * COPYRIGHT:   See COPYING in the top level directory
22  * PROJECT:     ReactOS kernel
23  * FILE:        hal/halx86/mca.c
24  * PURPOSE:     Interfaces to the MicroChannel bus
25  * PROGRAMMER:  Eric Kohl (ekohl@rz-online.de)
26  */
27
28 /*
29  * TODO:
30  *   What Adapter ID is read from an empty slot?
31  */
32
33 /* INCLUDES *****************************************************************/
34
35 #include <ddk/ntddk.h>
36 #include <bus.h>
37
38 #define NDEBUG
39 #include <internal/debug.h>
40
41
42 /* FUNCTIONS ****************************************************************/
43
44 ULONG STDCALL
45 HalpGetMicroChannelData(PBUS_HANDLER BusHandler,
46                         ULONG BusNumber,
47                         ULONG SlotNumber,
48                         PVOID Buffer,
49                         ULONG Offset,
50                         ULONG Length)
51 {
52   PCM_MCA_POS_DATA PosData = (PCM_MCA_POS_DATA)Buffer;
53
54   DPRINT("HalpGetMicroChannelData() called.\n");
55   DPRINT("  BusNumber %lu\n", BusNumber);
56   DPRINT("  SlotNumber %lu\n", SlotNumber);
57   DPRINT("  Offset 0x%lx\n", Offset);
58   DPRINT("  Length 0x%lx\n", Length);
59
60   if ((BusNumber != 0) ||
61       (SlotNumber == 0) || (SlotNumber > 8) ||
62       (Length < sizeof(CM_MCA_POS_DATA)))
63     return(0);
64
65   /* Enter Setup-Mode for given slot */
66   WRITE_PORT_UCHAR((PUCHAR)0x96, ((UCHAR)(SlotNumber - 1) & 0x07) | 0x08);
67
68   /* Read POS data */
69   PosData->AdapterId = (READ_PORT_UCHAR((PUCHAR)0x101) << 8) +
70                         READ_PORT_UCHAR((PUCHAR)0x100);
71   PosData->PosData1 = READ_PORT_UCHAR((PUCHAR)0x102);
72   PosData->PosData2 = READ_PORT_UCHAR((PUCHAR)0x103);
73   PosData->PosData3 = READ_PORT_UCHAR((PUCHAR)0x104);
74   PosData->PosData4 = READ_PORT_UCHAR((PUCHAR)0x105);
75
76   /* Leave Setup-Mode for given slot */
77   WRITE_PORT_UCHAR((PUCHAR)0x96, (UCHAR)(SlotNumber - 1) & 0x07);
78
79   return(sizeof(CM_MCA_POS_DATA));
80 }
81
82 /* EOF */