예제 #1
0
def set640x480x16():
	ports.inb(0x3DA)
	ports.outb(0, 0x3C0)

	ports.writevec(0x3C4,0x3C5,  1,1,4,0,6)

	ports.outb(0xe3, 0x3C2)
	ports.writevec(0x3C4,0x3C5,  3)

	ports.outb(0x11, 0x3D4)
	ports.outb(   0, 0x3D5)

	ports.writevec(0x3D4,0x3D5,
                0x5f, 0x4f, 0x50, 0x82,  0x54, 0x80, 0x0b, 0x3e,
                0x00, 0x40, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
                0xea, 0x8c, 0xdf, 0x28,  0x00, 0xe7, 0x04, 0xe3,
                0xff)

	ports.writevec(0x3CC,0x3CA,  1)
        ports.writevec(0x3CE,0x3CF,
                0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x05, 0x0f,
                0xff)

	ports.inb(0x3DA)
	ports.writevec(0x3C0,0x3C0,
                0x00, 0x01, 0x02, 0x03,  0x04, 0x05, 0x06, 0x07,
                0x08, 0x09, 0x0A, 0x0B,  0x0C, 0x0D, 0x0E, 0x0F,
                0x01, 0x00, 0x0F, 0x00)

	ports.inb(0x3DA)
	ports.outb(0x20, 0x3C0)
예제 #2
0
def set320x200x256():
	ports.inb(0x3DA)
	ports.outb(0, 0x3C0)

	ports.writevec(0x3C4,0x3C5,  3,1,0xf,0,0xe) # 6 for mode X
	
	ports.outb(0x63, 0x3C2)
	ports.writevec(0x3C4,0x3C5,  3)

	ports.outb(0x11, 0x3D4)
	ports.outb(   0, 0x3D5)
	ports.writevec(0x3D4,0x3D5,
		0x5f, 0x4f, 0x50, 0x82,  0x54, 0x80, 0xbf, 0x1f,
		0x00, 0x41, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
		0x9c, 0x0e, 0x8f, 0x28,  0x40, 0x96, 0xb9, 0xa3,
					# 0x00, ..., 0xe3 for mode X
		0xff)

	ports.writevec(0x3CC,0x3CA,  1)
        ports.writevec(0x3CE,0x3CF,
		0x00, 0x00, 0x00, 0x00,  0x00, 0x40, 0x05, 0x0f,
		0xff)

	ports.inb(0x3DA)
	ports.writevec(0x3C0,0x3C0,
		0x00, 0x01, 0x02, 0x03,  0x04, 0x05, 0x06, 0x07,
		0x08, 0x09, 0x0A, 0x0B,  0x0C, 0x0D, 0x0E, 0x0F,
		0x41, 0x00, 0x0F, 0x00)

	ports.inb(0x3DA)
	ports.outb(0x20, 0x3C0)
예제 #3
0
def set80x25():
    ports.inb(0x3DA)
    ports.outb(0, 0x3C0)

    ports.writevec(0x3C4, 0x3C5, 1, 0, 3, 0, 2)

    ports.outb(0x67, 0x3C2)
    ports.writevec(0x3C4, 0x3C5, 3)

    ports.outb(0x11, 0x3D4)
    ports.outb(0, 0x3D5)
    ports.writevec(0x3D4, 0x3D5, 0x5f, 0x4f, 0x50, 0x82, 0x55, 0x81, 0xbf,
                   0x1f, 0x00, 0x4f, 0x0d, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x9c,
                   0x8e, 0x8f, 0x28, 0x1f, 0x96, 0xb9, 0xa3, 0xff)

    ports.writevec(0x3CC, 0x3CA, 1)
    ports.writevec(0x3CE, 0x3CF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x0e,
                   0x00, 0xff)

    ports.inb(0x3DA)
    ports.writevec(0x3C0, 0x3C0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                   0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x0C,
                   0x00, 0x0F, 0x08)

    ports.inb(0x3DA)
    ports.outb(0x20, 0x3C0)
