aboutsummaryrefslogtreecommitdiff
path: root/include/segment.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2015-05-20 16:03:33 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2015-05-21 11:44:57 +0200
commitedba90fb16ec7224da591ab8f83efe3673853a3f (patch)
tree61b37be2e6e96a2163878e2df98e1f638ce5590e /include/segment.h
parentd092feedb023a3d631a1cd549dd1d5c18d852ac7 (diff)
downloadqboot-edba90fb16ec7224da591ab8f83efe3673853a3f.zip
qboot-edba90fb16ec7224da591ab8f83efe3673853a3f.tar.gz
qboot-edba90fb16ec7224da591ab8f83efe3673853a3f.tar.bz2
first commit
Based on x86/bios from lkvm Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'include/segment.h')
-rw-r--r--include/segment.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/segment.h b/include/segment.h
new file mode 100644
index 0000000..694eb4b
--- /dev/null
+++ b/include/segment.h
@@ -0,0 +1,19 @@
+#ifndef KVM_SEGMENT_H
+#define KVM_SEGMENT_H
+
+static inline uint32_t segment_to_flat(uint16_t selector, uint16_t offset)
+{
+ return ((uint32_t)selector << 4) + (uint32_t) offset;
+}
+
+static inline uint16_t flat_to_seg16(uint32_t address)
+{
+ return address >> 4;
+}
+
+static inline uint16_t flat_to_off16(uint32_t address, uint32_t segment)
+{
+ return address - (segment << 4);
+}
+
+#endif /* KVM_SEGMENT_H */