ports.inc 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. This file is part of the Free Pascal run time library.
  3. and implements some stuff for protected mode programming
  4. Copyright (c) 1999-2000 by the Free Pascal development team.
  5. These files adds support for TP styled port accesses
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  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.
  11. **********************************************************************}
  12. {$asmmode ATT}
  13. { to give easy port access like tp with port[] }
  14. {$ifdef VER3_0}
  15. procedure tport.writeport(p : word;data : byte);assembler;stdcall;
  16. asm
  17. movw p,%dx
  18. movb data,%al
  19. outb %al,%dx
  20. end;
  21. function tport.readport(p : word) : byte;assembler;stdcall;
  22. asm
  23. movw p,%dx
  24. inb %dx,%al
  25. end;
  26. procedure tportw.writeport(p : word;data : word);assembler;stdcall;
  27. asm
  28. movw p,%dx
  29. movw data,%ax
  30. outw %ax,%dx
  31. end;
  32. function tportw.readport(p : word) : word;assembler;stdcall;
  33. asm
  34. movw p,%dx
  35. inw %dx,%ax
  36. end;
  37. procedure tportl.writeport(p : word;data : longint);assembler;stdcall;
  38. asm
  39. movw p,%dx
  40. movl data,%eax
  41. outl %eax,%dx
  42. end;
  43. function tportl.readport(p : word) : longint;assembler;stdcall;
  44. asm
  45. movw p,%dx
  46. inl %dx,%eax
  47. end;
  48. {$else VER3_0}
  49. procedure tport.writeport(p : word;data : byte);inline;
  50. begin
  51. fpc_x86_outportb(p,data);
  52. end;
  53. function tport.readport(p : word) : byte;inline;
  54. begin
  55. readport:=fpc_x86_inportb(p);
  56. end;
  57. procedure tportw.writeport(p : word;data : word);inline;
  58. begin
  59. fpc_x86_outportw(p,data);
  60. end;
  61. function tportw.readport(p : word) : word;inline;
  62. begin
  63. readport:=fpc_x86_inportw(p);
  64. end;
  65. procedure tportl.writeport(p : word;data : longint);inline;
  66. begin
  67. fpc_x86_outportl(p,data);
  68. end;
  69. function tportl.readport(p : word) : longint;inline;
  70. begin
  71. readport:=fpc_x86_inportl(p);
  72. end;
  73. {$endif VER3_0}