예제 #4
0
def set640x480x16():
    ports.inb(0x3DA)
    ports.outb(0, 0x3C0)

    ports.writevec(0x3C4, 0x3C5, 1, 1, 4, 0, 6)

    ports.outb(0xe3, 0x3C2)
    ports.writevec(0x3C4, 0x3C5, 3)

    ports.outb(0x11, 0x3D4)
    ports.outb(0, 0x3D5)

    ports.writevec(0x3D4, 0x3D5, 0x5f, 0x4f, 0x50, 0x82, 0x54, 0x80, 0x0b,
                   0x3e, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xea,
                   0x8c, 0xdf, 0x28, 0x00, 0xe7, 0x04, 0xe3, 0xff)

    ports.writevec(0x3CC, 0x3CA, 1)
    ports.writevec(0x3CE, 0x3CF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05,
                   0x0f, 0xff)

    ports.inb(0x3DA)
    ports.writevec(0x3C0, 0x3C0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                   0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x01,
                   0x00, 0x0F, 0x00)

    ports.inb(0x3DA)
    ports.outb(0x20, 0x3C0)
예제 #5
0
def set80x25():
	ports.inb(0x3DA)
	ports.outb(0, 0x3C0)

	ports.writevec(0x3C4,0x3C5,  1,0,3,0,2)

	ports.outb(0x67, 0x3C2)
	ports.writevec(0x3C4,0x3C5,  3)

	ports.outb(0x11, 0x3D4)
	ports.outb(   0, 0x3D5)
	ports.writevec(0x3D4,0x3D5,
		0x5f, 0x4f, 0x50, 0x82,  0x55, 0x81, 0xbf, 0x1f,
		0x00, 0x4f, 0x0d, 0x0e,  0x00, 0x00, 0x00, 0x00,
		0x9c, 0x8e, 0x8f, 0x28,  0x1f, 0x96, 0xb9, 0xa3,
		0xff)

	ports.writevec(0x3CC,0x3CA,  1)
        ports.writevec(0x3CE,0x3CF,
		0x00, 0x00, 0x00, 0x00,  0x00, 0x10, 0x0e, 0x00,
		0xff)

	ports.inb(0x3DA)
	ports.writevec(0x3C0,0x3C0,
		0x00, 0x01, 0x02, 0x03,  0x04, 0x05, 0x06, 0x07,
		0x08, 0x09, 0x0A, 0x0B,  0x0C, 0x0D, 0x0E, 0x0F,
		0x0C, 0x00, 0x0F, 0x08)

	ports.inb(0x3DA)
	ports.outb(0x20, 0x3C0)
예제 #6
0
파일: keyb.py 프로젝트: thompson42/cleese
def translate_at(scancode):
    if scancode == 0x71 and _alt == 1 and _ctl == 1:
        ports.outb(0xfe, 0x64)  # reboot
    if scancode == 0xE0: return None  # FIXME

    if break_at(scancode) == 1:
        return None

    if scancode > 0x60: return None  # FIXME
    if _ctl == 1: return None  # chr(ord(shifted[scancode]) & 0x1F)
    elif _shift == 1: return shft_at[scancode]
    else: return nosh_at[scancode]
예제 #7
0
def translate_at(scancode):
    if scancode == 0x71 and _alt == 1 and _ctl == 1:
	ports.outb(0xfe, 0x64) # reboot
    if scancode == 0xE0: return None		# FIXME

    if break_at(scancode) == 1:
	return None

    if scancode > 0x60: return None	# FIXME
    if _ctl == 1:	return None	# chr(ord(shifted[scancode]) & 0x1F)
    elif _shift == 1:	return shft_at[scancode]
    else:		return nosh_at[scancode]
