clear_page.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifdef CONFIG_ITANIUM
  14. # define L3_LINE_SIZE 64 // Itanium L3 line size
  15. # define PREFETCH_LINES 9 // magic number
  16. #else
  17. # define L3_LINE_SIZE 128 // McKinley L3 line size
  18. # define PREFETCH_LINES 12 // magic number
  19. #endif
  20. #define saved_lc r2
  21. #define dst_fetch r3
  22. #define dst1 r8
  23. #define dst2 r9
  24. #define dst3 r10
  25. #define dst4 r11
  26. #define dst_last r31
  27. GLOBAL_ENTRY(clear_page)
  28. .prologue
  29. .regstk 1,0,0,0
  30. mov r16 = PAGE_SIZE/L3_LINE_SIZE-1 // main loop count, -1=repeat/until
  31. .save ar.lc, saved_lc
  32. mov saved_lc = ar.lc
  33. .body
  34. mov ar.lc = (PREFETCH_LINES - 1)
  35. mov dst_fetch = in0
  36. adds dst1 = 16, in0
  37. adds dst2 = 32, in0
  38. ;;
  39. .fetch: stf.spill.nta [dst_fetch] = f0, L3_LINE_SIZE
  40. adds dst3 = 48, in0 // executing this multiple times is harmless
  41. br.cloop.sptk.few .fetch
  42. ;;
  43. addl dst_last = (PAGE_SIZE - PREFETCH_LINES*L3_LINE_SIZE), dst_fetch
  44. mov ar.lc = r16 // one L3 line per iteration
  45. adds dst4 = 64, in0
  46. ;;
  47. #ifdef CONFIG_ITANIUM
  48. // Optimized for Itanium
  49. 1: stf.spill.nta [dst1] = f0, 64
  50. stf.spill.nta [dst2] = f0, 64
  51. cmp.lt p8,p0=dst_fetch, dst_last
  52. ;;
  53. #else
  54. // Optimized for McKinley
  55. 1: stf.spill.nta [dst1] = f0, 64
  56. stf.spill.nta [dst2] = f0, 64
  57. stf.spill.nta [dst3] = f0, 64
  58. stf.spill.nta [dst4] = f0, 128
  59. cmp.lt p8,p0=dst_fetch, dst_last
  60. ;;
  61. stf.spill.nta [dst1] = f0, 64
  62. stf.spill.nta [dst2] = f0, 64
  63. #endif
  64. stf.spill.nta [dst3] = f0, 64
  65. (p8) stf.spill.nta [dst_fetch] = f0, L3_LINE_SIZE
  66. br.cloop.sptk.few 1b
  67. ;;
  68. mov ar.lc = saved_lc // restore lc
  69. br.ret.sptk.many rp
  70. END(clear_page)