aboutsummaryrefslogtreecommitdiff
path: root/include/segment.h
blob: 694eb4b9eaf7b2664907b5991dd5cc6179b21711 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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 */