All pastes #633453 Raw Edit

Unnamed

public text v1 · immutable
#633453 ·published 2007-07-25 18:20 UTC
rendered paste body
	void dump_segment(entry_t &segment)
	{
		cdebug.print("base %x, limit %x, type %x(%c), dpl %x, %s present, %s-bit, granularity %d\n",
			segment.base_low + (segment.base_middle << 16) + (segment.base_high << 24),
			segment.limit_low + (segment.gflags.limit_high << 16),
			segment.aflags.type, "sd"[segment.aflags.system],
			segment.aflags.dpl, segment.aflags.present? "":"not",
			segment.gflags.bitness? "16":"32",
			segment.gflags.granularity);
	}

// You may have to change your GDT struct to something like this:
	typedef struct __attribute__((packed))
	{
		uint_16 limit_low;
		uint_16 base_low;
		uint_8 base_middle;
		union
		{
			uint_8 access;
			struct
			{
				uint_8 type:4;
				uint_8 system:1;
				uint_8 dpl:2;
				uint_8 present:1;
			} aflags;
		};
		union
		{
			uint_8 granularity;
			struct
			{
				uint_8 limit_high:4;
				uint_8 unused:1;
				uint_8 reserved:1;
				uint_8 bitness:1;
				uint_8 granularity:1;
			} gflags;
		};
		uint_8 base_high;
	} entry_t;