예제 #8
0
def set320x200x256():
    ports.inb(0x3DA)
    ports.outb(0, 0x3C0)

    ports.writevec(0x3C4, 0x3C5, 3, 1, 0xf, 0, 0xe)  # 6 for mode X

    ports.outb(0x63, 0x3C2)
    ports.writevec(0x3C4, 0x3C5, 3)

    ports.outb(0x11, 0x3D4)
    ports.outb(0, 0x3D5)
    ports.writevec(
        0x3D4,
        0x3D5,
        0x5f,
        0x4f,
        0x50,
        0x82,
        0x54,
        0x80,
        0xbf,
        0x1f,
        0x00,
        0x41,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
        0x9c,
        0x0e,
        0x8f,
        0x28,
        0x40,
        0x96,
        0xb9,
        0xa3,
        # 0x00, ..., 0xe3 for mode X
        0xff)

    ports.writevec(0x3CC, 0x3CA, 1)
    ports.writevec(0x3CE, 0x3CF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05,
                   0x0f, 0xff)

    ports.inb(0x3DA)
    ports.writevec(0x3C0, 0x3C0, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
                   0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x41,
                   0x00, 0x0F, 0x00)

    ports.inb(0x3DA)
    ports.outb(0x20, 0x3C0)
예제 #9
0
def vgadefaultpalette():
    i = 0
    while i < 128:  # for i in range(256):
        ports.outb(i, 0x3C8)
        ports.outb(r[i], 0x3C9)
        ports.outb(g[i], 0x3C9)
        ports.outb(b[i], 0x3C9)
        i = i + 1
예제 #10
0
def vgadefaultpalette():
	i = 0
	while i < 128:	# for i in range(256):
		ports.outb(i, 0x3C8)
		ports.outb(r[i], 0x3C9)
		ports.outb(g[i], 0x3C9)
		ports.outb(b[i], 0x3C9)
		i = i + 1
예제 #11
0
def translate_xt(scancode):
    global _shift, _ctl, _alt
    if scancode == 0xE0 and _alt == 1 and _ctl == 1:
	ports.outb(0xfe, 0x64) # reboot

    if (scancode & 0x80): # high bit set (key release)
    	if scancode == 0x9D:   _ctl = 0;   return None
    	elif scancode == 0xAA: _shift = 0; return None
    	elif scancode == 0xB6: _shift = 0; return None
	elif scancode == 0xB8: _alt = 0;   return None
        return None

    if scancode == 0x1D:   _ctl = 1;   return None
    elif scancode == 0x2A: _shift = 1; return None
    elif scancode == 0x36: _shift = 1; return None
    elif scancode == 0x38: _alt = 1;   return None

    if scancode > 0x3F: return None	# FIXME
    if _ctl == 1:	return None	# chr(ord(shifted[scancode]) & 0x1F)
    elif _shift == 1:	return shft_xt[scancode]
    else:		return nosh_xt[scancode]
예제 #12
0
파일: keyb.py 프로젝트: thompson42/cleese
def translate_xt(scancode):
    global _shift, _ctl, _alt
    if scancode == 0xE0 and _alt == 1 and _ctl == 1:
        ports.outb(0xfe, 0x64)  # reboot

    if (scancode & 0x80):  # high bit set (key release)
        if scancode == 0x9D:
            _ctl = 0
            return None
        elif scancode == 0xAA:
            _shift = 0
            return None
        elif scancode == 0xB6:
            _shift = 0
            return None
        elif scancode == 0xB8:
            _alt = 0
            return None
        return None

    if scancode == 0x1D:
        _ctl = 1
        return None
    elif scancode == 0x2A:
        _shift = 1
        return None
    elif scancode == 0x36:
        _shift = 1
        return None
    elif scancode == 0x38:
        _alt = 1
        return None

    if scancode > 0x3F: return None  # FIXME
    if _ctl == 1: return None  # chr(ord(shifted[scancode]) & 0x1F)
    elif _shift == 1: return shft_xt[scancode]
    else: return nosh_xt[scancode]
