4 ISA-PnP -- A Plug And Play ISA software layer for AmigaOS.
5 Copyright (C) 2001 Martin Blom <martin@blom.org>
6 Copyright (C) 2009 The AROS Development Team
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
18 You should have received a copy of the GNU Library General Public
19 License along with this library; if not, write to the
20 Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge,
24 #include <aros/asmcall.h>
27 #include <proto/exec.h>
28 #include <proto/dos.h>
30 #include <resources/isapnp.h>
32 #include "isapnp_private.h"
33 #include "pnp_structs.h"
35 #define TEMPLATE "SHOWCONFIG/S,SHOWOPTIONS/S" /*,REMOVE/S"*/
37 /******************************************************************************
38 ** Globals ********************************************************************
39 ******************************************************************************/
41 struct DosLibrary
* DOSBase
= NULL
;
42 struct ExecBase
* SysBase
= NULL
;
45 ShowCards( BOOL show_options
,
46 struct ISAPNPBase
* res
);
55 ResourceEntry( void );
57 /******************************************************************************
58 ** Startup trampoline *********************************************************
59 ******************************************************************************/
61 AROS_UFH3(__startup
static int, Start
,
62 AROS_UFHA(char *, argstr
, A0
),
63 AROS_UFHA(ULONG
, argsize
, D0
),
64 AROS_UFHA(struct ExecBase
*, sBase
, A6
))
69 return ResourceEntry();
74 /******************************************************************************
75 ** Resource entry *************************************************************
76 ******************************************************************************/
81 struct ISAPNPBase
* ISAPNPBase
;
82 struct RDArgs
* rdargs
;
90 } args
= { FALSE
, FALSE
/*, FALSE*/ };
98 ISAPNPBase
= (struct ISAPNPBase
* ) OpenResource( ISAPNPNAME
);
100 if( ISAPNPBase
== NULL
)
102 Printf( ISAPNPNAME
" not found.\n" );
107 rdargs
= ReadArgs(TEMPLATE
, (IPTR
*)&args
, NULL
);
111 if( ! args
.m_ShowConfig
&& args
.m_ShowOptions
)
113 Printf( "SHOWOPTIONS can only be used together with SHOWCONFIG\n" );
118 if( args
.m_ShowConfig
)
120 ShowCards( args
.m_ShowOptions
, ISAPNPBase
);
124 /* if( args.m_Remove )
126 // Dangerous! Only for debugging
128 FreeISAPNPBase( ISAPNPBase );
130 ISAPNPBase->m_ConfigDev->cd_Flags |= CDF_CONFIGME;
131 ISAPNPBase->m_ConfigDev->cd_Driver = NULL;
132 RemResource( ISAPNPBase );
143 Printf( "Usage: ISA-PnP [ SHOWCONFIG [ SHOWOPTIONS ] ] [ REMOVE ]\n" );
154 /******************************************************************************
155 ** Prints information about all cards on a serial port terminal ***************
156 ******************************************************************************/
159 ShowResource( struct ISAPNP_Resource
* resource
,
160 struct ISAPNPBase
* res
)
162 switch( resource
->isapnpr_Type
)
164 case ISAPNP_NT_IRQ_RESOURCE
:
166 struct ISAPNP_IRQResource
* r
= (struct ISAPNP_IRQResource
*) resource
;
171 for( b
= 0; b
< 16; ++b
)
173 if( r
->isapnpirqr_IRQMask
& ( 1 << b
) )
181 if( r
->isapnpirqr_IRQType
& ISAPNP_IRQRESOURCE_ITF_HIGH_EDGE
)
186 if( r
->isapnpirqr_IRQType
& ISAPNP_IRQRESOURCE_ITF_LOW_EDGE
)
191 if( r
->isapnpirqr_IRQType
& ISAPNP_IRQRESOURCE_ITF_HIGH_LEVEL
)
196 if( r
->isapnpirqr_IRQType
& ISAPNP_IRQRESOURCE_ITF_LOW_LEVEL
)
205 case ISAPNP_NT_DMA_RESOURCE
:
207 struct ISAPNP_DMAResource
* r
= (struct ISAPNP_DMAResource
*) resource
;
212 for( b
= 0; b
< 8; ++b
)
214 if( r
->isapnpdmar_ChannelMask
& ( 1 << b
) )
221 switch( r
->isapnpdmar_Flags
& ISAPNP_DMARESOURCE_F_TRANSFER_MASK
)
223 case ISAPNP_DMARESOURCE_F_TRANSFER_8BIT
:
227 case ISAPNP_DMARESOURCE_F_TRANSFER_BOTH
:
228 Printf( "8 and 16" );
231 case ISAPNP_DMARESOURCE_F_TRANSFER_16BIT
:
236 Printf( " bit transfer, " );
238 switch( r
->isapnpdmar_Flags
& ISAPNP_DMARESOURCE_F_SPEED_MASK
)
240 case ISAPNP_DMARESOURCE_F_SPEED_COMPATIBLE
:
241 Printf( "compatible" );
244 case ISAPNP_DMARESOURCE_F_SPEED_TYPE_A
:
248 case ISAPNP_DMARESOURCE_F_SPEED_TYPE_B
:
252 case ISAPNP_DMARESOURCE_F_SPEED_TYPE_F
:
259 if( r
->isapnpdmar_Flags
& ISAPNP_DMARESOURCE_FF_BUS_MASTER
)
261 Printf( " [Bus master]" );
264 if( r
->isapnpdmar_Flags
& ISAPNP_DMARESOURCE_FF_BYTE_MODE
)
266 Printf( " [Byte mode]" );
269 if( r
->isapnpdmar_Flags
& ISAPNP_DMARESOURCE_FF_WORD_MODE
)
271 Printf( " [Word mode]" );
280 case ISAPNP_NT_IO_RESOURCE
:
282 struct ISAPNP_IOResource
* r
= (struct ISAPNP_IOResource
*) resource
;
284 if( r
->isapnpior_MinBase
== r
->isapnpior_MaxBase
)
286 Printf( "IO at 0x%04lx, length 0x%02lx.",
287 r
->isapnpior_MinBase
, r
->isapnpior_Length
);
291 Printf( "IO between 0x%04lx and 0x%04lx, length 0x%02lx, %ld byte aligned.",
292 r
->isapnpior_MinBase
, r
->isapnpior_MaxBase
, r
->isapnpior_Length
, r
->isapnpior_Alignment
);
295 if( ( r
->isapnpior_Flags
& ISAPNP_IORESOURCE_FF_FULL_DECODE
) == 0 )
297 Printf( " [10 bit decode only]" );
305 case ISAPNP_NT_MEMORY_RESOURCE
:
306 Printf( "Memory\n" );
310 Printf( "Unknown resource!" );
316 ShowResourceGroup( struct ISAPNP_ResourceGroup
* resource_group
,
317 struct ISAPNPBase
* res
)
319 struct ISAPNP_Resource
* r
;
320 struct ISAPNP_ResourceGroup
* rg
;
322 for( r
= (struct ISAPNP_Resource
*) resource_group
->isapnprg_Resources
.mlh_Head
;
323 r
->isapnpr_MinNode
.mln_Succ
!= NULL
;
324 r
= (struct ISAPNP_Resource
*) r
->isapnpr_MinNode
.mln_Succ
)
327 ShowResource( r
, res
);
330 if( resource_group
->isapnprg_ResourceGroups
.mlh_Head
->mln_Succ
!= NULL
)
332 Printf( " One of\n" );
334 for( rg
= (struct ISAPNP_ResourceGroup
*) resource_group
->isapnprg_ResourceGroups
.mlh_Head
;
335 rg
->isapnprg_MinNode
.mln_Succ
!= NULL
;
336 rg
= (struct ISAPNP_ResourceGroup
*) rg
->isapnprg_MinNode
.mln_Succ
)
339 ShowResourceGroup( rg
, res
);
347 ShowCards( BOOL show_options
,
348 struct ISAPNPBase
* res
)
350 struct ISAPNP_Card
* card
;
352 for( card
= (struct ISAPNP_Card
*) res
->m_Cards
.lh_Head
;
353 card
->isapnpc_Node
.ln_Succ
!= NULL
;
354 card
= (struct ISAPNP_Card
*) card
->isapnpc_Node
.ln_Succ
)
356 struct ISAPNP_Device
* dev
;
358 Printf( "Card %ld: %s%03lx%lx/%ld ('%s')\n",
360 (ULONG
) card
->isapnpc_ID
.isapnpid_Vendor
,
361 card
->isapnpc_ID
.isapnpid_ProductID
,
362 card
->isapnpc_ID
.isapnpid_Revision
,
363 card
->isapnpc_SerialNumber
,
364 card
->isapnpc_Node
.ln_Name
!= NULL
? (ULONG
) card
->isapnpc_Node
.ln_Name
367 Printf( " PnP version: %ld.%ld\n",
368 card
->isapnpc_MajorPnPVersion
,
369 card
->isapnpc_MinorPnPVersion
);
371 Printf( " Vendor specific version number: %ld.%ld\n",
372 card
->isapnpc_VendorPnPVersion
>> 4,
373 card
->isapnpc_VendorPnPVersion
& 0x0f );
375 for( dev
= (struct ISAPNP_Device
*) card
->isapnpc_Devices
.lh_Head
;
376 dev
->isapnpd_Node
.ln_Succ
!= NULL
;
377 dev
= (struct ISAPNP_Device
*) dev
->isapnpd_Node
.ln_Succ
)
379 struct ISAPNP_Identifier
* id
;
380 struct ISAPNP_Resource
* r
;
382 Printf( " Logical device %ld: ",
383 dev
->isapnpd_DeviceNumber
);
385 for( id
= (struct ISAPNP_Identifier
*) dev
->isapnpd_IDs
.mlh_Head
;
386 id
->isapnpid_MinNode
.mln_Succ
!= NULL
;
387 id
= (struct ISAPNP_Identifier
*) id
->isapnpid_MinNode
.mln_Succ
)
389 Printf( "%s%03lx%lx ",
390 (ULONG
) id
->isapnpid_Vendor
,
391 id
->isapnpid_ProductID
,
392 id
->isapnpid_Revision
);
395 if( dev
->isapnpd_Node
.ln_Name
!= NULL
)
397 Printf( "('%s')", (ULONG
) dev
->isapnpd_Node
.ln_Name
);
402 if( dev
->isapnpd_SupportedCommands
& ISAPNP_DEVICE_SCF_BOOTABLE
)
404 Printf( " Device is capable of participating in the boot process.\n" );
407 if( dev
->isapnpd_SupportedCommands
& ISAPNP_DEVICE_SCF_RANGE_CHECK
)
409 Printf( " Device supports IO range checking.\n" );
412 Printf( " Allocated resources:\n" );
414 if( dev
->isapnpd_Resources
.mlh_Head
->mln_Succ
!= NULL
)
416 for( r
= (struct ISAPNP_Resource
*) dev
->isapnpd_Resources
.mlh_Head
;
417 r
->isapnpr_MinNode
.mln_Succ
!= NULL
;
418 r
= (struct ISAPNP_Resource
*) r
->isapnpr_MinNode
.mln_Succ
)
421 ShowResource( r
, res
);
426 Printf( " None.\n" );
431 Printf( " Requested resources:\n" );
432 ShowResourceGroup( dev
->isapnpd_Options
, res
);
438 /******************************************************************************
439 ** OpenLibs *******************************************************************
440 ******************************************************************************/
447 DOSBase
= (struct DosLibrary
*) OpenLibrary( "dos.library", 37 );
449 if( DOSBase
== NULL
)
458 /******************************************************************************
459 ** CloseLibs *******************************************************************
460 ******************************************************************************/
465 CloseLibrary( (struct Library
*) DOSBase
);