在重建系统的时候发现linux-0.11原来这两个宏函数经常出错,迫不得已。改写了这两个函数。
extern inline void set_base(void * addr, unsigned long base)
{
*((char *)addr+2) = (short) base;
base >>= 16;
*((char *)addr+4) = (char) base;
base >>= 8;
*((char *)addr+7) = (char) base;
}
extern inline void set_limit(void * addr, unsigned long limit)
{
limit -= 1;
limit >>= 12; /* 假设界限以4kb为度量 */
*((unsigned short *)addr) = (unsigned short) limit;
limit >>= 16;
limit &= 0x0f;
*((char *)addr+6) &= (char)0xf0;
*((char *)addr+6) |= (char)limit;
}
而以下是linux-0.11中的两个宏函数。。。特附上
#define _set_base(addr, base) /
__asm__("movw %%dx, %0/n/t" /
"rorl $16, %%edx/n/t" /
"movb %%dl, %1/n/t" /
"movb %%dh, %2" /
::"m" (*((addr)+2)), /
"m" (*((addr)+4)), /
"m" (*((addr)+7)), /
"edx" (base))
#define _set_limit(addr, limit) /
__asm__ volatile ("movw %%dx, %0/n/t" /
"rorl $16, %%edx/n/t" /
"movb $1, %%dh/n/t" /
"andb $0xf0, %%dh/n/t" /
"orb %%dh, %%dl/n/t" /
"movb %%dl, %1" /
::"m" (*(addr)), /
"m" (*((addr)+6)), /
"edx" (limit))
#define set_base(ldt, base) _set_base(((char *)&(ldt)), base)
#define set_limit(ldt, limit) _set_limit(((char *)(ldt)), (limit-1)>>12)