Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
1.1 KiB

  1. //
  2. // MODULE : MEMIO.C
  3. // PURPOSE : Memory mapped IO
  4. // AUTHOR : JBS Yadawa
  5. // CREATED : 7/20/96
  6. //
  7. //
  8. // Copyright (C) 1996 SGS-THOMSON Microelectronics
  9. //
  10. //
  11. // REVISION HISTORY :
  12. //
  13. // DATE :
  14. //
  15. // COMMENTS :
  16. //
  17. #include "common.h"
  18. #include "stdefs.h"
  19. #include <conio.h>
  20. #include "memio.h"
  21. volatile PUCHAR lpBase = NULL;
  22. volatile PUSHORT lpWordPtr = NULL;
  23. volatile PULONG lpDwordPtr = NULL;
  24. BOOL FARAPI AllocMemoryBase(DWORD addr, DWORD memsize)
  25. {
  26. lpBase = (volatile PUCHAR)addr;
  27. lpWordPtr = (volatile PUSHORT)addr;
  28. lpDwordPtr = (volatile PULONG)addr;
  29. return TRUE;
  30. }
  31. BOOL FARAPI FreeMemoryBase(void)
  32. {
  33. lpBase = NULL;
  34. return TRUE;
  35. }
  36. void FARAPI memOutByte(WORD reg, BYTE Val)
  37. {
  38. lpBase[reg] = Val;
  39. }
  40. void FARAPI memOutWord(WORD reg, WORD Val)
  41. {
  42. lpWordPtr[reg>>1] = Val;
  43. }
  44. void FARAPI memOutDword(WORD reg, DWORD Val)
  45. {
  46. lpDwordPtr[reg>>2] = Val;
  47. }
  48. BYTE FARAPI memInByte(WORD reg)
  49. {
  50. return lpBase[reg];
  51. }
  52. WORD FARAPI memInWord(WORD reg)
  53. {
  54. return lpWordPtr[reg>>1];
  55. }
  56. DWORD FARAPI memInDword(WORD reg)
  57. {
  58. return lpDwordPtr[reg>>2];
  59. }
  60.