Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / pnp / pnpbios / bioscalls.c
index 2ac20b5..a1f0b0b 100644 (file)
@@ -31,15 +31,6 @@ static struct {
 } pnp_bios_callpoint;
 
 
-/* The PnP BIOS entries in the GDT */
-#define PNP_GDT    (GDT_ENTRY_PNPBIOS_BASE * 8)
-
-#define PNP_CS32   (PNP_GDT+0x00)      /* segment for calling fn */
-#define PNP_CS16   (PNP_GDT+0x08)      /* code segment for BIOS */
-#define PNP_DS     (PNP_GDT+0x10)      /* data segment for BIOS */
-#define PNP_TS1    (PNP_GDT+0x18)      /* transfer data segment */
-#define PNP_TS2    (PNP_GDT+0x20)      /* another data segment */
-
 /*
  * These are some opcodes for a "static asmlinkage"
  * As this code is *not* executed inside the linux kernel segment, but in a
@@ -67,16 +58,11 @@ __asm__(
        ".previous              \n"
 );
 
-#define Q_SET_SEL(cpu, selname, address, size) \
-do { \
-set_base(cpu_gdt_table[cpu][(selname) >> 3], __va((u32)(address))); \
-set_limit(cpu_gdt_table[cpu][(selname) >> 3], size); \
-} while(0)
-
 #define Q2_SET_SEL(cpu, selname, address, size) \
 do { \
-set_base(cpu_gdt_table[cpu][(selname) >> 3], (u32)(address)); \
-set_limit(cpu_gdt_table[cpu][(selname) >> 3], size); \
+struct desc_struct *gdt = get_cpu_gdt_table((cpu)); \
+set_base(gdt[(selname) >> 3], (u32)(address)); \
+set_limit(gdt[(selname) >> 3], size); \
 } while(0)
 
 static struct desc_struct bad_bios_desc = { 0, 0x00409200 };
@@ -115,8 +101,8 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
                return PNP_FUNCTION_NOT_SUPPORTED;
 
        cpu = get_cpu();
-       save_desc_40 = cpu_gdt_table[cpu][0x40 / 8];
-       cpu_gdt_table[cpu][0x40 / 8] = bad_bios_desc;
+       save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
+       get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
 
        /* On some boxes IRQ's during PnP BIOS calls are deadly.  */
        spin_lock_irqsave(&pnp_bios_lock, flags);
@@ -158,14 +144,14 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
        );
        spin_unlock_irqrestore(&pnp_bios_lock, flags);
 
-       cpu_gdt_table[cpu][0x40 / 8] = save_desc_40;
+       get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
        put_cpu();
 
        /* If we get here and this is set then the PnP BIOS faulted on us. */
        if(pnp_bios_is_utter_crap)
        {
                printk(KERN_ERR "PnPBIOS: Warning! Your PnP BIOS caused a fatal error. Attempting to continue\n");
-               printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"nobiospnp\" option to operate stably\n");
+               printk(KERN_ERR "PnPBIOS: You may need to reboot with the \"pnpbios=off\" option to operate stably\n");
                printk(KERN_ERR "PnPBIOS: Check with your vendor for an updated BIOS\n");
        }
 
@@ -260,7 +246,7 @@ static int __pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_NUM_SYS_DEV_NODES, 0, PNP_TS1, 2, PNP_TS1, PNP_DS, 0, 0,
-                              data, sizeof(struct pnp_dev_node_info), 0, 0);
+                              data, sizeof(struct pnp_dev_node_info), NULL, 0);
        data->no_nodes &= 0xff;
        return status;
 }
@@ -290,12 +276,15 @@ int pnp_bios_dev_node_info(struct pnp_dev_node_info *data)
 static int __pnp_bios_get_dev_node(u8 *nodenum, char boot, struct pnp_bios_node *data)
 {
        u16 status;
+       u16 tmp_nodenum;
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        if ( !boot && pnpbios_dont_use_current_config )
                return PNP_FUNCTION_NOT_SUPPORTED;
+       tmp_nodenum = *nodenum;
        status = call_pnp_bios(PNP_GET_SYS_DEV_NODE, 0, PNP_TS1, 0, PNP_TS2, boot ? 2 : 1, PNP_DS, 0,
-                              nodenum, sizeof(char), data, 65536);
+                              &tmp_nodenum, sizeof(tmp_nodenum), data, 65536);
+       *nodenum = tmp_nodenum;
        return status;
 }
 
