0001-meminfo-Access-to-io-memory-via-pointers.patch 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. From 5c0a443ba336f10a8db6a99c769aa84ad37ed4d2 Mon Sep 17 00:00:00 2001
  2. From: Vadim Kochan <vadim4j@gmail.com>
  3. Date: Wed, 20 Feb 2019 02:48:43 +0200
  4. Subject: [PATCH] meminfo: Access to io memory via pointers
  5. The main reason for this is to be able compile with musl library,
  6. because there is no support of inx/outx functions for ARM platform.
  7. Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
  8. ---
  9. meminfo.c | 11 ++++++-----
  10. 1 file changed, 6 insertions(+), 5 deletions(-)
  11. diff --git a/meminfo.c b/meminfo.c
  12. index 0b0ff23..7d9f10f 100644
  13. --- a/meminfo.c
  14. +++ b/meminfo.c
  15. @@ -22,7 +22,6 @@
  16. #include <sys/mman.h>
  17. #include <stdint.h>
  18. #include <errno.h>
  19. -#include <sys/io.h>
  20. #include <stdbool.h>
  21. #include "common.h"
  22. @@ -74,24 +73,26 @@ static enum sunxi_soc_version soc_version;
  23. unsigned int
  24. sunxi_io_read(void *base, int offset)
  25. {
  26. - return inl((unsigned long) (base + offset));
  27. + unsigned long port = (unsigned long) (base + offset);
  28. + return *((volatile unsigned long *) port);
  29. }
  30. void
  31. sunxi_io_write(void *base, int offset, unsigned int value)
  32. {
  33. - outl(value, (unsigned long) (base + offset));
  34. + unsigned long port = (unsigned long) (base + offset);
  35. + *((volatile unsigned long *) port) = value;
  36. }
  37. void
  38. sunxi_io_mask(void *base, int offset, unsigned int value, unsigned int mask)
  39. {
  40. - unsigned int tmp = inl((unsigned long) (base + offset));
  41. + unsigned int tmp = sunxi_io_read(base, offset);
  42. tmp &= ~mask;
  43. tmp |= value & mask;
  44. - outl(tmp, (unsigned long) (base + offset));
  45. + sunxi_io_write(base, offset, tmp);
  46. }
  47. --
  48. 2.14.1