copy.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* ----------------------------------------------------------------------- *
  2. *
  3. * Copyright (C) 1991, 1992 Linus Torvalds
  4. * Copyright 2007 rPath, Inc. - All Rights Reserved
  5. *
  6. * This file is part of the Linux kernel, and is made available under
  7. * the terms of the GNU General Public License version 2.
  8. *
  9. * ----------------------------------------------------------------------- */
  10. /*
  11. * Memory copy routines
  12. */
  13. .code16gcc
  14. .text
  15. .globl memcpy
  16. .type memcpy, @function
  17. memcpy:
  18. pushw %si
  19. pushw %di
  20. movw %ax, %di
  21. movw %dx, %si
  22. pushw %cx
  23. shrw $2, %cx
  24. rep; movsl
  25. popw %cx
  26. andw $3, %cx
  27. rep; movsb
  28. popw %di
  29. popw %si
  30. ret
  31. .size memcpy, .-memcpy
  32. .globl memset
  33. .type memset, @function
  34. memset:
  35. pushw %di
  36. movw %ax, %di
  37. movzbl %dl, %eax
  38. imull $0x01010101,%eax
  39. pushw %cx
  40. shrw $2, %cx
  41. rep; stosl
  42. popw %cx
  43. andw $3, %cx
  44. rep; stosb
  45. popw %di
  46. ret
  47. .size memset, .-memset
  48. .globl copy_from_fs
  49. .type copy_from_fs, @function
  50. copy_from_fs:
  51. pushw %ds
  52. pushw %fs
  53. popw %ds
  54. call memcpy
  55. popw %ds
  56. ret
  57. .size copy_from_fs, .-copy_from_fs
  58. .globl copy_to_fs
  59. .type copy_to_fs, @function
  60. copy_to_fs:
  61. pushw %es
  62. pushw %fs
  63. popw %es
  64. call memcpy
  65. popw %es
  66. ret
  67. .size copy_to_fs, .-copy_to_fs
  68. #if 0 /* Not currently used, but can be enabled as needed */
  69. .globl copy_from_gs
  70. .type copy_from_gs, @function
  71. copy_from_gs:
  72. pushw %ds
  73. pushw %gs
  74. popw %ds
  75. call memcpy
  76. popw %ds
  77. ret
  78. .size copy_from_gs, .-copy_from_gs
  79. .globl copy_to_gs
  80. .type copy_to_gs, @function
  81. copy_to_gs:
  82. pushw %es
  83. pushw %gs
  84. popw %es
  85. call memcpy
  86. popw %es
  87. ret
  88. .size copy_to_gs, .-copy_to_gs
  89. #endif