@@ -323,7 +312,7 @@ static int __pnp_bios_set_dev_node(u8 nodenum, char boot, struct pnp_bios_node *
        if ( !boot && pnpbios_dont_use_current_config )
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_SET_SYS_DEV_NODE, nodenum, 0, PNP_TS1, boot ? 2 : 1, PNP_DS, 0, 0,
-                              data, 65536, 0, 0);
+                              data, 65536, NULL, 0);
        return status;
 }
 
@@ -353,7 +342,7 @@ static int pnp_bios_get_event(u16 *event)
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_EVENT, 0, PNP_TS1, PNP_DS, 0, 0 ,0 ,0,
-                              event, sizeof(u16), 0, 0);
+                              event, sizeof(u16), NULL, 0);
        return status;
 }
 #endif
@@ -381,7 +370,7 @@ int pnp_bios_dock_station_info(struct pnp_docking_station_info *data)
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_DOCKING_STATION_INFORMATION, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
-                              data, sizeof(struct pnp_docking_station_info), 0, 0);
+                              data, sizeof(struct pnp_docking_station_info), NULL, 0);
        return status;
 }
 
@@ -411,7 +400,7 @@ static int __pnp_bios_get_stat_res(char *info)
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_STATIC_ALLOCED_RES_INFO, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
-                              info, 65536, 0, 0);
+                              info, 65536, NULL, 0);
        return status;
 }
 
@@ -448,7 +437,7 @@ static int __pnp_bios_isapnp_config(struct pnp_isa_config_struc *data)
        if (!pnp_bios_present())
                return PNP_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_PNP_ISA_CONFIG_STRUC, 0, PNP_TS1, PNP_DS, 0, 0, 0, 0,
-                              data, sizeof(struct pnp_isa_config_struc), 0, 0);
+                              data, sizeof(struct pnp_isa_config_struc), NULL, 0);
        return status;
 }
 
@@ -470,7 +459,7 @@ static int __pnp_bios_escd_info(struct escd_info_struc *data)
        if (!pnp_bios_present())
                return ESCD_FUNCTION_NOT_SUPPORTED;
        status = call_pnp_bios(PNP_GET_ESCD_INFO, 0, PNP_TS1, 2, PNP_TS1, 4, PNP_TS1, PNP_DS,
-                              data, sizeof(struct escd_info_struc), 0, 0);
+                              data, sizeof(struct escd_info_struc), NULL, 0);
        return status;
 }
 
@@ -535,10 +524,12 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
 
        set_base(bad_bios_desc, __va((unsigned long)0x40 << 4));
        _set_limit((char *)&bad_bios_desc, 4095 - (0x40 << 4));
-       for(i=0; i < NR_CPUS; i++)
-       {
-               Q2_SET_SEL(i, PNP_CS32, &pnp_bios_callfunc, 64 * 1024);
-               Q_SET_SEL(i, PNP_CS16, header->fields.pm16cseg, 64 * 1024);
-               Q_SET_SEL(i, PNP_DS, header->fields.pm16dseg, 64 * 1024);
-       }
+       for (i = 0; i < NR_CPUS; i++) {
+               struct desc_struct *gdt = get_cpu_gdt_table(i);
+               if (!gdt)
+                       continue;
+               set_base(gdt[GDT_ENTRY_PNPBIOS_CS32], &pnp_bios_callfunc);
+               set_base(gdt[GDT_ENTRY_PNPBIOS_CS16], __va(header->fields.pm16cseg));
+               set_base(gdt[GDT_ENTRY_PNPBIOS_DS], __va(header->fields.pm16dseg));
+       }
 }