mmio.pp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {
  2. Copyright (c) 1998-2022 by the Free Pascal development team
  3. Memory mapped IO helpers
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {$IFNDEF FPC_DOTTEDUNITS}
  18. unit mmio;
  19. {$ENDIF FPC_DOTTEDUNITS}
  20. interface
  21. procedure DUMMY(Count: DWord);
  22. procedure PUT32(Address: DWord; Value: DWord); inline;
  23. function GET32(Address: DWord) : DWord; inline;
  24. implementation
  25. procedure DUMMY(Count: DWord);
  26. var
  27. i : DWord;
  28. begin
  29. for i := 0 to Count do
  30. begin
  31. asm
  32. nop
  33. end;
  34. end;
  35. end;
  36. procedure PUT32(Address: DWord; Value: DWord); inline;
  37. VAR
  38. p: ^DWord;
  39. begin
  40. p := POINTER (Address);
  41. p^ := Value;
  42. end;
  43. function GET32(Address: DWord) : DWord; inline;
  44. VAR
  45. p: ^DWord;
  46. begin
  47. p := POINTER (Address);
  48. GET32 := p^;
  49. end;
  50. procedure PUT64(Address: QWord; Value: QWord); inline;
  51. VAR
  52. p: ^QWord;
  53. begin
  54. p := POINTER (Address);
  55. p^ := Value;
  56. end;
  57. function GET64(Address: QWord) : QWord; inline;
  58. VAR
  59. p: ^QWord;
  60. begin
  61. p := POINTER (Address);
  62. GET64 := p^;
  63. end;
  64. end.