ports.pp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2000 by Michael Van Canneyt
  4. member of the Free Pascal development team
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. Unit ports;
  12. {$inline on}
  13. { Implements the
  14. port[] portw[] and portl[]
  15. constructs using objects }
  16. Interface
  17. type
  18. tport = object
  19. protected
  20. procedure writeport(p : longint;data : byte);inline;
  21. function readport(p : longint) : byte;inline;
  22. public
  23. property pp[w : longint] : byte read readport write writeport;default;
  24. end;
  25. tportw = object
  26. protected
  27. procedure writeport(p : longint;data : word);inline;
  28. function readport(p : longint) : word;inline;
  29. public
  30. property pp[w : longint] : word read readport write writeport;default;
  31. end;
  32. tportl = object
  33. Protected
  34. procedure writeport(p : longint;data : longint);inline;
  35. function readport(p : longint) : longint;inline;
  36. Public
  37. property pp[w : Longint] : longint read readport write writeport;default;
  38. end;
  39. { Non-Instantiaded vars. As yet, they don't have to be instantiated,
  40. because there is no need for 'self' etc. }
  41. var
  42. port,
  43. portb : tport;
  44. portw : tportw;
  45. portl : tportl;
  46. implementation
  47. {$IFDEF VER3_0}
  48. { Bootstrapping kludge. Note that these do nothing, but since I/O ports are not
  49. necessary for bootstrapping, these are only added to make the rtl compile
  50. with 3.0.
  51. }
  52. procedure fpc_x86_outportb(p:longint;v:byte); begin end;
  53. procedure fpc_x86_outportw(p:longint;v:word); begin end;
  54. procedure fpc_x86_outportl(p:longint;v:longint); begin end;
  55. function fpc_x86_inportb(p:word):byte; begin fpc_x86_inportb:=0; end;
  56. function fpc_x86_inportw(p:word):word; begin fpc_x86_inportw:=0; end;
  57. function fpc_x86_inportl(p:word):longint; begin fpc_x86_inportl:=0; end;
  58. {$ENDIF VER3_0}
  59. { to give easy port access like tp with port[] }
  60. procedure tport.writeport(p : Longint;data : byte);inline;
  61. begin
  62. fpc_x86_outportb(p,data)
  63. end;
  64. function tport.readport(p : Longint) : byte;inline;
  65. begin
  66. readport := fpc_x86_inportb(p);
  67. end;
  68. procedure tportw.writeport(p : longint;data : word);inline;
  69. begin
  70. fpc_x86_outportw(p,data)
  71. end;
  72. function tportw.readport(p : longint) : word;inline;
  73. begin
  74. readport := fpc_x86_inportw(p);
  75. end;
  76. procedure tportl.writeport(p : longint;data : longint);inline;
  77. begin
  78. fpc_x86_outportl(p,data)
  79. end;
  80. function tportl.readport(p : longint) : longint;inline;
  81. begin
  82. readPort := fpc_x86_inportl(p);
  83. end;
  84. end.