예제 #13
0
def vgaunchain():
	ports.outb(4, 0x3CE); ports.outb(2, 0x3CF)	# plane 2
	ports.writevec(0x3C4,0x3C5,  3,1,4,0,6)		# unchained
	ports.outb(0x14, 0x3D4); ports.outb(0x00, 0x3D5)
	ports.outb(0x17, 0x3D4); ports.outb(0xe3, 0x3D5)
예제 #14
0
def key_isr():
    ports.outb(0xfe, 0x64)  # reboot!
예제 #15
0
파일: ne2000.py 프로젝트: thompson42/cleese
def configure_device(adapter_addr, mac_address):

    print "Configuring network device..."

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    ports.outb(adapter_addr + ds0_dcr, DSDC_WTS | DSDC_BMS | DSDC_FT1)

    ports.outb(adapter_addr + ds0_rbcr0, 0)
    ports.outb(adapter_addr + ds0_rbcr1, 0)

    ports.outb(adapter_addr + ds0_rcr, DSRC_MON)

    ports.outb(adapter_addr + ds0_tcr, DSTC_LB0)

    ports.outb(adapter_addr + ds0_pstart, RBUF / DS_PGSIZE)
    ports.outb(adapter_addr + ds0_pstop, RBUFEND / DS_PGSIZE)
    ports.outb(adapter_addr + ds0_bnry, RBUF / DS_PGSIZE)

    ports.outb(adapter_addr + ds0_isr, 0xFF)

    ports.outb(adapter_addr + ds0_imr, 0XFF)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG1 | DSCM_STOP)

    for i, b in enumerate(mac_address):
        ports.outb(adapter_addr + ds1_par0 + i, b)

    for i in range(8):
        ports.outb(adapter_addr + ds1_mar0 + i, 0xFF)

    ports.outb(adapter_addr + ds1_curr, RBUF / DS_PGSIZE)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START)

    ports.outb(adapter_addr + ds0_tcr, 0)

    ports.outb(adapter_addr + ds0_rcr, DSRC_AB)

    print "Device successfully configured!"
예제 #16
0
def vgarechain():
    ports.outb(4, 0x3CE)
    ports.outb(0, 0x3CF)  # plane 0
    ports.writevec(0x3C4, 0x3C5, 3, 1, 0xf, 0, 0xe)  # chain-4
    ports.outb(0x14, 0x3D4)
    ports.outb(0x40, 0x3D5)
    ports.outb(0x17, 0x3D4)
    ports.outb(0xa3, 0x3D5)
예제 #17
0
파일: ne2000.py 프로젝트: thompson42/cleese
def fetch(adapter_addr, addr, length):

    cmd = ports.inb(adapter_addr + ds_cmd)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START)

    ports.outb(adapter_addr + ds0_isr, DSIS_RDC)
    ports.outb(adapter_addr + ds0_rbcr0, length)
    ports.outb(adapter_addr + ds0_rbcr1, length >> 8)
    ports.outb(adapter_addr + ds0_rsar0, addr)
    ports.outb(adapter_addr + ds0_rsar1, addr >> 8)

    ports.outb(adapter_addr + ds_cmd, DSCM_RREAD | DSCM_PG0 | DSCM_START)

    #buffer = ports.repinsw(adapter_addr + ne_data, length / 2)
    #if length & 1:
    #    buffer += ports.inb(adapter_addr + ne_data)

    buffer = ports.repinsb(adapter_addr + ne_data, length)

    while not (ports.inb(adapter_addr + ds0_isr) & DSIS_RDC):
        pass

    ports.outb(adapter_addr + ds0_isr, DSIS_RDC)
    ports.outb(adapter_addr + ds_cmd, cmd)

    return buffer
예제 #18
0
def key_isr():
	ports.outb(0xfe,0x64)	# reboot!
