diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/arch/i386/image/bzimage.c | 7 | ||||
| -rw-r--r-- | src/arch/i386/include/librm.h | 3 | ||||
| -rw-r--r-- | src/arch/i386/prefix/libprefix.S | 470 | ||||
| -rw-r--r-- | src/arch/i386/transitions/librm.S | 58 | ||||
| -rw-r--r-- | src/arch/i386/transitions/librm_mgmt.c | 48 | ||||
| -rw-r--r-- | src/drivers/net/r8169.c | 58 |
6 files changed, 322 insertions, 322 deletions
diff --git a/src/arch/i386/image/bzimage.c b/src/arch/i386/image/bzimage.c index ad2a04cf8..439153e21 100644 --- a/src/arch/i386/image/bzimage.c +++ b/src/arch/i386/image/bzimage.c @@ -141,6 +141,7 @@ static int bzimage_parse_cmdline ( struct image *image, "terminator '%c'\n", image, *mem ); break; } + exec_ctx->mem_limit -= 1; } return 0; @@ -266,7 +267,7 @@ static int bzimage_load_initrds ( struct image *image, return -ENOBUFS; } /* Check that we are within the kernel's range */ - if ( ( address + total_len ) > exec_ctx->mem_limit ) + if ( ( address + total_len - 1 ) > exec_ctx->mem_limit ) continue; /* Prepare and verify segment */ if ( ( rc = prep_segment ( phys_to_user ( address ), 0, @@ -315,9 +316,9 @@ static int bzimage_exec ( struct image *image ) { ( bzhdr.heap_end_ptr + 0x200 ); exec_ctx.vid_mode = bzhdr.vid_mode; if ( bzhdr.version >= 0x0203 ) { - exec_ctx.mem_limit = ( bzhdr.initrd_addr_max + 1 ); + exec_ctx.mem_limit = bzhdr.initrd_addr_max; } else { - exec_ctx.mem_limit = ( BZI_INITRD_MAX + 1 ); + exec_ctx.mem_limit = BZI_INITRD_MAX; } /* Parse command line for bootloader parameters */ diff --git a/src/arch/i386/include/librm.h b/src/arch/i386/include/librm.h index e60bc69ec..32dceed67 100644 --- a/src/arch/i386/include/librm.h +++ b/src/arch/i386/include/librm.h @@ -60,9 +60,6 @@ extern char *text16; ( ( ( void * ) &(variable) ) - ( ( void * ) text16 ) ) ) ) /* Variables in librm.S, present in the normal data segment */ -extern uint16_t rm_sp; -extern uint16_t rm_ss; -extern uint32_t pm_esp; extern uint16_t __data16 ( rm_cs ); #define rm_cs __use_data16 ( rm_cs ) extern uint16_t __text16 ( rm_ds ); diff --git a/src/arch/i386/prefix/libprefix.S b/src/arch/i386/prefix/libprefix.S index 26ec752d9..12cf9184d 100644 --- a/src/arch/i386/prefix/libprefix.S +++ b/src/arch/i386/prefix/libprefix.S @@ -47,17 +47,181 @@ .section ".data16", "aw", @progbits /**************************************************************************** - * install_block (real-mode near call) + * pm_call (real-mode near call) + * + * Call routine in 16-bit protected mode for access to extended memory + * + * Parameters: + * %ax : address of routine to call in 16-bit protected mode + * Returns: + * none + * Corrupts: + * %ax + * + * The specified routine is called in 16-bit protected mode, with: + * + * %cs : 16-bit code segment with base matching real-mode %cs + * %ss : 16-bit data segment with base matching real-mode %ss + * %ds,%es,%fs,%gs : 32-bit data segment with zero base and 4GB limit + * + **************************************************************************** + */ + +#ifndef KEEP_IT_REAL + + /* GDT for protected-mode calls */ + .section ".data16" + .align 16 +gdt: +gdt_limit: .word gdt_length - 1 +gdt_base: .long 0 + .word 0 /* padding */ +pm_cs: /* 16-bit protected-mode code segment */ + .equ PM_CS, pm_cs - gdt + .word 0xffff, 0 + .byte 0, 0x9b, 0x00, 0 +pm_ss: /* 16-bit protected-mode stack segment */ + .equ PM_SS, pm_ss - gdt + .word 0xffff, 0 + .byte 0, 0x93, 0x00, 0 +pm_ds: /* 32-bit protected-mode flat data segment */ + .equ PM_DS, pm_ds - gdt + .word 0xffff, 0 + .byte 0, 0x93, 0xcf, 0 +gdt_end: + .equ gdt_length, . - gdt + .size gdt, . - gdt + + .section ".data16" + .align 16 +pm_saved_gdt: + .long 0, 0 + .size pm_saved_gdt, . - pm_saved_gdt + + .section ".prefix.lib" + .code16 +pm_call: + /* Preserve registers, flags, GDT, and RM return point */ + pushfl + sgdt pm_saved_gdt + pushw %gs + pushw %fs + pushw %es + pushw %ds + pushw %ss + pushw %cs + pushw $99f + + /* Set up GDT bases */ + pushl %eax + pushw %bx + xorl %eax, %eax + movw %ds, %ax + shll $4, %eax + addl $gdt, %eax + movl %eax, gdt_base + movw %cs, %ax + movw $pm_cs, %bx + call set_seg_base + movw %ss, %ax + movw $pm_ss, %bx + call set_seg_base + popw %bx + popl %eax + + /* Switch CPU to protected mode and load up segment registers */ + pushl %eax + cli + lgdt gdt + movl %cr0, %eax + orb $CR0_PE, %al + movl %eax, %cr0 + ljmp $PM_CS, $1f +1: movw $PM_SS, %ax + movw %ax, %ss + movw $PM_DS, %ax + movw %ax, %ds + movw %ax, %es + movw %ax, %fs + movw %ax, %gs + popl %eax + + /* Call PM routine */ + call *%ax + + /* Set real-mode segment limits on %ds, %es, %fs and %gs */ + movw %ss, %ax + movw %ax, %ds + movw %ax, %es + movw %ax, %fs + movw %ax, %gs + + /* Return CPU to real mode */ + movl %cr0, %eax + andb $0!CR0_PE, %al + movl %eax, %cr0 + + /* Restore registers and flags */ + lret /* will ljmp to 99f */ +99: popw %ss + popw %ds + popw %es + popw %fs + popw %gs + lgdt pm_saved_gdt + popfl + + ret + .size pm_call, . - pm_call + +set_seg_base: + rolw $4, %ax + movw %ax, 2(%bx) + andw $0xfff0, 2(%bx) + movb %al, 4(%bx) + andb $0x0f, 4(%bx) + ret + .size set_seg_base, . - set_seg_base + +#endif /* KEEP_IT_REAL */ + +/**************************************************************************** + * copy_bytes (real-mode or 16-bit protected-mode near call) + * + * Copy bytes + * + * Parameters: + * %ds:esi : source address + * %es:edi : destination address + * %ecx : length + * Returns: + * %ds:esi : next source address + * %ds:esi : next destination address + * Corrupts: + * None + **************************************************************************** + */ + .section ".prefix.lib" + .code16 +copy_bytes: + pushl %ecx + rep addr32 movsb + popl %ecx + ret + .size copy_bytes, . - copy_bytes + +/**************************************************************************** + * install_block (real-mode or 16-bit protected-mode near call) * * Install block to specified address * * Parameters: - * %esi : start offset within loaded image (must be a multiple of 16) + * %ds:esi : source address (must be a multiple of 16) * %es:edi : destination address * %ecx : length of (decompressed) data * %edx : total length of block (including any uninitialised data portion) * Returns: - * %esi : end offset within image (rounded up to next multiple of 16) + * %ds:esi : next source address (will be a multiple of 16) * Corrupts: * %edi, %ecx, %edx **************************************************************************** @@ -65,46 +229,26 @@ .section ".prefix.lib" .code16 install_block: - /* Preserve registers */ - pushw %ds - pushl %eax - pushl %ebx - movl %esi, %ebx - - /* Starting segment => %ds */ - movw %cs, %ax - shrl $4, %esi - addw %si, %ax - movw %ax, %ds - xorl %esi, %esi - - /* Calculate start and length of uninitialised data portion */ - addr32 leal (%edi,%ecx), %eax - subl %ecx, %edx - - /* Do the copy */ - cld #if COMPRESS + /* Decompress source to destination */ call decompress16 #else - rep addr32 movsb + /* Copy source to destination */ + call copy_bytes #endif - /* Zero remaining space */ - movl %eax, %edi - movl %edx, %ecx - xorb %al, %al + /* Zero .bss portion */ + negl %ecx + addl %edx, %ecx + pushw %ax + xorw %ax, %ax rep addr32 stosb + popw %ax - /* Adjust %esi */ - addl %ebx, %esi + /* Round up %esi to start of next source block */ addl $0xf, %esi andl $~0xf, %esi - /* Restore registers */ - popl %ebx - popl %eax - popw %ds ret .size install_block, . - install_block @@ -154,61 +298,60 @@ alloc_basemem: /**************************************************************************** * install_basemem (real-mode near call) * - * Install .text16 and .data16 into base memory + * Install source block into base memory * - * Parameters: - * %ax : .text16 segment address - * %bx : .data16 segment address - * %esi : start offset within loaded image (must be a multiple of 16) + * Parameters: + * %esi : source physical address (must be a multiple of 16) + * %es : destination segment address + * %cx : length of (decompressed) data + * %dx : total length of block (including any uninitialised data portion) * Returns: - * %esi : end offset within image (rounded up to next multiple of 16) + * %esi : next source physical address (will be a multiple of 16) * Corrupts: - * none + * %edi, %ecx, %edx **************************************************************************** */ .section ".prefix.lib" .code16 install_basemem: /* Preserve registers */ - pushw %es - pushl %edi - pushl %ecx - pushl %edx + pushw %ds - /* Install .text16 */ - movw %ax, %es + /* Preserve original %esi */ + pushl %esi + + /* Install to specified address */ + shrl $4, %esi + movw %si, %ds + xorw %si, %si xorl %edi, %edi - movl $_text16_size, %ecx - movl %ecx, %edx + movzwl %cx, %ecx + movzwl %dx, %edx call install_block - /* Install .data16 */ - movw %bx, %es - xorl %edi, %edi - movl $_data16_progbits_size, %ecx - movl $_data16_size, %edx - call install_block + /* Fix up %esi for return */ + popl %ecx + addl %ecx, %esi /* Restore registers */ - popl %edx - popl %ecx - popl %edi - popw %es + popw %ds ret .size install_basemem, . - install_basemem /**************************************************************************** - * install_highmem (flat real-mode near call) + * install_highmem (real-mode near call) * - * Install .text and .data into high memory + * Install source block into high memory * * Parameters: - * %esi : start offset within loaded image (must be a multiple of 16) - * %es:edi : address in high memory + * %esi : source physical address (must be a multiple of 16) + * %edi : destination physical address + * %ecx : length of (decompressed) data + * %edx : total length of block (including any uninitialised data portion) * Returns: - * %esi : end offset within image (rounded up to next multiple of 16) + * %esi : next source physical address (will be a multiple of 16) * Corrupts: - * none + * %edi, %ecx, %edx **************************************************************************** */ @@ -218,112 +361,16 @@ install_basemem: .code16 install_highmem: /* Preserve registers */ - pushl %edi - pushl %ecx - pushl %edx - - /* Install .text and .data to specified address */ - movl $_textdata_progbits_size, %ecx - movl $_textdata_size, %edx - call install_block - - /* Restore registers and interrupt status */ - popl %edx - popl %ecx - popl %edi - ret - .size install_highmem, . - install_highmem - -#endif /* KEEP_IT_REAL */ - -/**************************************************************************** - * GDT for flat real mode - * - * We only ever use this GDT to set segment limits; the bases are - * unused. Also, we only change data segments, so we don't need to - * worry about the code or stack segments. This makes everything much - * simpler. - **************************************************************************** - */ - -#ifndef KEEP_IT_REAL - - .section ".prefix.lib" - .align 16 -gdt: -gdt_limit: .word gdt_length - 1 -gdt_base: .long 0 - .word 0 /* padding */ - -flat_ds: /* Flat real mode data segment */ - .equ FLAT_DS, flat_ds - gdt - .word 0xffff, 0 - .byte 0, 0x93, 0xcf, 0 - -real_ds: /* Normal real mode data segment */ - .equ REAL_DS, real_ds - gdt - .word 0xffff, 0 - .byte 0, 0x93, 0x00, 0 - -gdt_end: - .equ gdt_length, gdt_end - gdt - .size gdt, . - gdt - -#endif /* KEEP_IT_REAL */ - -/**************************************************************************** - * set_real_mode_limits (real-mode near call) - * - * Sets limits on the data segments %ds and %es. - * - * Parameters: - * %dx : segment type (FLAT_DS for 4GB or REAL_DS for 64kB) - **************************************************************************** - */ - -#ifndef KEEP_IT_REAL - - .section ".prefix.lib" - .code16 -set_real_mode_limits: - /* Preserve real-mode segment values and temporary registers */ - pushw %es - pushw %ds - pushw %bp - pushl %eax - - /* Set GDT base and load GDT */ - xorl %eax, %eax - movw %cs, %ax - shll $4, %eax - addl $gdt, %eax - pushl %eax - pushw %cs:gdt_limit - movw %sp, %bp - lgdt (%bp) - addw $6, %sp - - /* Switch to protected mode */ - movl %cr0, %eax - orb $CR0_PE, %al - movl %eax, %cr0 - - /* Set flat segment limits */ - movw %dx, %ds - movw %dx, %es + pushw %ax - /* Switch back to real mode */ - movl %cr0, %eax - andb $0!CR0_PE, %al - movl %eax, %cr0 + /* Install to specified address */ + movw $install_block, %ax + call pm_call - /* Restore real-mode segment values and temporary registers */ - popl %eax - popw %bp - popw %ds - popw %es + /* Restore registers */ + popw %ax ret - .size set_real_mode_limits, . - set_real_mode_limits + .size install_highmem, . - install_highmem #endif /* KEEP_IT_REAL */ @@ -354,72 +401,83 @@ install: .globl install_prealloc install_prealloc: /* Save registers */ + pushw %ds + pushw %es pushl %esi - pushw %dx - /* Install .text16 and .data16 */ - movl $_payload_offset, %esi + pushl %ecx + pushl %edx + + /* Sanity: clear the direction flag asap */ + cld + + /* Calculate physical address of payload (i.e. first source) */ + xorl %esi, %esi + movw %cs, %si + shll $4, %esi + addl $_payload_offset, %esi + + /* Install .text16 */ + movw %ax, %es + movw $_text16_size, %cx + movw %cx, %dx call install_basemem -#ifdef KEEP_IT_REAL - /* Preserve %ds, call init_libkir, restore registers */ - pushw %ds + /* Install .data16 */ + movw %bx, %es + movw $_data16_progbits_size, %cx + movw $_data16_size, %dx + call install_basemem + + /* Set up %ds for access to .data16 */ movw %bx, %ds + +#ifdef KEEP_IT_REAL + /* Initialise libkir */ movw %ax, (init_libkir_vector+2) lcall *init_libkir_vector - popw %ds #else - /* Preserve registers and interrupt status, and disable interrupts */ - pushfw - pushw %ds - pushw %es - pushl %ecx - cli - - /* Load up %ds and %es, and set up vectors for far calls to .text16 */ - movw %bx, %ds - xorw %cx, %cx - movw %cx, %es - movw %ax, (init_librm_vector+2) - movw %ax, (prot_call_vector+2) - /* Install .text and .data to temporary area in high memory, * prior to reading the E820 memory map and relocating * properly. */ - movw $FLAT_DS, %dx - call set_real_mode_limits movl $HIGHMEM_LOADPOINT, %edi + movl $_textdata_progbits_size, %ecx + movl $_textdata_size, %edx + pushl %edi call install_highmem + popl %edi - /* Set up initial protected-mode GDT, call relocate(). + /* Initialise librm at current location */ + movw %ax, (init_librm_vector+2) + lcall *init_librm_vector + + /* Call relocate() to determine target address for relocation. * relocate() will return with %esi, %edi and %ecx set up * ready for the copy to the new location. */ - lcall *init_librm_vector + movw %ax, (prot_call_vector+2) pushl $relocate lcall *prot_call_vector - addw $4, %sp + popl %edx /* discard */ - /* Move code to new location, set up new protected-mode GDT */ - movw $FLAT_DS, %dx - call set_real_mode_limits + /* Copy code to new location */ pushl %edi - es rep addr32 movsb + pushw %ax + movw $copy_bytes, %ax + call pm_call + popw %ax popl %edi - lcall *init_librm_vector - /* Restore real-mode segment limits */ - movw $REAL_DS, %dx - call set_real_mode_limits + /* Initialise librm at new location */ + lcall *init_librm_vector - /* Restore registers and interrupt status */ +#endif + /* Restore registers */ + popl %edx popl %ecx + popl %esi popw %es popw %ds - popfw -#endif - popw %dx - popl %esi ret .size install_prealloc, . - install_prealloc diff --git a/src/arch/i386/transitions/librm.S b/src/arch/i386/transitions/librm.S index 2072ee3e9..fbf3b2ac5 100644 --- a/src/arch/i386/transitions/librm.S +++ b/src/arch/i386/transitions/librm.S @@ -186,9 +186,14 @@ real_to_prot: pushl _data16 addw $16, %cx /* %ecx must be less than 64kB anyway */ - /* Real-mode %ss:%sp => %bp:%esi */ + /* Real-mode %ss:%sp => %ebp:%edx and virtual address => %esi */ + xorl %ebp, %ebp movw %ss, %bp - movzwl %sp, %esi + movzwl %sp, %edx + movl %ebp, %eax + shll $4, %eax + leal (%eax,%edx), %esi + subl _virt_offset, %esi /* Switch to protected mode */ cli @@ -200,23 +205,24 @@ real_to_prot: .section ".text" .code32 1: - /* Set up protected-mode data segments */ + /* Set up protected-mode data segments and stack pointer */ movw $VIRTUAL_DS, %ax movw %ax, %ds movw %ax, %es movw %ax, %fs movw %ax, %gs - - /* Move data from RM stack to PM stack and set up PM stack */ - movl pm_esp, %esp - subl %ecx, %esp - movl %esp, %edi - rep ss movsb movw %ax, %ss + movl pm_esp, %esp /* Record real-mode %ss:sp (after removal of data) */ movw %bp, rm_ss - movw %si, rm_sp + addl %ecx, %edx + movw %dx, rm_sp + + /* Move data from RM stack to PM stack */ + subl %ecx, %esp + movl %esp, %edi + rep movsb /* Publish virt_offset, text16 and data16 for PM code to use */ popl data16 @@ -251,16 +257,16 @@ prot_to_real: /* Add return address to data to be moved to RM stack */ addl $4, %ecx - /* Real-mode %ss:sp => %ebp:edx */ + /* Real-mode %ss:sp => %ebp:edx and virtual address => %edi */ movzwl rm_ss, %ebp movzwl rm_sp, %edx subl %ecx, %edx - - /* Move data from PM stack to RM stack */ movl %ebp, %eax shll $4, %eax leal (%eax,%edx), %edi subl virt_offset, %edi + + /* Move data from PM stack to RM stack */ movl %esp, %esi rep movsb @@ -285,16 +291,14 @@ prot_to_real: ljmp *p2r_jump_vector p2r_jump_target: - /* Set up real-mode stack */ - movw %bp, %ss - movl %edx, %esp - - /* Set up real-mode data segments */ + /* Set up real-mode data segments and stack pointer */ movw %cs:rm_ds, %ax movw %ax, %ds movw %ax, %es movw %ax, %fs movw %ax, %gs + movw %bp, %ss + movl %edx, %esp /* Return to real-mode address */ data32 ret @@ -398,9 +402,7 @@ prot_call: .section ".text16" .code16 1: - /* Reload GDT, restore registers and flags and return. Note - * that %esp is restored manually, since popal discards it. - */ + /* Reload GDT, restore registers and flags and return */ movw %sp, %bp lgdt (%bp) addw $12, %sp /* also skip %cs and %ss */ @@ -409,11 +411,12 @@ prot_call: popw %fs popw %gs popal - addr32 movl -20(%esp), %esp /* -20(%sp) is not a valid 80386 - * expression. -20(%esp) is safe - * because prot_to_real zeroes the - * high word of %esp, and interrupts - * are still disabled at this point. */ + /* popal skips %esp. We therefore want to do "movl -20(%sp), + * %esp", but -20(%sp) is not a valid 80386 expression. + * Fortunately, prot_to_real() zeroes the high word of %esp, so + * we can just use -20(%esp) instead. + */ + addr32 movl -20(%esp), %esp popfl lret @@ -528,11 +531,8 @@ rc_function: .word 0, 0 **************************************************************************** */ .section ".data" - .globl rm_sp rm_sp: .word 0 - .globl rm_ss rm_ss: .word 0 - .globl pm_esp pm_esp: .long _estack /**************************************************************************** diff --git a/src/arch/i386/transitions/librm_mgmt.c b/src/arch/i386/transitions/librm_mgmt.c deleted file mode 100644 index d0ff4ea59..000000000 --- a/src/arch/i386/transitions/librm_mgmt.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * librm: a library for interfacing to real-mode code - * - * Michael Brown <mbrown@fensystems.co.uk> - * - */ - -#ifdef KEEP_IT_REAL -/* Build a null object under -DKEEP_IT_REAL */ -#else - -#include <stdint.h> -#include <librm.h> - -/* - * This file provides functions for managing librm. - * - */ - -/* - * Allocate space on the real-mode stack and copy data there. - * - */ -uint16_t copy_to_rm_stack ( void *data, size_t size ) { -#ifdef DEBUG_LIBRM - if ( rm_sp <= size ) { - printf ( "librm: out of space in RM stack\n" ); - lockup(); - } -#endif - rm_sp -= size; - copy_to_real ( rm_ss, rm_sp, data, size ); - return rm_sp; -}; - -/* - * Deallocate space on the real-mode stack, optionally copying back - * data. - * - */ -void remove_from_rm_stack ( void *data, size_t size ) { - if ( data ) { - copy_from_real ( data, rm_ss, rm_sp, size ); - } - rm_sp += size; -}; - -#endif /* KEEP_IT_REAL */ diff --git a/src/drivers/net/r8169.c b/src/drivers/net/r8169.c index 08d1c6f62..90dd2c3b0 100644 --- a/src/drivers/net/r8169.c +++ b/src/drivers/net/r8169.c @@ -48,6 +48,7 @@ #include "nic.h" #include <gpxe/pci.h> #include <gpxe/ethernet.h> +#include <gpxe/malloc.h> #include "timer.h" #define drv_version "v1.6" @@ -73,25 +74,6 @@ static u32 ioaddr; #define RTL8169_USE_IO -#ifdef RTL8169_DEBUG - -#if 0 -#define assert(expr) \ - if(!(expr)) { printk( "Assertion failed! %s,%s,%s,line=%d\n", #expr,__FILE__,__FUNCTION__,__LINE__); } -#endif - -#define DBG_PRINTF( fmt, args...) printk("r8169: " fmt, ## args); - -#else - -#if 0 -#define assert(expr) do {} while (0) -#endif - -#define DBG_PRINTF( fmt, args...) ; - -#endif // end of #ifdef RTL8169_DEBUG - /* media options _10_Half = 0x01, _10_Full = 0x02, @@ -354,11 +336,11 @@ struct { unsigned char txb[NUM_TX_DESC * RX_BUF_SIZE]; struct RxDesc rx_ring[NUM_RX_DESC] __align_256; unsigned char rxb[NUM_RX_DESC * RX_BUF_SIZE]; -} r8169_bufs __shared; -#define tx_ring r8169_bufs.tx_ring -#define rx_ring r8169_bufs.rx_ring -#define txb r8169_bufs.txb -#define rxb r8169_bufs.rxb +} *r8169_bufs; +#define tx_ring r8169_bufs->tx_ring +#define rx_ring r8169_bufs->rx_ring +#define txb r8169_bufs->txb +#define rxb r8169_bufs->rxb static struct rtl8169_private { void *mmio_addr; /* memory map physical address */ @@ -759,11 +741,11 @@ static void rtl8169_hw_start(struct nic *nic) if (tpc->mcfg == MCFG_METHOD_2 || tpc->mcfg == MCFG_METHOD_3) { RTL_W16(CPlusCmd, (RTL_R16(CPlusCmd) | (1 << 14) | (1 << 3))); - DBG_PRINTF + DBG ("Set MAC Reg C+CR Offset 0xE0: bit-3 and bit-14\n"); } else { RTL_W16(CPlusCmd, (RTL_R16(CPlusCmd) | (1 << 3))); - DBG_PRINTF("Set MAC Reg C+CR Offset 0xE0: bit-3.\n"); + DBG("Set MAC Reg C+CR Offset 0xE0: bit-3.\n"); } { @@ -876,6 +858,7 @@ static struct pci_device_id r8169_nics[] = { PCI_ROM(0x10ec, 0x8169, "r8169", "RealTek RTL8169 Gigabit Ethernet"), PCI_ROM(0x16ec, 0x0116, "usr-r8169", "US Robotics RTL8169 Gigabit Ethernet"), PCI_ROM(0x1186, 0x4300, "dlink-r8169", "D-Link RTL8169 Gigabit Ethernet"), + PCI_ROM(0x1737, 0x1032, "linksys-r8169", "Linksys RTL8169 Gigabit Ethernet"), }; PCI_DRIVER ( r8169_driver, r8169_nics, PCI_NO_CLASS ); @@ -900,6 +883,15 @@ static int r8169_probe ( struct nic *nic, struct pci_device *pci ) { printed_version = 1; + /* Quick and very dirty hack to get r8169 driver working + * again, pre-rewrite + */ + if ( ! r8169_bufs ) + r8169_bufs = malloc_dma ( sizeof ( *r8169_bufs ), 256 ); + if ( ! r8169_bufs ) + return 0; + memset ( r8169_bufs, 0, sizeof ( *r8169_bufs ) ); + /* point to private storage */ tpc = &tpx; @@ -919,18 +911,18 @@ static int r8169_probe ( struct nic *nic, struct pci_device *pci ) { /* Config PHY */ rtl8169_hw_PHY_config(nic); - DBG_PRINTF("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); + DBG("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); RTL_W8(0x82, 0x01); if (tpc->mcfg < MCFG_METHOD_3) { - DBG_PRINTF("Set PCI Latency=0x40\n"); + DBG("Set PCI Latency=0x40\n"); pci_write_config_byte(pci, PCI_LATENCY_TIMER, 0x40); } if (tpc->mcfg == MCFG_METHOD_2) { - DBG_PRINTF("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); + DBG("Set MAC Reg C+CR Offset 0x82h = 0x01h\n"); RTL_W8(0x82, 0x01); - DBG_PRINTF("Set PHY Reg 0x0bh = 0x00h\n"); + DBG("Set PHY Reg 0x0bh = 0x00h\n"); RTL8169_WRITE_GMII_REG(ioaddr, 0x0b, 0x0000); //w 0x0b 15 0 0 } @@ -1049,7 +1041,7 @@ static void rtl8169_hw_PHY_reset(struct nic *nic __unused) struct rtl8169_private *priv = dev->priv; unsigned long ioaddr = priv->ioaddr; - DBG_PRINTF("%s: Reset RTL8169s PHY\n", dev->name); + DBG("%s: Reset RTL8169s PHY\n", dev->name); val = ( RTL8169_READ_GMII_REG( ioaddr, 0 ) | 0x8000 ) & 0xffff; RTL8169_WRITE_GMII_REG( ioaddr, 0, val ); @@ -1074,7 +1066,7 @@ static void rtl8169_hw_PHY_reset(struct nic *nic __unused) static void rtl8169_hw_PHY_config(struct nic *nic __unused) { - DBG_PRINTF("priv->mcfg=%d, priv->pcfg=%d\n", tpc->mcfg, tpc->pcfg); + DBG("priv->mcfg=%d, priv->pcfg=%d\n", tpc->mcfg, tpc->pcfg); if (tpc->mcfg == MCFG_METHOD_4) { /* @@ -1175,7 +1167,7 @@ static void rtl8169_hw_PHY_config(struct nic *nic __unused) RTL8169_WRITE_GMII_REG((unsigned long) ioaddr, 0x0B, 0x0000); } else { - DBG_PRINTF("tpc->mcfg=%d. Discard hw PHY config.\n", + DBG("tpc->mcfg=%d. Discard hw PHY config.\n", tpc->mcfg); } } |
