Rev 4280 | Rev 4398 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4280 | Rev 4293 | ||
---|---|---|---|
1 | #include |
1 | #include |
2 | #include |
2 | #include |
3 | #include |
3 | #include |
4 | #include "i915_drv.h" |
4 | #include "i915_drv.h" |
5 | //#include "intel_drv.h" |
5 | //#include "intel_drv.h" |
6 | 6 | ||
7 | #include |
7 | #include |
8 | #include |
8 | #include |
9 | #include |
9 | #include |
10 | #include |
10 | #include |
11 | #include |
11 | #include |
12 | #include |
12 | #include |
13 | 13 | ||
14 | #include "bitmap.h" |
14 | #include "bitmap.h" |
15 | 15 | ||
16 | struct pci_device { |
16 | struct pci_device { |
17 | uint16_t domain; |
17 | uint16_t domain; |
18 | uint8_t bus; |
18 | uint8_t bus; |
19 | uint8_t dev; |
19 | uint8_t dev; |
20 | uint8_t func; |
20 | uint8_t func; |
21 | uint16_t vendor_id; |
21 | uint16_t vendor_id; |
22 | uint16_t device_id; |
22 | uint16_t device_id; |
23 | uint16_t subvendor_id; |
23 | uint16_t subvendor_id; |
24 | uint16_t subdevice_id; |
24 | uint16_t subdevice_id; |
25 | uint32_t device_class; |
25 | uint32_t device_class; |
26 | uint8_t revision; |
26 | uint8_t revision; |
27 | }; |
27 | }; |
28 | 28 | ||
29 | struct drm_device *main_device; |
29 | struct drm_device *main_device; |
30 | struct drm_file *drm_file_handlers[256]; |
30 | struct drm_file *drm_file_handlers[256]; |
31 | videomode_t usermode; |
31 | videomode_t usermode; |
32 | 32 | ||
33 | void cpu_detect(); |
33 | void cpu_detect(); |
34 | 34 | ||
35 | int _stdcall display_handler(ioctl_t *io); |
35 | int _stdcall display_handler(ioctl_t *io); |
36 | int init_agp(void); |
36 | int init_agp(void); |
37 | 37 | ||
38 | int srv_blit_bitmap(u32 hbitmap, int dst_x, int dst_y, |
38 | int srv_blit_bitmap(u32 hbitmap, int dst_x, int dst_y, |
39 | int src_x, int src_y, u32 w, u32 h); |
39 | int src_x, int src_y, u32 w, u32 h); |
40 | 40 | ||
41 | int blit_textured(u32 hbitmap, int dst_x, int dst_y, |
41 | int blit_textured(u32 hbitmap, int dst_x, int dst_y, |
42 | int src_x, int src_y, u32 w, u32 h); |
42 | int src_x, int src_y, u32 w, u32 h); |
43 | 43 | ||
44 | int blit_tex(u32 hbitmap, int dst_x, int dst_y, |
44 | int blit_tex(u32 hbitmap, int dst_x, int dst_y, |
45 | int src_x, int src_y, u32 w, u32 h); |
45 | int src_x, int src_y, u32 w, u32 h); |
46 | 46 | ||
47 | void get_pci_info(struct pci_device *dev); |
47 | void get_pci_info(struct pci_device *dev); |
48 | int i915_getparam(struct drm_device *dev, void *data, |
48 | int i915_getparam(struct drm_device *dev, void *data, |
49 | struct drm_file *file_priv); |
49 | struct drm_file *file_priv); |
50 | 50 | ||
51 | int i915_mask_update(struct drm_device *dev, void *data, |
51 | int i915_mask_update(struct drm_device *dev, void *data, |
52 | struct drm_file *file); |
52 | struct drm_file *file); |
53 | 53 | ||
54 | struct cmdtable cmdtable[]= { |
54 | struct cmdtable cmdtable[]= { |
55 | CMDENTRY("-pm=", i915_powersave), |
55 | CMDENTRY("-pm=", i915_powersave), |
56 | CMDENTRY("-rc6=", i915_enable_rc6), |
56 | CMDENTRY("-rc6=", i915_enable_rc6), |
57 | CMDENTRY("-fbc=", i915_enable_fbc), |
57 | CMDENTRY("-fbc=", i915_enable_fbc), |
58 | CMDENTRY("-ppgt=", i915_enable_ppgtt), |
58 | CMDENTRY("-ppgt=", i915_enable_ppgtt), |
59 | CMDENTRY("-pc8=", i915_enable_pc8), |
59 | CMDENTRY("-pc8=", i915_enable_pc8), |
60 | {NULL, 0} |
60 | {NULL, 0} |
61 | }; |
61 | }; |
62 | 62 | ||
63 | 63 | ||
64 | static char log[256]; |
64 | static char log[256]; |
65 | 65 | ||
66 | struct workqueue_struct *system_wq; |
66 | struct workqueue_struct *system_wq; |
67 | int driver_wq_state; |
67 | int driver_wq_state; |
68 | 68 | ||
69 | int x86_clflush_size; |
69 | int x86_clflush_size; |
70 | unsigned int tsc_khz; |
70 | unsigned int tsc_khz; |
71 | 71 | ||
72 | int i915_modeset = 1; |
72 | int i915_modeset = 1; |
73 | 73 | ||
74 | typedef union __attribute__((packed)) |
74 | typedef union __attribute__((packed)) |
75 | { |
75 | { |
76 | uint32_t val; |
76 | uint32_t val; |
77 | struct |
77 | struct |
78 | { |
78 | { |
79 | uint8_t state; |
79 | uint8_t state; |
80 | uint8_t code; |
80 | uint8_t code; |
81 | uint16_t ctrl_key; |
81 | uint16_t ctrl_key; |
82 | }; |
82 | }; |
83 | }oskey_t; |
83 | }oskey_t; |
84 | 84 | ||
85 | static inline oskey_t get_key(void) |
85 | static inline oskey_t get_key(void) |
86 | { |
86 | { |
87 | oskey_t val; |
87 | oskey_t val; |
88 | asm volatile("int $0x40":"=a"(val):"a"(2)); |
88 | asm volatile("int $0x40":"=a"(val):"a"(2)); |
89 | return val; |
89 | return val; |
90 | }; |
90 | }; |
91 | 91 | ||
92 | void i915_dpms(struct drm_device *dev, int mode); |
92 | void i915_dpms(struct drm_device *dev, int mode); |
93 | 93 | ||
94 | void i915_driver_thread() |
94 | void i915_driver_thread() |
95 | { |
95 | { |
96 | struct drm_i915_private *dev_priv = main_device->dev_private; |
96 | struct drm_i915_private *dev_priv = main_device->dev_private; |
97 | struct workqueue_struct *cwq = dev_priv->wq; |
97 | struct workqueue_struct *cwq = dev_priv->wq; |
98 | static int dpms = 1; |
98 | static int dpms = 1; |
99 | static int dpms_lock = 0; |
99 | static int dpms_lock = 0; |
100 | oskey_t key; |
100 | oskey_t key; |
101 | unsigned long irqflags; |
101 | unsigned long irqflags; |
102 | int tmp; |
102 | int tmp; |
103 | 103 | ||
104 | printf("%s\n",__FUNCTION__); |
104 | printf("%s\n",__FUNCTION__); |
105 | 105 | ||
106 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(1),"c"(1)); |
106 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(1),"c"(1)); |
107 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(4),"c"(0x46),"d"(0x330)); |
107 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(4),"c"(0x46),"d"(0x330)); |
108 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(4),"c"(0xC6),"d"(0x330)); |
108 | asm volatile("int $0x40":"=a"(tmp):"a"(66),"b"(4),"c"(0xC6),"d"(0x330)); |
109 | 109 | ||
110 | while(driver_wq_state != 0) |
110 | while(driver_wq_state != 0) |
111 | { |
111 | { |
112 | key = get_key(); |
112 | key = get_key(); |
113 | 113 | ||
114 | if( (key.val != 1) && (key.state == 0x02)) |
114 | if( (key.val != 1) && (key.state == 0x02)) |
115 | { |
115 | { |
116 | if(key.code == 0x46 && dpms_lock == 0) |
116 | if(key.code == 0x46 && dpms_lock == 0) |
117 | { |
117 | { |
118 | dpms_lock = 1; |
118 | dpms_lock = 1; |
119 | if(dpms == 1) |
119 | if(dpms == 1) |
120 | { |
120 | { |
121 | i915_dpms(main_device, DRM_MODE_DPMS_OFF); |
121 | i915_dpms(main_device, DRM_MODE_DPMS_OFF); |
122 | printf("dpms off\n"); |
122 | printf("dpms off\n"); |
123 | } |
123 | } |
124 | else |
124 | else |
125 | { |
125 | { |
126 | i915_dpms(main_device, DRM_MODE_DPMS_ON); |
126 | i915_dpms(main_device, DRM_MODE_DPMS_ON); |
127 | printf("dpms on\n"); |
127 | printf("dpms on\n"); |
128 | }; |
128 | }; |
129 | dpms ^= 1; |
129 | dpms ^= 1; |
130 | } |
130 | } |
131 | else if(key.code == 0xC6) |
131 | else if(key.code == 0xC6) |
132 | dpms_lock = 0; |
132 | dpms_lock = 0; |
133 | }; |
133 | }; |
134 | 134 | ||
135 | spin_lock_irqsave(&cwq->lock, irqflags); |
135 | spin_lock_irqsave(&cwq->lock, irqflags); |
136 | 136 | ||
137 | while (!list_empty(&cwq->worklist)) |
137 | while (!list_empty(&cwq->worklist)) |
138 | { |
138 | { |
139 | struct work_struct *work = list_entry(cwq->worklist.next, |
139 | struct work_struct *work = list_entry(cwq->worklist.next, |
140 | struct work_struct, entry); |
140 | struct work_struct, entry); |
141 | work_func_t f = work->func; |
141 | work_func_t f = work->func; |
142 | list_del_init(cwq->worklist.next); |
142 | list_del_init(cwq->worklist.next); |
143 | 143 | ||
144 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
144 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
145 | f(work); |
145 | f(work); |
146 | spin_lock_irqsave(&cwq->lock, irqflags); |
146 | spin_lock_irqsave(&cwq->lock, irqflags); |
147 | } |
147 | } |
148 | 148 | ||
149 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
149 | spin_unlock_irqrestore(&cwq->lock, irqflags); |
150 | 150 | ||
151 | delay(1); |
151 | delay(1); |
152 | }; |
152 | }; |
153 | 153 | ||
154 | asm volatile ("int $0x40"::"a"(-1)); |
154 | asm volatile ("int $0x40"::"a"(-1)); |
155 | } |
155 | } |
156 | 156 | ||
157 | u32_t __attribute__((externally_visible)) drvEntry(int action, char *cmdline) |
157 | u32_t __attribute__((externally_visible)) drvEntry(int action, char *cmdline) |
158 | { |
158 | { |
159 | int err = 0; |
159 | int err = 0; |
160 | 160 | ||
161 | if(action != 1) |
161 | if(action != 1) |
162 | { |
162 | { |
163 | driver_wq_state = 0; |
163 | driver_wq_state = 0; |
164 | return 0; |
164 | return 0; |
165 | }; |
165 | }; |
166 | 166 | ||
167 | if( GetService("DISPLAY") != 0 ) |
167 | if( GetService("DISPLAY") != 0 ) |
168 | return 0; |
168 | return 0; |
169 | 169 | ||
170 | printf("i915 v3.12\n\nusage: i915 [options]\n" |
170 | printf("i915 v3.12\n\nusage: i915 [options]\n" |
171 | "-pm=<0,1> Enable powersavings, fbc, downclocking, etc. (default: 0 - false)\n"); |
171 | "-pm=<0,1> Enable powersavings, fbc, downclocking, etc. (default: 0 - false)\n"); |
172 | printf("-rc6=<-1,0-7> Enable power-saving render C-state 6.\n" |
172 | printf("-rc6=<-1,0-7> Enable power-saving render C-state 6.\n" |
173 | " Different stages can be selected via bitmask values\n" |
173 | " Different stages can be selected via bitmask values\n" |
174 | " (0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6).\n" |
174 | " (0 = disable; 1 = enable rc6; 2 = enable deep rc6; 4 = enable deepest rc6).\n" |
175 | " For example, 3 would enable rc6 and deep rc6, and 7 would enable everything.\n" |
175 | " For example, 3 would enable rc6 and deep rc6, and 7 would enable everything.\n" |
176 | " default: -1 (use per-chip default)\n"); |
176 | " default: -1 (use per-chip default)\n"); |
177 | printf("-fbc=<-1,0,1> Enable frame buffer compression for power savings\n" |
177 | printf("-fbc=<-1,0,1> Enable frame buffer compression for power savings\n" |
178 | " (default: 0 - false)\n"); |
178 | " (default: 0 - false)\n"); |
179 | printf("-ppgt=<0,1> Enable PPGTT (default: 0 - false)\n"); |
179 | printf("-ppgt=<0,1> Enable PPGTT (default: 0 - false)\n"); |
180 | printf("-pc8=<0,1> Enable support for low power package C states (PC8+) (default: 0 - false)\n"); |
180 | printf("-pc8=<0,1> Enable support for low power package C states (PC8+) (default: 0 - false)\n"); |
181 | printf("-l |
181 | printf("-l |
182 | printf("-m |
182 | printf("-m |
183 | 183 | ||
184 | if( cmdline && *cmdline ) |
184 | if( cmdline && *cmdline ) |
185 | parse_cmdline(cmdline, cmdtable, log, &usermode); |
185 | parse_cmdline(cmdline, cmdtable, log, &usermode); |
186 | 186 | ||
187 | if(!dbg_open(log)) |
- | |
188 | { |
- | |
189 | strcpy(log, "/tmp1/1/i915.log"); |
- | |
190 | - | ||
191 | if(!dbg_open(log)) |
187 | if( *log && !dbg_open(log)) |
192 | { |
188 | { |
193 | printf("Can't open %s\nExit\n", log); |
189 | printf("Can't open %s\nExit\n", log); |
194 | return 0; |
190 | return 0; |
195 | }; |
- | |
196 | } |
191 | } |
197 | 192 | ||
198 | cpu_detect(); |
193 | cpu_detect(); |
199 | // dbgprintf("\ncache line size %d\n", x86_clflush_size); |
194 | // dbgprintf("\ncache line size %d\n", x86_clflush_size); |
200 | 195 | ||
201 | enum_pci_devices(); |
196 | enum_pci_devices(); |
202 | 197 | ||
203 | err = i915_init(); |
198 | err = i915_init(); |
204 | if(err) |
199 | if(err) |
205 | { |
200 | { |
206 | dbgprintf("Epic Fail :(\n"); |
201 | dbgprintf("Epic Fail :(\n"); |
207 | return 0; |
202 | return 0; |
208 | }; |
203 | }; |
209 | 204 | ||
210 | init_display_kms(main_device, &usermode); |
205 | init_display_kms(main_device, &usermode); |
211 | 206 | ||
212 | err = RegService("DISPLAY", display_handler); |
207 | err = RegService("DISPLAY", display_handler); |
213 | 208 | ||
214 | if( err != 0) |
209 | if( err != 0) |
215 | dbgprintf("Set DISPLAY handler\n"); |
210 | dbgprintf("Set DISPLAY handler\n"); |
216 | 211 | ||
217 | driver_wq_state = 1; |
212 | driver_wq_state = 1; |
218 | 213 | ||
219 | CreateKernelThread(i915_driver_thread); |
214 | CreateKernelThread(i915_driver_thread); |
220 | 215 | ||
221 | return err; |
216 | return err; |
222 | }; |
217 | }; |
223 | 218 | ||
224 | 219 | ||
225 | #define CURRENT_API 0x0200 /* 2.00 */ |
220 | #define CURRENT_API 0x0200 /* 2.00 */ |
226 | #define COMPATIBLE_API 0x0100 /* 1.00 */ |
221 | #define COMPATIBLE_API 0x0100 /* 1.00 */ |
227 | 222 | ||
228 | #define API_VERSION (COMPATIBLE_API << 16) | CURRENT_API |
223 | #define API_VERSION (COMPATIBLE_API << 16) | CURRENT_API |
229 | #define DISPLAY_VERSION API_VERSION |
224 | #define DISPLAY_VERSION API_VERSION |
230 | 225 | ||
231 | 226 | ||
232 | #define SRV_GETVERSION 0 |
227 | #define SRV_GETVERSION 0 |
233 | #define SRV_ENUM_MODES 1 |
228 | #define SRV_ENUM_MODES 1 |
234 | #define SRV_SET_MODE 2 |
229 | #define SRV_SET_MODE 2 |
235 | #define SRV_GET_CAPS 3 |
230 | #define SRV_GET_CAPS 3 |
236 | 231 | ||
237 | #define SRV_CREATE_SURFACE 10 |
232 | #define SRV_CREATE_SURFACE 10 |
238 | #define SRV_DESTROY_SURFACE 11 |
233 | #define SRV_DESTROY_SURFACE 11 |
239 | #define SRV_LOCK_SURFACE 12 |
234 | #define SRV_LOCK_SURFACE 12 |
240 | #define SRV_UNLOCK_SURFACE 13 |
235 | #define SRV_UNLOCK_SURFACE 13 |
241 | #define SRV_RESIZE_SURFACE 14 |
236 | #define SRV_RESIZE_SURFACE 14 |
242 | #define SRV_BLIT_BITMAP 15 |
237 | #define SRV_BLIT_BITMAP 15 |
243 | #define SRV_BLIT_TEXTURE 16 |
238 | #define SRV_BLIT_TEXTURE 16 |
244 | #define SRV_BLIT_VIDEO 17 |
239 | #define SRV_BLIT_VIDEO 17 |
245 | 240 | ||
246 | 241 | ||
247 | #define SRV_GET_PCI_INFO 20 |
242 | #define SRV_GET_PCI_INFO 20 |
248 | #define SRV_I915_GET_PARAM 21 |
243 | #define SRV_I915_GET_PARAM 21 |
249 | #define SRV_I915_GEM_CREATE 22 |
244 | #define SRV_I915_GEM_CREATE 22 |
250 | #define SRV_DRM_GEM_CLOSE 23 |
245 | #define SRV_DRM_GEM_CLOSE 23 |
251 | #define SRV_DRM_GEM_FLINK 24 |
246 | #define SRV_DRM_GEM_FLINK 24 |
252 | #define SRV_DRM_GEM_OPEN 25 |
247 | #define SRV_DRM_GEM_OPEN 25 |
253 | #define SRV_I915_GEM_PIN 26 |
248 | #define SRV_I915_GEM_PIN 26 |
254 | #define SRV_I915_GEM_UNPIN 27 |
249 | #define SRV_I915_GEM_UNPIN 27 |
255 | #define SRV_I915_GEM_SET_CACHING 28 |
250 | #define SRV_I915_GEM_SET_CACHING 28 |
256 | #define SRV_I915_GEM_PWRITE 29 |
251 | #define SRV_I915_GEM_PWRITE 29 |
257 | #define SRV_I915_GEM_BUSY 30 |
252 | #define SRV_I915_GEM_BUSY 30 |
258 | #define SRV_I915_GEM_SET_DOMAIN 31 |
253 | #define SRV_I915_GEM_SET_DOMAIN 31 |
259 | #define SRV_I915_GEM_MMAP 32 |
254 | #define SRV_I915_GEM_MMAP 32 |
260 | #define SRV_I915_GEM_SET_TILING 33 |
255 | #define SRV_I915_GEM_SET_TILING 33 |
261 | #define SRV_I915_GEM_GET_TILING 34 |
256 | #define SRV_I915_GEM_GET_TILING 34 |
262 | #define SRV_I915_GEM_GET_APERTURE 35 |
257 | #define SRV_I915_GEM_GET_APERTURE 35 |
263 | #define SRV_I915_GEM_MMAP_GTT 36 |
258 | #define SRV_I915_GEM_MMAP_GTT 36 |
264 | #define SRV_I915_GEM_THROTTLE 37 |
259 | #define SRV_I915_GEM_THROTTLE 37 |
265 | #define SRV_I915_GEM_EXECBUFFER2 38 |
260 | #define SRV_I915_GEM_EXECBUFFER2 38 |
266 | #define SRV_I915_GEM_WAIT 39 |
261 | #define SRV_I915_GEM_WAIT 39 |
267 | #define SRV_I915_GEM_CONTEXT_CREATE 40 |
262 | #define SRV_I915_GEM_CONTEXT_CREATE 40 |
268 | #define SRV_I915_GEM_CONTEXT_DESTROY 41 |
263 | #define SRV_I915_GEM_CONTEXT_DESTROY 41 |
269 | #define SRV_I915_REG_READ 42 |
264 | #define SRV_I915_REG_READ 42 |
270 | 265 | ||
271 | #define SRV_FBINFO 43 |
266 | #define SRV_FBINFO 43 |
272 | #define SRV_MASK_UPDATE 44 |
267 | #define SRV_MASK_UPDATE 44 |
273 | 268 | ||
274 | 269 | ||
275 | #define check_input(size) \ |
270 | #define check_input(size) \ |
276 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
271 | if( unlikely((inp==NULL)||(io->inp_size != (size))) ) \ |
277 | break; |
272 | break; |
278 | 273 | ||
279 | #define check_output(size) \ |
274 | #define check_output(size) \ |
280 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
275 | if( unlikely((outp==NULL)||(io->out_size != (size))) ) \ |
281 | break; |
276 | break; |
282 | 277 | ||
283 | int _stdcall display_handler(ioctl_t *io) |
278 | int _stdcall display_handler(ioctl_t *io) |
284 | { |
279 | { |
285 | struct drm_file *file; |
280 | struct drm_file *file; |
286 | 281 | ||
287 | int retval = -1; |
282 | int retval = -1; |
288 | u32_t *inp; |
283 | u32_t *inp; |
289 | u32_t *outp; |
284 | u32_t *outp; |
290 | 285 | ||
291 | inp = io->input; |
286 | inp = io->input; |
292 | outp = io->output; |
287 | outp = io->output; |
293 | 288 | ||
294 | file = drm_file_handlers[0]; |
289 | file = drm_file_handlers[0]; |
295 | 290 | ||
296 | switch(io->io_code) |
291 | switch(io->io_code) |
297 | { |
292 | { |
298 | case SRV_GETVERSION: |
293 | case SRV_GETVERSION: |
299 | check_output(4); |
294 | check_output(4); |
300 | *outp = DISPLAY_VERSION; |
295 | *outp = DISPLAY_VERSION; |
301 | retval = 0; |
296 | retval = 0; |
302 | break; |
297 | break; |
303 | 298 | ||
304 | case SRV_ENUM_MODES: |
299 | case SRV_ENUM_MODES: |
305 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
300 | // dbgprintf("SRV_ENUM_MODES inp %x inp_size %x out_size %x\n", |
306 | // inp, io->inp_size, io->out_size ); |
301 | // inp, io->inp_size, io->out_size ); |
307 | check_output(4); |
302 | check_output(4); |
308 | // check_input(*outp * sizeof(videomode_t)); |
303 | // check_input(*outp * sizeof(videomode_t)); |
309 | if( i915_modeset) |
304 | if( i915_modeset) |
310 | retval = get_videomodes((videomode_t*)inp, outp); |
305 | retval = get_videomodes((videomode_t*)inp, outp); |
311 | break; |
306 | break; |
312 | 307 | ||
313 | case SRV_SET_MODE: |
308 | case SRV_SET_MODE: |
314 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
309 | // dbgprintf("SRV_SET_MODE inp %x inp_size %x\n", |
315 | // inp, io->inp_size); |
310 | // inp, io->inp_size); |
316 | check_input(sizeof(videomode_t)); |
311 | check_input(sizeof(videomode_t)); |
317 | if( i915_modeset ) |
312 | if( i915_modeset ) |
318 | retval = set_user_mode((videomode_t*)inp); |
313 | retval = set_user_mode((videomode_t*)inp); |
319 | break; |
314 | break; |
320 | 315 | ||
321 | case SRV_GET_CAPS: |
316 | case SRV_GET_CAPS: |
322 | retval = get_driver_caps((hwcaps_t*)inp); |
317 | retval = get_driver_caps((hwcaps_t*)inp); |
323 | break; |
318 | break; |
324 | 319 | ||
325 | case SRV_CREATE_SURFACE: |
320 | case SRV_CREATE_SURFACE: |
326 | // check_input(8); |
321 | // check_input(8); |
327 | // retval = create_surface(main_device, (struct io_call_10*)inp); |
322 | // retval = create_surface(main_device, (struct io_call_10*)inp); |
328 | break; |
323 | break; |
329 | 324 | ||
330 | case SRV_LOCK_SURFACE: |
325 | case SRV_LOCK_SURFACE: |
331 | // retval = lock_surface((struct io_call_12*)inp); |
326 | // retval = lock_surface((struct io_call_12*)inp); |
332 | break; |
327 | break; |
333 | 328 | ||
334 | case SRV_RESIZE_SURFACE: |
329 | case SRV_RESIZE_SURFACE: |
335 | // retval = resize_surface((struct io_call_14*)inp); |
330 | // retval = resize_surface((struct io_call_14*)inp); |
336 | break; |
331 | break; |
337 | 332 | ||
338 | case SRV_BLIT_BITMAP: |
333 | case SRV_BLIT_BITMAP: |
339 | // srv_blit_bitmap( inp[0], inp[1], inp[2], |
334 | // srv_blit_bitmap( inp[0], inp[1], inp[2], |
340 | // inp[3], inp[4], inp[5], inp[6]); |
335 | // inp[3], inp[4], inp[5], inp[6]); |
341 | 336 | ||
342 | // blit_tex( inp[0], inp[1], inp[2], |
337 | // blit_tex( inp[0], inp[1], inp[2], |
343 | // inp[3], inp[4], inp[5], inp[6]); |
338 | // inp[3], inp[4], inp[5], inp[6]); |
344 | 339 | ||
345 | break; |
340 | break; |
346 | 341 | ||
347 | case SRV_GET_PCI_INFO: |
342 | case SRV_GET_PCI_INFO: |
348 | get_pci_info((struct pci_device *)inp); |
343 | get_pci_info((struct pci_device *)inp); |
349 | retval = 0; |
344 | retval = 0; |
350 | break; |
345 | break; |
351 | 346 | ||
352 | case SRV_I915_GET_PARAM: |
347 | case SRV_I915_GET_PARAM: |
353 | retval = i915_getparam(main_device, inp, file); |
348 | retval = i915_getparam(main_device, inp, file); |
354 | break; |
349 | break; |
355 | 350 | ||
356 | case SRV_I915_GEM_CREATE: |
351 | case SRV_I915_GEM_CREATE: |
357 | retval = i915_gem_create_ioctl(main_device, inp, file); |
352 | retval = i915_gem_create_ioctl(main_device, inp, file); |
358 | break; |
353 | break; |
359 | 354 | ||
360 | case SRV_DRM_GEM_CLOSE: |
355 | case SRV_DRM_GEM_CLOSE: |
361 | retval = drm_gem_close_ioctl(main_device, inp, file); |
356 | retval = drm_gem_close_ioctl(main_device, inp, file); |
362 | break; |
357 | break; |
363 | 358 | ||
364 | case SRV_DRM_GEM_FLINK: |
359 | case SRV_DRM_GEM_FLINK: |
365 | retval = drm_gem_flink_ioctl(main_device, inp, file); |
360 | retval = drm_gem_flink_ioctl(main_device, inp, file); |
366 | break; |
361 | break; |
367 | 362 | ||
368 | case SRV_DRM_GEM_OPEN: |
363 | case SRV_DRM_GEM_OPEN: |
369 | retval = drm_gem_open_ioctl(main_device, inp, file); |
364 | retval = drm_gem_open_ioctl(main_device, inp, file); |
370 | break; |
365 | break; |
371 | 366 | ||
372 | case SRV_I915_GEM_PIN: |
367 | case SRV_I915_GEM_PIN: |
373 | retval = i915_gem_pin_ioctl(main_device, inp, file); |
368 | retval = i915_gem_pin_ioctl(main_device, inp, file); |
374 | break; |
369 | break; |
375 | 370 | ||
376 | case SRV_I915_GEM_UNPIN: |
371 | case SRV_I915_GEM_UNPIN: |
377 | retval = i915_gem_unpin_ioctl(main_device, inp, file); |
372 | retval = i915_gem_unpin_ioctl(main_device, inp, file); |
378 | break; |
373 | break; |
379 | 374 | ||
380 | case SRV_I915_GEM_SET_CACHING: |
375 | case SRV_I915_GEM_SET_CACHING: |
381 | retval = i915_gem_set_caching_ioctl(main_device, inp, file); |
376 | retval = i915_gem_set_caching_ioctl(main_device, inp, file); |
382 | break; |
377 | break; |
383 | 378 | ||
384 | case SRV_I915_GEM_PWRITE: |
379 | case SRV_I915_GEM_PWRITE: |
385 | retval = i915_gem_pwrite_ioctl(main_device, inp, file); |
380 | retval = i915_gem_pwrite_ioctl(main_device, inp, file); |
386 | break; |
381 | break; |
387 | 382 | ||
388 | case SRV_I915_GEM_BUSY: |
383 | case SRV_I915_GEM_BUSY: |
389 | retval = i915_gem_busy_ioctl(main_device, inp, file); |
384 | retval = i915_gem_busy_ioctl(main_device, inp, file); |
390 | break; |
385 | break; |
391 | 386 | ||
392 | case SRV_I915_GEM_SET_DOMAIN: |
387 | case SRV_I915_GEM_SET_DOMAIN: |
393 | retval = i915_gem_set_domain_ioctl(main_device, inp, file); |
388 | retval = i915_gem_set_domain_ioctl(main_device, inp, file); |
394 | break; |
389 | break; |
395 | 390 | ||
396 | case SRV_I915_GEM_MMAP: |
391 | case SRV_I915_GEM_MMAP: |
397 | retval = i915_gem_mmap_ioctl(main_device, inp, file); |
392 | retval = i915_gem_mmap_ioctl(main_device, inp, file); |
398 | break; |
393 | break; |
399 | 394 | ||
400 | case SRV_I915_GEM_SET_TILING: |
395 | case SRV_I915_GEM_SET_TILING: |
401 | retval = i915_gem_set_tiling(main_device, inp, file); |
396 | retval = i915_gem_set_tiling(main_device, inp, file); |
402 | break; |
397 | break; |
403 | 398 | ||
404 | case SRV_I915_GEM_GET_TILING: |
399 | case SRV_I915_GEM_GET_TILING: |
405 | retval = i915_gem_get_tiling(main_device, inp, file); |
400 | retval = i915_gem_get_tiling(main_device, inp, file); |
406 | break; |
401 | break; |
407 | 402 | ||
408 | case SRV_I915_GEM_GET_APERTURE: |
403 | case SRV_I915_GEM_GET_APERTURE: |
409 | // printf("SRV_I915_GEM_GET_APERTURE "); |
404 | // printf("SRV_I915_GEM_GET_APERTURE "); |
410 | retval = i915_gem_get_aperture_ioctl(main_device, inp, file); |
405 | retval = i915_gem_get_aperture_ioctl(main_device, inp, file); |
411 | // printf(" retval=%d\n", retval); |
406 | // printf(" retval=%d\n", retval); |
412 | break; |
407 | break; |
413 | 408 | ||
414 | case SRV_I915_GEM_MMAP_GTT: |
409 | case SRV_I915_GEM_MMAP_GTT: |
415 | retval = i915_gem_mmap_gtt_ioctl(main_device, inp, file); |
410 | retval = i915_gem_mmap_gtt_ioctl(main_device, inp, file); |
416 | break; |
411 | break; |
417 | 412 | ||
418 | case SRV_I915_GEM_THROTTLE: |
413 | case SRV_I915_GEM_THROTTLE: |
419 | retval = i915_gem_throttle_ioctl(main_device, inp, file); |
414 | retval = i915_gem_throttle_ioctl(main_device, inp, file); |
420 | break; |
415 | break; |
421 | 416 | ||
422 | case SRV_I915_GEM_EXECBUFFER2: |
417 | case SRV_I915_GEM_EXECBUFFER2: |
423 | // printf("SRV_I915_GEM_EXECBUFFER2\n"); |
418 | // printf("SRV_I915_GEM_EXECBUFFER2\n"); |
424 | retval = i915_gem_execbuffer2(main_device, inp, file); |
419 | retval = i915_gem_execbuffer2(main_device, inp, file); |
425 | break; |
420 | break; |
426 | 421 | ||
427 | case SRV_I915_GEM_WAIT: |
422 | case SRV_I915_GEM_WAIT: |
428 | retval = i915_gem_wait_ioctl(main_device, inp, file); |
423 | retval = i915_gem_wait_ioctl(main_device, inp, file); |
429 | break; |
424 | break; |
430 | 425 | ||
431 | case SRV_I915_GEM_CONTEXT_CREATE: |
426 | case SRV_I915_GEM_CONTEXT_CREATE: |
432 | retval = i915_gem_context_create_ioctl(main_device, inp, file); |
427 | retval = i915_gem_context_create_ioctl(main_device, inp, file); |
433 | break; |
428 | break; |
434 | 429 | ||
435 | case SRV_I915_GEM_CONTEXT_DESTROY: |
430 | case SRV_I915_GEM_CONTEXT_DESTROY: |
436 | retval = i915_gem_context_destroy_ioctl(main_device, inp, file); |
431 | retval = i915_gem_context_destroy_ioctl(main_device, inp, file); |
437 | break; |
432 | break; |
438 | 433 | ||
439 | case SRV_I915_REG_READ: |
434 | case SRV_I915_REG_READ: |
440 | retval = i915_reg_read_ioctl(main_device, inp, file); |
435 | retval = i915_reg_read_ioctl(main_device, inp, file); |
441 | break; |
436 | break; |
442 | 437 | ||
443 | case SRV_FBINFO: |
438 | case SRV_FBINFO: |
444 | retval = i915_fbinfo(inp); |
439 | retval = i915_fbinfo(inp); |
445 | break; |
440 | break; |
446 | 441 | ||
447 | case SRV_MASK_UPDATE: |
442 | case SRV_MASK_UPDATE: |
448 | retval = i915_mask_update(main_device, inp, file); |
443 | retval = i915_mask_update(main_device, inp, file); |
449 | break; |
444 | break; |
450 | }; |
445 | }; |
451 | 446 | ||
452 | return retval; |
447 | return retval; |
453 | } |
448 | } |
454 | 449 | ||
455 | 450 | ||
456 | #define PCI_CLASS_REVISION 0x08 |
451 | #define PCI_CLASS_REVISION 0x08 |
457 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
452 | #define PCI_CLASS_DISPLAY_VGA 0x0300 |
458 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
453 | #define PCI_CLASS_BRIDGE_HOST 0x0600 |
459 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
454 | #define PCI_CLASS_BRIDGE_ISA 0x0601 |
460 | 455 | ||
461 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
456 | int pci_scan_filter(u32_t id, u32_t busnr, u32_t devfn) |
462 | { |
457 | { |
463 | u16_t vendor, device; |
458 | u16_t vendor, device; |
464 | u32_t class; |
459 | u32_t class; |
465 | int ret = 0; |
460 | int ret = 0; |
466 | 461 | ||
467 | vendor = id & 0xffff; |
462 | vendor = id & 0xffff; |
468 | device = (id >> 16) & 0xffff; |
463 | device = (id >> 16) & 0xffff; |
469 | 464 | ||
470 | if(vendor == 0x8086) |
465 | if(vendor == 0x8086) |
471 | { |
466 | { |
472 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
467 | class = PciRead32(busnr, devfn, PCI_CLASS_REVISION); |
473 | class >>= 16; |
468 | class >>= 16; |
474 | 469 | ||
475 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
470 | if( (class == PCI_CLASS_DISPLAY_VGA) || |
476 | (class == PCI_CLASS_BRIDGE_HOST) || |
471 | (class == PCI_CLASS_BRIDGE_HOST) || |
477 | (class == PCI_CLASS_BRIDGE_ISA)) |
472 | (class == PCI_CLASS_BRIDGE_ISA)) |
478 | ret = 1; |
473 | ret = 1; |
479 | } |
474 | } |
480 | return ret; |
475 | return ret; |
481 | }; |
476 | }; |
482 | 477 | ||
483 | 478 | ||
484 | 479 | ||
485 | 480 | ||
486 | static inline void __cpuid(unsigned int *eax, unsigned int *ebx, |
481 | static inline void __cpuid(unsigned int *eax, unsigned int *ebx, |
487 | unsigned int *ecx, unsigned int *edx) |
482 | unsigned int *ecx, unsigned int *edx) |
488 | { |
483 | { |
489 | /* ecx is often an input as well as an output. */ |
484 | /* ecx is often an input as well as an output. */ |
490 | asm volatile("cpuid" |
485 | asm volatile("cpuid" |
491 | : "=a" (*eax), |
486 | : "=a" (*eax), |
492 | "=b" (*ebx), |
487 | "=b" (*ebx), |
493 | "=c" (*ecx), |
488 | "=c" (*ecx), |
494 | "=d" (*edx) |
489 | "=d" (*edx) |
495 | : "0" (*eax), "2" (*ecx) |
490 | : "0" (*eax), "2" (*ecx) |
496 | : "memory"); |
491 | : "memory"); |
497 | } |
492 | } |
498 | 493 | ||
499 | 494 | ||
500 | 495 | ||
501 | static inline void cpuid(unsigned int op, |
496 | static inline void cpuid(unsigned int op, |
502 | unsigned int *eax, unsigned int *ebx, |
497 | unsigned int *eax, unsigned int *ebx, |
503 | unsigned int *ecx, unsigned int *edx) |
498 | unsigned int *ecx, unsigned int *edx) |
504 | { |
499 | { |
505 | *eax = op; |
500 | *eax = op; |
506 | *ecx = 0; |
501 | *ecx = 0; |
507 | __cpuid(eax, ebx, ecx, edx); |
502 | __cpuid(eax, ebx, ecx, edx); |
508 | } |
503 | } |
509 | 504 | ||
510 | void cpu_detect() |
505 | void cpu_detect() |
511 | { |
506 | { |
512 | u32 junk, tfms, cap0, misc; |
507 | u32 junk, tfms, cap0, misc; |
513 | 508 | ||
514 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); |
509 | cpuid(0x00000001, &tfms, &misc, &junk, &cap0); |
515 | 510 | ||
516 | if (cap0 & (1<<19)) |
511 | if (cap0 & (1<<19)) |
517 | { |
512 | { |
518 | x86_clflush_size = ((misc >> 8) & 0xff) * 8; |
513 | x86_clflush_size = ((misc >> 8) & 0xff) * 8; |
519 | } |
514 | } |
520 | 515 | ||
521 | tsc_khz = (unsigned int)(GetCpuFreq()/1000); |
516 | tsc_khz = (unsigned int)(GetCpuFreq()/1000); |
522 | } |
517 | } |
523 | 518 | ||
524 | 519 | ||
525 | int get_driver_caps(hwcaps_t *caps) |
520 | int get_driver_caps(hwcaps_t *caps) |
526 | { |
521 | { |
527 | int ret = 0; |
522 | int ret = 0; |
528 | 523 | ||
529 | switch(caps->idx) |
524 | switch(caps->idx) |
530 | { |
525 | { |
531 | case 0: |
526 | case 0: |
532 | caps->opt[0] = 0; |
527 | caps->opt[0] = 0; |
533 | caps->opt[1] = 0; |
528 | caps->opt[1] = 0; |
534 | break; |
529 | break; |
535 | 530 | ||
536 | case 1: |
531 | case 1: |
537 | caps->cap1.max_tex_width = 4096; |
532 | caps->cap1.max_tex_width = 4096; |
538 | caps->cap1.max_tex_height = 4096; |
533 | caps->cap1.max_tex_height = 4096; |
539 | break; |
534 | break; |
540 | default: |
535 | default: |
541 | ret = 1; |
536 | ret = 1; |
542 | }; |
537 | }; |
543 | caps->idx = 1; |
538 | caps->idx = 1; |
544 | return ret; |
539 | return ret; |
545 | } |
540 | } |
546 | 541 | ||
547 | 542 | ||
548 | void get_pci_info(struct pci_device *dev) |
543 | void get_pci_info(struct pci_device *dev) |
549 | { |
544 | { |
550 | struct pci_dev *pdev = main_device->pdev; |
545 | struct pci_dev *pdev = main_device->pdev; |
551 | 546 | ||
552 | memset(dev, sizeof(*dev), 0); |
547 | memset(dev, sizeof(*dev), 0); |
553 | 548 | ||
554 | dev->domain = 0; |
549 | dev->domain = 0; |
555 | dev->bus = pdev->busnr; |
550 | dev->bus = pdev->busnr; |
556 | dev->dev = pdev->devfn >> 3; |
551 | dev->dev = pdev->devfn >> 3; |
557 | dev->func = pdev->devfn & 7; |
552 | dev->func = pdev->devfn & 7; |
558 | dev->vendor_id = pdev->vendor; |
553 | dev->vendor_id = pdev->vendor; |
559 | dev->device_id = pdev->device; |
554 | dev->device_id = pdev->device; |
560 | dev->revision = pdev->revision; |
555 | dev->revision = pdev->revision; |
561 | }; |
556 | }; |
562 | 557 | ||
563 | 558 | ||
564 | 559 | ||
565 | char *strstr(const char *cs, const char *ct); |
560 | char *strstr(const char *cs, const char *ct); |
566 | 561 | ||
567 | static int my_atoi(char **cmd) |
562 | static int my_atoi(char **cmd) |
568 | { |
563 | { |
569 | char* p = *cmd; |
564 | char* p = *cmd; |
570 | int val = 0; |
565 | int val = 0; |
571 | int sign = 1; |
566 | int sign = 1; |
572 | 567 | ||
573 | if(*p == '-') |
568 | if(*p == '-') |
574 | { |
569 | { |
575 | sign = -1; |
570 | sign = -1; |
576 | p++; |
571 | p++; |
577 | }; |
572 | }; |
578 | 573 | ||
579 | for (;; *p++) { |
574 | for (;; *p++) { |
580 | switch (*p) { |
575 | switch (*p) { |
581 | case '0' ... '9': |
576 | case '0' ... '9': |
582 | val = 10*val+(*p-'0'); |
577 | val = 10*val+(*p-'0'); |
583 | break; |
578 | break; |
584 | default: |
579 | default: |
585 | *cmd = p; |
580 | *cmd = p; |
586 | return val*sign; |
581 | return val*sign; |
587 | } |
582 | } |
588 | } |
583 | } |
589 | } |
584 | } |
590 | 585 | ||
591 | char* parse_mode(char *p, videomode_t *mode) |
586 | char* parse_mode(char *p, videomode_t *mode) |
592 | { |
587 | { |
593 | char c; |
588 | char c; |
594 | 589 | ||
595 | while( (c = *p++) == ' '); |
590 | while( (c = *p++) == ' '); |
596 | 591 | ||
597 | if( c ) |
592 | if( c ) |
598 | { |
593 | { |
599 | p--; |
594 | p--; |
600 | 595 | ||
601 | mode->width = my_atoi(&p); |
596 | mode->width = my_atoi(&p); |
602 | if(*p == 'x') p++; |
597 | if(*p == 'x') p++; |
603 | 598 | ||
604 | mode->height = my_atoi(&p); |
599 | mode->height = my_atoi(&p); |
605 | if(*p == 'x') p++; |
600 | if(*p == 'x') p++; |
606 | 601 | ||
607 | mode->bpp = 32; |
602 | mode->bpp = 32; |
608 | 603 | ||
609 | mode->freq = my_atoi(&p); |
604 | mode->freq = my_atoi(&p); |
610 | 605 | ||
611 | if( mode->freq == 0 ) |
606 | if( mode->freq == 0 ) |
612 | mode->freq = 60; |
607 | mode->freq = 60; |
613 | } |
608 | } |
614 | 609 | ||
615 | return p; |
610 | return p; |
616 | }; |
611 | }; |
617 | 612 | ||
618 | 613 | ||
619 | static char* parse_path(char *p, char *log) |
614 | static char* parse_path(char *p, char *log) |
620 | { |
615 | { |
621 | char c; |
616 | char c; |
622 | 617 | ||
623 | while( (c = *p++) == ' '); |
618 | while( (c = *p++) == ' '); |
624 | p--; |
619 | p--; |
625 | while( (c = *log++ = *p++) && (c != ' ')); |
620 | while((c = *p++) && (c != ' ')) |
- | 621 | *log++ = c; |
|
- | 622 | ||
626 | *log = 0; |
623 | *log = 0; |
627 | 624 | ||
628 | return p; |
625 | return p; |
629 | }; |
626 | }; |
630 | 627 | ||
631 | void parse_cmdline(char *cmdline, struct cmdtable *table, char *log, videomode_t *mode) |
628 | void parse_cmdline(char *cmdline, struct cmdtable *table, char *log, videomode_t *mode) |
632 | { |
629 | { |
633 | char *p = cmdline; |
630 | char *p = cmdline; |
634 | char *p1; |
631 | char *p1; |
635 | int val; |
632 | int val; |
636 | char c = *p++; |
633 | char c = *p++; |
637 | 634 | ||
638 | if( table ) |
635 | if( table ) |
639 | { |
636 | { |
640 | while(table->key) |
637 | while(table->key) |
641 | { |
638 | { |
642 | if(p1 = strstr(cmdline, table->key)) |
639 | if(p1 = strstr(cmdline, table->key)) |
643 | { |
640 | { |
644 | p1+= table->size; |
641 | p1+= table->size; |
645 | *table->val = my_atoi(&p1); |
642 | *table->val = my_atoi(&p1); |
646 | // printf("%s %d\n", table->key, *table->val); |
- | |
647 | } |
643 | } |
648 | table++; |
644 | table++; |
649 | } |
645 | } |
650 | } |
646 | } |
651 | 647 | ||
652 | while( c ) |
648 | while( c ) |
653 | { |
649 | { |
654 | if( c == '-') |
650 | if( c == '-') |
655 | { |
651 | { |
656 | switch(*p++) |
652 | switch(*p++) |
657 | { |
653 | { |
658 | case 'l': |
654 | case 'l': |
659 | p = parse_path(p, log); |
655 | p = parse_path(p, log); |
660 | break; |
656 | break; |
661 | 657 | ||
662 | case 'm': |
658 | case 'm': |
663 | p = parse_mode(p, mode); |
659 | p = parse_mode(p, mode); |
664 | break; |
660 | break; |
665 | }; |
661 | }; |
666 | }; |
662 | }; |
667 | c = *p++; |
663 | c = *p++; |
668 | }; |
664 | }; |
669 | }; |
665 | }; |
670 | 666 | ||
671 | char *strstr(const char *cs, const char *ct) |
667 | char *strstr(const char *cs, const char *ct) |
672 | { |
668 | { |
673 | int d0, d1; |
669 | int d0, d1; |
674 | register char *__res; |
670 | register char *__res; |
675 | __asm__ __volatile__( |
671 | __asm__ __volatile__( |
676 | "movl %6,%%edi\n\t" |
672 | "movl %6,%%edi\n\t" |
677 | "repne\n\t" |
673 | "repne\n\t" |
678 | "scasb\n\t" |
674 | "scasb\n\t" |
679 | "notl %%ecx\n\t" |
675 | "notl %%ecx\n\t" |
680 | "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ |
676 | "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ |
681 | "movl %%ecx,%%edx\n" |
677 | "movl %%ecx,%%edx\n" |
682 | "1:\tmovl %6,%%edi\n\t" |
678 | "1:\tmovl %6,%%edi\n\t" |
683 | "movl %%esi,%%eax\n\t" |
679 | "movl %%esi,%%eax\n\t" |
684 | "movl %%edx,%%ecx\n\t" |
680 | "movl %%edx,%%ecx\n\t" |
685 | "repe\n\t" |
681 | "repe\n\t" |
686 | "cmpsb\n\t" |
682 | "cmpsb\n\t" |
687 | "je 2f\n\t" /* also works for empty string, see above */ |
683 | "je 2f\n\t" /* also works for empty string, see above */ |
688 | "xchgl %%eax,%%esi\n\t" |
684 | "xchgl %%eax,%%esi\n\t" |
689 | "incl %%esi\n\t" |
685 | "incl %%esi\n\t" |
690 | "cmpb $0,-1(%%eax)\n\t" |
686 | "cmpb $0,-1(%%eax)\n\t" |
691 | "jne 1b\n\t" |
687 | "jne 1b\n\t" |
692 | "xorl %%eax,%%eax\n\t" |
688 | "xorl %%eax,%%eax\n\t" |
693 | "2:" |
689 | "2:" |
694 | : "=a" (__res), "=&c" (d0), "=&S" (d1) |
690 | : "=a" (__res), "=&c" (d0), "=&S" (d1) |
695 | : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct) |
691 | : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct) |
696 | : "dx", "di"); |
692 | : "dx", "di"); |
697 | return __res; |
693 | return __res; |
698 | }19)) |
694 | }19)) |
- | 695 | ><19)) |
|
- | 696 | >><>0,1>0,1>-1,0,1>-1,0-7>0,1> |
|
699 | ><19)) |
- | |
700 | >><>0,1>0,1>-1,0,1>-1,0-7>0,1> |
- |