예제 #19
0
def vgarechain():
	ports.outb(4, 0x3CE); ports.outb(0, 0x3CF)	# plane 0
	ports.writevec(0x3C4,0x3C5,  3,1,0xf,0,0xe)	# chain-4
	ports.outb(0x14, 0x3D4); ports.outb(0x40, 0x3D5)
	ports.outb(0x17, 0x3D4); ports.outb(0xa3, 0x3D5)
예제 #20
0
def send(ch):
	while not ready(): pass
	ports.outb(ord(ch), 0x3F8)
예제 #21
0
import ports

# simple synchronous serial port
# (enough to debug with, anyway)

def ready():
	return (ports.inb(0x3FD) & 0x20)

def send(ch):
	while not ready(): pass
	ports.outb(ord(ch), 0x3F8)

ports.outb(0x80,0x3FB)
ports.outb(0x01,0x3F8)	# baud rate:
ports.outb(0x00,0x3F9)	# 115200
ports.outb(0x03,0x3FB)
ports.outb(0x03,0x3FC)
ports.outb(0x00,0x3F9)
예제 #22
0
파일: ne2000.py 프로젝트: thompson42/cleese
def init_device(adapter_addr):

    print "Initializing network device..."

    print "Resetting device"

    val = ports.inb(adapter_addr + ne_reset)
    pause()
    ports.outb(adapter_addr + ne_reset, val)
    ports.outb(adapter_addr + ds_cmd, DSCM_STOP | DSCM_NODMA)

    i = 20000
    while i > 0:
        i = i - 1
        if ports.inb(adapter_addr + ds0_isr) & DSIS_RESET:
            break

    if not i:
        print "FAILURE: reset timed out"
        return

    print "Device successfully reset"

    ports.outb(adapter_addr + ds0_isr, 0xFF)

    ports.outb(adapter_addr + ds0_dcr, DSDC_WTS | DSDC_BMS | DSDC_FT1)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    pause()

    if ports.inb(adapter_addr + ds_cmd) != (DSCM_NODMA | DSCM_PG0 | DSCM_STOP):
        print "Initialization failed"
        return

    ports.outb(adapter_addr + ds0_tcr, 0)
    ports.outb(adapter_addr + ds0_rcr, DSRC_MON)
    ports.outb(adapter_addr + ds0_pstart, RBUF / DS_PGSIZE)
    ports.outb(adapter_addr + ds0_pstop, RBUFEND / DS_PGSIZE)
    ports.outb(adapter_addr + ds0_bnry, RBUF / DS_PGSIZE)
    ports.outb(adapter_addr + ds0_imr, 0)
    ports.outb(adapter_addr + ds0_isr, 0)
    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG1 | DSCM_STOP)
    ports.outb(adapter_addr + ds1_curr, RBUF / DS_PGSIZE)
    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    data = fetch(adapter_addr, 0, 16)
    global mac_address
    mac_address = data[0], data[2], data[4], data[6], data[8], data[10]

    print mac_address

    print "Device successfully initialized!"
예제 #23
0
def fetch(adapter_addr, addr, length):

    cmd = ports.inb(adapter_addr + ds_cmd)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START)

    ports.outb(adapter_addr + ds0_isr, DSIS_RDC)
    ports.outb(adapter_addr + ds0_rbcr0, length)
    ports.outb(adapter_addr + ds0_rbcr1, length >> 8)
    ports.outb(adapter_addr + ds0_rsar0, addr)
    ports.outb(adapter_addr + ds0_rsar1, addr >> 8)

    ports.outb(adapter_addr + ds_cmd, DSCM_RREAD | DSCM_PG0 | DSCM_START)

    #buffer = ports.repinsw(adapter_addr + ne_data, length / 2)
    #if length & 1:
    #    buffer += ports.inb(adapter_addr + ne_data)

    buffer = ports.repinsb(adapter_addr + ne_data, length)

    while not (ports.inb(adapter_addr + ds0_isr) & DSIS_RDC):
        pass

    ports.outb(adapter_addr + ds0_isr, DSIS_RDC)
    ports.outb(adapter_addr + ds_cmd, cmd)

    return buffer
