Discussion:
Punteros a funciones
(demasiado antiguo para responder)
DJ
2004-06-22 21:21:25 UTC
Permalink
Hola!

Estoy intentando escribir un pequeño programa para averiguar los
dispositivos instalados en un ordenador, a traves de la BIOS PNP. Tengo la
direccion en memoria donde esta ubicada la entrada a la rutina del BIOS q
hace esto (0xF000:0xC180). Lo he escrito con el Borland ++ 3.1 y con el GCC
(Rhide) para MS-DOS/WIN 98.En el Borland me va bien, pero cuando intento
asignar la direccion y luego llamarla se levanta una excepcion por fallo en
la segmentacion.


Borland

Prototipo

int far (*entrypoint)(int Funcion,uchar far *NumNodes,uint far *NodeSize,
uint BiosSelector);
...........
entrypoint = (void far *)MK_FP(0xF000,0xC180);

..........


GCC

Prototipo

"el mismo q para borland"

en la asignacion tengo dudas, he probado con los siguiente

entrypoint = (int (*)(int,ucha far*,uint far *,uint) 0xfc180; <-- Esto lo
admite.
resultado = entrypoint(Funcion,NumNodes,NodeSize,BiosSelector); <----- Aqui
es dnd falla, alguna idea?

Gracias.

Dj.


P.D.: He estado mirando en la ayuda y he visto la funcion
_go32_simulate_fcall (registros_dpmi), pero no me convence.Hay alguna otra
forma de hacerlo. Gracias de nuevo
Jose Antonio
2004-06-24 20:58:58 UTC
Permalink
Post by DJ
Hola!
Estoy intentando escribir un pequeño programa para averiguar los
dispositivos instalados en un ordenador, a traves de la BIOS PNP. Tengo la
direccion en memoria donde esta ubicada la entrada a la rutina del BIOS q
hace esto (0xF000:0xC180). Lo he escrito con el Borland ++ 3.1 y con el GCC
(Rhide) para MS-DOS/WIN 98.En el Borland me va bien, pero cuando intento
asignar la direccion y luego llamarla se levanta una excepcion por fallo en
la segmentacion.
Lógico, normalmente para acceder a los servicios de la bios tendrás que
usar una llamada al sistema a través de una interrupción software.
DJ
2004-06-25 07:29:22 UTC
Permalink
Si bien es cierto q existen esas funciones, la especificacion
PNPBIOSSpecification -v1.0a habla de buscar a traves de la memoria , entre
las posiciones 0xE0000 - 0xFFFFF la marca $PnP. Una vez encontrada, esta
marca es el inicio de una estructura q entre otras cosas como la version del
Bios PnP (1.0, el mio) te da el par seg:off para hacer las llamadas en modo
real y en modo protegido.

Pongo un extracto de la especificacion, de la funcion q puse de ejemplo en
el otro mail.

4.5.1 Function 0 - Get Number of System Device Nodes
Synopsis:
int FAR (*entryPoint)(Function, NumNodes, NodeSize, BiosSelector);
int Function; /* PnP BIOS Function 0 */
unsigned char FAR *NumNodes; /* Number of nodes the BIOS will return */
unsigned int FAR *NodeSize; /* Size of the largest device node */
unsigned int BiosSelector; /* PnP BIOS readable/writable selector */
Description:
Required. This function will return the number of nodes that the system BIOS
will return information for
in NumNodes. These nodes represent only the systemboard devices. In addition
to the number of nodes,
the system BIOS will return the size, in bytes, of the largest System Device
Node in NodeSize. This
information can be utilized by the system software to determine the amount
of memory required to get all
of the System Device Nodes.
The BiosSelector parameter enables the system BIOS, if necessary, to update
system variables that are
contained in the system BIOS memory space. If this function is called from
protected mode, the caller
must create a data segment descriptor using the 16-bit Protected Mode data
segment base address
specified in the Plug and Play Installation Check data structure, a limit of
64KB, and the descriptor must
be read/write capable. If this function is called from real mode,
BiosSelector should be set to the Real
Mode 16-bit data segment address as specified in the Plug and Play
Installation Check structure. Refer to
section 4.4 above for more information on the Plug and Play Installation
Check Structure and the
elements that make up the structure.
The function is available in real mode and 16-bit protected mode.
Returns:
0 if successful - SUCCESS
!0 if an error (Bit 7 set) or a warning occurred - error code (The function
return codes are described in
Appendix C)
The FLAGS and registers will be preserved, except for AX which contains the
return code.
Example:
The following example illustrates how the 'C' style call interface could be
made from an assembly
language module:
.
.
.
push Bios Selector
push segment/selector of NodeSize ; pointer to NodeSize
push offset of NodeSize
push segment/selector of NumNodes ; pointer to NumNodes
push offset of NumNodes
push GET_NUM_NODES ; Function 0
call FAR PTR entryPoint
add sp,12 ; Clean up stack
cmp ax,SUCCESS ; Function completed successfully?
jne error ; No-handle error condition


Como puedes ver el problema no son las llamadas al BIOS, si no, hacer un far
call desde el modo protegido.Soy novatillo en este modo y tengo algun q otro
lio con los descriptores y demas.

Gracias y perdon por el rollo.

Dj.



.
.

Loading...