clear_page.S 1.9 KB

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