예제 #24
0
def init_device(adapter_addr):

    print "Initializing network device..."

    print "Resetting device"

    val = ports.inb(adapter_addr + ne_reset)
    pause()
    ports.outb(adapter_addr + ne_reset, val)
    ports.outb(adapter_addr + ds_cmd, DSCM_STOP | DSCM_NODMA)

    i = 20000
    while i > 0:
        i = i - 1
        if ports.inb(adapter_addr + ds0_isr) & DSIS_RESET:
            break

    if not i:
        print "FAILURE: reset timed out"
        return

    print "Device successfully reset"

    ports.outb(adapter_addr + ds0_isr, 0xFF);

    ports.outb(adapter_addr + ds0_dcr, DSDC_WTS | DSDC_BMS | DSDC_FT1)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    pause()

    if ports.inb(adapter_addr + ds_cmd) != (DSCM_NODMA | DSCM_PG0 | DSCM_STOP):
        print "Initialization failed"
        return

    ports.outb(adapter_addr + ds0_tcr, 0)
    ports.outb(adapter_addr + ds0_rcr, DSRC_MON)
    ports.outb(adapter_addr + ds0_pstart, RBUF/DS_PGSIZE)
    ports.outb(adapter_addr + ds0_pstop, RBUFEND/DS_PGSIZE)
    ports.outb(adapter_addr + ds0_bnry, RBUF/DS_PGSIZE)
    ports.outb(adapter_addr + ds0_imr, 0)
    ports.outb(adapter_addr + ds0_isr, 0)
    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG1 | DSCM_STOP)
    ports.outb(adapter_addr + ds1_curr, RBUF/DS_PGSIZE)
    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    data = fetch(adapter_addr, 0, 16)
    global mac_address
    mac_address = data[0], data[2], data[4], data[6], data[8], data[10]

    print mac_address

    print "Device successfully initialized!"
예제 #25
0
def vgaunchain():
    ports.outb(4, 0x3CE)
    ports.outb(2, 0x3CF)  # plane 2
    ports.writevec(0x3C4, 0x3C5, 3, 1, 4, 0, 6)  # unchained
    ports.outb(0x14, 0x3D4)
    ports.outb(0x00, 0x3D5)
    ports.outb(0x17, 0x3D4)
    ports.outb(0xe3, 0x3D5)
예제 #26
0
def configure_device(adapter_addr, mac_address):

    print "Configuring network device..."

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_STOP)

    ports.outb(adapter_addr + ds0_dcr, DSDC_WTS | DSDC_BMS | DSDC_FT1)

    ports.outb(adapter_addr + ds0_rbcr0, 0)
    ports.outb(adapter_addr + ds0_rbcr1, 0)

    ports.outb(adapter_addr + ds0_rcr, DSRC_MON)

    ports.outb(adapter_addr + ds0_tcr, DSTC_LB0)

    ports.outb(adapter_addr + ds0_pstart, RBUF/DS_PGSIZE)
    ports.outb(adapter_addr + ds0_pstop, RBUFEND/DS_PGSIZE)
    ports.outb(adapter_addr + ds0_bnry, RBUF/DS_PGSIZE)

    ports.outb(adapter_addr + ds0_isr, 0xFF)

    ports.outb(adapter_addr + ds0_imr, 0XFF)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG1 | DSCM_STOP)

    for i, b in enumerate(mac_address):
        ports.outb(adapter_addr + ds1_par0 + i, b)

    for i in range(8):
        ports.outb(adapter_addr + ds1_mar0 + i, 0xFF)

    ports.outb(adapter_addr + ds1_curr, RBUF/DS_PGSIZE)

    ports.outb(adapter_addr + ds_cmd, DSCM_NODMA | DSCM_PG0 | DSCM_START)

    ports.outb(adapter_addr + ds0_tcr, 0)

    ports.outb(adapter_addr + ds0_rcr, DSRC_AB)

    print "Device successfully configured!"