clear_page.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 1999-2002 Hewlett-Packard Co
  3. * Stephane Eranian <eranian@hpl.hp.com>
  4. * David Mosberger-Tang <davidm@hpl.hp.com>
  5. * Copyright (C) 2002 Ken Chen <kenneth.w.chen@intel.com>
  6. *
  7. * 1/06/01 davidm Tuned for Itanium.
  8. * 2/12/02 kchen Tuned for both Itanium and McKinley
  9. * 3/08/02 davidm Some more tweaking
  10. */
  11. #include <asm/asmmacro.h>
  12. #include <asm/page.h>
  13. #include <asm/export.h>
  14. #ifdef CONFIG_ITANIUM
  15. # define L3_LINE_SIZE 64 // Itanium L3 line size
  16. # define PREFETCH_LINES 9 // magic number
  17. #else
  18. # define L3_LINE_SIZE 128 // McKinley L3 line size
  19. # define PREFETCH_LINES 12 // magic number
  20. #endif
  21. #define saved_lc r2
  22. #define dst_fetch r3
  23. #define dst1 r8
  24. #define dst2 r9
  25. #define dst3 r10
  26. #define dst4 r11
  27. #define dst_last r31
  28. GLOBAL_ENTRY(clear_page)
  29. .prologue
  30. .regstk 1,0,0,0
  31. mov r16 = PAGE_SIZE/L3_LINE_SIZE-1 // main loop count, -1=repeat/until
  32. .save ar.lc, saved_lc
  33. mov saved_lc = ar.lc
  34. .body
  35. mov ar.lc = (PREFETCH_LINES - 1)
  36. mov dst_fetch = in0
  37. adds dst1 = 16, in0
  38. adds dst2 = 32, in0
  39. ;;
  40. .fetch: stf.spill.nta [dst_fetch] = f0, L3_LINE_SIZE
  41. adds dst3 = 48, in0 // executing this multiple times is harmless
  42. br.cloop.sptk.few .fetch
  43. ;;
  44. addl dst_last = (PAGE_SIZE - PREFETCH_LINES*L3_LINE_SIZE), dst_fetch
  45. mov ar.lc = r16 // one L3 line per iteration
  46. adds dst4 = 64, in0
  47. ;;
  48. #ifdef CONFIG_ITANIUM
  49. // Optimized for Itanium
  50. 1: stf.spill.nta [dst1] = f0, 64
  51. stf.spill.nta [dst2] = f0, 64
  52. cmp.lt p8,p0=dst_fetch, dst_last
  53. ;;
  54. #else
  55. // Optimized for McKinley
  56. 1: stf.spill.nta [dst1] = f0, 64
  57. stf.spill.nta [dst2] = f0, 64
  58. stf.spill.nta [dst3] = f0, 64
  59. stf.spill.nta [dst4] = f0, 128
  60. cmp.lt p8,p0=dst_fetch, dst_last
  61. ;;
  62. stf.spill.nta [dst1] = f0, 64
  63. stf.spill.nta [dst2] = f0, 64
  64. #endif
  65. stf.spill.nta [dst3] = f0, 64
  66. (p8) stf.spill.nta [dst_fetch] = f0, L3_LINE_SIZE
  67. br.cloop.sptk.few 1b
  68. ;;
  69. mov ar.lc = saved_lc // restore lc
  70. br.ret.sptk.many rp
  71. END(clear_page)
  72. EXPORT_SYMBOL(clear_page)