Matthew Fioravante
2012-Oct-02 14:27 UTC
[PATCH 01/12] Add ioread/iowrite functions to mini-os
This patch adds iowritexx() and ioreadxx() functions for interacting
with hardware memory to mini-os. The functions are available in a header
iorw.h
Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>
---
Changes since last
* remove ia64 support
diff --git a/extras/mini-os/arch/x86/iorw.c b/extras/mini-os/arch/x86/iorw.c
new file mode 100644
index 0000000..3080769
--- /dev/null
+++ b/extras/mini-os/arch/x86/iorw.c
@@ -0,0 +1,35 @@
+#include <mini-os/iorw.h>
+
+void iowrite8(volatile void* addr, uint8_t val)
+{
+ *((volatile uint8_t*)addr) = val;
+}
+void iowrite16(volatile void* addr, uint16_t val)
+{
+ *((volatile uint16_t*)addr) = val;
+}
+void iowrite32(volatile void* addr, uint32_t val)
+{
+ *((volatile uint32_t*)addr) = val;
+}
+void iowrite64(volatile void* addr, uint64_t val)
+{
+ *((volatile uint64_t*)addr) = val;
+}
+
+uint8_t ioread8(volatile void* addr)
+{
+ return *((volatile uint8_t*) addr);
+}
+uint16_t ioread16(volatile void* addr)
+{
+ return *((volatile uint16_t*) addr);
+}
+uint32_t ioread32(volatile void* addr)
+{
+ return *((volatile uint32_t*) addr);
+}
+uint64_t ioread64(volatile void* addr)
+{
+ return *((volatile uint64_t*) addr);
+}
diff --git a/extras/mini-os/include/iorw.h b/extras/mini-os/include/iorw.h
new file mode 100644
index 0000000..d5ec065
--- /dev/null
+++ b/extras/mini-os/include/iorw.h
@@ -0,0 +1,16 @@
+#ifndef MINIOS_IORW_H
+#define MINIOS_IORW_H
+
+#include <mini-os/types.h>
+
+void iowrite8(volatile void* addr, uint8_t val);
+void iowrite16(volatile void* addr, uint16_t val);
+void iowrite32(volatile void* addr, uint32_t val);
+void iowrite64(volatile void* addr, uint64_t val);
+
+uint8_t ioread8(volatile void* addr);
+uint16_t ioread16(volatile void* addr);
+uint32_t ioread32(volatile void* addr);
+uint64_t ioread64(volatile void* addr);
+
+#endif
--
1.7.4.4
Ian Campbell
2012-Oct-05 14:37 UTC
Re: [PATCH 01/12] Add ioread/iowrite functions to mini-os
On Tue, 2012-10-02 at 15:27 +0100, Matthew Fioravante wrote:> This patch adds iowritexx() and ioreadxx() functions for interacting > with hardware memory to mini-os. The functions are available in a header > iorw.h > > Signed-off-by: Matthew Fioravante <matthew.fioravante@jhuapl.edu> > Acked-by: Samuel Thibault <samuel.thibault@ens-lyons.org>I was looking for a version of this (and the other acked mini-os patches to apply) but I''m a bit confused as to which version I should be taking and in which order I should apply things. This one seems to be 01/12 but I only seem to have 4 patches in the /12 series (#1, #4 and two lots of #8) in my INBOX -- I''m not sure what''s happened to the rest of them. The previous posting was NN/11 but I don''t want to be cherry picking bits of different series (I''ll only mess it up). So, to avoid confusion can you collect the Acks/Reviewed-bys and resend using git format-patch''s --subject-prefix option to tag the [PATCH V2] (I know there have been more than 2 previous postings but we haven''t been counting until now). Thanks, Ian.> --- > Changes since last > * remove ia64 support > > diff --git a/extras/mini-os/arch/x86/iorw.c b/extras/mini-os/arch/x86/iorw.c > new file mode 100644 > index 0000000..3080769 > --- /dev/null > +++ b/extras/mini-os/arch/x86/iorw.c > @@ -0,0 +1,35 @@ > +#include <mini-os/iorw.h> > + > +void iowrite8(volatile void* addr, uint8_t val) > +{ > + *((volatile uint8_t*)addr) = val; > +} > +void iowrite16(volatile void* addr, uint16_t val) > +{ > + *((volatile uint16_t*)addr) = val; > +} > +void iowrite32(volatile void* addr, uint32_t val) > +{ > + *((volatile uint32_t*)addr) = val; > +} > +void iowrite64(volatile void* addr, uint64_t val) > +{ > + *((volatile uint64_t*)addr) = val; > +} > + > +uint8_t ioread8(volatile void* addr) > +{ > + return *((volatile uint8_t*) addr); > +} > +uint16_t ioread16(volatile void* addr) > +{ > + return *((volatile uint16_t*) addr); > +} > +uint32_t ioread32(volatile void* addr) > +{ > + return *((volatile uint32_t*) addr); > +} > +uint64_t ioread64(volatile void* addr) > +{ > + return *((volatile uint64_t*) addr); > +} > diff --git a/extras/mini-os/include/iorw.h b/extras/mini-os/include/iorw.h > new file mode 100644 > index 0000000..d5ec065 > --- /dev/null > +++ b/extras/mini-os/include/iorw.h > @@ -0,0 +1,16 @@ > +#ifndef MINIOS_IORW_H > +#define MINIOS_IORW_H > + > +#include <mini-os/types.h> > + > +void iowrite8(volatile void* addr, uint8_t val); > +void iowrite16(volatile void* addr, uint16_t val); > +void iowrite32(volatile void* addr, uint32_t val); > +void iowrite64(volatile void* addr, uint64_t val); > + > +uint8_t ioread8(volatile void* addr); > +uint16_t ioread16(volatile void* addr); > +uint32_t ioread32(volatile void* addr); > +uint64_t ioread64(volatile void* addr); > + > +#endif