Mail Archives: djgpp/1999/12/05/13:39:59
Eli Zaretskii <eliz AT is DOT elta DOT co DOT il> wrote:
>This probably means that you should use the real-mode interface, since
>mixing 16-bit code with 32-bit code in the DPMI environment is tricky,
>if not impossible.
Out of curiosity, could you give me a brief idea of how it works?
If I ever need to do this, should I first create a descriptor and then
try changing the access rights, or is it something totally different?
Thanks in advance.
>So I think you need to forget about 16-bit PM selectors, and instead
>work via the real-mode interface, using the transfer buffer,
>__dpmi_int, and the other functions that allow to invoke real-mode
>procedures. If you have problems with doing that, please post
>specific questions.
I've put a portion of the copy of the latest version of the SysInfo I'm
working on. Have a look at this. If you find this interesting, you can
get the entire source from
http://prashanttr.tripod.com/
This code is 16-bit, but my intention is to help you get the basic
idea of how to access PnP device information. This one gives
you a detailed description of the PnP and ISA/PnP devices
(such as your sound card). Maybe I'll need your help to write a
DJGPP version of this.
And please excuse me for this horribly long mail.
Thanks,
Prashant
------------------------------------------
One pound of knowledge requires ten pounds of
common sense to apply it.
/*
* EXTERNAL.H - Contains external functions.
* Copyright (C) 1998, 1999 Prashant TR
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See the file COPYING.TR for more details.
*/
// ID for this file.
#define _EXTERNAL_H_
// External variables.
#ifndef _PNP_CC_
extern int errflag;
#endif
// PNP structure.
typedef struct _PNP_tag {
char signature[4];
unsigned char version;
char misc[8];
unsigned short (*pnp_entry_point)(...);
unsigned short protected_mode_entry_offset;
char misc_1[8];
unsigned short bios_selector;
char misc_3[4];
unsigned short isa_read_port;
char misc_4[8];
} PNP;
// Function definitions.
void newhandler();
void checkerrors();
int pinrun(const char *, const char *);
FILE *pinseek(const char *, const char *);
----------------------
/*
* PNP.CPP - Contains Plug and Play functions.
* Copyright (C) 1998, 1999 Prashant TR
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* See the file COPYING.TR for more details.
*/
// ID for this file.
#define _PNP_CC_
#include "pnp.h"
FILE *fp;
char cmdline[20];
int errflag = 0;
unsigned char buf1[512], buf2[256], owner[256];
unsigned char pnpname[256], flag;
unsigned short count, isaport = 0, type = 1;
PNP *header;
unsigned _stklen = 0x2000;
// Write any string to the file and check for successfulness.
void writestring(const char *string)
{
if (fprintf(fp, "%s", string) == EOF) {
errflag = 2;
checkerrors();
}
}
PNP *get_pnp_entry_point()
{
unsigned short segment, offset, f;
char flag;
// Search for $PNP.
segment = 0xf000;
offset = flag = 0;
do {
if (!strncmp((char *)MK_FP(segment, offset), "$PnP", 4))
flag++;
else offset += 0x10;
} while ((offset) && (!flag));
// Check if actually PnP.
if (flag) {
flag = 0;
for(f = 0; f <= 0x20; f++)
flag += *(char *)MK_FP(segment, offset + f);
flag = (!flag) ? 1 : 0;
}
return ((offset) ? (PNP *)MK_FP(segment, offset) : NULL);
}
void writepnpinfo()
{
char output[256];
unsigned short f, count;
int irq, dma, portid, mask, masknum, card = 1;
// Get the starting specifier type.
count = 12;
flag = irq = dma = 0;
flag = buf1[count]; // The specifier.
// Process PnP Information.
while (((unsigned char)flag >> 3) != 0xf)
{
flag = buf1[count]; // The specifier.
if ((flag & 0x78) == 0x10) {
sprintf(output, "\n\tDevice Identification : "
"%c%c%c%02X%02X\n",
((*(unsigned short *)&buf1[count + 1] >> 2) & 0x1f)
+ 0x40,
(char)((unsigned long)(((((unsigned long)
*(unsigned short *)&buf1[count + 1]) >> 13)
& 7)
| ((buf1[count + 1] & 3) << 3))
+ 0x40),
(buf1[count + 2] & 0x1f)
+ 0x40,
buf1[count + 3],
buf1[count + 4]);
writestring(output);
count += 6;
continue;
}
switch (((unsigned char)flag >> 3) - 2) {
case 0:
case 1:
case 4:
case 5:
case 8: // Probably Memory - 8.
break;
// IRQ Setting.
case 2:
mask = *(unsigned short *)
&buf1[count + 1];
masknum = 0;
do {
if ((mask >> masknum) & 1) {
irq++;
sprintf(output,
"\tIRQ "
"Setting"
" (%03u)"
" "
" : "
"%d\n",
irq,
masknum);
writestring(output);
break;
}
masknum++;
} while (masknum <= 15);
break;
// DMA Channel.
case 3:
mask = buf1[count + 1];
masknum = 0;
do {
if ((mask >> masknum) & 1) {
dma++;
sprintf(output,
"\tDMA "
"Channel"
" (%03u)"
" "
" : "
"%d\n",
dma,
masknum);
writestring(output);
break;
}
masknum++;
} while (masknum <= 7);
break;
// I/O Ports.
case 6:
sprintf(output, "\tI/O Range "
" : "
"%04X - %04X\n",
*(int *)&buf1[count + 4],
*(int *)&buf1[count + 4] +
buf1[count + 7] - 1);
writestring(output);
break;
// I/O Ports.
case 7:
sprintf(output, "\tI/O Range "
" : "
"%04X - %04X\n",
*(int *)&buf1[count + 1],
*(int *)&buf1[count + 1] +
buf1[count + 3] - 1);
writestring(output);
break;
default:
if (!(flag & 0x80)) break;
// Check if memory type specifier.
if ((flag & 0xf) == 6) {
sprintf(output, "\tMemory Range "
" : "
"%08lX - %08lX\n",
*(long *)&buf1[count + 4],
*(unsigned long *)&
buf1[count + 4] +
*(unsigned long *)&
buf1[count + 8]
- 1);
writestring(output);
}
// Check if Card name specifier.
if ((flag & 0xf) == 2) {
char x = buf1[count +
*(unsigned short *)&
buf1[count + 1] + 3];
buf1[count +
*(unsigned short *)&
buf1[count + 1] + 3] = 0;
sprintf(output, (card == 1) ?
"\tPlug and Play Ca"
"rd : "
"%s\n" :
"\tPlug and Play De"
"vice : "
"%s\n",
&buf1[count + 3]);
writestring(output);
buf1[count +
*(unsigned short *)&
buf1[count + 1] + 3] = x;
if (card) card = 0;
}
// Modify counter and type;
count += *(unsigned short *)
&buf1[count + 1] + 2;
flag &= 0x80;
break;
}
// Increment pointer.
count += (flag & 7) + 1;
}
}
...
...
...
__________________________________________________
Do You Yahoo!?
Thousands of Stores. Millions of Products. All in one place.
Yahoo! Shopping: http://shopping.yahoo.com
- Raw text -