While creating a hercules driver for 4.2.0, I ran into some resource sharing issues. Gecause the vga
and vesa drivers claim the monochrome ports and memory, I initially declared them shared in the
hercules driver. This leads to a crash in xf86Bus.c down around line 2080 (last line of setAccess).
Protecting this busAcc->set_f call the same way the other set_f calls are protected fixes the problem.


Since the hercules driver really does require exclusive use of the mono resources, the vga and vesa
conflicts should be fixed in those drivers. The vesa fix is simpler because there are no monochrome
vesa modes, it just needs to have the resource list in xf86Resources.h and xf86Bus.c adjusted. The vga
driver needs to choose which resource set it needs based on the same function the vgaHW module
determines the IObase, which is reading bit 0 of the misc out register (0x3CC).
The last change is adding the new resource symbols to the loader seed file, xf86sym.c.


I attached context diffs for the changes described above. The hercules driver will be in a separate message.
Enjoy
Lee Olsen
[EMAIL PROTECTED]
*** generic.c   Wed Mar 19 14:29:01 2003
--- generic.c.orig      Tue Mar 18 13:16:52 2003
***************
*** 206,232 ****
  
  enum GenericTypes
  {
!     CHIP_VGA_GENERIC,
!     CHIP_VGA_MONOCHROME
  };
  
  /* Supported chipsets */
  static SymTabRec GenericChipsets[] =
  {
!     {CHIP_VGA_GENERIC, "generic color"},
!     {CHIP_VGA_MONOCHROME, "generic monochrome"},
      {-1,               NULL}
  };
  
  static PciChipsets GenericPCIchipsets[] = {
!   { CHIP_VGA_MONOCHROME, PCI_CHIP_VGA, RES_SHARED_VGA_MONO },
!   { CHIP_VGA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA_COLOR },
    { -1,               -1,           RES_UNDEFINED },
  };
  
  static IsaChipsets GenericISAchipsets[] = {
!   {CHIP_VGA_MONOCHROME, RES_EXCLUSIVE_VGA_MONO},
!   {CHIP_VGA_GENERIC, RES_EXCLUSIVE_VGA_COLOR},
    {-1,                0 }
  };
  
--- 206,228 ----
  
  enum GenericTypes
  {
!     CHIP_VGA_GENERIC
  };
  
  /* Supported chipsets */
  static SymTabRec GenericChipsets[] =
  {
!     {CHIP_VGA_GENERIC, "generic"},
      {-1,               NULL}
  };
  
  static PciChipsets GenericPCIchipsets[] = {
!   { CHIP_VGA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA },
    { -1,               -1,           RES_UNDEFINED },
  };
  
  static IsaChipsets GenericISAchipsets[] = {
!   {CHIP_VGA_GENERIC, RES_EXCLUSIVE_VGA},
    {-1,                0 }
  };
  
***************
*** 361,370 ****
      if ((CurrentValue ^ 0x0F) != TestValue)
        return -1;
  #endif
!     if (inb(0x3CC) & 1)
!       return (int)CHIP_VGA_GENERIC;
!     else
!       return (int)CHIP_VGA_MONOCHROME;
  }
  
  static Bool
--- 357,363 ----
      if ((CurrentValue ^ 0x0F) != TestValue)
        return -1;
  #endif
!     return (int)CHIP_VGA_GENERIC;
  }
  
  static Bool
*** vesa.c      Tue Mar 18 13:54:01 2003
--- vesa.c.orig Wed Mar  5 05:55:36 2003
***************
*** 119,130 ****
  };
  
  static PciChipsets VESAPCIchipsets[] = {
!   { CHIP_VESA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA_COLOR },
    { -1,               -1,        RES_UNDEFINED },
  };
  
  static IsaChipsets VESAISAchipsets[] = {
!   {CHIP_VESA_GENERIC, RES_EXCLUSIVE_VGA_COLOR},
    {-1,                0 }
  };
  
--- 119,130 ----
  };
  
  static PciChipsets VESAPCIchipsets[] = {
!   { CHIP_VESA_GENERIC, PCI_CHIP_VGA, RES_SHARED_VGA },
    { -1,               -1,        RES_UNDEFINED },
  };
  
  static IsaChipsets VESAISAchipsets[] = {
!   {CHIP_VESA_GENERIC, RES_EXCLUSIVE_VGA},
    {-1,                0 }
  };
  
*** xf86Bus.c   Wed Mar 19 13:46:50 2003
--- xf86Bus.c.orig      Sat Oct 27 20:33:17 2001
***************
*** 53,62 ****
  resPtr ResRange = NULL;
  
  /* predefined special resources */
! resRange resVgaExclusive[] = {_VGA_EXCLUSIVE_COLOR, _END};
! resRange resVgaShared[] = {_VGA_SHARED_COLOR, _END};
! resRange resVgaExclusiveMono[] = {_VGA_EXCLUSIVE_MONO, _END};
! resRange resVgaSharedMono[] = {_VGA_SHARED_MONO, _END};
  resRange resVgaMemShared[] = {_VGA_SHARED_MEM,_END};
  resRange resVgaIoShared[] = {_VGA_SHARED_IO,_END};
  resRange resVgaUnusedExclusive[] = {_VGA_EXCLUSIVE_UNUSED, _END};
