plan 9 kernel history: overview | file list | diff list

pc/apm.c (diff list | history)

2000/1018/sys/src/9/pc/apm.c:1,52000/1019/sys/src/9/pc/apm.c:1,12 (short | long)
Bug fix: work around NEC Versa SX hardware issue. Comment edits.
rsc Fri Mar 4 12:44:25 2005
2000/1018    
/* 
 * Advanced Power Management 1.2 driver 
2000/1019    
 * Interface to Advanced Power Management 1.2 BIOS 
 * 
 * This is, in many ways, a giant hack, and when things settle down  
 * a bit and standardize, hopefully we can write a driver that deals 
 * more directly with the hardware and thus might be a bit cleaner. 
 *  
 * ACPI might be the answer, but at the moment this is simpler 
 * and more widespread. 
2000/1018    
 */ 
 
#include	"u.h" 
2000/1018/sys/src/9/pc/apm.c:39,442000/1019/sys/src/9/pc/apm.c:46,54
2000/1018    
 * type is 0 for system segment, 1 for code/data. 
 * 
 * clearly we know way too much about the memory unit. 
2000/1019    
 * however, knowing this much about the memory unit 
 * means that the memory unit need not know anything 
 * about us. 
2000/1018    
 * 
 * what a crock. 
 */ 
2000/1018/sys/src/9/pc/apm.c:67,792000/1019/sys/src/9/pc/apm.c:77,82
2000/1018    
	lgdt(ptr); 
} 
 
/* 
 * Must run before mmuinit, since we modify the GDT that 
 * we want the processor to inherit.  I think (but am not sure) 
 * that we could run after mmuinit on processor 0 and just 
 * modify m->gdt and then call lgdt() as mmuinit() does, 
 * but this is a bit simpler and safer. 
 */ 
static	ulong ax, cx, dx, di, ebx, esi; 
static Ureg apmu; 
static long 
2000/1018/sys/src/9/pc/apm.c:139,1442000/1019/sys/src/9/pc/apm.c:142,154
2000/1018    
		print("apm: missing register %s\n", s); 
		return; 
	} 
2000/1019    
 
	/* 
	 * The NEC Versa SX bios does not report the correct 16-bit code 
	 * segment length when loaded directly from mbr -> 9load (as compared 
	 * with going through ld.com).  We'll make both code segments 64k-1 bytes. 
	 */ 
	esi = 0xFFFFFFFF; 
2000/1018    
 
	/* 
	 * We are required by the BIOS to set up three consecutive segments, 
2000/1019/sys/src/9/pc/apm.c:162,1672000/1221/sys/src/9/pc/apm.c:162,168 (short | long)
Set new doze function pointer.
rsc Fri Mar 4 12:44:25 2005
2000/1018    
	loadgdt(); 
 
	addarchfile("apm", 0660, apmread, apmwrite); 
2000/1221    
	doze = halt; 
2000/1018    
 
print("apm0: configured cbase %.8lux off %.8lux\n", ax<<4, ebx); 
 
2000/1221/sys/src/9/pc/apm.c:97,1092000/1229/sys/src/9/pc/apm.c:97,104 (short | long)
Remove experimental attempt to resume 3C589.
rsc Fri Mar 4 12:44:25 2005
2000/1018    
apmwrite(Chan*, void *a, long n, vlong off) 
{ 
	int s; 
	if(off || n != sizeof apmu){ 
//		if(n == 5 && strncmp(a, "ether", 5) == 0){ 
//			ether589reset(); 
//			return 5; 
//		} 
2000/1229    
	if(off || n != sizeof apmu) 
2000/1018    
		error("write a Ureg"); 
	} 
 
	memmove(&apmu, a, sizeof apmu); 
	s = splhi(); 
2000/1229/sys/src/9/pc/apm.c:157,1632001/0123/sys/src/9/pc/apm.c:157,162 (short | long)
Remove doze function pointer.
rsc Fri Mar 4 12:44:25 2005
2000/1018    
	loadgdt(); 
 
	addarchfile("apm", 0660, apmread, apmwrite); 
2000/1221    
	doze = halt; 
2000/1018    
 
print("apm0: configured cbase %.8lux off %.8lux\n", ax<<4, ebx); 
 
2001/0123/sys/src/9/pc/apm.c:64,822002/0109/sys/src/9/pc/apm.c:64,69 (short | long)
Remove loadgdt after changing GDT. XXX Why?
rsc Fri Mar 4 12:44:25 2005
2000/1018    
			((base>>16)&0xFF) | SEGP | SEGPL(0) | flag; 
} 
 
static void 
loadgdt(void) 
{ 
	ulong x; 
	ushort ptr[3]; 
                 
	ptr[0] = sizeof(m->gdt); 
	x = (ulong)m->gdt; 
	ptr[1] = x & 0xFFFF; 
	ptr[2] = (x>>16) & 0xFFFF; 
	lgdt(ptr); 
} 
                 
static	ulong ax, cx, dx, di, ebx, esi; 
static Ureg apmu; 
static long 
2001/0123/sys/src/9/pc/apm.c:154,1602002/0109/sys/src/9/pc/apm.c:141,146
2000/1018    
	setgdt(APMCSEG, ax<<4, ((esi&0xFFFF)-1)&0xFFFF, SEGEXEC|SEGR|SEGD); 
	setgdt(APMCSEG16, cx<<4, ((esi>>16)-1)&0xFFFF, SEGEXEC|SEGR); 
	setgdt(APMDSEG, dx<<4, (di-1)&0xFFFF, SEGDATA|SEGW|SEGD); 
	loadgdt(); 
 
	addarchfile("apm", 0660, apmread, apmwrite); 
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)