mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
Make the evil broken pnpbios compensation slightly less evil.
This is the hack that compensates for when bios vendors "forget" to include the fdc control (0x3f7) port in their io port mappings. Instead of accessing ports outside of a range allocated to a handle, simply allocate the port directly. It even shows up in the probe..
This commit is contained in:
parent
8e1b368f04
commit
b9da888fcb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55471
@ -642,27 +642,32 @@ fdc_alloc_resources(struct fdc_data *fdc)
|
||||
* have a different method of programming the transfer speed which
|
||||
* doesn't require the control register, but it's mighty bogus as the
|
||||
* chip still responds to the address for the control register.
|
||||
* This hack is truely evil as we use the 6th port in a 4-port chunk.
|
||||
*/
|
||||
/* 0x3f2-0x3f5 */
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4 &&
|
||||
bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
|
||||
fdc->port_off = -2;
|
||||
ispnp = 0; /* hack, don't reserve second port chunk */
|
||||
}
|
||||
/* 0x3f0-0x3f5 */
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 6 &&
|
||||
bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
|
||||
ispnp = 0; /* hack, don't reserve second port chunk */
|
||||
}
|
||||
if (ispnp) {
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4)
|
||||
int cntport0;
|
||||
int cntport1;
|
||||
u_long ctlstart;
|
||||
u_long ctlend;
|
||||
|
||||
cntport0 = bus_get_resource_count(dev, SYS_RES_IOPORT, 0);
|
||||
cntport1 = bus_get_resource_count(dev, SYS_RES_IOPORT, 1);
|
||||
ctlstart = 0ul;
|
||||
ctlend = ~0ul;
|
||||
if (cntport0 == 4)
|
||||
fdc->port_off = -2;
|
||||
if (cntport1 == 0) {
|
||||
/* GRRR, request a specific port */
|
||||
ctlstart = rman_get_start(fdc->res_ioport) +
|
||||
fdc->port_off + 7; /* usually 0x3f7 */
|
||||
ctlend = ctlstart;
|
||||
if (bootverbose)
|
||||
device_printf(dev, "added missing ctrl port\n");
|
||||
}
|
||||
fdc->flags |= FDC_ISPNP;
|
||||
fdc->rid_ctl = 1;
|
||||
fdc->res_ctl = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
&fdc->rid_ctl, 0ul, ~0ul,
|
||||
1, RF_ACTIVE);
|
||||
&fdc->rid_ctl, ctlstart,
|
||||
ctlend, 1, RF_ACTIVE);
|
||||
if (fdc->res_ctl == 0) {
|
||||
device_printf(dev, "cannot reserve I/O port range 2\n");
|
||||
return ENXIO;
|
||||
|
35
sys/isa/fd.c
35
sys/isa/fd.c
@ -642,27 +642,32 @@ fdc_alloc_resources(struct fdc_data *fdc)
|
||||
* have a different method of programming the transfer speed which
|
||||
* doesn't require the control register, but it's mighty bogus as the
|
||||
* chip still responds to the address for the control register.
|
||||
* This hack is truely evil as we use the 6th port in a 4-port chunk.
|
||||
*/
|
||||
/* 0x3f2-0x3f5 */
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4 &&
|
||||
bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
|
||||
fdc->port_off = -2;
|
||||
ispnp = 0; /* hack, don't reserve second port chunk */
|
||||
}
|
||||
/* 0x3f0-0x3f5 */
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 6 &&
|
||||
bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
|
||||
ispnp = 0; /* hack, don't reserve second port chunk */
|
||||
}
|
||||
if (ispnp) {
|
||||
if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4)
|
||||
int cntport0;
|
||||
int cntport1;
|
||||
u_long ctlstart;
|
||||
u_long ctlend;
|
||||
|
||||
cntport0 = bus_get_resource_count(dev, SYS_RES_IOPORT, 0);
|
||||
cntport1 = bus_get_resource_count(dev, SYS_RES_IOPORT, 1);
|
||||
ctlstart = 0ul;
|
||||
ctlend = ~0ul;
|
||||
if (cntport0 == 4)
|
||||
fdc->port_off = -2;
|
||||
if (cntport1 == 0) {
|
||||
/* GRRR, request a specific port */
|
||||
ctlstart = rman_get_start(fdc->res_ioport) +
|
||||
fdc->port_off + 7; /* usually 0x3f7 */
|
||||
ctlend = ctlstart;
|
||||
if (bootverbose)
|
||||
device_printf(dev, "added missing ctrl port\n");
|
||||
}
|
||||
fdc->flags |= FDC_ISPNP;
|
||||
fdc->rid_ctl = 1;
|
||||
fdc->res_ctl = bus_alloc_resource(dev, SYS_RES_IOPORT,
|
||||
&fdc->rid_ctl, 0ul, ~0ul,
|
||||
1, RF_ACTIVE);
|
||||
&fdc->rid_ctl, ctlstart,
|
||||
ctlend, 1, RF_ACTIVE);
|
||||
if (fdc->res_ctl == 0) {
|
||||
device_printf(dev, "cannot reserve I/O port range 2\n");
|
||||
return ENXIO;
|
||||
|
Loading…
Reference in New Issue
Block a user