xref: /linux/drivers/pnp/pnpbios/pnpbios.h (revision 24bce201d79807b668bf9d9e0aca801c5c0d5f78)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * pnpbios.h - contains local definitions
4  */
5 
6 /*
7  * Include file for the interface to a PnP BIOS
8  *
9  * Original BIOS code (C) 1998 Christian Schmidt (chr.schmidt@tu-bs.de)
10  * PnP handler parts (c) 1998 Tom Lees <tom@lpsg.demon.co.uk>
11  * Minor reorganizations by David Hinds <dahinds@users.sourceforge.net>
12  */
13 
14 /*
15  * Return codes
16  */
17 #define PNP_SUCCESS                     0x00
18 #define PNP_NOT_SET_STATICALLY          0x7f
19 #define PNP_UNKNOWN_FUNCTION            0x81
20 #define PNP_FUNCTION_NOT_SUPPORTED      0x82
21 #define PNP_INVALID_HANDLE              0x83
22 #define PNP_BAD_PARAMETER               0x84
23 #define PNP_SET_FAILED                  0x85
24 #define PNP_EVENTS_NOT_PENDING          0x86
25 #define PNP_SYSTEM_NOT_DOCKED           0x87
26 #define PNP_NO_ISA_PNP_CARDS            0x88
27 #define PNP_UNABLE_TO_DETERMINE_DOCK_CAPABILITIES 0x89
28 #define PNP_CONFIG_CHANGE_FAILED_NO_BATTERY 0x8a
29 #define PNP_CONFIG_CHANGE_FAILED_RESOURCE_CONFLICT 0x8b
30 #define PNP_BUFFER_TOO_SMALL            0x8c
31 #define PNP_USE_ESCD_SUPPORT            0x8d
32 #define PNP_MESSAGE_NOT_SUPPORTED       0x8e
33 #define PNP_HARDWARE_ERROR              0x8f
34 
35 #define ESCD_SUCCESS                    0x00
36 #define ESCD_IO_ERROR_READING           0x55
37 #define ESCD_INVALID                    0x56
38 #define ESCD_BUFFER_TOO_SMALL           0x59
39 #define ESCD_NVRAM_TOO_SMALL            0x5a
40 #define ESCD_FUNCTION_NOT_SUPPORTED     0x81
41 
42 /*
43  * Events that can be received by "get event"
44  */
45 #define PNPEV_ABOUT_TO_CHANGE_CONFIG	0x0001
46 #define PNPEV_DOCK_CHANGED		0x0002
47 #define PNPEV_SYSTEM_DEVICE_CHANGED	0x0003
48 #define PNPEV_CONFIG_CHANGED_FAILED	0x0004
49 #define PNPEV_UNKNOWN_SYSTEM_EVENT	0xffff
50 /* 0x8000 through 0xfffe are OEM defined */
51 
52 /*
53  * Messages that should be sent through "send message"
54  */
55 #define PNPMSG_OK			0x00
56 #define PNPMSG_ABORT			0x01
57 #define PNPMSG_UNDOCK_DEFAULT_ACTION	0x40
58 #define PNPMSG_POWER_OFF		0x41
59 #define PNPMSG_PNP_OS_ACTIVE		0x42
60 #define PNPMSG_PNP_OS_INACTIVE		0x43
61 
62 /*
63  * Plug and Play BIOS flags
64  */
65 #define PNPBIOS_NO_DISABLE		0x0001
66 #define PNPBIOS_NO_CONFIG		0x0002
67 #define PNPBIOS_OUTPUT			0x0004
68 #define PNPBIOS_INPUT			0x0008
69 #define PNPBIOS_BOOTABLE		0x0010
70 #define PNPBIOS_DOCK			0x0020
71 #define PNPBIOS_REMOVABLE		0x0040
72 #define pnpbios_is_static(x) (((x)->flags & 0x0100) == 0x0000)
73 #define pnpbios_is_dynamic(x) ((x)->flags & 0x0080)
74 
75 /*
76  * Function Parameters
77  */
78 #define PNPMODE_STATIC 1
79 #define PNPMODE_DYNAMIC 0
80 
81 /* 0x8000 through 0xffff are OEM defined */
82 
83 #pragma pack(1)
84 struct pnp_dev_node_info {
85 	__u16 no_nodes;
86 	__u16 max_node_size;
87 };
88 struct pnp_docking_station_info {
89 	__u32 location_id;
90 	__u32 serial;
91 	__u16 capabilities;
92 };
93 struct pnp_isa_config_struc {
94 	__u8 revision;
95 	__u8 no_csns;
96 	__u16 isa_rd_data_port;
97 	__u16 reserved;
98 };
99 struct escd_info_struc {
100 	__u16 min_escd_write_size;
101 	__u16 escd_size;
102 	__u32 nv_storage_base;
103 };
104 struct pnp_bios_node {
105 	__u16 size;
106 	__u8 handle;
107 	__u32 eisa_id;
108 	__u8 type_code[3];
109 	__u16 flags;
110 	__u8 data[];
111 };
112 #pragma pack()
113 
114 /* non-exported */
115 extern struct pnp_dev_node_info node_info;
116 
117 extern int pnp_bios_dev_node_info(struct pnp_dev_node_info *data);
118 extern int pnp_bios_get_dev_node(u8 *nodenum, char config,
119 				 struct pnp_bios_node *data);
120 extern int pnp_bios_set_dev_node(u8 nodenum, char config,
121 				 struct pnp_bios_node *data);
122 extern int pnp_bios_get_stat_res(char *info);
123 extern int pnp_bios_isapnp_config(struct pnp_isa_config_struc *data);
124 extern int pnp_bios_escd_info(struct escd_info_struc *data);
125 extern int pnp_bios_read_escd(char *data, u32 nvram_base);
126 extern int pnp_bios_dock_station_info(struct pnp_docking_station_info *data);
127 
128 #pragma pack(1)
129 union pnp_bios_install_struct {
130 	struct {
131 		u32 signature;    /* "$PnP" */
132 		u8 version;	  /* in BCD */
133 		u8 length;	  /* length in bytes, currently 21h */
134 		u16 control;	  /* system capabilities */
135 		u8 checksum;	  /* all bytes must add up to 0 */
136 
137 		u32 eventflag;    /* phys. address of the event flag */
138 		u16 rmoffset;     /* real mode entry point */
139 		u16 rmcseg;
140 		u16 pm16offset;   /* 16 bit protected mode entry */
141 		u32 pm16cseg;
142 		u32 deviceID;	  /* EISA encoded system ID or 0 */
143 		u16 rmdseg;	  /* real mode data segment */
144 		u32 pm16dseg;	  /* 16 bit pm data segment base */
145 	} fields;
146 	char chars[0x21];	  /* To calculate the checksum */
147 };
148 #pragma pack()
149 
150 extern int pnp_bios_present(void);
151 extern int  pnpbios_dont_use_current_config;
152 
153 extern int pnpbios_parse_data_stream(struct pnp_dev *dev, struct pnp_bios_node * node);
154 extern int pnpbios_read_resources_from_node(struct pnp_dev *dev, struct pnp_bios_node *node);
155 extern int pnpbios_write_resources_to_node(struct pnp_dev *dev, struct pnp_bios_node *node);
156 extern void pnpid32_to_pnpid(u32 id, char *str);
157 
158 extern void pnpbios_print_status(const char * module, u16 status);
159 extern void pnpbios_calls_init(union pnp_bios_install_struct * header);
160 
161 #ifdef CONFIG_PNPBIOS_PROC_FS
162 extern int pnpbios_interface_attach_device(struct pnp_bios_node * node);
163 extern int pnpbios_proc_init (void);
164 extern void pnpbios_proc_exit (void);
165 #else
166 static inline int pnpbios_interface_attach_device(struct pnp_bios_node * node) { return 0; }
167 static inline int pnpbios_proc_init (void) { return 0; }
168 static inline void pnpbios_proc_exit (void) { ; }
169 #endif /* CONFIG_PNPBIOS_PROC_FS */
170