copy.S 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. * arch/i386/boot/copy.S
  12. *
  13. * Memory copy routines
  14. */
  15. .code16gcc
  16. .text
  17. .globl memcpy
  18. .type memcpy, @function
  19. memcpy:
  20. pushw %si
  21. pushw %di
  22. movw %ax, %di
  23. movw %dx, %si
  24. pushw %cx
  25. shrw $2, %cx
  26. rep; movsl
  27. popw %cx
  28. andw $3, %cx
  29. rep; movsb
  30. popw %di
  31. popw %si
  32. ret
  33. .size memcpy, .-memcpy
  34. .globl memset
  35. .type memset, @function
  36. memset:
  37. pushw %di
  38. movw %ax, %di
  39. movzbl %dl, %eax
  40. imull $0x01010101,%eax
  41. pushw %cx
  42. shrw $2, %cx
  43. rep; stosl
  44. popw %cx
  45. andw $3, %cx
  46. rep; stosb
  47. popw %di
  48. ret
  49. .size memset, .-memset
  50. .globl copy_from_fs
  51. .type copy_from_fs, @function
  52. copy_from_fs:
  53. pushw %ds
  54. pushw %fs
  55. popw %ds
  56. call memcpy
  57. popw %ds
  58. ret
  59. .size copy_from_fs, .-copy_from_fs
  60. .globl copy_to_fs
  61. .type copy_to_fs, @function
  62. copy_to_fs:
  63. pushw %es
  64. pushw %fs
  65. popw %es
  66. call memcpy
  67. popw %es
  68. ret
  69. .size copy_to_fs, .-copy_to_fs
  70. #if 0 /* Not currently used, but can be enabled as needed */
  71. .globl copy_from_gs
  72. .type copy_from_gs, @function
  73. copy_from_gs:
  74. pushw %ds
  75. pushw %gs
  76. popw %ds
  77. call memcpy
  78. popw %ds
  79. ret
  80. .size copy_from_gs, .-copy_from_gs
  81. .globl copy_to_gs
  82. .type copy_to_gs, @function
  83. copy_to_gs:
  84. pushw %es
  85. pushw %gs
  86. popw %es
  87. call memcpy
  88. popw %es
  89. ret
  90. .size copy_to_gs, .-copy_to_gs
  91. #endif