--- 53,60 ----
  resPtr ResRange = NULL;
  
  /* predefined special resources */
! resRange resVgaExclusive[] = {_VGA_EXCLUSIVE, _END};
! resRange resVgaShared[] = {_VGA_SHARED, _END};
  resRange resVgaMemShared[] = {_VGA_SHARED_MEM,_END};
  resRange resVgaIoShared[] = {_VGA_SHARED_IO,_END};
  resRange resVgaUnusedExclusive[] = {_VGA_EXCLUSIVE_UNUSED, _END};
***************
*** 2079,2087 ****
      if (!pEnt->access->pAccess
        && (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP :
                                NEED_VGA_ROUTED))) 
!       if (((BusAccPtr)pEnt->busAcc)
!        && ((BusAccPtr)pEnt->busAcc)->set_f)
!               ((BusAccPtr)pEnt->busAcc)->set_f(pEnt->busAcc);
  }
  
      
--- 2077,2083 ----
      if (!pEnt->access->pAccess
        && (pEnt->entityProp & (state == SETUP ? NEED_VGA_ROUTED_SETUP :
                                NEED_VGA_ROUTED))) 
!       ((BusAccPtr)pEnt->busAcc)->set_f(pEnt->busAcc);
  }
  
      
*** xf86Resources.h     Wed Mar 19 13:56:31 2003
--- xf86Resources.h.orig        Fri Jun  1 11:43:49 2001
***************
*** 8,33 ****
  
  #define _END {ResEnd,0,0}
  
! #define _VGA_EXCLUSIVE_COLOR \
                {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
                {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
                {ResExcIoBlock  | ResBios | ResBus,     0x03C0,     0x03DF}
  
! #define _VGA_SHARED_COLOR \
                {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
                {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
                {ResShrIoBlock  | ResBios | ResBus,     0x03C0,     0x03DF}
  
- #define _VGA_EXCLUSIVE_MONO \
-               {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
-               {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
-               {ResExcIoBlock  | ResBios | ResBus,     0x03B0,     0x03CF}
- 
- #define _VGA_SHARED_MONO \
-               {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
-               {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
-               {ResShrIoBlock  | ResBios | ResBus,     0x03B0,     0x03CF}
- 
  #define _VGA_SHARED_MEM \
                {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
                {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
--- 8,27 ----
  
  #define _END {ResEnd,0,0}
  
! #define _VGA_EXCLUSIVE \
                {ResExcMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+               {ResExcMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
                {ResExcMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+               {ResExcIoBlock  | ResBios | ResBus,     0x03B0,     0x03BB},\
                {ResExcIoBlock  | ResBios | ResBus,     0x03C0,     0x03DF}
  
! #define _VGA_SHARED \
                {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+               {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
                {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
+               {ResShrIoBlock  | ResBios | ResBus,     0x03B0,     0x03BB},\
                {ResShrIoBlock  | ResBios | ResBus,     0x03C0,     0x03DF}
  
  #define _VGA_SHARED_MEM \
                {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
                {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
***************
*** 87,95 ****
  
  /* predefined resources */
  extern resRange resVgaExclusive[];
- extern resRange resVgaExclusiveMono[];
  extern resRange resVgaShared[];
- extern resRange resVgaSharedMono[];
  extern resRange resVgaIoShared[];
  extern resRange resVgaMemShared[];
  extern resRange resVgaUnusedExclusive[];
--- 81,87 ----
***************
*** 104,113 ****
  #define resVgaIo  resVgaIoShared
  
  /* old style names */
! #define RES_EXCLUSIVE_VGA_COLOR   resVgaExclusive
! #define RES_SHARED_VGA_COLOR      resVgaShared
! #define RES_EXCLUSIVE_VGA_MONO   resVgaExclusiveMono
! #define RES_SHARED_VGA_MONO      resVgaSharedMono
  #define RES_EXCLUSIVE_8514  res8514Exclusive
  #define RES_SHARED_8514     res8514Shared
  
--- 96,103 ----
  #define resVgaIo  resVgaIoShared
  
  /* old style names */
! #define RES_EXCLUSIVE_VGA   resVgaExclusive
! #define RES_SHARED_VGA      resVgaShared
  #define RES_EXCLUSIVE_8514  res8514Exclusive
  #define RES_SHARED_8514     res8514Shared
  
*** xf86sym.c   Wed Mar 19 13:40:46 2003
--- xf86sym.c.orig      Wed Mar 19 14:49:08 2003
***************
*** 1045,1052 ****
     /* predefined resource lists from xf86Bus.h */
     SYMVAR(resVgaExclusive)
     SYMVAR(resVgaShared)
-    SYMVAR(resVgaExclusiveMono)
-    SYMVAR(resVgaSharedMono)
     SYMVAR(resVgaMemShared)
     SYMVAR(resVgaIoShared)
     SYMVAR(resVgaUnusedExclusive)
--- 1045,1050 ----

Reply via email to