Rev 5271 | Rev 6321 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5271 | Rev 6104 | ||
---|---|---|---|
Line 224... | Line 224... | ||
224 | * linebuf, sizeof(linebuf), true); |
224 | * linebuf, sizeof(linebuf), true); |
225 | * |
225 | * |
226 | * example output buffer: |
226 | * example output buffer: |
227 | * 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
227 | * 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO |
228 | */ |
228 | */ |
229 | void hex_dump_to_buffer(const void *buf, size_t len, int rowsize, |
229 | int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize, |
230 | int groupsize, char *linebuf, size_t linebuflen, |
230 | char *linebuf, size_t linebuflen, bool ascii) |
231 | bool ascii) |
- | |
232 | { |
231 | { |
233 | const u8 *ptr = buf; |
232 | const u8 *ptr = buf; |
- | 233 | int ngroups; |
|
234 | u8 ch; |
234 | u8 ch; |
235 | int j, lx = 0; |
235 | int j, lx = 0; |
236 | int ascii_column; |
236 | int ascii_column; |
- | 237 | int ret; |
|
Line 237... | Line 238... | ||
237 | 238 | ||
238 | if (rowsize != 16 && rowsize != 32) |
239 | if (rowsize != 16 && rowsize != 32) |
Line 239... | Line -... | ||
239 | rowsize = 16; |
- | |
240 | - | ||
241 | if (!len) |
240 | rowsize = 16; |
242 | goto nil; |
241 | |
- | 242 | if (len > rowsize) /* limit to one line at a time */ |
|
- | 243 | len = rowsize; |
|
243 | if (len > rowsize) /* limit to one line at a time */ |
244 | if (!is_power_of_2(groupsize) || groupsize > 8) |
244 | len = rowsize; |
245 | groupsize = 1; |
Line 245... | Line 246... | ||
245 | if ((len % groupsize) != 0) /* no mixed size output */ |
246 | if ((len % groupsize) != 0) /* no mixed size output */ |
246 | groupsize = 1; |
- | |
247 | - | ||
248 | switch (groupsize) { |
247 | groupsize = 1; |
Line 249... | Line 248... | ||
249 | case 8: { |
248 | |
250 | const u64 *ptr8 = buf; |
- | |
251 | int ngroups = len / groupsize; |
- | |
252 | - | ||
253 | for (j = 0; j < ngroups; j++) |
- | |
254 | lx += scnprintf(linebuf + lx, linebuflen - lx, |
249 | ngroups = len / groupsize; |
255 | "%s%16.16llx", j ? " " : "", |
- | |
Line 256... | Line 250... | ||
256 | (unsigned long long)*(ptr8 + j)); |
250 | ascii_column = rowsize * 2 + rowsize / groupsize + 1; |
257 | ascii_column = 17 * ngroups + 2; |
251 | |
258 | break; |
- | |
Line 259... | Line 252... | ||
259 | } |
252 | if (!linebuflen) |
260 | - | ||
261 | case 4: { |
- | |
262 | const u32 *ptr4 = buf; |
253 | goto overflow1; |
263 | int ngroups = len / groupsize; |
- | |
264 | - | ||
Line -... | Line 254... | ||
- | 254 | ||
- | 255 | if (!len) |
|
- | 256 | goto nil; |
|
- | 257 | ||
- | 258 | if (groupsize == 8) { |
|
- | 259 | const u64 *ptr8 = buf; |
|
- | 260 | ||
265 | for (j = 0; j < ngroups; j++) |
261 | for (j = 0; j < ngroups; j++) { |
266 | lx += scnprintf(linebuf + lx, linebuflen - lx, |
262 | ret = snprintf(linebuf + lx, linebuflen - lx, |
267 | "%s%8.8x", j ? " " : "", *(ptr4 + j)); |
263 | "%s%16.16llx", j ? " " : "", |
Line 268... | Line 264... | ||
268 | ascii_column = 9 * ngroups + 2; |
264 | (unsigned long long)*(ptr8 + j)); |
269 | break; |
265 | if (ret >= linebuflen - lx) |
270 | } |
266 | goto overflow1; |
271 | 267 | lx += ret; |
|
- | 268 | } |
|
- | 269 | } else if (groupsize == 4) { |
|
272 | case 2: { |
270 | const u32 *ptr4 = buf; |
273 | const u16 *ptr2 = buf; |
271 | |
- | 272 | for (j = 0; j < ngroups; j++) { |
|
- | 273 | ret = snprintf(linebuf + lx, linebuflen - lx, |
|
Line -... | Line 274... | ||
- | 274 | "%s%8.8x", j ? " " : "", |
|
- | 275 | *(ptr4 + j)); |
|
- | 276 | if (ret >= linebuflen - lx) |
|
- | 277 | goto overflow1; |
|
- | 278 | lx += ret; |
|
- | 279 | } |
|
- | 280 | } else if (groupsize == 2) { |
|
- | 281 | const u16 *ptr2 = buf; |
|
274 | int ngroups = len / groupsize; |
282 | |
275 | 283 | for (j = 0; j < ngroups; j++) { |
|
- | 284 | ret = snprintf(linebuf + lx, linebuflen - lx, |
|
- | 285 | "%s%4.4x", j ? " " : "", |
|
276 | for (j = 0; j < ngroups; j++) |
286 | *(ptr2 + j)); |
277 | lx += scnprintf(linebuf + lx, linebuflen - lx, |
287 | if (ret >= linebuflen - lx) |
278 | "%s%4.4x", j ? " " : "", *(ptr2 + j)); |
288 | goto overflow1; |
279 | ascii_column = 5 * ngroups + 2; |
289 | lx += ret; |
280 | break; |
290 | } |
281 | } |
291 | } else { |
282 | 292 | for (j = 0; j < len; j++) { |
|
283 | default: |
- | |
284 | for (j = 0; (j < len) && (lx + 3) <= linebuflen; j++) { |
- | |
285 | ch = ptr[j]; |
- | |
286 | linebuf[lx++] = hex_asc_hi(ch); |
293 | if (linebuflen < lx + 3) |
287 | linebuf[lx++] = hex_asc_lo(ch); |
294 | goto overflow2; |
288 | linebuf[lx++] = ' '; |
295 | ch = ptr[j]; |
Line 289... | Line 296... | ||
289 | } |
296 | linebuf[lx++] = hex_asc_hi(ch); |
- | 297 | linebuf[lx++] = hex_asc_lo(ch); |
|
- | 298 | linebuf[lx++] = ' '; |
|
290 | if (j) |
299 | } |
- | 300 | if (j) |
|
291 | lx--; |
301 | lx--; |
- | 302 | } |
|
- | 303 | if (!ascii) |
|
292 | 304 | goto nil; |
|
293 | ascii_column = 3 * rowsize + 2; |
305 | |
294 | break; |
306 | while (lx < ascii_column) { |
295 | } |
307 | if (linebuflen < lx + 2) |
- | 308 | goto overflow2; |
|
- | 309 | linebuf[lx++] = ' '; |
|
- | 310 | } |
|
296 | if (!ascii) |
311 | for (j = 0; j < len; j++) { |
- | 312 | if (linebuflen < lx + 2) |
|
- | 313 | goto overflow2; |
|
297 | goto nil; |
314 | ch = ptr[j]; |
298 | - | ||
299 | while (lx < (linebuflen - 1) && lx < (ascii_column - 1)) |
315 | linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.'; |
300 | linebuf[lx++] = ' '; |
316 | } |
301 | for (j = 0; (j < len) && (lx + 2) < linebuflen; j++) { |
317 | nil: |
302 | ch = ptr[j]; |
318 | linebuf[lx] = '\0'; |
303 | linebuf[lx++] = (isascii(ch) && isprint(ch)) ? ch : '.'; |
319 | return lx; |
Line 375... | Line 391... | ||
375 | { |
391 | { |
376 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, 16, 1, |
392 | print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, 16, 1, |
377 | buf, len, true); |
393 | buf, len, true); |
378 | } |
394 | } |
Line -... | Line 395... | ||
- | 395 | ||
- | 396 | #define KMAP_MAX 256 |
|
- | 397 | ||
- | 398 | static struct mutex kmap_mutex; |
|
- | 399 | static struct page* kmap_table[KMAP_MAX]; |
|
- | 400 | static int kmap_av; |
|
- | 401 | static int kmap_first; |
|
- | 402 | static void* kmap_base; |
|
- | 403 | ||
- | 404 | ||
- | 405 | int kmap_init() |
|
- | 406 | { |
|
- | 407 | kmap_base = AllocKernelSpace(KMAP_MAX*4096); |
|
- | 408 | if(kmap_base == NULL) |
|
- | 409 | return -1; |
|
- | 410 | ||
- | 411 | kmap_av = KMAP_MAX; |
|
- | 412 | MutexInit(&kmap_mutex); |
|
- | 413 | return 0; |
|
- | 414 | }; |
|
- | 415 | ||
- | 416 | void *kmap(struct page *page) |
|
- | 417 | { |
|
- | 418 | void *vaddr = NULL; |
|
- | 419 | int i; |
|
- | 420 | ||
- | 421 | do |
|
- | 422 | { |
|
- | 423 | MutexLock(&kmap_mutex); |
|
- | 424 | if(kmap_av != 0) |
|
- | 425 | { |
|
- | 426 | for(i = kmap_first; i < KMAP_MAX; i++) |
|
- | 427 | { |
|
- | 428 | if(kmap_table[i] == NULL) |
|
- | 429 | { |
|
- | 430 | kmap_av--; |
|
- | 431 | kmap_first = i; |
|
- | 432 | kmap_table[i] = page; |
|
- | 433 | vaddr = kmap_base + (i<<12); |
|
- | 434 | MapPage(vaddr,(addr_t)page,3); |
|
- | 435 | break; |
|
- | 436 | }; |
|
- | 437 | }; |
|
- | 438 | }; |
|
- | 439 | MutexUnlock(&kmap_mutex); |
|
- | 440 | }while(vaddr == NULL); |
|
- | 441 | ||
- | 442 | return vaddr; |
|
- | 443 | }; |
|
- | 444 | ||
- | 445 | void *kmap_atomic(struct page *page) __attribute__ ((alias ("kmap"))); |
|
- | 446 | ||
- | 447 | void kunmap(struct page *page) |
|
- | 448 | { |
|
- | 449 | void *vaddr; |
|
- | 450 | int i; |
|
- | 451 | ||
- | 452 | MutexLock(&kmap_mutex); |
|
- | 453 | ||
- | 454 | for(i = 0; i < KMAP_MAX; i++) |
|
- | 455 | { |
|
- | 456 | if(kmap_table[i] == page) |
|
- | 457 | { |
|
- | 458 | kmap_av++; |
|
- | 459 | if(i < kmap_first) |
|
- | 460 | kmap_first = i; |
|
- | 461 | kmap_table[i] = NULL; |
|
- | 462 | vaddr = kmap_base + (i<<12); |
|
- | 463 | MapPage(vaddr,0,0); |
|
- | 464 | break; |
|
- | 465 | }; |
|
- | 466 | }; |
|
- | 467 | ||
- | 468 | MutexUnlock(&kmap_mutex); |
|
- | 469 | }; |
|
- | 470 | ||
- | 471 | void kunmap_atomic(void *vaddr) |
|
- | 472 | { |
|
- | 473 | int i; |
|
- | 474 | ||
- | 475 | MapPage(vaddr,0,0); |
|
- | 476 | ||
- | 477 | i = (vaddr - kmap_base) >> 12; |
|
- | 478 | ||
- | 479 | MutexLock(&kmap_mutex); |
|
- | 480 | ||
- | 481 | kmap_av++; |
|
- | 482 | if(i < kmap_first) |
|
- | 483 | kmap_first = i; |
|
- | 484 | kmap_table[i] = NULL; |
|
- | 485 | ||
- | 486 | MutexUnlock(&kmap_mutex); |
|
379 | 487 | } |
|
380 | void msleep(unsigned int msecs) |
488 | void msleep(unsigned int msecs) |
381 | { |
489 | { |
382 | msecs /= 10; |
490 | msecs /= 10; |
Line 972... | Line 1080... | ||
972 | void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) |
1080 | void call_rcu_sched(struct rcu_head *head, void (*func)(struct rcu_head *rcu)) |
973 | { |
1081 | { |
974 | __call_rcu(head, func, &rcu_sched_ctrlblk); |
1082 | __call_rcu(head, func, &rcu_sched_ctrlblk); |
975 | }>>>>>30)); |
1083 | } |
Line -... | Line 1084... | ||
- | 1084 | ||
- | 1085 | fb_get_options(const char *name, char **option) |
|
- | 1086 | { |
|
- | 1087 | return 1; |
|
- | 1088 | ||
- | 1089 | } |
|
- | 1090 | ||
- | 1091 | ktime_t ktime_get(void) |
|
- | 1092 | { |
|
- | 1093 | ktime_t t; |
|
- | 1094 | ||
- | 1095 | t.tv64 = GetClockNs(); |
|
- | 1096 | ||
- | 1097 | return t; |
|
- | 1098 | } |
|
- | 1099 | ||
- | 1100 | void radeon_cursor_reset(struct drm_crtc *crtc) |
|
- | 1101 | { |
|
- | 1102 | ||
- | 1103 | } |
|
- | 1104 | ||
- | 1105 | /* Greatest common divisor */ |
|
- | 1106 | unsigned long gcd(unsigned long a, unsigned long b) |
|
- | 1107 | { |
|
- | 1108 | unsigned long r; |
|
- | 1109 | ||
- | 1110 | if (a < b) |
|
- | 1111 | swap(a, b); |
|
- | 1112 | ||
- | 1113 | if (!b) |
|
- | 1114 | return a; |
|
- | 1115 | while ((r = a % b) != 0) { |
|
- | 1116 | a = b; |
|
- | 1117 | b = r; |
|
- | 1118 | } |
|
- | 1119 | return b; |