1 Commits
Author SHA1 Message Date
Michael Brown 0dc80d20d3 [tls] Add ECDHE cipher suites
Signed-off-by: Michael Brown <mcb30@ipxe.org>
2024-01-30 18:03:31 +00:00
175 changed files with 2330 additions and 12647 deletions
+7 -7
View File
@@ -12,7 +12,7 @@ jobs:
run: |
sudo chown $(id -un) /var/cache/apt/archives
- name: Cache packages
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
@@ -32,14 +32,14 @@ jobs:
needs: cache
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache permissions
run: |
sudo chown $(id -un) /var/cache/apt/archives
- name: Cache packages
uses: actions/cache/restore@v4
uses: actions/cache/restore@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
@@ -68,14 +68,14 @@ jobs:
needs: cache
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache permissions
run: |
sudo chown $(id -un) /var/cache/apt/archives
- name: Cache packages
uses: actions/cache/restore@v4
uses: actions/cache/restore@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
@@ -97,14 +97,14 @@ jobs:
needs: cache
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache permissions
run: |
sudo chown $(id -un) /var/cache/apt/archives
- name: Cache packages
uses: actions/cache/restore@v4
uses: actions/cache/restore@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-cache-${{ github.run_id }}-${{ github.run_attempt }}
+1 -1
View File
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Download Coverity Scan
run: |
curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \
+2 -2
View File
@@ -23,9 +23,9 @@ NON_AUTO_MEDIA += efidrv
NON_AUTO_MEDIA += drv.efi
NON_AUTO_MEDIA += efirom
# Include SNP and MNP drivers in the all-drivers build
# Include SNP driver in the all-drivers build
#
DRIVERS_net += snp mnp
DRIVERS_net += snp
# Rules for building EFI files
#
-12
View File
@@ -1,12 +0,0 @@
#ifndef _BITS_MP_H
#define _BITS_MP_H
/** @file
*
* ARM-specific multiprocessor API implementation
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#endif /* _BITS_MP_H */
+1 -5
View File
@@ -46,12 +46,8 @@ static void efiarm_cpu_nap ( void ) {
* The EFI shell doesn't seem to bother sleeping the CPU; it
* just sits there idly burning power.
*
* If a shutdown is in progess, there may be nothing to
* generate an interrupt since the timer is disabled in the
* first step of ExitBootServices().
*/
if ( ! efi_shutdown_in_progress )
__asm__ __volatile__ ( "wfi" );
__asm__ __volatile__ ( "wfi" );
}
PROVIDE_NAP ( efiarm, cpu_nap, efiarm_cpu_nap );
-12
View File
@@ -1,12 +0,0 @@
#ifndef _BITS_MP_H
#define _BITS_MP_H
/** @file
*
* LoongArch64-specific multiprocessor API implementation
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#endif /* _BITS_MP_H */
@@ -46,12 +46,8 @@ static void efiloong64_cpu_nap ( void ) {
* The EFI shell doesn't seem to bother sleeping the CPU; it
* just sits there idly burning power.
*
* If a shutdown is in progess, there may be nothing to
* generate an interrupt since the timer is disabled in the
* first step of ExitBootServices().
*/
if ( ! efi_shutdown_in_progress )
__asm__ __volatile__ ( "idle 0" );
__asm__ __volatile__ ( "idle 0" );
}
PROVIDE_NAP ( efiloong64, cpu_nap, efiloong64_cpu_nap );
-197
View File
@@ -1,197 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
/** @file
*
* Multiprocessor functions
*
*/
.section ".note.GNU-stack", "", @progbits
.text
/* Selectively assemble code for 32-bit/64-bit builds */
#if defined ( __x86_64__ ) && ! defined ( PLATFORM_pcbios )
#define codemp code64
#define DI rdi
#define SP rsp
#define if32 if 0
#define if64 if 1
#else
#define codemp code32
#define DI edi
#define SP esp
#define if32 if 1
#define if64 if 0
#endif
/* Standard features CPUID leaf */
#define CPUID_FEATURES 0x00000001
/* x2APIC is supported */
#define CPUID_FEATURES_ECX_X2APIC 0x00200000
/* Extended topology enumeration CPUID leaf */
#define CPUID_XT_ENUM 0x0000000b
/*
* Call multiprocessor function from C code
*
* Parameters:
* 4(%esp)/%rdi Multiprocessor function
* 8(%esp)/%rsi Opaque data pointer
*/
.section ".text.mp_call", "ax", @progbits
.codemp
.globl mp_call
mp_call:
.if64 /* Preserve registers, load incoming parameters into registers */
pushq %rax
pushq %rcx
pushq %rdx
pushq %rbx
pushq %rsp
pushq %rbp
pushq %rsi
pushq %rdi
pushq %r8
pushq %r9
pushq %r10
pushq %r11
pushq %r12
pushq %r13
pushq %r14
pushq %r15
.else
pushal
movl 36(%esp), %eax
movl 40(%esp), %edx
.endif
/* Call multiprocessor function */
call mp_jump
.if64 /* Restore registers and return */
popq %r15
popq %r14
popq %r13
popq %r12
popq %r11
popq %r10
popq %r9
popq %r8
popq %rdi
popq %rsi
popq %rbp
leaq 8(%rsp), %rsp /* discard */
popq %rbx
popq %rdx
popq %rcx
popq %rax
.else
popal
.endif
ret
.size mp_call, . - mp_call
/*
* Jump to multiprocessor function
*
* Parameters:
* %eax/%rdi Multiprocessor function
* %edx/%rsi Opaque data pointer
* %esp/%rsp Stack, or NULL to halt AP upon completion
*
* Obtain the CPU identifier (i.e. the APIC ID) and perform a tail
* call into the specified multiprocessor function.
*
* This code may run with no stack on an application processor.
*/
.section ".text.mp_jump", "ax", @progbits
.codemp
.globl mp_jump
mp_jump:
.if32 /* Move function parameters to available registers */
movl %eax, %edi
movl %edx, %esi
.endif
/* Get 8-bit APIC ID and x2APIC feature bit */
movl $CPUID_FEATURES, %eax
cpuid
shrl $24, %ebx
movl %ebx, %edx
/* Get 32-bit x2APIC ID if applicable */
testl $CPUID_FEATURES_ECX_X2APIC, %ecx
jz 1f
movl $CPUID_XT_ENUM, %eax
xorl %ecx, %ecx
cpuid
1:
.if64 /* Tail call to function */
movq %rdi, %rax
movq %rsi, %rdi
movl %edx, %esi
jmp *%rax
.else
movl %esi, %eax
jmp *%edi
.endif
.size mp_jump, . - mp_jump
/*
* Update maximum CPU identifier
*
* Parameters:
* %eax/%rdi Pointer to shared maximum APIC ID
* %edx/%rsi CPU identifier (APIC ID)
* %esp/%rsp Stack, or NULL to halt AP upon completion
*
* This code may run with no stack on an application processor.
*/
.section ".text.mp_update_max_cpuid", "ax", @progbits
.codemp
.globl mp_update_max_cpuid
mp_update_max_cpuid:
.if32 /* Move function parameters to available registers */
movl %eax, %edi
movl %edx, %esi
.endif
/* Update maximum APIC ID (atomically) */
movl (%DI), %eax
1: cmpl %esi, %eax
jae 2f
lock cmpxchgl %esi, (%DI)
jnz 1b
2:
/* Return to caller (if stack exists), or halt application processor */
test %SP, %SP
jz 3f
ret
3: cli
hlt
jmp 3b
.size mp_update_max_cpuid, . - mp_update_max_cpuid
-257
View File
@@ -1,257 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Microcode updates
*
*/
.section ".note.GNU-stack", "", @progbits
.text
/* Selectively assemble code for 32-bit/64-bit builds */
#if defined ( __x86_64__ ) && ! defined ( PLATFORM_pcbios )
#define codemp code64
#define AX rax
#define BX rbx
#define CX rcx
#define DX rdx
#define SI rsi
#define DI rdi
#define BP rbp
#define SP rsp
#define if32 if 0
#define if64 if 1
#else
#define codemp code32
#define AX eax
#define BX ebx
#define CX ecx
#define DX edx
#define SI esi
#define DI edi
#define BP ebp
#define SP esp
#define if32 if 1
#define if64 if 0
#endif
/* Standard features CPUID leaf */
#define CPUID_FEATURES 0x00000001
/* BIOS update signature MSR */
#define MSR_BIOS_SIGN_ID 0x0000008b
/** Microcode update control layout
*
* This must match the layout of struct ucode_control.
*/
.struct 0
CONTROL_DESC:
.space 8
CONTROL_STATUS:
.space 8
CONTROL_TRIGGER_MSR:
.space 4
CONTROL_APIC_MAX:
.space 4
CONTROL_APIC_UNEXPECTED:
.space 4
CONTROL_APIC_MASK:
.space 4
CONTROL_APIC_TEST:
.space 4
CONTROL_VER_CLEAR:
.space 1
CONTROL_VER_HIGH:
.space 1
CONTROL_LEN:
/* We use register %ebp/%rbp to hold the address of the update control */
#define CONTROL BP
/* Microcode update descriptor layout
*
* This must match the layout of struct ucode_descriptor.
*/
.struct 0
DESC_SIGNATURE:
.space 4
DESC_VERSION:
.space 4
DESC_ADDRESS:
.space 8
DESC_LEN:
/* We use register %esi/%rsi to hold the address of the descriptor */
#define DESC SI
/** Microcode update status report layout
*
* This must match the layout of struct ucode_status.
*/
.struct 0
STATUS_SIGNATURE:
.space 4
STATUS_ID:
.space 4
STATUS_BEFORE:
.space 4
STATUS_AFTER:
.space 4
STATUS_LEN:
.equ LOG2_STATUS_LEN, 4
.if ( 1 << LOG2_STATUS_LEN ) - STATUS_LEN
.error "LOG2_STATUS_LEN value is incorrect"
.endif
/* We use register %edi/%rdi to hold the address of the status report */
#define STATUS DI
/*
* Update microcode
*
* Parameters:
* %eax/%rdi Microcode update structure
* %edx/%rsi CPU identifier (APIC ID)
* %esp/%rsp Stack, or NULL to halt AP upon completion
*
* This code may run with no stack on an application processor (AP).
* All values must be held in registers, and no subroutine calls are
* possible. No firmware routines may be called.
*
* Since cpuid/rdmsr/wrmsr require the use of %eax, %ebx, %ecx, and
* %edx, we have essentially only three registers available for
* long-term state.
*/
.text
.globl ucode_update
.codemp
.section ".text.ucode_update", "ax", @progbits
ucode_update:
.if64 /* Get input parameters */
movq %rdi, %CONTROL
movl %esi, %edx
.else
movl %eax, %CONTROL
.endif
/* Check against maximum expected APIC ID */
cmpl CONTROL_APIC_MAX(%CONTROL), %edx
jbe 1f
movl %edx, CONTROL_APIC_UNEXPECTED(%CONTROL)
jmp done
1:
/* Calculate per-CPU status report buffer address */
mov %DX, %STATUS
shl $LOG2_STATUS_LEN, %STATUS
add CONTROL_STATUS(%CONTROL), %STATUS
/* Report APIC ID */
movl %edx, STATUS_ID(%STATUS)
/* Get and report CPU signature */
movl $CPUID_FEATURES, %eax
cpuid
movl %eax, STATUS_SIGNATURE(%STATUS)
/* Check APIC ID mask */
movl STATUS_ID(%STATUS), %eax
andl CONTROL_APIC_MASK(%CONTROL), %eax
cmpl CONTROL_APIC_TEST(%CONTROL), %eax
jne done
/* Clear BIOS_SIGN_ID MSR if applicable */
movl $MSR_BIOS_SIGN_ID, %ecx
xorl %eax, %eax
xorl %edx, %edx
testb $0xff, CONTROL_VER_CLEAR(%CONTROL)
jz 1f
wrmsr
1:
/* Get CPU signature to repopulate BIOS_SIGN_ID MSR (for Intel) */
movl $CPUID_FEATURES, %eax
cpuid
/* Get initial microcode version */
movl $MSR_BIOS_SIGN_ID, %ecx
rdmsr
testb $0xff, CONTROL_VER_HIGH(%CONTROL)
jz 1f
movl %edx, %eax
1: movl %eax, STATUS_BEFORE(%STATUS)
/* Get start of descriptor list */
mov CONTROL_DESC(%CONTROL), %DESC
sub $DESC_LEN, %DESC
1: /* Walk update descriptor list to find a matching CPU signature */
add $DESC_LEN, %DESC
movl DESC_SIGNATURE(%DESC), %eax
testl %eax, %eax
jz noload
cmpl STATUS_SIGNATURE(%STATUS), %eax
jne 1b
/* Compare (signed) microcode versions */
movl STATUS_BEFORE(%STATUS), %eax
cmpl DESC_VERSION(%DESC), %eax
jge noload
/* Load microcode update */
movl CONTROL_TRIGGER_MSR(%CONTROL), %ecx
movl (DESC_ADDRESS + 0)(%DESC), %eax
movl (DESC_ADDRESS + 4)(%DESC), %edx
wrmsr
noload: /* Clear BIOS_SIGN_ID MSR if applicable */
movl $MSR_BIOS_SIGN_ID, %ecx
xorl %eax, %eax
xorl %edx, %edx
testb $0xff, CONTROL_VER_CLEAR(%CONTROL)
jz 1f
wrmsr
1:
/* Get CPU signature to repopulate BIOS_SIGN_ID MSR (for Intel) */
movl $CPUID_FEATURES, %eax
cpuid
/* Get and report final microcode version */
movl $MSR_BIOS_SIGN_ID, %ecx
rdmsr
testb $0xff, CONTROL_VER_HIGH(%CONTROL)
jz 1f
movl %edx, %eax
1: movl %eax, STATUS_AFTER(%STATUS)
done: /* Return to caller (if stack exists), or halt application processor */
test %SP, %SP
jz 1f
ret
1: cli
hlt
jmp 1b
.size ucode_update, . - ucode_update
-798
View File
@@ -1,798 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Microcode updates
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
#include <ipxe/uaccess.h>
#include <ipxe/umalloc.h>
#include <ipxe/image.h>
#include <ipxe/cpuid.h>
#include <ipxe/msr.h>
#include <ipxe/mp.h>
#include <ipxe/timer.h>
#include <ipxe/ucode.h>
/**
* Maximum number of hyperthread siblings
*
* Microcode updates must not be performed on hyperthread siblings at
* the same time, since they share microcode storage.
*
* Hyperthread siblings are always the lowest level of the CPU
* topology and correspond to the least significant bits of the APIC
* ID. We may therefore avoid collisions by performing the microcode
* updates in batches, with each batch targeting just one value for
* the least significant N bits of the APIC ID.
*
* We assume that no CPUs exist with more than this number of
* hyperthread siblings. (This must be a power of two.)
*/
#define UCODE_MAX_HT 8
/** Time to wait for a microcode update to complete */
#define UCODE_WAIT_MS 10
/** A CPU vendor string */
union ucode_vendor_id {
/** CPUID registers */
uint32_t dword[3];
/** Human-readable string */
uint8_t string[12];
};
/** A CPU vendor */
struct ucode_vendor {
/** Vendor string */
union ucode_vendor_id id;
/** Microcode load trigger MSR */
uint32_t trigger_msr;
/** Microcode version requires manual clear */
uint8_t ver_clear;
/** Microcode version is reported via high dword */
uint8_t ver_high;
};
/** A microcode update */
struct ucode_update {
/** CPU vendor, if known */
struct ucode_vendor *vendor;
/** Boot processor CPU signature */
uint32_t signature;
/** Platform ID */
uint32_t platform;
/** Number of potentially relevant signatures found */
unsigned int count;
/** Update descriptors (if being populated) */
struct ucode_descriptor *desc;
};
/** A microcode update summary */
struct ucode_summary {
/** Number of CPUs processed */
unsigned int count;
/** Lowest observed microcode version */
int32_t low;
/** Highest observed microcode version */
int32_t high;
};
/** Intel CPU vendor */
static struct ucode_vendor ucode_intel = {
.id = { .string = "GenuineIntel" },
.ver_clear = 1,
.ver_high = 1,
.trigger_msr = MSR_UCODE_TRIGGER_INTEL,
};
/** AMD CPU vendor */
static struct ucode_vendor ucode_amd = {
.id = { .string = "AuthenticAMD" },
.trigger_msr = MSR_UCODE_TRIGGER_AMD,
};
/** List of known CPU vendors */
static struct ucode_vendor *ucode_vendors[] = {
&ucode_intel,
&ucode_amd,
};
/**
* Get CPU vendor name (for debugging)
*
* @v vendor CPU vendor
* @ret name Name
*/
static const char * ucode_vendor_name ( const union ucode_vendor_id *vendor ) {
static union {
union ucode_vendor_id vendor;
char text[ sizeof ( *vendor ) + 1 /* NUL */ ];
} u;
/* Construct name */
memcpy ( &u.vendor, vendor, sizeof ( u.vendor ) );
u.text[ sizeof ( u.text ) - 1 ] = '\0';
return u.text;
}
/**
* Check status report
*
* @v update Microcode update
* @v control Microcode update control
* @v summary Microcode update summary
* @v id APIC ID
* @v optional Status report is optional
* @ret rc Return status code
*/
static int ucode_status ( struct ucode_update *update,
struct ucode_control *control,
struct ucode_summary *summary,
unsigned int id, int optional ) {
struct ucode_status status;
struct ucode_descriptor *desc;
/* Sanity check */
assert ( id <= control->apic_max );
/* Read status report */
copy_from_user ( &status, phys_to_user ( control->status ),
( id * sizeof ( status ) ), sizeof ( status ) );
/* Ignore empty optional status reports */
if ( optional && ( ! status.signature ) )
return 0;
DBGC ( update, "UCODE %#08x signature %#08x ucode %#08x->%#08x\n",
id, status.signature, status.before, status.after );
/* Check CPU signature */
if ( ! status.signature ) {
DBGC2 ( update, "UCODE %#08x has no signature\n", id );
return -ENOENT;
}
/* Check APIC ID is correct */
if ( status.id != id ) {
DBGC ( update, "UCODE %#08x wrong APIC ID %#08x\n",
id, status.id );
return -EINVAL;
}
/* Check that maximum APIC ID was not exceeded */
if ( control->apic_unexpected ) {
DBGC ( update, "UCODE %#08x saw unexpected APIC ID %#08x\n",
id, control->apic_unexpected );
return -ERANGE;
}
/* Check microcode was not downgraded */
if ( status.after < status.before ) {
DBGC ( update, "UCODE %#08x was downgraded %#08x->%#08x\n",
id, status.before, status.after );
return -ENOTTY;
}
/* Check that expected updates (if any) were applied */
for ( desc = update->desc ; desc->signature ; desc++ ) {
if ( ( desc->signature == status.signature ) &&
( status.after < desc->version ) ) {
DBGC ( update, "UCODE %#08x failed update %#08x->%#08x "
"(wanted %#08x)\n", id, status.before,
status.after, desc->version );
return -EIO;
}
}
/* Update summary */
summary->count++;
if ( status.before < summary->low )
summary->low = status.before;
if ( status.after > summary->high )
summary->high = status.after;
return 0;
}
/**
* Update microcode on all CPUs
*
* @v image Microcode image
* @v update Microcode update
* @v summary Microcode update summary to fill in
* @ret rc Return status code
*/
static int ucode_update_all ( struct image *image,
struct ucode_update *update,
struct ucode_summary *summary ) {
struct ucode_control control;
struct ucode_vendor *vendor;
userptr_t status;
unsigned int max;
unsigned int i;
size_t len;
int rc;
/* Initialise summary */
summary->count = 0;
summary->low = UCODE_VERSION_MAX;
summary->high = UCODE_VERSION_MIN;
/* Allocate status reports */
max = mp_max_cpuid();
len = ( ( max + 1 ) * sizeof ( struct ucode_status ) );
status = umalloc ( len );
if ( ! status ) {
DBGC ( image, "UCODE %s could not allocate %d status reports\n",
image->name, ( max + 1 ) );
rc = -ENOMEM;
goto err_alloc;
}
memset_user ( status, 0, 0, len );
/* Construct control structure */
memset ( &control, 0, sizeof ( control ) );
control.desc = virt_to_phys ( update->desc );
control.status = user_to_phys ( status, 0 );
vendor = update->vendor;
if ( vendor ) {
control.ver_clear = vendor->ver_clear;
control.ver_high = vendor->ver_high;
control.trigger_msr = vendor->trigger_msr;
} else {
assert ( update->count == 0 );
}
control.apic_max = max;
/* Update microcode on boot processor */
mp_exec_boot ( ucode_update, &control );
if ( ( rc = ucode_status ( update, &control, summary,
mp_boot_cpuid(), 0 ) ) != 0 ) {
DBGC ( image, "UCODE %s failed on boot processor: %s\n",
image->name, strerror ( rc ) );
goto err_boot;
}
/* Update microcode on application processors, avoiding
* simultaneous updates on hyperthread siblings.
*/
build_assert ( ( UCODE_MAX_HT & ( UCODE_MAX_HT - 1 ) ) == 0 );
control.apic_mask = ( UCODE_MAX_HT - 1 );
for ( ; control.apic_test <= control.apic_mask ; control.apic_test++ ) {
mp_start_all ( ucode_update, &control );
mdelay ( UCODE_WAIT_MS );
}
/* Check status reports */
summary->count = 0;
for ( i = 0 ; i <= max ; i++ ) {
if ( ( rc = ucode_status ( update, &control, summary,
i, 1 ) ) != 0 ) {
goto err_status;
}
}
/* Success */
rc = 0;
err_status:
err_boot:
ufree ( status );
err_alloc:
return rc;
}
/**
* Add descriptor to list (if applicable)
*
* @v image Microcode image
* @v start Starting offset within image
* @v vendor CPU vendor
* @v desc Microcode descriptor
* @v platforms Supported platforms, or 0 for all platforms
* @v update Microcode update
*/
static void ucode_describe ( struct image *image, size_t start,
const struct ucode_vendor *vendor,
const struct ucode_descriptor *desc,
uint32_t platforms, struct ucode_update *update ) {
/* Dump descriptor information */
DBGC2 ( image, "UCODE %s+%#04zx %s %#08x", image->name, start,
ucode_vendor_name ( &vendor->id ), desc->signature );
if ( platforms )
DBGC2 ( image, " (%#02x)", platforms );
DBGC2 ( image, " version %#08x\n", desc->version );
/* Check applicability */
if ( vendor != update->vendor )
return;
if ( ( desc->signature ^ update->signature ) & UCODE_SIGNATURE_MASK )
return;
if ( platforms && ( ! ( platforms & update->platform ) ) )
return;
/* Add descriptor, if applicable */
if ( update->desc ) {
memcpy ( &update->desc[update->count], desc, sizeof ( *desc ) );
DBGC ( image, "UCODE %s+%#04zx found %s %#08x version %#08x\n",
image->name, start, ucode_vendor_name ( &vendor->id ),
desc->signature, desc->version );
}
update->count++;
}
/**
* Verify checksum
*
* @v image Microcode image
* @v start Starting offset
* @v len Length
* @ret rc Return status code
*/
static int ucode_verify ( struct image *image, size_t start, size_t len ) {
uint32_t checksum = 0;
uint32_t dword;
size_t offset;
/* Check length is a multiple of dwords */
if ( ( len % sizeof ( dword ) ) != 0 ) {
DBGC ( image, "UCODE %s+%#04zx invalid length %#zx\n",
image->name, start, len );
return -EINVAL;
}
/* Calculate checksum */
for ( offset = start ; len ;
offset += sizeof ( dword ), len -= sizeof ( dword ) ) {
copy_from_user ( &dword, image->data, offset,
sizeof ( dword ) );
checksum += dword;
}
if ( checksum != 0 ) {
DBGC ( image, "UCODE %s+%#04zx bad checksum %#08x\n",
image->name, start, checksum );
return -EINVAL;
}
return 0;
}
/**
* Parse Intel microcode image
*
* @v image Microcode image
* @v start Starting offset within image
* @v update Microcode update
* @ret len Length consumed, or negative error
*/
static int ucode_parse_intel ( struct image *image, size_t start,
struct ucode_update *update ) {
struct intel_ucode_header hdr;
struct intel_ucode_ext_header exthdr;
struct intel_ucode_ext ext;
struct ucode_descriptor desc;
size_t remaining;
size_t offset;
size_t data_len;
size_t len;
unsigned int i;
int rc;
/* Read header */
remaining = ( image->len - start );
if ( remaining < sizeof ( hdr ) ) {
DBGC ( image, "UCODE %s+%#04zx too small for Intel header\n",
image->name, start );
return -ENOEXEC;
}
copy_from_user ( &hdr, image->data, start, sizeof ( hdr ) );
/* Determine lengths */
data_len = hdr.data_len;
if ( ! data_len )
data_len = INTEL_UCODE_DATA_LEN;
len = hdr.len;
if ( ! len )
len = ( sizeof ( hdr ) + data_len );
/* Verify a selection of fields */
if ( ( hdr.hver != INTEL_UCODE_HVER ) ||
( hdr.lver != INTEL_UCODE_LVER ) ||
( len < sizeof ( hdr ) ) ||
( len > remaining ) ||
( data_len > ( len - sizeof ( hdr ) ) ) ||
( ( data_len % sizeof ( uint32_t ) ) != 0 ) ||
( ( len % INTEL_UCODE_ALIGN ) != 0 ) ) {
DBGC2 ( image, "UCODE %s+%#04zx is not an Intel update\n",
image->name, start );
return -EINVAL;
}
DBGC2 ( image, "UCODE %s+%#04zx is an Intel update\n",
image->name, start );
/* Verify checksum */
if ( ( rc = ucode_verify ( image, start, len ) ) != 0 )
return rc;
/* Populate descriptor */
desc.signature = hdr.signature;
desc.version = hdr.version;
desc.address = user_to_phys ( image->data,
( start + sizeof ( hdr ) ) );
/* Add non-extended descriptor, if applicable */
ucode_describe ( image, start, &ucode_intel, &desc, hdr.platforms,
update );
/* Construct extended descriptors, if applicable */
offset = ( sizeof ( hdr ) + data_len );
if ( offset <= ( len - sizeof ( exthdr ) ) ) {
/* Read extended header */
copy_from_user ( &exthdr, image->data, ( start + offset ),
sizeof ( exthdr ) );
offset += sizeof ( exthdr );
/* Read extended signatures */
for ( i = 0 ; i < exthdr.count ; i++ ) {
/* Read extended signature */
if ( offset > ( len - sizeof ( ext ) ) ) {
DBGC ( image, "UCODE %s+%#04zx extended "
"signature overrun\n",
image->name, start );
return -EINVAL;
}
copy_from_user ( &ext, image->data, ( start + offset ),
sizeof ( ext ) );
offset += sizeof ( ext );
/* Avoid duplicating non-extended descriptor */
if ( ( ext.signature == hdr.signature ) &&
( ext.platforms == hdr.platforms ) ) {
continue;
}
/* Construct descriptor, if applicable */
desc.signature = ext.signature;
ucode_describe ( image, start, &ucode_intel, &desc,
ext.platforms, update );
}
}
return len;
}
/**
* Parse AMD microcode image
*
* @v image Microcode image
* @v start Starting offset within image
* @v update Microcode update
* @ret len Length consumed, or negative error
*/
static int ucode_parse_amd ( struct image *image, size_t start,
struct ucode_update *update ) {
struct amd_ucode_header hdr;
struct amd_ucode_equivalence equiv;
struct amd_ucode_patch_header phdr;
struct amd_ucode_patch patch;
struct ucode_descriptor desc;
size_t remaining;
size_t offset;
unsigned int count;
unsigned int used;
unsigned int i;
/* Read header */
remaining = ( image->len - start );
if ( remaining < sizeof ( hdr ) ) {
DBGC ( image, "UCODE %s+%#04zx too small for AMD header\n",
image->name, start );
return -ENOEXEC;
}
copy_from_user ( &hdr, image->data, start, sizeof ( hdr ) );
/* Check header */
if ( hdr.magic != AMD_UCODE_MAGIC ) {
DBGC2 ( image, "UCODE %s+%#04zx is not an AMD update\n",
image->name, start );
return -ENOEXEC;
}
DBGC2 ( image, "UCODE %s+%#04zx is an AMD update\n",
image->name, start );
if ( hdr.type != AMD_UCODE_EQUIV_TYPE ) {
DBGC ( image, "UCODE %s+%#04zx unsupported equivalence table "
"type %d\n", image->name, start, hdr.type );
return -ENOTSUP;
}
if ( hdr.len > ( remaining - sizeof ( hdr ) ) ) {
DBGC ( image, "UCODE %s+%#04zx truncated equivalence table\n",
image->name, start );
return -EINVAL;
}
/* Count number of equivalence table entries */
offset = sizeof ( hdr );
for ( count = 0 ; offset < ( sizeof ( hdr ) + hdr.len ) ;
count++, offset += sizeof ( equiv ) ) {
copy_from_user ( &equiv, image->data, ( start + offset ),
sizeof ( equiv ) );
if ( ! equiv.signature )
break;
}
DBGC2 ( image, "UCODE %s+%#04zx has %d equivalence table entries\n",
image->name, start, count );
/* Parse available updates */
offset = ( sizeof ( hdr ) + hdr.len );
used = 0;
while ( used < count ) {
/* Read patch header */
if ( ( offset + sizeof ( phdr ) ) > remaining ) {
DBGC ( image, "UCODE %s+%#04zx truncated patch "
"header\n", image->name, start );
return -EINVAL;
}
copy_from_user ( &phdr, image->data, ( start + offset ),
sizeof ( phdr ) );
offset += sizeof ( phdr );
/* Validate patch header */
if ( phdr.type != AMD_UCODE_PATCH_TYPE ) {
DBGC ( image, "UCODE %s+%#04zx unsupported patch type "
"%d\n", image->name, start, phdr.type );
return -ENOTSUP;
}
if ( phdr.len < sizeof ( patch ) ) {
DBGC ( image, "UCODE %s+%#04zx underlength patch\n",
image->name, start );
return -EINVAL;
}
if ( phdr.len > ( remaining - offset ) ) {
DBGC ( image, "UCODE %s+%#04zx truncated patch\n",
image->name, start );
return -EINVAL;
}
/* Read patch and construct descriptor */
copy_from_user ( &patch, image->data, ( start + offset ),
sizeof ( patch ) );
desc.version = patch.version;
desc.address = user_to_phys ( image->data, ( start + offset ) );
offset += phdr.len;
/* Parse equivalence table to find matching signatures */
for ( i = 0 ; i < count ; i++ ) {
copy_from_user ( &equiv, image->data,
( start + sizeof ( hdr ) +
( i * ( sizeof ( equiv ) ) ) ),
sizeof ( equiv ) );
if ( patch.id == equiv.id ) {
desc.signature = equiv.signature;
ucode_describe ( image, start, &ucode_amd,
&desc, 0, update );
used++;
}
}
}
return offset;
}
/**
* Parse microcode image
*
* @v image Microcode image
* @v update Microcode update
* @ret rc Return status code
*/
static int ucode_parse ( struct image *image, struct ucode_update *update ) {
size_t start;
int len;
/* Attempt to parse concatenated microcode updates */
for ( start = 0 ; start < image->len ; start += len ) {
/* Attempt to parse as Intel microcode */
len = ucode_parse_intel ( image, start, update );
if ( len > 0 )
continue;
/* Attempt to parse as AMD microcode */
len = ucode_parse_amd ( image, start, update );
if ( len > 0 )
continue;
/* Not a recognised microcode format */
DBGC ( image, "UCODE %s+%zx not recognised\n",
image->name, start );
return -ENOEXEC;
}
return 0;
}
/**
* Execute microcode update
*
* @v image Microcode image
* @ret rc Return status code
*/
static int ucode_exec ( struct image *image ) {
struct ucode_update update;
struct ucode_vendor *vendor;
struct ucode_summary summary;
union ucode_vendor_id id;
uint64_t platform_id;
uint32_t discard_a;
uint32_t discard_b;
uint32_t discard_c;
uint32_t discard_d;
unsigned int check;
unsigned int i;
size_t len;
int rc;
/* Initialise update */
memset ( &update, 0, sizeof ( update ) );
cpuid ( CPUID_VENDOR_ID, 0, &discard_a, &id.dword[0], &id.dword[2],
&id.dword[1] );
cpuid ( CPUID_FEATURES, 0, &update.signature, &discard_b,
&discard_c, &discard_d );
/* Identify CPU vendor, if recognised */
for ( i = 0 ; i < ( sizeof ( ucode_vendors ) /
sizeof ( ucode_vendors[0] ) ) ; i++ ) {
vendor = ucode_vendors[i];
if ( memcmp ( &id, &vendor->id, sizeof ( id ) ) == 0 )
update.vendor = vendor;
}
/* Identify platform, if applicable */
if ( update.vendor == &ucode_intel ) {
platform_id = rdmsr ( MSR_PLATFORM_ID );
update.platform =
( 1 << MSR_PLATFORM_ID_VALUE ( platform_id ) );
}
/* Count number of matching update descriptors */
DBGC ( image, "UCODE %s applying to %s %#08x",
image->name, ucode_vendor_name ( &id ), update.signature );
if ( update.platform )
DBGC ( image, " (%#02x)", update.platform );
DBGC ( image, "\n" );
if ( ( rc = ucode_parse ( image, &update ) ) != 0 )
goto err_count;
DBGC ( image, "UCODE %s found %d matching update(s)\n",
image->name, update.count );
/* Allocate descriptors */
len = ( ( update.count + 1 /* terminator */ ) *
sizeof ( update.desc[0] ) );
update.desc = zalloc ( len );
if ( ! update.desc ) {
rc = -ENOMEM;
goto err_alloc;
}
/* Populate descriptors */
check = update.count;
update.count = 0;
if ( ( rc = ucode_parse ( image, &update ) ) != 0 )
goto err_parse;
assert ( check == update.count );
/* Perform update */
if ( ( rc = ucode_update_all ( image, &update, &summary ) ) != 0 )
goto err_update;
/* Print summary if directed to do so */
if ( image->cmdline && ( strstr ( image->cmdline, "-v" ) ) ) {
printf ( "Microcode: " );
if ( summary.low == summary.high ) {
printf ( "already version %#x", summary.low );
} else {
printf ( "updated version %#x->%#x",
summary.low, summary.high );
}
printf ( " (x%d)\n", summary.count );
}
err_update:
err_parse:
free ( update.desc );
err_alloc:
err_count:
return rc;
}
/**
* Probe microcode update image
*
* @v image Microcode image
* @ret rc Return status code
*/
static int ucode_probe ( struct image *image ) {
union {
struct intel_ucode_header intel;
struct amd_ucode_header amd;
} header;
/* Sanity check */
if ( image->len < sizeof ( header ) ) {
DBGC ( image, "UCODE %s too short\n", image->name );
return -ENOEXEC;
}
/* Read first microcode image header */
copy_from_user ( &header, image->data, 0, sizeof ( header ) );
/* Check for something that looks like an Intel update
*
* Intel updates unfortunately have no magic signatures or
* other easily verifiable fields. We check a small selection
* of header fields that can be easily verified.
*
* We do not attempt to fully parse the update, since we want
* errors to be reported at the point of attempting to execute
* the image, and do not want to have a microcode image
* erroneously treated as a PXE boot executable.
*/
if ( ( header.intel.hver == INTEL_UCODE_HVER ) &&
( header.intel.lver == INTEL_UCODE_LVER ) &&
( ( header.intel.date.century == 0x19 ) ||
( ( header.intel.date.century >= 0x20 ) &&
( header.intel.date.century <= 0x29 ) ) ) ) {
DBGC ( image, "UCODE %s+%#04zx looks like an Intel update\n",
image->name, ( ( size_t ) 0 ) );
return 0;
}
/* Check for AMD update signature */
if ( ( header.amd.magic == AMD_UCODE_MAGIC ) &&
( header.amd.type == AMD_UCODE_EQUIV_TYPE ) ) {
DBGC ( image, "UCODE %s+%#04zx looks like an AMD update\n",
image->name, ( ( size_t ) 0 ) );
return 0;
}
return -ENOEXEC;
}
/** Microcode update image type */
struct image_type ucode_image_type __image_type ( PROBE_NORMAL ) = {
.name = "ucode",
.probe = ucode_probe,
.exec = ucode_exec,
};
-1
View File
@@ -44,7 +44,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define ERRFILE_sdi ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000b0000 )
#define ERRFILE_initrd ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000c0000 )
#define ERRFILE_pxe_call ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000d0000 )
#define ERRFILE_ucode ( ERRFILE_ARCH | ERRFILE_IMAGE | 0x000e0000 )
#define ERRFILE_undi ( ERRFILE_ARCH | ERRFILE_NET | 0x00000000 )
#define ERRFILE_undiload ( ERRFILE_ARCH | ERRFILE_NET | 0x00010000 )
-14
View File
@@ -1,14 +0,0 @@
#ifndef _BITS_MP_H
#define _BITS_MP_H
/** @file
*
* x86-specific multiprocessor API implementation
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/bios_mp.h>
#endif /* _BITS_MP_H */
-32
View File
@@ -1,32 +0,0 @@
#ifndef _IPXE_BIOS_MP_H
#define _IPXE_BIOS_MP_H
/** @file
*
* BIOS multiprocessor API implementation
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/io.h>
#ifdef MPAPI_PCBIOS
#define MPAPI_PREFIX_pcbios
#else
#define MPAPI_PREFIX_pcbios __pcbios_
#endif
/**
* Calculate address as seen by a multiprocessor function
*
* @v address Address in boot processor address space
* @ret address Address in application processor address space
*/
static inline __attribute__ (( always_inline )) mp_addr_t
MPAPI_INLINE ( pcbios, mp_address ) ( void *address ) {
return virt_to_phys ( address );
}
#endif /* _IPXE_BIOS_MP_H */
-223
View File
@@ -1,223 +0,0 @@
#ifndef _IPXE_UCODE_H
#define _IPXE_UCODE_H
/** @file
*
* Microcode updates
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <ipxe/mp.h>
/** Platform ID MSR */
#define MSR_PLATFORM_ID 0x00000017UL
/** Extract platform ID from MSR value */
#define MSR_PLATFORM_ID_VALUE( value ) ( ( (value) >> 50 ) & 0x7 )
/** Intel microcode load trigger MSR */
#define MSR_UCODE_TRIGGER_INTEL 0x00000079UL
/** AMD microcode load trigger MSR */
#define MSR_UCODE_TRIGGER_AMD 0xc0010020UL
/** CPUID signature applicability mask
*
* We assume that only steppings may vary between the boot CPU and any
* application processors.
*/
#define UCODE_SIGNATURE_MASK 0xfffffff0UL
/** Minimum possible microcode version */
#define UCODE_VERSION_MIN -0x80000000L
/** Maximum possible microcode version */
#define UCODE_VERSION_MAX 0x7fffffffL
/** A microcode update control
*
* This must match the layout as used by the assembly code in
* ucode_mp.S.
*/
struct ucode_control {
/** Microcode descriptor list physical address */
uint64_t desc;
/** Microcode status array physical address */
uint64_t status;
/** Microcode load trigger MSR */
uint32_t trigger_msr;
/** Maximum expected APIC ID */
uint32_t apic_max;
/** Unexpected APIC ID
*
* Any application processor may set this to indicate that its
* APIC ID was higher than the maximum expected APIC ID.
*/
uint32_t apic_unexpected;
/** APIC ID eligibility mask bits */
uint32_t apic_mask;
/** APIC ID eligibility test bits */
uint32_t apic_test;
/** Microcode version requires manual clear */
uint8_t ver_clear;
/** Microcode version is reported via high dword */
uint8_t ver_high;
} __attribute__ (( packed ));
/** A microcode update descriptor
*
* This must match the layout as used by the assembly code in
* ucode_mp.S.
*/
struct ucode_descriptor {
/** CPUID signature (or 0 to terminate list) */
uint32_t signature;
/** Microcode version */
int32_t version;
/** Microcode physical address */
uint64_t address;
} __attribute__ (( packed ));
/** A microcode update status report
*
* This must match the layout as used by the assembly code in
* ucode_mp.S.
*/
struct ucode_status {
/** CPU signature */
uint32_t signature;
/** APIC ID (for sanity checking) */
uint32_t id;
/** Initial microcode version */
int32_t before;
/** Final microcode version */
int32_t after;
} __attribute__ (( packed ));
/** A microcode date */
struct ucode_date {
/** Year (BCD) */
uint8_t year;
/** Century (BCD) */
uint8_t century;
/** Day (BCD) */
uint8_t day;
/** Month (BCD) */
uint8_t month;
} __attribute__ (( packed ));
/** An Intel microcode update file header */
struct intel_ucode_header {
/** Header version number */
uint32_t hver;
/** Microcode version */
int32_t version;
/** Date */
struct ucode_date date;
/** CPUID signature */
uint32_t signature;
/** Checksum */
uint32_t checksum;
/** Loader version */
uint32_t lver;
/** Supported platforms */
uint32_t platforms;
/** Microcode data size (or 0 to indicate 2000 bytes) */
uint32_t data_len;
/** Total size (or 0 to indicate 2048 bytes) */
uint32_t len;
/** Reserved */
uint8_t reserved[12];
} __attribute__ (( packed ));
/** Intel microcode header version number */
#define INTEL_UCODE_HVER 0x00000001UL
/** Intel microcode loader version number */
#define INTEL_UCODE_LVER 0x00000001UL
/** Intel microcode default data length */
#define INTEL_UCODE_DATA_LEN 2000
/** Intel microcode file alignment */
#define INTEL_UCODE_ALIGN 1024
/** An Intel microcode update file extended header */
struct intel_ucode_ext_header {
/** Extended signature count */
uint32_t count;
/** Extended checksum */
uint32_t checksum;
/** Reserved */
uint8_t reserved[12];
} __attribute__ (( packed ));
/** An Intel microcode extended signature */
struct intel_ucode_ext {
/** CPUID signature */
uint32_t signature;
/** Supported platforms */
uint32_t platforms;
/** Checksum */
uint32_t checksum;
} __attribute__ (( packed ));
/** An AMD microcode update file header */
struct amd_ucode_header {
/** Magic signature */
uint32_t magic;
/** Equivalence table type */
uint32_t type;
/** Equivalence table length */
uint32_t len;
} __attribute__ (( packed ));
/** AMD microcode magic signature */
#define AMD_UCODE_MAGIC ( ( 'A' << 16 ) | ( 'M' << 8 ) | ( 'D' << 0 ) )
/** AMD microcode equivalence table type */
#define AMD_UCODE_EQUIV_TYPE 0x00000000UL
/** An AMD microcode equivalence table entry */
struct amd_ucode_equivalence {
/** CPU signature */
uint32_t signature;
/** Reserved */
uint8_t reserved_a[8];
/** Equivalence ID */
uint16_t id;
/** Reserved */
uint8_t reserved_b[2];
} __attribute__ (( packed ));
/** An AMD microcode patch header */
struct amd_ucode_patch_header {
/** Patch type */
uint32_t type;
/** Patch length */
uint32_t len;
} __attribute__ (( packed ));
/** An AMD microcode patch */
struct amd_ucode_patch {
/** Date */
struct ucode_date date;
/** Microcode version */
int32_t version;
/** Reserved */
uint8_t reserved_a[16];
/** Equivalence ID */
uint16_t id;
/** Reserved */
uint8_t reserved_b[14];
} __attribute__ (( packed ));
/** AMD patch type */
#define AMD_UCODE_PATCH_TYPE 0x00000001UL
extern mp_func_t ucode_update;
#endif /* _IPXE_UCODE_H */
-20
View File
@@ -474,26 +474,6 @@ extern struct page_table io_pages;
*/
#define IO_BASE ( ( void * ) 0x100000000ULL )
/** Startup IPI real-mode handler */
extern char __text16_array ( sipi, [] );
#define sipi __use_text16 ( sipi )
/** Length of startup IPI real-mode handler */
extern char sipi_len[];
/** Startup IPI real-mode handler copy of real-mode data segment */
extern uint16_t __text16 ( sipi_ds );
#define sipi_ds __use_text16 ( sipi_ds )
/** Startup IPI protected-mode handler (physical address) */
extern uint32_t sipi_handler;
/** Startup IPI register state */
extern struct i386_regs sipi_regs;
extern void setup_sipi ( unsigned int vector, uint32_t handler,
struct i386_regs *regs );
#endif /* ASSEMBLY */
#endif /* LIBRM_H */
+1 -5
View File
@@ -46,12 +46,8 @@ static void efix86_cpu_nap ( void ) {
* The EFI shell doesn't seem to bother sleeping the CPU; it
* just sits there idly burning power.
*
* If a shutdown is in progess, there may be nothing to
* generate an interrupt since the timer is disabled in the
* first step of ExitBootServices().
*/
if ( ! efi_shutdown_in_progress )
__asm__ __volatile__ ( "hlt" );
__asm__ __volatile__ ( "hlt" );
}
PROVIDE_NAP ( efix86, cpu_nap, efix86_cpu_nap );
-173
View File
@@ -1,173 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* BIOS multiprocessor API implementation
*
*/
#include <registers.h>
#include <ipxe/uaccess.h>
#include <ipxe/timer.h>
#include <ipxe/msr.h>
#include <ipxe/mp.h>
/** Local APIC base address MSR */
#define MSR_APIC_BASE 0x0000001b
/** Local APIC is in x2APIC mode */
#define MSR_APIC_BASE_X2APIC 0x400
/** Local APIC base address mask */
#define MSR_APIC_BASE_MASK ( ~0xfffULL )
/** Interrupt command register */
#define APIC_ICR 0x0300
/** Interrupt command register (x2APIC) */
#define MSR_X2APIC_ICR 0x830
/** Interrupt command register: send to all excluding self */
#define APIC_ICR_ALL_NOT_SELF 0x000c0000
/** Interrupt command register: level mode */
#define APIC_ICR_LEVEL 0x00008000
/** Interrupt command register: level asserted */
#define APIC_ICR_LEVEL_ASSERT 0x00004000
/** Interrupt command register: INIT */
#define APIC_ICR_INIT 0x00000500
/** Interrupt command register: SIPI */
#define APIC_ICR_SIPI( vector ) ( 0x00000600 | (vector) )
/** Time to wait for an IPI to complete */
#define IPI_WAIT_MS 10
/**
* Startup IPI vector
*
* The real-mode startup IPI code must be copied to a page boundary in
* base memory. We fairly arbitrarily choose to place this at 0x8000.
*/
#define SIPI_VECTOR 0x08
/** Protected-mode startup IPI handler */
extern void __asmcall mp_jump ( mp_addr_t func, mp_addr_t opaque );
/**
* Execute a multiprocessor function on the boot processor
*
* @v func Multiprocessor function
* @v opaque Opaque data pointer
*/
static void bios_mp_exec_boot ( mp_func_t func, void *opaque ) {
/* Call multiprocessor function with physical addressing */
__asm__ __volatile__ ( PHYS_CODE ( "pushl %k2\n\t"
"pushl %k1\n\t"
"call *%k0\n\t"
"addl $8, %%esp\n\t" )
: : "r" ( mp_address ( mp_call ) ),
"r" ( mp_address ( func ) ),
"r" ( mp_address ( opaque ) ) );
}
/**
* Send an interprocessor interrupt
*
* @v apic APIC base address
* @v x2apic x2APIC mode enabled
* @v icr Interrupt control register value
*/
static void bios_mp_ipi ( void *apic, int x2apic, uint32_t icr ) {
/* Write ICR according to APIC/x2APIC mode */
DBGC ( MSR_APIC_BASE, "BIOSMP sending IPI %#08x\n", icr );
if ( x2apic ) {
wrmsr ( MSR_X2APIC_ICR, icr );
} else {
writel ( icr, ( apic + APIC_ICR ) );
}
/* Allow plenty of time for delivery to complete */
mdelay ( IPI_WAIT_MS );
}
/**
* Start a multiprocessor function on all application processors
*
* @v func Multiprocessor function
* @v opaque Opaque data pointer
*/
static void bios_mp_start_all ( mp_func_t func, void *opaque ) {
struct i386_regs regs;
uint64_t base;
uint32_t ipi;
void *apic;
int x2apic;
/* Prepare SIPI handler */
regs.eax = mp_address ( func );
regs.edx = mp_address ( opaque );
setup_sipi ( SIPI_VECTOR, virt_to_phys ( mp_jump ), &regs );
/* Get local APIC base address and mode */
base = rdmsr ( MSR_APIC_BASE );
x2apic = ( base & MSR_APIC_BASE_X2APIC );
DBGC ( MSR_APIC_BASE, "BIOSMP local %sAPIC base %#llx\n",
( x2apic ? "x2" : "" ), ( ( unsigned long long ) base ) );
/* Map local APIC */
apic = ioremap ( ( base & MSR_APIC_BASE_MASK ), PAGE_SIZE );
if ( ! apic )
goto err_ioremap;
/* Assert INIT IPI */
ipi = ( APIC_ICR_ALL_NOT_SELF | APIC_ICR_LEVEL |
APIC_ICR_LEVEL_ASSERT | APIC_ICR_INIT );
bios_mp_ipi ( apic, x2apic, ipi );
/* Clear INIT IPI */
ipi &= ~APIC_ICR_LEVEL_ASSERT;
bios_mp_ipi ( apic, x2apic, ipi );
/* Send SIPI */
ipi = ( APIC_ICR_ALL_NOT_SELF | APIC_ICR_SIPI ( SIPI_VECTOR ) );
bios_mp_ipi ( apic, x2apic, ipi );
iounmap ( apic );
err_ioremap:
/* No way to handle errors: caller must check that
* multiprocessor function executed as expected.
*/
return;
}
PROVIDE_MPAPI_INLINE ( pcbios, mp_address );
PROVIDE_MPAPI ( pcbios, mp_exec_boot, bios_mp_exec_boot );
PROVIDE_MPAPI ( pcbios, mp_start_all, bios_mp_start_all );
+103 -112
View File
@@ -183,8 +183,8 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) {
/* Read boot record volume descriptor */
if ( ( rc = sandev_read ( sandev, ELTORITO_LBA, 1,
virt_to_user ( boot ) ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x could not read El "
"Torito boot record volume descriptor: %s\n",
DBGC ( sandev, "INT13 drive %02x could not read El Torito boot "
"record volume descriptor: %s\n",
sandev->drive, strerror ( rc ) );
return rc;
}
@@ -192,11 +192,10 @@ static int int13_parse_eltorito ( struct san_device *sandev, void *scratch ) {
/* Check for an El Torito boot catalog */
if ( memcmp ( boot, &boot_check, sizeof ( boot_check ) ) == 0 ) {
int13->boot_catalog = boot->sector;
DBGC ( sandev->drive, "INT13 drive %02x has an El Torito boot "
"catalog at LBA %08x\n", sandev->drive,
int13->boot_catalog );
DBGC ( sandev, "INT13 drive %02x has an El Torito boot catalog "
"at LBA %08x\n", sandev->drive, int13->boot_catalog );
} else {
DBGC ( sandev->drive, "INT13 drive %02x has no El Torito boot "
DBGC ( sandev, "INT13 drive %02x has no El Torito boot "
"catalog\n", sandev->drive );
}
@@ -229,14 +228,14 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch,
/* Read partition table */
if ( ( rc = sandev_read ( sandev, 0, 1, virt_to_user ( mbr ) ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x could not read "
DBGC ( sandev, "INT13 drive %02x could not read "
"partition table to guess geometry: %s\n",
sandev->drive, strerror ( rc ) );
return rc;
}
DBGC2 ( sandev->drive, "INT13 drive %02x has MBR:\n", sandev->drive );
DBGC2_HDA ( sandev->drive, 0, mbr, sizeof ( *mbr ) );
DBGC ( sandev->drive, "INT13 drive %02x has signature %08x\n",
DBGC2 ( sandev, "INT13 drive %02x has MBR:\n", sandev->drive );
DBGC2_HDA ( sandev, 0, mbr, sizeof ( *mbr ) );
DBGC ( sandev, "INT13 drive %02x has signature %08x\n",
sandev->drive, mbr->signature );
/* Scan through partition table and modify guesses for
@@ -261,8 +260,8 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch,
if ( ( start_cylinder == 0 ) && ( start_head != 0 ) ) {
*sectors = ( ( partition->start + 1 - start_sector ) /
start_head );
DBGC ( sandev->drive, "INT13 drive %02x guessing "
"C/H/S xx/xx/%d based on partition %d\n",
DBGC ( sandev, "INT13 drive %02x guessing C/H/S "
"xx/xx/%d based on partition %d\n",
sandev->drive, *sectors, ( i + 1 ) );
}
@@ -273,14 +272,14 @@ static int int13_guess_geometry_hdd ( struct san_device *sandev, void *scratch,
end_sector = PART_SECTOR ( partition->chs_end );
if ( ( end_head + 1 ) > *heads ) {
*heads = ( end_head + 1 );
DBGC ( sandev->drive, "INT13 drive %02x guessing "
"C/H/S xx/%d/xx based on partition %d\n",
DBGC ( sandev, "INT13 drive %02x guessing C/H/S "
"xx/%d/xx based on partition %d\n",
sandev->drive, *heads, ( i + 1 ) );
}
if ( end_sector > *sectors ) {
*sectors = end_sector;
DBGC ( sandev->drive, "INT13 drive %02x guessing "
"C/H/S xx/xx/%d based on partition %d\n",
DBGC ( sandev, "INT13 drive %02x guessing C/H/S "
"xx/xx/%d based on partition %d\n",
sandev->drive, *sectors, ( i + 1 ) );
}
}
@@ -344,10 +343,9 @@ static int int13_guess_geometry_fdd ( struct san_device *sandev,
*heads = INT13_FDD_HEADS ( geometry );
*sectors = INT13_FDD_SECTORS ( geometry );
if ( ( cylinders * (*heads) * (*sectors) ) == blocks ) {
DBGC ( sandev->drive, "INT13 drive %02x guessing "
"C/H/S %d/%d/%d based on size %dK\n",
sandev->drive, cylinders, *heads, *sectors,
( blocks / 2 ) );
DBGC ( sandev, "INT13 drive %02x guessing C/H/S "
"%d/%d/%d based on size %dK\n", sandev->drive,
cylinders, *heads, *sectors, ( blocks / 2 ) );
return 0;
}
}
@@ -357,9 +355,8 @@ static int int13_guess_geometry_fdd ( struct san_device *sandev,
*/
*heads = 2;
*sectors = 18;
DBGC ( sandev->drive, "INT13 drive %02x guessing C/H/S xx/%d/%d "
"based on size %dK\n", sandev->drive, *heads, *sectors,
( blocks / 2 ) );
DBGC ( sandev, "INT13 drive %02x guessing C/H/S xx/%d/%d based on size "
"%dK\n", sandev->drive, *heads, *sectors, ( blocks / 2 ) );
return 0;
}
@@ -434,8 +431,8 @@ static void int13_sync_num_drives ( void ) {
required = ( ( max_drive & 0x7f ) + 1 );
if ( *counter < required ) {
*counter = required;
DBGC ( sandev->drive, "INT13 drive %02x added to "
"drive count: %d HDDs, %d FDDs\n",
DBGC ( sandev, "INT13 drive %02x added to drive count: "
"%d HDDs, %d FDDs\n",
sandev->drive, num_drives, num_fdds );
}
}
@@ -475,7 +472,7 @@ static int int13_reset ( struct san_device *sandev,
struct i386_all_regs *ix86 __unused ) {
int rc;
DBGC2 ( sandev->drive, "Reset drive\n" );
DBGC2 ( sandev, "Reset drive\n" );
/* Reset SAN device */
if ( ( rc = sandev_reset ( sandev ) ) != 0 )
@@ -494,7 +491,7 @@ static int int13_get_last_status ( struct san_device *sandev,
struct i386_all_regs *ix86 __unused ) {
struct int13_data *int13 = sandev->priv;
DBGC2 ( sandev->drive, "Get status of last operation\n" );
DBGC2 ( sandev, "Get status of last operation\n" );
return int13->last_status;
}
@@ -527,8 +524,8 @@ static int int13_rw_sectors ( struct san_device *sandev,
/* Validate blocksize */
if ( sandev_blksize ( sandev ) != INT13_BLKSIZE ) {
DBGC ( sandev->drive, "\nINT 13 drive %02x invalid blocksize "
"(%zd) for non-extended read/write\n",
DBGC ( sandev, "\nINT 13 drive %02x invalid blocksize (%zd) "
"for non-extended read/write\n",
sandev->drive, sandev_blksize ( sandev ) );
return -INT13_STATUS_INVALID;
}
@@ -540,10 +537,9 @@ static int int13_rw_sectors ( struct san_device *sandev,
if ( ( cylinder >= int13->cylinders ) ||
( head >= int13->heads ) ||
( sector < 1 ) || ( sector > int13->sectors_per_track ) ) {
DBGC ( sandev->drive, "C/H/S %d/%d/%d out of range for "
"geometry %d/%d/%d\n", cylinder, head, sector,
int13->cylinders, int13->heads,
int13->sectors_per_track );
DBGC ( sandev, "C/H/S %d/%d/%d out of range for geometry "
"%d/%d/%d\n", cylinder, head, sector, int13->cylinders,
int13->heads, int13->sectors_per_track );
return -INT13_STATUS_INVALID;
}
lba = ( ( ( ( cylinder * int13->heads ) + head )
@@ -551,13 +547,13 @@ static int int13_rw_sectors ( struct san_device *sandev,
count = ix86->regs.al;
buffer = real_to_user ( ix86->segs.es, ix86->regs.bx );
DBGC2 ( sandev->drive, "C/H/S %d/%d/%d = LBA %08lx <-> %04x:%04x "
"(count %d)\n", cylinder, head, sector, lba, ix86->segs.es,
ix86->regs.bx, count );
DBGC2 ( sandev, "C/H/S %d/%d/%d = LBA %08lx <-> %04x:%04x (count %d)\n",
cylinder, head, sector, lba, ix86->segs.es, ix86->regs.bx,
count );
/* Read from / write to block device */
if ( ( rc = sandev_rw ( sandev, lba, count, buffer ) ) != 0 ){
DBGC ( sandev->drive, "INT13 drive %02x I/O failed: %s\n",
DBGC ( sandev, "INT13 drive %02x I/O failed: %s\n",
sandev->drive, strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
}
@@ -581,7 +577,7 @@ static int int13_rw_sectors ( struct san_device *sandev,
static int int13_read_sectors ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
DBGC2 ( sandev->drive, "Read: " );
DBGC2 ( sandev, "Read: " );
return int13_rw_sectors ( sandev, ix86, sandev_read );
}
@@ -601,7 +597,7 @@ static int int13_read_sectors ( struct san_device *sandev,
static int int13_write_sectors ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
DBGC2 ( sandev->drive, "Write: " );
DBGC2 ( sandev, "Write: " );
return int13_rw_sectors ( sandev, ix86, sandev_write );
}
@@ -623,12 +619,12 @@ static int int13_get_parameters ( struct san_device *sandev,
unsigned int max_head = int13->heads - 1;
unsigned int max_sector = int13->sectors_per_track; /* sic */
DBGC2 ( sandev->drive, "Get drive parameters\n" );
DBGC2 ( sandev, "Get drive parameters\n" );
/* Validate blocksize */
if ( sandev_blksize ( sandev ) != INT13_BLKSIZE ) {
DBGC ( sandev->drive, "\nINT 13 drive %02x invalid blocksize "
"(%zd) for non-extended parameters\n",
DBGC ( sandev, "\nINT 13 drive %02x invalid blocksize (%zd) "
"for non-extended parameters\n",
sandev->drive, sandev_blksize ( sandev ) );
return -INT13_STATUS_INVALID;
}
@@ -661,7 +657,7 @@ static int int13_get_disk_type ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
uint32_t blocks;
DBGC2 ( sandev->drive, "Get disk type\n" );
DBGC2 ( sandev, "Get disk type\n" );
if ( int13_is_fdd ( sandev ) ) {
return INT13_DISK_TYPE_FDD;
@@ -686,7 +682,7 @@ static int int13_extension_check ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
if ( ( ix86->regs.bx == 0x55aa ) && ! int13_is_fdd ( sandev ) ) {
DBGC2 ( sandev->drive, "INT13 extensions check\n" );
DBGC2 ( sandev, "INT13 extensions installation check\n" );
ix86->regs.bx = 0xaa55;
ix86->regs.cx = ( INT13_EXTENSION_LINEAR |
INT13_EXTENSION_EDD |
@@ -729,8 +725,7 @@ static int int13_extended_rw ( struct san_device *sandev,
get_real ( bufsize, ix86->segs.ds,
( ix86->regs.si + offsetof ( typeof ( addr ), bufsize ) ) );
if ( bufsize < offsetof ( typeof ( addr ), buffer_phys ) ) {
DBGC2 ( sandev->drive, "<invalid buffer size %#02x\n>\n",
bufsize );
DBGC2 ( sandev, "<invalid buffer size %#02x\n>\n", bufsize );
return -INT13_STATUS_INVALID;
}
@@ -738,18 +733,17 @@ static int int13_extended_rw ( struct san_device *sandev,
memset ( &addr, 0, sizeof ( addr ) );
copy_from_real ( &addr, ix86->segs.ds, ix86->regs.si, bufsize );
lba = addr.lba;
DBGC2 ( sandev->drive, "LBA %08llx <-> ",
( ( unsigned long long ) lba ) );
DBGC2 ( sandev, "LBA %08llx <-> ", ( ( unsigned long long ) lba ) );
if ( ( addr.count == 0xff ) ||
( ( addr.buffer.segment == 0xffff ) &&
( addr.buffer.offset == 0xffff ) ) ) {
buffer = phys_to_user ( addr.buffer_phys );
DBGC2 ( sandev->drive, "%08llx",
DBGC2 ( sandev, "%08llx",
( ( unsigned long long ) addr.buffer_phys ) );
} else {
buffer = real_to_user ( addr.buffer.segment,
addr.buffer.offset );
DBGC2 ( sandev->drive, "%04x:%04x", addr.buffer.segment,
DBGC2 ( sandev, "%04x:%04x", addr.buffer.segment,
addr.buffer.offset );
}
if ( addr.count <= 0x7f ) {
@@ -757,15 +751,15 @@ static int int13_extended_rw ( struct san_device *sandev,
} else if ( addr.count == 0xff ) {
count = addr.long_count;
} else {
DBGC2 ( sandev->drive, " <invalid count %#02x>\n", addr.count );
DBGC2 ( sandev, " <invalid count %#02x>\n", addr.count );
return -INT13_STATUS_INVALID;
}
DBGC2 ( sandev->drive, " (count %ld)\n", count );
DBGC2 ( sandev, " (count %ld)\n", count );
/* Read from / write to block device */
if ( ( rc = sandev_rw ( sandev, lba, count, buffer ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x extended I/O failed: "
"%s\n", sandev->drive, strerror ( rc ) );
DBGC ( sandev, "INT13 drive %02x extended I/O failed: %s\n",
sandev->drive, strerror ( rc ) );
/* Record that no blocks were transferred successfully */
addr.count = 0;
put_real ( addr.count, ix86->segs.ds,
@@ -787,7 +781,7 @@ static int int13_extended_rw ( struct san_device *sandev,
static int int13_extended_read ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
DBGC2 ( sandev->drive, "Extended read: " );
DBGC2 ( sandev, "Extended read: " );
return int13_extended_rw ( sandev, ix86, sandev_read );
}
@@ -801,7 +795,7 @@ static int int13_extended_read ( struct san_device *sandev,
static int int13_extended_write ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
DBGC2 ( sandev->drive, "Extended write: " );
DBGC2 ( sandev, "Extended write: " );
return int13_extended_rw ( sandev, ix86, sandev_write );
}
@@ -824,7 +818,7 @@ static int int13_extended_verify ( struct san_device *sandev,
sizeof ( addr ));
lba = addr.lba;
count = addr.count;
DBGC2 ( sandev->drive, "Verify: LBA %08llx (count %ld)\n",
DBGC2 ( sandev, "Verify: LBA %08llx (count %ld)\n",
( ( unsigned long long ) lba ), count );
}
@@ -851,7 +845,7 @@ static int int13_extended_seek ( struct san_device *sandev,
sizeof ( addr ));
lba = addr.lba;
count = addr.count;
DBGC2 ( sandev->drive, "Seek: LBA %08llx (count %ld)\n",
DBGC2 ( sandev, "Seek: LBA %08llx (count %ld)\n",
( ( unsigned long long ) lba ), count );
}
@@ -885,8 +879,8 @@ static int int13_device_path_info ( struct san_device *sandev,
/* Get underlying hardware device */
device = identify_device ( &sanpath->block );
if ( ! device ) {
DBGC ( sandev->drive, "INT13 drive %02x cannot identify "
"hardware device\n", sandev->drive );
DBGC ( sandev, "INT13 drive %02x cannot identify hardware "
"device\n", sandev->drive );
return -ENODEV;
}
@@ -901,16 +895,16 @@ static int int13_device_path_info ( struct san_device *sandev,
dpi->interface_path.pci.channel = 0xff; /* unused */
break;
default:
DBGC ( sandev->drive, "INT13 drive %02x unrecognised bus "
"type %d\n", sandev->drive, desc->bus_type );
DBGC ( sandev, "INT13 drive %02x unrecognised bus type %d\n",
sandev->drive, desc->bus_type );
return -ENOTSUP;
}
/* Get EDD block device description */
if ( ( rc = edd_describe ( &sanpath->block, &dpi->interface_type,
&dpi->device_path ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x cannot identify "
"block device: %s\n", sandev->drive, strerror ( rc ) );
DBGC ( sandev, "INT13 drive %02x cannot identify block device: "
"%s\n", sandev->drive, strerror ( rc ) );
return rc;
}
@@ -944,8 +938,8 @@ static int int13_get_extended_parameters ( struct san_device *sandev,
get_real ( bufsize, ix86->segs.ds,
( ix86->regs.si + offsetof ( typeof ( params ), bufsize )));
DBGC2 ( sandev->drive, "Get extended drive parameters to "
"%04x:%04x+%02x\n", ix86->segs.ds, ix86->regs.si, bufsize );
DBGC2 ( sandev, "Get extended drive parameters to %04x:%04x+%02x\n",
ix86->segs.ds, ix86->regs.si, bufsize );
/* Build drive parameters */
memset ( &params, 0, sizeof ( params ) );
@@ -961,8 +955,8 @@ static int int13_get_extended_parameters ( struct san_device *sandev,
params.sector_size = sandev_blksize ( sandev );
memset ( &params.dpte, 0xff, sizeof ( params.dpte ) );
if ( ( rc = int13_device_path_info ( sandev, &params.dpi ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x could not provide "
"device path information: %s\n",
DBGC ( sandev, "INT13 drive %02x could not provide device "
"path information: %s\n",
sandev->drive, strerror ( rc ) );
len = offsetof ( typeof ( params ), dpi );
}
@@ -979,11 +973,11 @@ static int int13_get_extended_parameters ( struct san_device *sandev,
params.bufsize = offsetof ( typeof ( params ), dpi );
}
DBGC ( sandev->drive, "INT 13 drive %02x described using extended "
DBGC ( sandev, "INT 13 drive %02x described using extended "
"parameters:\n", sandev->drive );
address.segment = ix86->segs.ds;
address.offset = ix86->regs.si;
DBGC_HDA ( sandev->drive, address, &params, len );
DBGC_HDA ( sandev, address, &params, len );
/* Return drive parameters */
if ( len > bufsize )
@@ -1004,13 +998,13 @@ static int int13_cdrom_status_terminate ( struct san_device *sandev,
struct i386_all_regs *ix86 ) {
struct int13_cdrom_specification specification;
DBGC2 ( sandev->drive, "Get CD-ROM emulation status to %04x:%04x%s\n",
DBGC2 ( sandev, "Get CD-ROM emulation status to %04x:%04x%s\n",
ix86->segs.ds, ix86->regs.si,
( ix86->regs.al ? "" : " and terminate" ) );
/* Fail if we are not a CD-ROM */
if ( ! sandev->is_cdrom ) {
DBGC ( sandev->drive, "INT13 drive %02x is not a CD-ROM\n",
DBGC ( sandev, "INT13 drive %02x is not a CD-ROM\n",
sandev->drive );
return -INT13_STATUS_INVALID;
}
@@ -1045,12 +1039,11 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev,
/* Read parameters from command packet */
copy_from_real ( &command, ix86->segs.ds, ix86->regs.si,
sizeof ( command ) );
DBGC2 ( sandev->drive, "Read CD-ROM boot catalog to %08x\n",
command.buffer );
DBGC2 ( sandev, "Read CD-ROM boot catalog to %08x\n", command.buffer );
/* Fail if we have no boot catalog */
if ( ! int13->boot_catalog ) {
DBGC ( sandev->drive, "INT13 drive %02x has no boot catalog\n",
DBGC ( sandev, "INT13 drive %02x has no boot catalog\n",
sandev->drive );
return -INT13_STATUS_INVALID;
}
@@ -1059,8 +1052,8 @@ static int int13_cdrom_read_boot_catalog ( struct san_device *sandev,
/* Read from boot catalog */
if ( ( rc = sandev_read ( sandev, start, command.count,
phys_to_user ( command.buffer ) ) ) != 0 ) {
DBGC ( sandev->drive, "INT13 drive %02x could not read boot "
"catalog: %s\n", sandev->drive, strerror ( rc ) );
DBGC ( sandev, "INT13 drive %02x could not read boot catalog: "
"%s\n", sandev->drive, strerror ( rc ) );
return -INT13_STATUS_READ_ERROR;
}
@@ -1087,8 +1080,8 @@ static __asmcall __used void int13 ( struct i386_all_regs *ix86 ) {
if ( bios_drive != sandev->drive ) {
/* Remap any accesses to this drive's natural number */
if ( bios_drive == int13->natural_drive ) {
DBGC2 ( sandev->drive, "INT13,%02x (%02x) "
"remapped to (%02x)\n", ix86->regs.ah,
DBGC2 ( sandev, "INT13,%02x (%02x) remapped to "
"(%02x)\n", ix86->regs.ah,
bios_drive, sandev->drive );
ix86->regs.dl = sandev->drive;
return;
@@ -1101,7 +1094,7 @@ static __asmcall __used void int13 ( struct i386_all_regs *ix86 ) {
}
}
DBGC2 ( sandev->drive, "INT13,%02x (%02x): ",
DBGC2 ( sandev, "INT13,%02x (%02x): ",
ix86->regs.ah, bios_drive );
switch ( command ) {
@@ -1148,7 +1141,7 @@ static __asmcall __used void int13 ( struct i386_all_regs *ix86 ) {
status = int13_cdrom_read_boot_catalog ( sandev, ix86 );
break;
default:
DBGC2 ( sandev->drive, "*** Unrecognised INT13 ***\n" );
DBGC2 ( sandev, "*** Unrecognised INT13 ***\n" );
status = -INT13_STATUS_INVALID;
break;
}
@@ -1159,9 +1152,8 @@ static __asmcall __used void int13 ( struct i386_all_regs *ix86 ) {
/* Negative status indicates an error */
if ( status < 0 ) {
status = -status;
DBGC ( sandev->drive, "INT13,%02x (%02x) failed with "
"status %02x\n", ix86->regs.ah, sandev->drive,
status );
DBGC ( sandev, "INT13,%02x (%02x) failed with status "
"%02x\n", ix86->regs.ah, sandev->drive, status );
} else {
ix86->flags &= ~CF;
}
@@ -1277,7 +1269,7 @@ static int int13_hook ( unsigned int drive, struct uri **uris,
/* Register SAN device */
if ( ( rc = register_sandev ( sandev, drive, flags ) ) != 0 ) {
DBGC ( drive, "INT13 drive %02x could not register: %s\n",
DBGC ( sandev, "INT13 drive %02x could not register: %s\n",
drive, strerror ( rc ) );
goto err_register;
}
@@ -1297,9 +1289,10 @@ static int int13_hook ( unsigned int drive, struct uri **uris,
( ( rc = int13_guess_geometry ( sandev, scratch ) ) != 0 ) )
goto err_guess_geometry;
DBGC ( drive, "INT13 drive %02x (naturally %02x) registered with "
"C/H/S geometry %d/%d/%d\n", drive, int13->natural_drive,
int13->cylinders, int13->heads, int13->sectors_per_track );
DBGC ( sandev, "INT13 drive %02x (naturally %02x) registered with "
"C/H/S geometry %d/%d/%d\n",
sandev->drive, int13->natural_drive, int13->cylinders,
int13->heads, int13->sectors_per_track );
/* Hook INT 13 vector if not already hooked */
if ( need_hook ) {
@@ -1339,7 +1332,7 @@ static void int13_unhook ( unsigned int drive ) {
/* Find drive */
sandev = sandev_find ( drive );
if ( ! sandev ) {
DBGC ( drive, "INT13 drive %02x is not a SAN drive\n", drive );
DBG ( "INT13 cannot find drive %02x\n", drive );
return;
}
@@ -1350,7 +1343,7 @@ static void int13_unhook ( unsigned int drive ) {
* to do so reliably.
*/
DBGC ( drive, "INT13 drive %02x unregistered\n", drive );
DBGC ( sandev, "INT13 drive %02x unregistered\n", sandev->drive );
/* Unhook INT 13 vector if no more drives */
if ( ! have_sandevs() ) {
@@ -1394,8 +1387,8 @@ static int int13_load_mbr ( unsigned int drive, struct segoff *address ) {
: "a" ( 0x0201 ), "b" ( *address ),
"c" ( 1 ), "d" ( drive ) );
if ( status ) {
DBGC ( drive, "INT13 drive %02x could not read MBR (status "
"%04x)\n", drive, status );
DBG ( "INT13 drive %02x could not read MBR (status %04x)\n",
drive, status );
return -EIO;
}
@@ -1404,8 +1397,8 @@ static int int13_load_mbr ( unsigned int drive, struct segoff *address ) {
( address->offset +
offsetof ( struct master_boot_record, magic ) ) );
if ( magic != INT13_MBR_MAGIC ) {
DBGC ( drive, "INT13 drive %02x does not contain a valid MBR\n",
drive );
DBG ( "INT13 drive %02x does not contain a valid MBR\n",
drive );
return -ENOEXEC;
}
@@ -1451,8 +1444,8 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
: "a" ( 0x4d00 ), "d" ( drive ),
"S" ( __from_data16 ( &eltorito_cmd ) ) );
if ( status ) {
DBGC ( drive, "INT13 drive %02x could not read El Torito boot "
"catalog (status %04x)\n", drive, status );
DBG ( "INT13 drive %02x could not read El Torito boot catalog "
"(status %04x)\n", drive, status );
return -EIO;
}
copy_from_user ( &catalog, phys_to_user ( eltorito_cmd.buffer ), 0,
@@ -1460,27 +1453,26 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
/* Sanity checks */
if ( catalog.valid.platform_id != ELTORITO_PLATFORM_X86 ) {
DBGC ( drive, "INT13 drive %02x El Torito specifies unknown "
"platform %02x\n", drive, catalog.valid.platform_id );
DBG ( "INT13 drive %02x El Torito specifies unknown platform "
"%02x\n", drive, catalog.valid.platform_id );
return -ENOEXEC;
}
if ( catalog.boot.indicator != ELTORITO_BOOTABLE ) {
DBGC ( drive, "INT13 drive %02x El Torito is not bootable\n",
drive );
DBG ( "INT13 drive %02x El Torito is not bootable\n", drive );
return -ENOEXEC;
}
if ( catalog.boot.media_type != ELTORITO_NO_EMULATION ) {
DBGC ( drive, "INT13 drive %02x El Torito requires emulation "
DBG ( "INT13 drive %02x El Torito requires emulation "
"type %02x\n", drive, catalog.boot.media_type );
return -ENOTSUP;
}
DBGC ( drive, "INT13 drive %02x El Torito boot image at LBA %08x "
"(count %d)\n", drive, catalog.boot.start, catalog.boot.length );
DBG ( "INT13 drive %02x El Torito boot image at LBA %08x (count %d)\n",
drive, catalog.boot.start, catalog.boot.length );
address->segment = ( catalog.boot.load_segment ?
catalog.boot.load_segment : 0x7c0 );
address->offset = 0;
DBGC ( drive, "INT13 drive %02x El Torito boot image loads at "
"%04x:%04x\n", drive, address->segment, address->offset );
DBG ( "INT13 drive %02x El Torito boot image loads at %04x:%04x\n",
drive, address->segment, address->offset );
/* Use INT 13, 42 to read the boot image */
eltorito_address.bufsize =
@@ -1499,8 +1491,8 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
: "a" ( 0x4200 ), "d" ( drive ),
"S" ( __from_data16 ( &eltorito_address ) ) );
if ( status ) {
DBGC ( drive, "INT13 drive %02x could not read El Torito boot "
"image (status %04x)\n", drive, status );
DBG ( "INT13 drive %02x could not read El Torito boot image "
"(status %04x)\n", drive, status );
return -EIO;
}
@@ -1511,7 +1503,7 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
* Attempt to boot from an INT 13 drive
*
* @v drive Drive number
* @v config Boot configuration parameters
* @v filename Filename (or NULL to use default)
* @ret rc Return status code
*
* This boots from the specified INT 13 drive by loading the Master
@@ -1521,8 +1513,7 @@ static int int13_load_eltorito ( unsigned int drive, struct segoff *address ) {
*
* Note that this function can never return success, by definition.
*/
static int int13_boot ( unsigned int drive,
struct san_boot_config *config __unused ) {
static int int13_boot ( unsigned int drive, const char *filename __unused ) {
struct memory_map memmap;
struct segoff address;
int rc;
@@ -1542,8 +1533,8 @@ static int int13_boot ( unsigned int drive,
/* Jump to boot sector */
if ( ( rc = call_bootsector ( address.segment, address.offset,
drive ) ) != 0 ) {
DBGC ( drive, "INT13 drive %02x boot returned: %s\n",
drive, strerror ( rc ) );
DBG ( "INT13 drive %02x boot returned: %s\n",
drive, strerror ( rc ) );
return rc;
}
-67
View File
@@ -1632,70 +1632,3 @@ init_pages:
/* Return */
ret
/****************************************************************************
* sipi (real-mode jump)
*
* Handle Startup IPI
*
* This code must be copied to a page-aligned boundary in base memory.
* It will be entered with %cs:0000 pointing to the start of the code.
* The stack pointer is undefined and so no stack space can be used.
*
****************************************************************************
*/
.section ".text16.sipi", "ax", @progbits
.code16
.globl sipi
sipi:
/* Retrieve rm_ds from copy */
movw %cs:( sipi_ds - sipi ), %ax
movw %ax, %ds
/* Load GDT and switch to protected mode */
data32 lgdt gdtr
movl %cr0, %eax
orb $CR0_PE, %al
movl %eax, %cr0
data32 ljmp $VIRTUAL_CS, $VIRTUAL(1f)
/* Copy of rm_ds required to access GDT */
.globl sipi_ds
sipi_ds:
.word 0
/* Length of real-mode SIPI handler to be copied */
.globl sipi_len
.equ sipi_len, . - sipi
.section ".text.sipi", "ax", @progbits
.code32
1: /* Set up protected-mode segment registers (with no stack) */
movw $VIRTUAL_DS, %ax
movw %ax, %ds
movw %ax, %ss
movw $PHYSICAL_DS, %ax
movw %ax, %es
movw %ax, %fs
movw %ax, %gs
/* Load register state and clear stack pointer */
movl $VIRTUAL(sipi_regs), %esp
popal
/* Switch to flat physical addressing */
movw $PHYSICAL_DS, %sp
movw %sp, %ds
movw %sp, %ss
/* Clear stack pointer */
xorl %esp, %esp
/* Jump to protected-mode SIPI handler */
ljmp %cs:*VIRTUAL(sipi_handler)
/* Protected-mode SIPI handler vector */
.section ".data.sipi_handler", "aw", @progbits
.globl sipi_handler
sipi_handler:
.long 0, PHYSICAL_CS
-26
View File
@@ -45,9 +45,6 @@ struct idtr64 idtr64 = {
.limit = ( sizeof ( idt64 ) - 1 ),
};
/** Startup IPI register state */
struct i386_regs sipi_regs;
/** Length of stack dump */
#define STACK_DUMP_LEN 128
@@ -405,29 +402,6 @@ __asmcall void check_fxsr ( struct i386_all_regs *regs ) {
( ( regs->flags & CF ) ? " not" : "" ) );
}
/**
* Set up startup IPI handler
*
* @v vector Startup IPI vector
* @v handler Protected-mode startup IPI handler physical address
* @v regs Initial register state
*/
void setup_sipi ( unsigned int vector, uint32_t handler,
struct i386_regs *regs ) {
/* Record protected-mode handler */
sipi_handler = handler;
/* Update copy of rm_ds */
sipi_ds = rm_ds;
/* Save register state */
memcpy ( &sipi_regs, regs, sizeof ( sipi_regs ) );
/* Copy real-mode handler */
copy_to_real ( ( vector << 8 ), 0, sipi, ( ( size_t ) sipi_len ) );
}
PROVIDE_UACCESS_INLINE ( librm, phys_to_user );
PROVIDE_UACCESS_INLINE ( librm, user_to_phys );
PROVIDE_UACCESS_INLINE ( librm, virt_to_user );
+1 -7
View File
@@ -188,9 +188,6 @@ REQUIRE_OBJECT ( zlib );
#ifdef IMAGE_GZIP
REQUIRE_OBJECT ( gzip );
#endif
#ifdef IMAGE_UCODE
REQUIRE_OBJECT ( ucode );
#endif
/*
* Drag in all requested commands
@@ -225,10 +222,7 @@ REQUIRE_OBJECT ( dhcp_cmd );
REQUIRE_OBJECT ( sanboot_cmd );
#endif
#ifdef MENU_CMD
REQUIRE_OBJECT ( dynui_cmd );
#endif
#ifdef FORM_CMD
REQUIRE_OBJECT ( dynui_cmd );
REQUIRE_OBJECT ( menu_cmd );
#endif
#ifdef LOGIN_CMD
REQUIRE_OBJECT ( login_cmd );
-42
View File
@@ -1,42 +0,0 @@
/*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <config/general.h>
/** @file
*
* EAP configuration options
*
*/
PROVIDE_REQUIRING_SYMBOL();
/*
* Drag in EAP authentication methods
*/
#ifdef EAP_METHOD_MD5
REQUIRE_OBJECT ( eap_md5 );
#endif
#ifdef EAP_METHOD_MSCHAPV2
REQUIRE_OBJECT ( eap_mschapv2 );
#endif
-1
View File
@@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define REBOOT_EFI
#define ACPI_EFI
#define FDT_EFI
#define MPAPI_EFI
#define NET_PROTO_IPV6 /* IPv6 protocol */
#define NET_PROTO_LLDP /* Link Layer Discovery protocol */
-1
View File
@@ -22,7 +22,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
#define PCIAPI_LINUX
#define DMAAPI_FLAT
#define ACPI_LINUX
#define MPAPI_NULL
#define DRIVERS_LINUX
-1
View File
@@ -24,7 +24,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define TIME_RTC
#define REBOOT_PCBIOS
#define ACPI_RSDP
#define MPAPI_PCBIOS
#ifdef __x86_64__
#define IOMAP_PAGES
-9
View File
@@ -91,13 +91,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define CRYPTO_80211_WPA /* WPA Personal, authenticating with passphrase */
#define CRYPTO_80211_WPA2 /* Add support for stronger WPA cryptography */
/*
* 802.1x EAP authentication methods
*
*/
#define EAP_METHOD_MD5 /* MD5-Challenge port authentication */
//#define EAP_METHOD_MSCHAPV2 /* MS-CHAPv2 port authentication */
/*
* Name resolution modules
*
@@ -127,7 +120,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define IMAGE_PEM /* PEM image support */
//#define IMAGE_ZLIB /* ZLIB image support */
//#define IMAGE_GZIP /* GZIP image support */
//#define IMAGE_UCODE /* Microcode update image support */
/*
* Command-line commands to include
@@ -145,7 +137,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define DHCP_CMD /* DHCP management commands */
#define SANBOOT_CMD /* SAN boot commands */
#define MENU_CMD /* Menu commands */
#define FORM_CMD /* Form commands */
#define LOGIN_CMD /* Login command */
#define SYNC_CMD /* Sync command */
#define SHELL_CMD /* Shell command */
+2 -13
View File
@@ -78,23 +78,12 @@ int hex_decode ( char separator, const char *encoded, void *data, size_t len ) {
unsigned int count = 0;
unsigned int sixteens;
unsigned int units;
int optional;
/* Strip out optionality flag from separator character */
optional = ( separator & HEX_DECODE_OPTIONAL );
separator &= ~HEX_DECODE_OPTIONAL;
/* Decode string */
while ( *encoded ) {
/* Check separator, if applicable */
if ( count && separator ) {
if ( *encoded == separator ) {
encoded++;
} else if ( ! optional ) {
return -EINVAL;
}
}
if ( count && separator && ( ( *(encoded++) != separator ) ) )
return -EINVAL;
/* Extract digits. Note that either digit may be NUL,
* which would be interpreted as an invalid value by
+10 -65
View File
@@ -46,20 +46,11 @@ struct cached_dhcp_packet {
struct dhcp_packet *dhcppkt;
/** VLAN tag (if applicable) */
unsigned int vlan;
/** Flags */
unsigned int flags;
};
/** Cached DHCP packet should be retained */
#define CACHEDHCP_RETAIN 0x0001
/** Cached DHCP packet has been used */
#define CACHEDHCP_USED 0x0002
/** Cached DHCPACK */
struct cached_dhcp_packet cached_dhcpack = {
.name = DHCP_SETTINGS_NAME,
.flags = CACHEDHCP_RETAIN,
};
/** Cached ProxyDHCPOFFER */
@@ -110,8 +101,8 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache,
size_t ll_addr_len;
int rc;
/* Do nothing if cache is empty or already in use */
if ( ( ! cache->dhcppkt ) || ( cache->flags & CACHEDHCP_USED ) )
/* Do nothing if cache is empty */
if ( ! cache->dhcppkt )
return 0;
chaddr = cache->dhcppkt->dhcphdr->chaddr;
@@ -178,12 +169,8 @@ static int cachedhcp_apply ( struct cached_dhcp_packet *cache,
return rc;
}
/* Mark as used */
cache->flags |= CACHEDHCP_USED;
/* Free cached DHCP packet, if applicable */
if ( ! ( cache->flags & CACHEDHCP_RETAIN ) )
cachedhcp_free ( cache );
/* Free cached DHCP packet */
cachedhcp_free ( cache );
return 0;
}
@@ -259,10 +246,10 @@ int cachedhcp_record ( struct cached_dhcp_packet *cache, unsigned int vlan,
}
/**
* Cached DHCP packet early startup function
* Cached DHCP packet startup function
*
*/
static void cachedhcp_startup_early ( void ) {
static void cachedhcp_startup ( void ) {
/* Apply cached ProxyDHCPOFFER, if any */
cachedhcp_apply ( &cached_proxydhcp, NULL );
@@ -271,20 +258,6 @@ static void cachedhcp_startup_early ( void ) {
/* Apply cached PXEBSACK, if any */
cachedhcp_apply ( &cached_pxebs, NULL );
cachedhcp_free ( &cached_pxebs );
}
/**
* Cache DHCP packet late startup function
*
*/
static void cachedhcp_startup_late ( void ) {
/* Clear retention flag */
cached_dhcpack.flags &= ~CACHEDHCP_RETAIN;
/* Free cached DHCPACK, if used by a network device */
if ( cached_dhcpack.flags & CACHEDHCP_USED )
cachedhcp_free ( &cached_dhcpack );
/* Report unclaimed DHCPACK, if any. Do not free yet, since
* it may still be claimed by a dynamically created device
@@ -311,16 +284,10 @@ static void cachedhcp_shutdown ( int booting __unused ) {
cachedhcp_free ( &cached_dhcpack );
}
/** Cached DHCP packet early startup function */
struct startup_fn cachedhcp_early_fn __startup_fn ( STARTUP_EARLY ) = {
.name = "cachedhcp1",
.startup = cachedhcp_startup_early,
};
/** Cached DHCP packet late startup function */
struct startup_fn cachedhcp_late_fn __startup_fn ( STARTUP_LATE ) = {
.name = "cachedhcp2",
.startup = cachedhcp_startup_late,
/** Cached DHCPACK startup function */
struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
.name = "cachedhcp",
.startup = cachedhcp_startup,
.shutdown = cachedhcp_shutdown,
};
@@ -342,25 +309,3 @@ struct net_driver cachedhcp_driver __net_driver = {
.name = "cachedhcp",
.probe = cachedhcp_probe,
};
/**
* Recycle cached DHCPACK
*
* @v netdev Network device
* @v priv Private data
*/
void cachedhcp_recycle ( struct net_device *netdev ) {
struct cached_dhcp_packet *cache = &cached_dhcpack;
struct settings *settings;
/* Return DHCPACK to cache, if applicable */
settings = find_child_settings ( netdev_settings ( netdev ),
cache->name );
if ( cache->dhcppkt && ( settings == &cache->dhcppkt->settings ) ) {
DBGC ( colour, "CACHEDHCP %s recycled from %s\n",
cache->name, netdev->name );
assert ( cache->flags & CACHEDHCP_USED );
unregister_settings ( settings );
cache->flags &= ~CACHEDHCP_USED;
}
}
+4 -4
View File
@@ -55,7 +55,7 @@ static int dummy_san_hook ( unsigned int drive, struct uri **uris,
/* Register SAN device */
if ( ( rc = register_sandev ( sandev, drive, flags ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x could not register: %s\n",
DBGC ( sandev, "SAN %#02x could not register: %s\n",
sandev->drive, strerror ( rc ) );
goto err_register;
}
@@ -80,7 +80,7 @@ static void dummy_san_unhook ( unsigned int drive ) {
/* Find drive */
sandev = sandev_find ( drive );
if ( ! sandev ) {
DBGC ( drive, "SAN %#02x does not exist\n", drive );
DBG ( "SAN %#02x does not exist\n", drive );
return;
}
@@ -95,11 +95,11 @@ static void dummy_san_unhook ( unsigned int drive ) {
* Boot from dummy SAN device
*
* @v drive Drive number
* @v config Boot configuration parameters
* @v filename Filename (or NULL to use default)
* @ret rc Return status code
*/
static int dummy_san_boot ( unsigned int drive __unused,
struct san_boot_config *config __unused ) {
const char *filename __unused ) {
return -EOPNOTSUPP;
}
-220
View File
@@ -1,220 +0,0 @@
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Dynamic user interfaces
*
*/
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ipxe/list.h>
#include <ipxe/dynui.h>
/** List of all dynamic user interfaces */
static LIST_HEAD ( dynamic_uis );
/**
* Create dynamic user interface
*
* @v name User interface name, or NULL
* @v title User interface title, or NULL
* @ret dynui Dynamic user interface, or NULL on failure
*/
struct dynamic_ui * create_dynui ( const char *name, const char *title ) {
struct dynamic_ui *dynui;
size_t name_len;
size_t title_len;
size_t len;
char *name_copy;
char *title_copy;
/* Destroy any existing user interface of this name */
dynui = find_dynui ( name );
if ( dynui )
destroy_dynui ( dynui );
/* Use empty title if none given */
if ( ! title )
title = "";
/* Allocate user interface */
name_len = ( name ? ( strlen ( name ) + 1 /* NUL */ ) : 0 );
title_len = ( strlen ( title ) + 1 /* NUL */ );
len = ( sizeof ( *dynui ) + name_len + title_len );
dynui = zalloc ( len );
if ( ! dynui )
return NULL;
name_copy = ( ( void * ) ( dynui + 1 ) );
title_copy = ( name_copy + name_len );
/* Initialise user interface */
if ( name ) {
strcpy ( name_copy, name );
dynui->name = name_copy;
}
strcpy ( title_copy, title );
dynui->title = title_copy;
INIT_LIST_HEAD ( &dynui->items );
/* Add to list of user interfaces */
list_add_tail ( &dynui->list, &dynamic_uis );
DBGC ( dynui, "DYNUI %s created with title \"%s\"\n",
dynui->name, dynui->title );
return dynui;
}
/**
* Add dynamic user interface item
*
* @v dynui Dynamic user interface
* @v name Name, or NULL
* @v text Text, or NULL
* @v flags Flags
* @v shortcut Shortcut key
* @ret item User interface item, or NULL on failure
*/
struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
const char *name, const char *text,
unsigned int flags, int shortcut ) {
struct dynamic_item *item;
size_t name_len;
size_t text_len;
size_t len;
char *name_copy;
char *text_copy;
/* Use empty text if none given */
if ( ! text )
text = "";
/* Allocate item */
name_len = ( name ? ( strlen ( name ) + 1 /* NUL */ ) : 0 );
text_len = ( strlen ( text ) + 1 /* NUL */ );
len = ( sizeof ( *item ) + name_len + text_len );
item = zalloc ( len );
if ( ! item )
return NULL;
name_copy = ( ( void * ) ( item + 1 ) );
text_copy = ( name_copy + name_len );
/* Initialise item */
if ( name ) {
strcpy ( name_copy, name );
item->name = name_copy;
}
strcpy ( text_copy, text );
item->text = text_copy;
item->index = dynui->count++;
item->flags = flags;
item->shortcut = shortcut;
/* Add to list of items */
list_add_tail ( &item->list, &dynui->items );
return item;
}
/**
* Destroy dynamic user interface
*
* @v dynui Dynamic user interface
*/
void destroy_dynui ( struct dynamic_ui *dynui ) {
struct dynamic_item *item;
struct dynamic_item *tmp;
/* Remove from list of user interfaces */
list_del ( &dynui->list );
/* Free items */
list_for_each_entry_safe ( item, tmp, &dynui->items, list ) {
list_del ( &item->list );
free ( item );
}
/* Free user interface */
free ( dynui );
}
/**
* Find dynamic user interface
*
* @v name User interface name, or NULL
* @ret dynui Dynamic user interface, or NULL if not found
*/
struct dynamic_ui * find_dynui ( const char *name ) {
struct dynamic_ui *dynui;
list_for_each_entry ( dynui, &dynamic_uis, list ) {
if ( ( dynui->name == name ) ||
( strcmp ( dynui->name, name ) == 0 ) ) {
return dynui;
}
}
return NULL;
}
/**
* Find dynamic user interface item by index
*
* @v dynui Dynamic user interface
* @v index Index
* @ret item User interface item, or NULL if not found
*/
struct dynamic_item * dynui_item ( struct dynamic_ui *dynui,
unsigned int index ) {
struct dynamic_item *item;
list_for_each_entry ( item, &dynui->items, list ) {
if ( index-- == 0 )
return item;
}
return NULL;
}
/**
* Find dynamic user interface item by shortcut key
*
* @v dynui Dynamic user interface
* @v key Shortcut key
* @ret item User interface item, or NULL if not found
*/
struct dynamic_item * dynui_shortcut ( struct dynamic_ui *dynui, int key ) {
struct dynamic_item *item;
list_for_each_entry ( item, &dynui->items, list ) {
if ( key && ( key == item->shortcut ) )
return item;
}
return NULL;
}
+4 -7
View File
@@ -134,13 +134,10 @@ int image_set_uri ( struct image *image, struct uri *uri ) {
int rc;
/* Set name, if image does not already have one */
if ( ! ( image->name && image->name[0] ) ) {
name = ( uri->path ? uri->path : uri->opaque );
if ( name ) {
name = basename ( ( char * ) name );
if ( ( rc = image_set_name ( image, name ) ) != 0 )
return rc;
}
if ( uri->path && ( ! ( image->name && image->name[0] ) ) ) {
name = basename ( ( char * ) uri->path );
if ( ( rc = image_set_name ( image, name ) ) != 0 )
return rc;
}
/* Update image URI */
+2 -1
View File
@@ -32,8 +32,9 @@ __asmcall int main ( void ) {
initialise();
/* Some devices take an unreasonably long time to initialise */
printf ( "%s initialising devices...\n", product_short_name );
printf ( "%s initialising devices...", product_short_name );
startup();
printf ( "ok\n" );
/* Attempt to boot */
if ( ( rc = ipxe ( NULL ) ) != 0 )
+182
View File
@@ -0,0 +1,182 @@
/*
* Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Menu selection
*
*/
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ipxe/list.h>
#include <ipxe/menu.h>
/** List of all menus */
static LIST_HEAD ( menus );
/**
* Create menu
*
* @v name Menu name, or NULL
* @v title Menu title, or NULL
* @ret menu Menu, or NULL on failure
*/
struct menu * create_menu ( const char *name, const char *title ) {
size_t name_len;
size_t title_len;
size_t len;
struct menu *menu;
char *name_copy;
char *title_copy;
/* Destroy any existing menu of this name */
menu = find_menu ( name );
if ( menu )
destroy_menu ( menu );
/* Use empty title if none given */
if ( ! title )
title = "";
/* Allocate menu */
name_len = ( name ? ( strlen ( name ) + 1 /* NUL */ ) : 0 );
title_len = ( strlen ( title ) + 1 /* NUL */ );
len = ( sizeof ( *menu ) + name_len + title_len );
menu = zalloc ( len );
if ( ! menu )
return NULL;
name_copy = ( ( void * ) ( menu + 1 ) );
title_copy = ( name_copy + name_len );
/* Initialise menu */
if ( name ) {
strcpy ( name_copy, name );
menu->name = name_copy;
}
strcpy ( title_copy, title );
menu->title = title_copy;
INIT_LIST_HEAD ( &menu->items );
/* Add to list of menus */
list_add_tail ( &menu->list, &menus );
DBGC ( menu, "MENU %s created with title \"%s\"\n",
menu->name, menu->title );
return menu;
}
/**
* Add menu item
*
* @v menu Menu
* @v label Label, or NULL
* @v text Text, or NULL
* @v shortcut Shortcut key
* @v is_default Item is the default item
* @ret item Menu item, or NULL on failure
*/
struct menu_item * add_menu_item ( struct menu *menu, const char *label,
const char *text, int shortcut,
int is_default ) {
size_t label_len;
size_t text_len;
size_t len;
struct menu_item *item;
char *label_copy;
char *text_copy;
/* Use empty text if none given */
if ( ! text )
text = "";
/* Allocate item */
label_len = ( label ? ( strlen ( label ) + 1 /* NUL */ ) : 0 );
text_len = ( strlen ( text ) + 1 /* NUL */ );
len = ( sizeof ( *item ) + label_len + text_len );
item = zalloc ( len );
if ( ! item )
return NULL;
label_copy = ( ( void * ) ( item + 1 ) );
text_copy = ( label_copy + label_len );
/* Initialise item */
if ( label ) {
strcpy ( label_copy, label );
item->label = label_copy;
}
strcpy ( text_copy, text );
item->text = text_copy;
item->shortcut = shortcut;
item->is_default = is_default;
/* Add to list of items */
list_add_tail ( &item->list, &menu->items );
return item;
}
/**
* Destroy menu
*
* @v menu Menu
*/
void destroy_menu ( struct menu *menu ) {
struct menu_item *item;
struct menu_item *tmp;
/* Remove from list of menus */
list_del ( &menu->list );
/* Free items */
list_for_each_entry_safe ( item, tmp, &menu->items, list ) {
list_del ( &item->list );
free ( item );
}
/* Free menu */
free ( menu );
}
/**
* Find menu
*
* @v name Menu name, or NULL
* @ret menu Menu, or NULL if not found
*/
struct menu * find_menu ( const char *name ) {
struct menu *menu;
list_for_each_entry ( menu, &menus, list ) {
if ( ( menu->name == name ) ||
( strcmp ( menu->name, name ) == 0 ) ) {
return menu;
}
}
return NULL;
}
-67
View File
@@ -1,67 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Multiprocessor functions
*
*/
#include <ipxe/timer.h>
#include <ipxe/mp.h>
/** Time to wait for application processors */
#define MP_MAX_CPUID_WAIT_MS 10
/**
* Get boot CPU identifier
*
* @ret id Boot CPU identifier
*/
unsigned int mp_boot_cpuid ( void ) {
unsigned int max = 0;
/* Update maximum to accommodate boot processor */
mp_exec_boot ( mp_update_max_cpuid, &max );
DBGC ( &mp_call, "MP boot processor ID is %#x\n", max );
return max;
}
/**
* Get maximum CPU identifier
*
* @ret max Maximum CPU identifier
*/
unsigned int mp_max_cpuid ( void ) {
unsigned int max = mp_boot_cpuid();
/* Update maximum to accommodate application processors */
mp_start_all ( mp_update_max_cpuid, &max );
mdelay ( MP_MAX_CPUID_WAIT_MS );
DBGC ( &mp_call, "MP observed maximum CPU ID is %#x\n", max );
return max;
}
-37
View File
@@ -1,37 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/**
* @file
*
* Null multiprocessor API
*
*/
#include <ipxe/mp.h>
PROVIDE_MPAPI_INLINE ( null, mp_address );
PROVIDE_MPAPI_INLINE ( null, mp_exec_boot );
PROVIDE_MPAPI_INLINE ( null, mp_start_all );
+1 -1
View File
@@ -38,7 +38,7 @@ static void null_san_unhook ( unsigned int drive __unused ) {
}
static int null_san_boot ( unsigned int drive __unused,
struct san_boot_config *config __unused ) {
const char *filename __unused ) {
return -EOPNOTSUPP;
}
+9 -33
View File
@@ -31,9 +31,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ctype.h>
#include <errno.h>
#include <getopt.h>
#include <ipxe/uuid.h>
#include <ipxe/netdevice.h>
#include <ipxe/dynui.h>
#include <ipxe/menu.h>
#include <ipxe/settings.h>
#include <ipxe/params.h>
#include <ipxe/timer.h>
@@ -125,29 +124,6 @@ int parse_timeout ( char *text, unsigned long *value ) {
return 0;
}
/**
* Parse UUID
*
* @v text Text
* @ret uuid UUID value
* @ret rc Return status code
*/
int parse_uuid ( char *text, struct uuid_option *uuid ) {
int rc;
/* Sanity check */
assert ( text != NULL );
/* Parse UUID */
if ( ( rc = uuid_aton ( text, &uuid->buf ) ) != 0 ) {
printf ( "\"%s\": invalid UUID\n", text );
return rc;
}
uuid->value = &uuid->buf;
return 0;
}
/**
* Parse network device name
*
@@ -194,21 +170,21 @@ int parse_netdev_configurator ( char *text,
}
/**
* Parse dynamic user interface name
* Parse menu name
*
* @v text Text
* @ret dynui Dynamic user interface
* @ret menu Menu
* @ret rc Return status code
*/
int parse_dynui ( char *text, struct dynamic_ui **dynui ) {
int parse_menu ( char *text, struct menu **menu ) {
/* Find user interface */
*dynui = find_dynui ( text );
if ( ! *dynui ) {
/* Find menu */
*menu = find_menu ( text );
if ( ! *menu ) {
if ( text ) {
printf ( "\"%s\": no such user interface\n", text );
printf ( "\"%s\": no such menu\n", text );
} else {
printf ( "No default user interface\n" );
printf ( "No default menu\n" );
}
return -ENOENT;
}
+32 -46
View File
@@ -44,6 +44,16 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/quiesce.h>
#include <ipxe/sanboot.h>
/**
* Default SAN drive number
*
* The drive number is a meaningful concept only in a BIOS
* environment, where it represents the INT13 drive number (0x80 for
* the first hard disk). We retain it in other environments to allow
* for a simple way for iPXE commands to refer to SAN drives.
*/
#define SAN_DEFAULT_DRIVE 0x80
/**
* Timeout for block device commands (in ticks)
*
@@ -97,22 +107,6 @@ struct san_device * sandev_find ( unsigned int drive ) {
return NULL;
}
/**
* Find next SAN device by drive number
*
* @v drive Minimum drive number
* @ret sandev SAN device, or NULL
*/
struct san_device * sandev_next ( unsigned int drive ) {
struct san_device *sandev;
list_for_each_entry ( sandev, &san_devices, list ) {
if ( sandev->drive >= drive )
return sandev;
}
return NULL;
}
/**
* Free SAN device
*
@@ -203,7 +197,7 @@ static int sanpath_open ( struct san_path *sanpath ) {
/* Open interface */
if ( ( rc = xfer_open_uri ( &sanpath->block, sanpath->uri ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x.%d could not (re)open URI: "
DBGC ( sandev, "SAN %#02x.%d could not (re)open URI: "
"%s\n", sandev->drive, sanpath->index, strerror ( rc ) );
return rc;
}
@@ -271,7 +265,7 @@ static void sanpath_block_close ( struct san_path *sanpath, int rc ) {
/* Any closure is an error from our point of view */
if ( rc == 0 )
rc = -ENOTCONN;
DBGC ( sandev->drive, "SAN %#02x.%d closed: %s\n",
DBGC ( sandev, "SAN %#02x.%d closed: %s\n",
sandev->drive, sanpath->index, strerror ( rc ) );
/* Close path */
@@ -313,11 +307,11 @@ static void sanpath_step ( struct san_path *sanpath ) {
/* Mark as active path or close as applicable */
if ( ! sandev->active ) {
DBGC ( sandev->drive, "SAN %#02x.%d is active\n",
DBGC ( sandev, "SAN %#02x.%d is active\n",
sandev->drive, sanpath->index );
sandev->active = sanpath;
} else {
DBGC ( sandev->drive, "SAN %#02x.%d is available\n",
DBGC ( sandev, "SAN %#02x.%d is available\n",
sandev->drive, sanpath->index );
sanpath_close ( sanpath, 0 );
}
@@ -404,9 +398,8 @@ int sandev_reopen ( struct san_device *sandev ) {
rc = sanpath->path_rc;
break;
}
DBGC ( sandev->drive, "SAN %#02x never became "
"available: %s\n", sandev->drive,
strerror ( rc ) );
DBGC ( sandev, "SAN %#02x never became available: %s\n",
sandev->drive, strerror ( rc ) );
goto err_none;
}
}
@@ -460,9 +453,8 @@ static int sandev_command_rw ( struct san_device *sandev,
if ( ( rc = params->rw.block_rw ( &sanpath->block, &sandev->command,
params->rw.lba, params->rw.count,
params->rw.buffer, len ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x.%d could not initiate "
"read/write: %s\n", sandev->drive, sanpath->index,
strerror ( rc ) );
DBGC ( sandev, "SAN %#02x.%d could not initiate read/write: "
"%s\n", sandev->drive, sanpath->index, strerror ( rc ) );
return rc;
}
@@ -488,9 +480,8 @@ sandev_command_read_capacity ( struct san_device *sandev,
/* Initiate read capacity command */
if ( ( rc = block_read_capacity ( &sanpath->block,
&sandev->command ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x.%d could not initiate read "
"capacity: %s\n", sandev->drive, sanpath->index,
strerror ( rc ) );
DBGC ( sandev, "SAN %#02x.%d could not initiate read capacity: "
"%s\n", sandev->drive, sanpath->index, strerror ( rc ) );
return rc;
}
@@ -574,7 +565,7 @@ sandev_command ( struct san_device *sandev,
int sandev_reset ( struct san_device *sandev ) {
int rc;
DBGC ( sandev->drive, "SAN %#02x reset\n", sandev->drive );
DBGC ( sandev, "SAN %#02x reset\n", sandev->drive );
/* Close and reopen underlying block device */
if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
@@ -707,8 +698,8 @@ static int sandev_describe ( struct san_device *sandev ) {
if ( ! desc )
continue;
if ( ( rc = desc->model->complete ( desc ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x.%d could not "
"be described: %s\n", sandev->drive,
DBGC ( sandev, "SAN %#02x.%d could not be "
"described: %s\n", sandev->drive,
sanpath->index, strerror ( rc ) );
return rc;
}
@@ -801,8 +792,8 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
/* Read primary volume descriptor */
if ( ( rc = sandev_read ( sandev, lba, count,
virt_to_user ( scratch ) ) ) != 0 ) {
DBGC ( sandev->drive, "SAN %#02x could not read ISO9660 "
"primary volume descriptor: %s\n",
DBGC ( sandev, "SAN %#02x could not read ISO9660 primary"
"volume descriptor: %s\n",
sandev->drive, strerror ( rc ) );
goto err_rw;
}
@@ -810,8 +801,8 @@ static int sandev_parse_iso9660 ( struct san_device *sandev ) {
/* Configure as CD-ROM if applicable */
if ( memcmp ( &scratch->primary.fixed, &primary_check,
sizeof ( primary_check ) ) == 0 ) {
DBGC ( sandev->drive, "SAN %#02x contains an ISO9660 "
"filesystem; treating as CD-ROM\n", sandev->drive );
DBGC ( sandev, "SAN %#02x contains an ISO9660 filesystem; "
"treating as CD-ROM\n", sandev->drive );
sandev->blksize_shift = blksize_shift;
sandev->is_cdrom = 1;
}
@@ -876,12 +867,11 @@ struct san_device * alloc_sandev ( struct uri **uris, unsigned int count,
*/
int register_sandev ( struct san_device *sandev, unsigned int drive,
unsigned int flags ) {
struct san_device *before;
int rc;
/* Check that drive number is not in use */
if ( sandev_find ( drive ) != NULL ) {
DBGC ( sandev->drive, "SAN %#02x is already in use\n", drive );
DBGC ( sandev, "SAN %#02x is already in use\n", drive );
rc = -EADDRINUSE;
goto err_in_use;
}
@@ -910,13 +900,9 @@ int register_sandev ( struct san_device *sandev, unsigned int drive,
if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
goto err_iso9660;
/* Add to list of SAN devices, in drive order */
for_each_sandev ( before ) {
if ( before->drive > sandev->drive )
break;
}
list_add_tail ( &sandev->list, &before->list );
DBGC ( sandev->drive, "SAN %#02x registered\n", sandev->drive );
/* Add to list of SAN devices */
list_add_tail ( &sandev->list, &san_devices );
DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
return 0;
@@ -950,7 +936,7 @@ void unregister_sandev ( struct san_device *sandev ) {
/* Remove ACPI descriptors */
sandev_undescribe ( sandev );
DBGC ( sandev->drive, "SAN %#02x unregistered\n", sandev->drive );
DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
}
/** The "san-drive" setting */
-140
View File
@@ -2194,37 +2194,6 @@ const struct setting_type setting_type_base64 __setting_type = {
.format = format_base64_setting,
};
/**
* Parse UUID/GUID setting value
*
* @v type Setting type
* @v value Formatted setting value
* @v buf Buffer to contain raw value
* @v len Length of buffer
* @v size Integer size, in bytes
* @ret len Length of raw value, or negative error
*/
static int parse_uuid_setting ( const struct setting_type *type,
const char *value, void *buf, size_t len ) {
union uuid uuid;
int rc;
/* Parse UUID */
if ( ( rc = uuid_aton ( value, &uuid ) ) != 0 )
return rc;
/* Mangle GUID byte ordering */
if ( type == &setting_type_guid )
uuid_mangle ( &uuid );
/* Copy value */
if ( len > sizeof ( uuid ) )
len = sizeof ( uuid );
memcpy ( buf, uuid.raw, len );
return ( sizeof ( uuid ) );
}
/**
* Format UUID/GUID setting value
*
@@ -2258,14 +2227,12 @@ static int format_uuid_setting ( const struct setting_type *type,
/** UUID setting type */
const struct setting_type setting_type_uuid __setting_type = {
.name = "uuid",
.parse = parse_uuid_setting,
.format = format_uuid_setting,
};
/** GUID setting type */
const struct setting_type setting_type_guid __setting_type = {
.name = "guid",
.parse = parse_uuid_setting,
.format = format_uuid_setting,
};
@@ -2650,113 +2617,6 @@ struct builtin_setting unixtime_builtin_setting __builtin_setting = {
.fetch = unixtime_fetch,
};
/**
* Fetch current working URI-related setting
*
* @v data Buffer to fill with setting data
* @v len Length of buffer
* @v rel Relative URI string
* @ret len Length of setting data, or negative error
*/
static int cwuri_fetch_uri ( void *data, size_t len, const char *rel ) {
struct uri *reluri;
struct uri *uri;
char *uristring;
int ret;
/* Check that current working URI is set */
if ( ! cwuri ) {
ret = -ENOENT;
goto err_unset;
}
/* Construct relative URI */
reluri = parse_uri ( rel );
if ( ! reluri ) {
ret = -ENOMEM;
goto err_parse;
}
/* Construct resolved URI */
uri = resolve_uri ( cwuri, reluri );
if ( ! uri ) {
ret = -ENOMEM;
goto err_resolve;
}
/* Format URI string into allocated buffer (with NUL) */
uristring = format_uri_alloc ( uri );
if ( ! uristring ) {
ret = -ENOMEM;
goto err_format;
}
/* Copy URI string to buffer */
strncpy ( data, uristring, len );
ret = strlen ( uristring );
free ( uristring );
err_format:
uri_put ( uri );
err_resolve:
uri_put ( reluri );
err_parse:
err_unset:
return ret;
}
/**
* Fetch current working URI setting
*
* @v data Buffer to fill with setting data
* @v len Length of buffer
* @ret len Length of setting data, or negative error
*/
static int cwuri_fetch ( void *data, size_t len ) {
return cwuri_fetch_uri ( data, len, "" );
}
/**
* Fetch current working directory URI setting
*
* @v data Buffer to fill with setting data
* @v len Length of buffer
* @ret len Length of setting data, or negative error
*/
static int cwduri_fetch ( void *data, size_t len ) {
return cwuri_fetch_uri ( data, len, "." );
}
/** Current working URI setting */
const struct setting cwuri_setting __setting ( SETTING_MISC, cwuri ) = {
.name = "cwuri",
.description = "Current working URI",
.type = &setting_type_string,
.scope = &builtin_scope,
};
/** Current working directory URI setting */
const struct setting cwduri_setting __setting ( SETTING_MISC, cwduri ) = {
.name = "cwduri",
.description = "Current working directory URI",
.type = &setting_type_string,
.scope = &builtin_scope,
};
/** Current working URI built-in setting */
struct builtin_setting cwuri_builtin_setting __builtin_setting = {
.setting = &cwuri_setting,
.fetch = cwuri_fetch,
};
/** Current working directory URI built-in setting */
struct builtin_setting cwduri_builtin_setting __builtin_setting = {
.setting = &cwduri_setting,
.fetch = cwduri_fetch,
};
/**
* Fetch built-in setting
*
+2 -15
View File
@@ -321,9 +321,9 @@ char * strstr ( const char *haystack, const char *needle ) {
*
* @v dest Destination string
* @v src Source string
* @ret dnul Terminating NUL of destination string
* @ret dest Destination string
*/
char * stpcpy ( char *dest, const char *src ) {
char * strcpy ( char *dest, const char *src ) {
const uint8_t *src_bytes = ( ( const uint8_t * ) src );
uint8_t *dest_bytes = ( ( uint8_t * ) dest );
@@ -333,19 +333,6 @@ char * stpcpy ( char *dest, const char *src ) {
if ( ! *dest_bytes )
break;
}
return ( ( char * ) dest_bytes );
}
/**
* Copy string
*
* @v dest Destination string
* @v src Source string
* @ret dest Destination string
*/
char * strcpy ( char *dest, const char *src ) {
stpcpy ( dest, src );
return dest;
}
-28
View File
@@ -25,9 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <stdio.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/base16.h>
#include <ipxe/uuid.h>
/** @file
@@ -55,29 +53,3 @@ const char * uuid_ntoa ( const union uuid *uuid ) {
uuid->canonical.e[4], uuid->canonical.e[5] );
return buf;
}
/**
* Parse UUID
*
* @v string UUID string
* @v uuid UUID to fill in
* @ret rc Return status code
*/
int uuid_aton ( const char *string, union uuid *uuid ) {
int len;
int rc;
/* Decode as hex string with optional '-' separator */
len = hex_decode ( ( '-' | HEX_DECODE_OPTIONAL ), string, uuid->raw,
sizeof ( *uuid ) );
if ( len < 0 ) {
rc = len;
return rc;
}
/* Check length */
if ( len != sizeof ( *uuid ) )
return -EINVAL;
return 0;
}
-695
View File
@@ -1,695 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* DES algorithm
*
* DES was not designed to be implemented in software, and therefore
* contains a large number of bit permutation operations that are
* essentially free in hardware (requiring only wires, no gates) but
* expensive in software.
*
* Since DES is no longer used as a practical block cipher for large
* volumes of data, we optimise for code size, and do not attempt to
* obtain fast throughput.
*
* The algorithm is specified in NIST SP 800-67, downloadable from
* https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-67r2.pdf
*/
#include <stdint.h>
#include <string.h>
#include <errno.h>
#include <byteswap.h>
#include <ipxe/rotate.h>
#include <ipxe/crypto.h>
#include <ipxe/ecb.h>
#include <ipxe/cbc.h>
#include <ipxe/init.h>
#include <ipxe/des.h>
/**
* DES shift schedule
*
* The DES shift schedule (ordered from round 16 down to round 1) is
* {1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,1}. In binary, this may be
* represented as {1,10,10,10,10,10,10,1,10,10,10,10,10,10,1,1} and
* concatenated (without padding) to produce a single binary integer
* 1101010101010110101010101011 (equal to 0x0d556aab in hexadecimal).
*
* This integer may then be consumed LSB-first, where a 1 bit
* indicates a shift and the generation of a round key, and a 0 bit
* indicates a shift without the generation of a round key.
*/
#define DES_SCHEDULE 0x0d556aab
/**
* Define an element pair in a DES S-box
*
* @v x Upper element of element pair
* @v y Lower element of element pair
*
* DES S-box elements are 4-bit values. We encode two values per
* byte, ordering the elements so that the six-bit input value may be
* used directly as a lookup index.
*
* Specifically, if the input value is {r1,c3,c2,c1,c0,r0}, where
* {r1,r0} is the table row index and {c3,c2,c1,c0} is the table
* column index (as used in the DES specification), then:
*
* - {r1,c3,c2,c1,c0} is the byte index into the table
*
* - (4*r0) is the required bit shift to extract the 4-bit value
*/
#define SBYTE( x, y ) ( ( (y) << 4 ) | (x) )
/**
* Define a row pair in a DES S-box
*
* @v x0..xf Upper row of row pair
* @v y0..yf Lower row of row pair
*/
#define SBOX( x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, xa, xb, xc, xd, xe, xf, \
y0, y1, y2, y3, y4, y5, y6, y7, y8, y9, ya, yb, yc, yd, ye, yf ) \
SBYTE ( x0, y0 ), SBYTE ( x1, y1 ), SBYTE ( x2, y2 ), SBYTE ( x3, y3 ),\
SBYTE ( x4, y4 ), SBYTE ( x5, y5 ), SBYTE ( x6, y6 ), SBYTE ( x7, y7 ),\
SBYTE ( x8, y8 ), SBYTE ( x9, y9 ), SBYTE ( xa, ya ), SBYTE ( xb, yb ),\
SBYTE ( xc, yc ), SBYTE ( xd, yd ), SBYTE ( xe, ye ), SBYTE ( xf, yf )
/** DES S-boxes S1..S8 */
static const uint8_t des_s[8][32] = { {
/* S1 */
SBOX ( 14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7,
0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8 ),
SBOX ( 4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0,
15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13 )
}, {
/* S2 */
SBOX ( 15, 1, 8, 14, 6, 11, 3, 4, 9, 7, 2, 13, 12, 0, 5, 10,
3, 13, 4, 7, 15, 2, 8, 14, 12, 0, 1, 10, 6, 9, 11, 5 ),
SBOX ( 0, 14, 7, 11, 10, 4, 13, 1, 5, 8, 12, 6, 9, 3, 2, 15,
13, 8, 10, 1, 3, 15, 4, 2, 11, 6, 7, 12, 0, 5, 14, 9 )
}, {
/* S3 */
SBOX ( 10, 0, 9, 14, 6, 3, 15, 5, 1, 13, 12, 7, 11, 4, 2, 8,
13, 7, 0, 9, 3, 4, 6, 10, 2, 8, 5, 14, 12, 11, 15, 1 ),
SBOX ( 13, 6, 4, 9, 8, 15, 3, 0, 11, 1, 2, 12, 5, 10, 14, 7,
1, 10, 13, 0, 6, 9, 8, 7, 4, 15, 14, 3, 11, 5, 2, 12 )
}, {
/* S4 */
SBOX ( 7, 13, 14, 3, 0, 6, 9, 10, 1, 2, 8, 5, 11, 12, 4, 15,
13, 8, 11, 5, 6, 15, 0, 3, 4, 7, 2, 12, 1, 10, 14, 9 ),
SBOX ( 10, 6, 9, 0, 12, 11, 7, 13, 15, 1, 3, 14, 5, 2, 8, 4,
3, 15, 0, 6, 10, 1, 13, 8, 9, 4, 5, 11, 12, 7, 2, 14 )
}, {
/* S5 */
SBOX ( 2, 12, 4, 1, 7, 10, 11, 6, 8, 5, 3, 15, 13, 0, 14, 9,
14, 11, 2, 12, 4, 7, 13, 1, 5, 0, 15, 10, 3, 9, 8, 6 ),
SBOX ( 4, 2, 1, 11, 10, 13, 7, 8, 15, 9, 12, 5, 6, 3, 0, 14,
11, 8, 12, 7, 1, 14, 2, 13, 6, 15, 0, 9, 10, 4, 5, 3 )
}, {
/* S6 */
SBOX ( 12, 1, 10, 15, 9, 2, 6, 8, 0, 13, 3, 4, 14, 7, 5, 11,
10, 15, 4, 2, 7, 12, 9, 5, 6, 1, 13, 14, 0, 11, 3, 8 ),
SBOX ( 9, 14, 15, 5, 2, 8, 12, 3, 7, 0, 4, 10, 1, 13, 11, 6,
4, 3, 2, 12, 9, 5, 15, 10, 11, 14, 1, 7, 6, 0, 8, 13 )
}, {
/* S7 */
SBOX ( 4, 11, 2, 14, 15, 0, 8, 13, 3, 12, 9, 7, 5, 10, 6, 1,
13, 0, 11, 7, 4, 9, 1, 10, 14, 3, 5, 12, 2, 15, 8, 6 ),
SBOX ( 1, 4, 11, 13, 12, 3, 7, 14, 10, 15, 6, 8, 0, 5, 9, 2,
6, 11, 13, 8, 1, 4, 10, 7, 9, 5, 0, 15, 14, 2, 3, 12 )
}, {
/* S8 */
SBOX ( 13, 2, 8, 4, 6, 15, 11, 1, 10, 9, 3, 14, 5, 0, 12, 7,
1, 15, 13, 8, 10, 3, 7, 4, 12, 5, 6, 11, 0, 14, 9, 2 ),
SBOX ( 7, 11, 4, 1, 9, 12, 14, 2, 0, 6, 10, 13, 15, 3, 5, 8,
2, 1, 14, 7, 4, 10, 8, 13, 15, 12, 9, 0, 3, 5, 6, 11 )
} };
/**
* Define a bit index within permuted choice 2 (PC2)
*
* @v bit Bit index
*
* Permuted choice 2 (PC2) is used to select bits from a concatenated
* pair of 28-bit registers ("C" and "D") as part of the key schedule.
* We store these as 32-bit registers and so must add 4 to indexes
* above 28.
*/
#define DES_PC2( x ) ( (x) + ( ( (x) > 28 ) ? 4 : 0 ) )
/**
* Define six bits of permuted choice 2 (PC2)
*
* @v r1:r0 Bits corresponding to S-box row index
* @v c3:c0 Bits corresponding to S-box column index
*
* There are 8 steps within a DES round (one step per S-box). Each
* step requires six bits of the round key, corresponding to the S-box
* input value {r1,c3,c2,c1,c0,r0}, where {r1,r0} is the table row
* index and {c3,c2,c1,c0} is the table column index.
*
* As an optimisation, we store the least significant of the 6 bits in
* the sign bit of a signed 8-bit value, and the remaining 5 bits in
* the least significant 5 bits of the 8-bit value. See the comments
* in des_sbox() for further details.
*/
#define DES_PC2R( r1, c3, c2, c1, c0, r0 ) \
DES_PC2 ( r0 ), /* LSB stored in sign bit */ \
DES_PC2 ( r0 ), /* Unused bit */ \
DES_PC2 ( r0 ), /* Unused bit */ \
DES_PC2 ( r1 ), /* Remaining 5 bits */ \
DES_PC2 ( c3 ), /* ... */ \
DES_PC2 ( c2 ), /* ... */ \
DES_PC2 ( c1 ), /* ... */ \
DES_PC2 ( c0 ) /* ... */
/**
* A DES systematic permutation generator
*
* Many of the permutations used in DES comprise systematic bit
* patterns. We generate these permutations at runtime to save on
* code size.
*/
struct des_generator {
/** Permutation */
uint8_t *permutation;
/** Seed value */
uint32_t seed;
};
/**
* Define a DES permutation generator
*
* @v PERMUTATION Permutation
* @v OFFSET Fixed input bit offset (0 or 1)
* @v INV<n> Input bit index bit <n> should be inverted
* @v BIT<n> Source bit for input bit index bit <n>
* @ret generator Permutation generator
*/
#define DES_GENERATOR( PERMUTATION, OFFSET, INV5, BIT5, INV4, BIT4, \
INV3, BIT3, INV2, BIT2, INV1, BIT1, INV0, BIT0 ) \
{ \
.permutation = (PERMUTATION), \
.seed = ( ( (INV0) << 31 ) | ( (BIT0) << 28 ) | \
( (INV1) << 27 ) | ( (BIT1) << 24 ) | \
( (INV2) << 23 ) | ( (BIT2) << 20 ) | \
( (INV3) << 19 ) | ( (BIT3) << 16 ) | \
( (INV4) << 15 ) | ( (BIT4) << 12 ) | \
( (INV5) << 11 ) | ( (BIT5) << 8 ) | \
( ( uint32_t ) sizeof (PERMUTATION) - 1 ) | \
(OFFSET) ), \
}
/** DES permuted choice 1 (PC1) "C" register */
static uint8_t des_pc1c[29];
/** DES permuted choice 1 (PC1) "D" register */
static uint8_t des_pc1d[33];
/** DES permuted choice 2 (PC2) */
static const uint8_t des_pc2[65] = {
DES_PC2R ( 14, 17, 11, 24, 1, 5 ),
DES_PC2R ( 3, 28, 15, 6, 21, 10 ),
DES_PC2R ( 23, 19, 12, 4, 26, 8 ),
DES_PC2R ( 16, 7, 27, 20, 13, 2 ),
DES_PC2R ( 41, 52, 31, 37, 47, 55 ),
DES_PC2R ( 30, 40, 51, 45, 33, 48 ),
DES_PC2R ( 44, 49, 39, 56, 34, 53 ),
DES_PC2R ( 46, 42, 50, 36, 29, 32 ),
0 /* terminator */
};
/** DES initial permutation (IP) */
static uint8_t des_ip[65];
/** DES data permutation (P) */
static const uint8_t des_p[33] = {
16, 7, 20, 21, 29, 12, 28, 17, 1, 15, 23, 26, 5, 18, 31, 10,
2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25,
0 /* terminator */
};
/** DES final / inverse initial permutation (FP / IP^-1) */
static uint8_t des_fp[65];
/** DES permutation generators */
static struct des_generator des_generators[] = {
/* The DES initial permutation transforms the bit index
* {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,x4,x3,~x5}+1
*/
DES_GENERATOR ( des_ip, 1, 1, 2, 1, 1, 1, 0, 0, 4, 0, 3, 1, 5 ),
/* The DES final permutation transforms the bit index
* {x5,x4,x3,x2,x1,x0}+1 into {~x0,x2,x1,~x5,~x4,~x3}+1
*
* There is an asymmetry in the DES block diagram for the last
* of the 16 rounds, which is functionally equivalent to
* performing 16 identical rounds and then swapping the left
* and right halves before applying the final permutation. We
* may therefore account for this asymmetry by inverting the
* MSB in each bit index, to point to the corresponding bit in
* the other half.
*
* This is equivalent to using a permutation that transforms
* {x5,x4,x3,x2,x1,x0}+1 into {x0,x2,x1,~x5,~x4,~x3}+1
*/
DES_GENERATOR ( des_fp, 1, 0, 0, 0, 2, 0, 1, 1, 5, 1, 4, 1, 3 ),
/* The "C" half of DES permuted choice 1 (PC1) transforms the
* bit index {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,x5,x4,x3}+1
*/
DES_GENERATOR ( des_pc1c, 1, 1, 2, 1, 1, 1, 0, 0, 5, 0, 4, 0, 3 ),
/* The "D" half of DES permuted choice 1 (PC1) transforms the
* bit index {x5,x4,x3,x2,x1,x0}+1 into {~x2,~x1,~x0,~x5,~x4,~x3}+0
*
* Due to the idosyncratic design choice of using 28-bit
* registers in the DES key expansion schedule, the final four
* permutation values appear at indices [28:31] instead of
* [24:27]. This is adjusted for in @c des_setkey().
*/
DES_GENERATOR ( des_pc1d, 0, 1, 2, 1, 1, 1, 0, 1, 5, 1, 4, 1, 3 ),
};
/**
* Generate DES permutation
*
* @v generator Generator
*/
static __attribute__ (( noinline )) void
des_generate ( struct des_generator *generator ) {
uint8_t *permutation = generator->permutation;
uint32_t seed = generator->seed;
unsigned int index = 0;
uint8_t accum;
uint8_t bit;
/* Generate permutations
*
* This loop is optimised for code size on a
* register-constrained architecture such as i386.
*/
do {
/* Rotate seed to access MSB's bit descriptor */
seed = ror32 ( seed, 8 );
/* Initialise accumulator with six flag bits */
accum = 0xfc;
/* Accumulate bits until all six flag bits are cleared */
do {
/* Extract specified bit from index. Use a
* rotation instead of a shift, since this
* will allow the mask to be elided.
*/
bit = ror8 ( index, ( seed & 0x07 ) );
seed = ror32 ( seed, 3 );
/* Toggle bit if applicable */
bit ^= seed;
seed = ror32 ( seed, 1 );
/* Add bit to accumulator and clear one flag bit */
accum <<= 1;
accum |= ( bit & 0x01 );
} while ( accum & 0x80 );
/* Add constant offset if applicable */
accum += ( seed & 0x01 );
/* Store permutation */
permutation[index] = accum;
/* Loop until reaching length (which is always even) */
} while ( ++index < ( seed & 0xfe ) );
DBGC2 ( permutation, "DES generated permutation %p:\n", permutation );
DBGC2_HDA ( permutation, 0, permutation,
( ( seed & 0xfe ) + 1 /* zero terminator */ ) );
}
/**
* Initialise permutations
*/
static void des_init ( void ) {
unsigned int i;
/* Generate all generated permutations */
for ( i = 0 ; i < ( sizeof ( des_generators ) /
sizeof ( des_generators[0] ) ) ; i++ ) {
des_generate ( &des_generators[i] );
}
}
/** Initialisation function */
struct init_fn des_init_fn __init_fn ( INIT_NORMAL ) = {
.initialise = des_init,
};
/**
* Perform bit permutation
*
* @v permutation Bit permutation (zero-terminated)
* @v in Input value
* @v out Output value
*/
static void des_permute ( const uint8_t *permutation, const uint8_t *in,
uint8_t *out ) {
uint8_t mask = 0x80;
uint8_t accum = 0;
unsigned int bit;
/* Extract individual input bits to construct output value */
while ( ( bit = *(permutation++) ) ) {
bit--;
if ( in[ bit / 8 ] & ( 0x80 >> ( bit % 8 ) ) )
accum |= mask;
*out = accum;
mask = ror8 ( mask, 1 );
if ( mask == 0x80 ) {
out++;
accum = 0;
}
}
}
/**
* Perform DES S-box substitution
*
* @v in 32-bit input value (native endian)
* @v rkey 48-bit round key
* @ret out 32-bit output value (native endian)
*/
static uint32_t des_sbox ( uint32_t in, const union des_round_key *rkey ) {
uint32_t out = 0;
uint32_t lookup;
int32_t key;
uint8_t sub;
unsigned int i;
/* Perform input expansion, key addition, and S-box substitution */
for ( i = 0 ; i < 8 ; i++ ) {
/* Rotate input and output */
out = rol32 ( out, 4 );
in = rol32 ( in, 4 );
/* Extract step key from relevant 6 bits of round key
*
* The least significant of the 6 bits (corresponding
* to bit r0 in the S-box lookup index) is stored in
* the sign bit of the step key byte. It will
* therefore be propagated via sign extension to the
* MSB of the 32-bit step key.
*
* The remaining 5 of the 6 bits (corresponding to
* bits {r1,c3,c2,c1,c0} in the S-box lookup index)
* are stored in the least significant 5 bits of the
* step key byte and will end up in the least
* significant 5 bits of the 32-bit step key.
*/
key = rkey->step[i];
/* Add step key to input to produce S-box lookup index
*
* We do not ever perform an explicit expansion of the
* input value from 32 to 48 bits. Instead, we rotate
* the 32-bit input value by 4 bits on each step, and
* extract the relevant 6 bits.
*
* The least significant of the 6 bits (corresponding
* to bit r0 in the S-box lookup index) is currently
* in the MSB of the 32-bit (rotated) input value.
*
* The remaining 5 of the 6 bits (corresponding to
* bits {r1,c3,c2,c1,c0} in the S-box lookup index)
* are currently in the least significant 5 bits of
* the 32-bit (rotated) input value.
*
* This aligns with the placement of the bits in the
* step key (see above), and we can therefore perform
* a single XOR to add the 6-bit step key to the
* relevant 6 bits of the input value.
*/
lookup = ( in ^ key );
/* Look up S[i][in ^ key] from S-box
*
* We have bits {r1,c3,c2,c1,c0} in the least
* significant 5 bits of the lookup index, and so can
* use the masked lookup index directly as a byte
* index into the relevant S-box to extract the byte
* containing both {r1,c3,c2,c1,c0,'0'} and
* {r1,c3,c2,c1,c0,'1'}.
*
* We then use the MSB of the 32-bit lookup index to
* extract the relevant nibble for the full lookup
* index {r1,c3,c2,c1,c0,r0}.
*/
sub = des_s[i][ lookup & 0x1f ];
sub >>= ( ( lookup >> 29 ) & 4 );
sub &= 0x0f;
/* Substitute S[i][input ^ key] into output */
out |= sub;
}
return out;
}
/**
* Perform a single DES round
*
* @v block DES block
* @v rkey 48-bit round key
*/
static void des_round ( union des_block *block,
const union des_round_key *rkey ) {
union des_dword sbox;
uint32_t left;
uint32_t right;
/* Extract left and right halves L[n-1] and R[n-1] */
left = block->left.dword;
right = block->right.dword;
DBGC2 ( block, "DES L=%08x R=%08x K=%08x%08x", be32_to_cpu ( left ),
be32_to_cpu ( right ), be32_to_cpu ( rkey->dword[0] ),
be32_to_cpu ( rkey->dword[1] ) );
/* L[n] = R[n-1] */
block->left.dword = right;
/* Calculate Feistel function f(R[n-1], K[n]) */
sbox.dword = cpu_to_be32 ( des_sbox ( be32_to_cpu ( right ), rkey ) );
des_permute ( des_p, sbox.byte, block->right.byte );
/* R[n] = L[n-1] + f(R[n-1], K[n]) */
block->right.dword ^= left;
DBGC2 ( block, " => L=%08x R=%08x\n",
be32_to_cpu ( block->left.dword ),
be32_to_cpu ( block->right.dword ) );
}
/**
* Perform all DES rounds
*
* @v in Input DES block
* @v out Output DES block
* @v rkey Starting 48-bit round key
* @v offset Byte offset between round keys
*/
static void des_rounds ( const union des_block *in, union des_block *out,
const union des_round_key *rkey,
ssize_t offset ) {
union des_block tmp;
unsigned int i;
/* Apply initial permutation */
des_permute ( des_ip, in->byte, tmp.byte );
/* Perform all DES rounds, consuming keys in the specified order */
for ( i = 0 ; i < DES_ROUNDS ; i++ ) {
des_round ( &tmp, rkey );
rkey = ( ( ( void * ) rkey ) + offset );
}
/* Apply final permutation */
DBGC ( &tmp, "DES %scrypted %08x%08x => ",
( ( offset > 0 ) ? "en" : "de" ), be32_to_cpu ( in->dword[0] ),
be32_to_cpu ( in->dword[1] ) );
des_permute ( des_fp, tmp.byte, out->byte );
DBGC ( &tmp, "%08x%08x\n", be32_to_cpu ( out->dword[0] ),
be32_to_cpu ( out->dword[1] ) );
}
/**
* Rotate 28-bit word
*
* @v dword 28-bit dword value
* @ret dword Rotated 28-bit dword value
*/
static uint32_t des_rol28 ( uint32_t dword ) {
int32_t sdword;
/* Convert to native-endian */
sdword = be32_to_cpu ( dword );
/* Signed shift right by 4 places to copy bit 31 to bits 27:31 */
sdword >>= 4;
/* Rotate left */
sdword = rol32 ( sdword, 1 );
/* Shift left by 4 places to restore bit positions */
sdword <<= 4;
/* Convert back to big-endian */
dword = cpu_to_be32 ( sdword );
return dword;
}
/**
* Set key
*
* @v ctx Context
* @v key Key
* @v keylen Key length
* @ret rc Return status code
*/
static int des_setkey ( void *ctx, const void *key, size_t keylen ) {
struct des_context *des = ctx;
union des_round_key *rkey = des->rkey;
union des_block reg;
uint32_t schedule;
/* Validate key length */
if ( keylen != DES_BLOCKSIZE )
return -EINVAL;
DBGC ( des, "DES %p new key:\n", des );
DBGC_HDA ( des, 0, key, keylen );
/* Apply permuted choice 1 */
des_permute ( des_pc1c, key, reg.c.byte );
des_permute ( des_pc1d, key, reg.d.byte );
reg.d.byte[3] <<= 4; /* see comment for @c des_pc1d */
DBGC2 ( des, "DES %p C[ 0]=%07x D[ 0]=%07x\n",
des, ( be32_to_cpu ( reg.c.dword ) >> 4 ),
( be32_to_cpu ( reg.d.dword ) >> 4 ) );
/* Generate round keys */
for ( schedule = DES_SCHEDULE ; schedule ; schedule >>= 1 ) {
/* Shift 28-bit words */
reg.c.dword = des_rol28 ( reg.c.dword );
reg.d.dword = des_rol28 ( reg.d.dword );
/* Skip rounds according to shift schedule */
if ( ! ( schedule & 1 ) )
continue;
/* Apply permuted choice 2 */
des_permute ( des_pc2, reg.byte, rkey->byte );
DBGC2 ( des, "DES %p C[%2zd]=%07x D[%2zd]=%07x K[%2zd]="
"%08x%08x\n", des, ( ( rkey - des->rkey ) + 1 ),
( be32_to_cpu ( reg.c.dword ) >> 4 ),
( ( rkey - des->rkey ) + 1 ),
( be32_to_cpu ( reg.d.dword ) >> 4 ),
( ( rkey - des->rkey ) + 1 ),
be32_to_cpu ( rkey->dword[0] ),
be32_to_cpu ( rkey->dword[1] ) );
/* Move to next key */
rkey++;
}
/* Sanity check */
assert ( rkey == &des->rkey[DES_ROUNDS] );
return 0;
}
/**
* Encrypt data
*
* @v ctx Context
* @v src Data to encrypt
* @v dst Buffer for encrypted data
* @v len Length of data
*/
static void des_encrypt ( void *ctx, const void *src, void *dst, size_t len ) {
struct des_context *des = ctx;
/* Sanity check */
assert ( len == DES_BLOCKSIZE );
/* Cipher using keys in forward direction */
des_rounds ( src, dst, &des->rkey[0], sizeof ( des->rkey[0] ) );
}
/**
* Decrypt data
*
* @v ctx Context
* @v src Data to decrypt
* @v dst Buffer for decrypted data
* @v len Length of data
*/
static void des_decrypt ( void *ctx, const void *src, void *dst, size_t len ) {
struct des_context *des = ctx;
/* Sanity check */
assert ( len == DES_BLOCKSIZE );
/* Cipher using keys in reverse direction */
des_rounds ( src, dst, &des->rkey[ DES_ROUNDS - 1 ],
-sizeof ( des->rkey[0] ) );
}
/** Basic DES algorithm */
struct cipher_algorithm des_algorithm = {
.name = "des",
.ctxsize = sizeof ( struct des_context ),
.blocksize = DES_BLOCKSIZE,
.alignsize = 0,
.authsize = 0,
.setkey = des_setkey,
.setiv = cipher_null_setiv,
.encrypt = des_encrypt,
.decrypt = des_decrypt,
.auth = cipher_null_auth,
};
/* DES in Electronic Codebook mode */
ECB_CIPHER ( des_ecb, des_ecb_algorithm,
des_algorithm, struct des_context, DES_BLOCKSIZE );
/* DES in Cipher Block Chaining mode */
CBC_CIPHER ( des_cbc, des_cbc_algorithm,
des_algorithm, struct des_context, DES_BLOCKSIZE );
+9 -15
View File
@@ -109,9 +109,6 @@ static union gcm_block gcm_cached_mult[256];
*/
static uint16_t gcm_cached_reduce[256];
/** Offset of a field within GCM context */
#define gcm_offset( field ) offsetof ( struct gcm_context, field )
/**
* Reverse bits in a byte
*
@@ -472,14 +469,16 @@ int gcm_setkey ( struct gcm_context *context, const void *key, size_t keylen,
* @v ivlen Initialisation vector length
*/
void gcm_setiv ( struct gcm_context *context, const void *iv, size_t ivlen ) {
union gcm_block *check = ( ( void * ) context );
/* Sanity checks */
build_assert ( &context->hash == check );
build_assert ( &context->len == check + 1 );
build_assert ( &context->ctr == check + 2 );
build_assert ( &context->key == check + 3 );
/* Reset non-key state */
memset ( context, 0, gcm_offset ( key ) );
build_assert ( gcm_offset ( key ) > gcm_offset ( hash ) );
build_assert ( gcm_offset ( key ) > gcm_offset ( len ) );
build_assert ( gcm_offset ( key ) > gcm_offset ( ctr ) );
build_assert ( gcm_offset ( key ) < gcm_offset ( raw_cipher ) );
build_assert ( gcm_offset ( key ) < gcm_offset ( raw_ctx ) );
memset ( context, 0, offsetof ( typeof ( *context ), key ) );
/* Reset counter */
context->ctr.ctr.value = cpu_to_be32 ( 1 );
@@ -498,12 +497,7 @@ void gcm_setiv ( struct gcm_context *context, const void *iv, size_t ivlen ) {
assert ( context->len.len.add == 0 );
/* Reset non-key, non-counter state */
memset ( context, 0, gcm_offset ( ctr ) );
build_assert ( gcm_offset ( ctr ) > gcm_offset ( hash ) );
build_assert ( gcm_offset ( ctr ) > gcm_offset ( len ) );
build_assert ( gcm_offset ( ctr ) < gcm_offset ( key ) );
build_assert ( gcm_offset ( ctr ) < gcm_offset ( raw_cipher ) );
build_assert ( gcm_offset ( ctr ) < gcm_offset ( raw_ctx ) );
memset ( context, 0, offsetof ( typeof ( *context ), ctr ) );
}
DBGC2 ( context, "GCM %p Y[0]:\n", context );
-363
View File
@@ -1,363 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* MS-CHAPv2 authentication
*
* The algorithms used for MS-CHAPv2 authentication are defined in
* RFC 2759 section 8.
*/
#include <stdio.h>
#include <string.h>
#include <byteswap.h>
#include <ipxe/md4.h>
#include <ipxe/sha1.h>
#include <ipxe/des.h>
#include <ipxe/mschapv2.h>
/**
* MS-CHAPv2 context block
*
* For no particularly discernible reason, MS-CHAPv2 uses two
* different digest algorithms and one block cipher. The uses do not
* overlap, so share the context storage between these to reduce stack
* usage.
*/
union mschapv2_context {
/** SHA-1 digest context */
uint8_t sha1[SHA1_CTX_SIZE];
/** MD4 digest context */
uint8_t md4[MD4_CTX_SIZE];
/** DES cipher context */
uint8_t des[DES_CTX_SIZE];
};
/**
* MS-CHAPv2 challenge hash
*
* MS-CHAPv2 calculates the SHA-1 digest of the peer challenge, the
* authenticator challenge, and the username, and then uses only the
* first 8 bytes of the result (as a DES plaintext block).
*/
union mschapv2_challenge_hash {
/** SHA-1 digest */
uint8_t sha1[SHA1_DIGEST_SIZE];
/** DES plaintext block */
uint8_t des[DES_BLOCKSIZE];
};
/**
* MS-CHAPv2 password hash
*
* MS-CHAPv2 calculates the MD4 digest of an unspecified two-byte
* little-endian Unicode encoding (presumably either UCS-2LE or
* UTF-16LE) of the password.
*
* For constructing the challenge response, the MD4 digest is then
* zero-padded to 21 bytes and used as three separate 56-bit DES keys.
*
* For constructing the authenticator response, the MD4 digest is then
* used as an input to a SHA-1 digest along with the NT response and a
* magic constant.
*/
union mschapv2_password_hash {
/** MD4 digest */
uint8_t md4[MD4_DIGEST_SIZE];
/** SHA-1 digest */
uint8_t sha1[SHA1_DIGEST_SIZE];
/** DES keys */
uint8_t des[3][DES_BLOCKSIZE];
/** DES key expansion */
uint8_t expand[ 3 * DES_BLOCKSIZE ];
};
/** MS-CHAPv2 magic constant 1 */
static const char mschapv2_magic1[39] =
"Magic server to client signing constant";
/** MS-CHAPv2 magic constant 2 */
static const char mschapv2_magic2[41] =
"Pad to make it do more than one iteration";
/**
* Calculate MS-CHAPv2 challenge hash
*
* @v ctx Context block
* @v challenge Authenticator challenge
* @v peer Peer challenge
* @v username User name (or NULL to use empty string)
* @v chash Challenge hash to fill in
*
* This is the ChallengeHash() function as documented in RFC 2759
* section 8.2.
*/
static void
mschapv2_challenge_hash ( union mschapv2_context *ctx,
const struct mschapv2_challenge *challenge,
const struct mschapv2_challenge *peer,
const char *username,
union mschapv2_challenge_hash *chash ) {
struct digest_algorithm *sha1 = &sha1_algorithm;
/* Calculate SHA-1 hash of challenges and username */
digest_init ( sha1, ctx->sha1 );
digest_update ( sha1, ctx->sha1, peer, sizeof ( *peer ) );
digest_update ( sha1, ctx->sha1, challenge, sizeof ( *challenge ) );
if ( username ) {
digest_update ( sha1, ctx->sha1, username,
strlen ( username ) );
}
digest_final ( sha1, ctx->sha1, chash->sha1 );
DBGC ( ctx, "MSCHAPv2 authenticator challenge:\n" );
DBGC_HDA ( ctx, 0, challenge, sizeof ( *challenge ) );
DBGC ( ctx, "MSCHAPv2 peer challenge:\n" );
DBGC_HDA ( ctx, 0, peer, sizeof ( *peer ) );
DBGC ( ctx, "MSCHAPv2 challenge hash:\n" );
DBGC_HDA ( ctx, 0, chash->des, sizeof ( chash->des ) );
}
/**
* Calculate MS-CHAPv2 password hash
*
* @v ctx Context block
* @v password Password (or NULL to use empty string)
* @v phash Password hash to fill in
*
* This is the NtPasswordHash() function as documented in RFC 2759
* section 8.3.
*/
static void mschapv2_password_hash ( union mschapv2_context *ctx,
const char *password,
union mschapv2_password_hash *phash ) {
struct digest_algorithm *md4 = &md4_algorithm;
uint16_t wc;
uint8_t c;
/* Construct zero-padded MD4 hash of encoded password */
memset ( phash, 0, sizeof ( *phash ) );
digest_init ( md4, ctx->md4 );
if ( password ) {
while ( ( c = *(password++) ) ) {
wc = cpu_to_le16 ( c );
digest_update ( md4, ctx->md4, &wc, sizeof ( wc ) );
}
}
digest_final ( md4, ctx->md4, phash->md4 );
DBGC ( ctx, "MSCHAPv2 password hash:\n" );
DBGC_HDA ( ctx, 0, phash->md4, sizeof ( phash->md4 ) );
}
/**
* Hash the MS-CHAPv2 password hash
*
* @v ctx Context block
* @v phash Password hash to be rehashed
*
* This is the HashNtPasswordHash() function as documented in RFC 2759
* section 8.4.
*/
static void mschapv2_hash_hash ( union mschapv2_context *ctx,
union mschapv2_password_hash *phash ) {
struct digest_algorithm *md4 = &md4_algorithm;
/* Calculate MD4 hash of existing MD4 hash */
digest_init ( md4, ctx->md4 );
digest_update ( md4, ctx->md4, phash->md4, sizeof ( phash->md4 ) );
digest_final ( md4, ctx->md4, phash->md4 );
DBGC ( ctx, "MSCHAPv2 password hash hash:\n" );
DBGC_HDA ( ctx, 0, phash->md4, sizeof ( phash->md4 ) );
}
/**
* Expand MS-CHAPv2 password hash by inserting DES dummy parity bits
*
* @v ctx Context block
* @v phash Password hash to expand
*
* This is part of the DesEncrypt() function as documented in RFC 2759
* section 8.6.
*/
static void mschapv2_expand_hash ( union mschapv2_context *ctx,
union mschapv2_password_hash *phash ) {
uint8_t *dst;
uint8_t *src;
unsigned int i;
/* Expand password hash by inserting (unused) DES parity bits */
for ( i = ( sizeof ( phash->expand ) - 1 ) ; i > 0 ; i-- ) {
dst = &phash->expand[i];
src = ( dst - ( i / 8 ) );
*dst = ( ( ( src[-1] << 8 ) | src[0] ) >> ( i % 8 ) );
}
DBGC ( ctx, "MSCHAPv2 expanded password hash:\n" );
DBGC_HDA ( ctx, 0, phash->expand, sizeof ( phash->expand ) );
}
/**
* Calculate MS-CHAPv2 challenge response
*
* @v ctx Context block
* @v chash Challenge hash
* @v phash Password hash (after expansion)
* @v nt NT response to fill in
*
* This is the ChallengeResponse() function as documented in RFC 2759
* section 8.5.
*/
static void
mschapv2_challenge_response ( union mschapv2_context *ctx,
const union mschapv2_challenge_hash *chash,
const union mschapv2_password_hash *phash,
struct mschapv2_nt_response *nt ) {
struct cipher_algorithm *des = &des_algorithm;
unsigned int i;
int rc;
/* Construct response. The design of the algorithm here is
* interesting, suggesting that an intern at Microsoft had
* heard the phrase "Triple DES" and hazarded a blind guess at
* what it might mean.
*/
for ( i = 0 ; i < ( sizeof ( phash->des ) /
sizeof ( phash->des[0] ) ) ; i++ ) {
rc = cipher_setkey ( des, ctx->des, phash->des[i],
sizeof ( phash->des[i] ) );
assert ( rc == 0 ); /* no failure mode exists */
cipher_encrypt ( des, ctx->des, chash->des, nt->block[i],
sizeof ( chash->des ) );
}
DBGC ( ctx, "MSCHAPv2 NT response:\n" );
DBGC_HDA ( ctx, 0, nt, sizeof ( *nt ) );
}
/**
* Calculate MS-CHAPv2 challenge response
*
* @v username User name (or NULL to use empty string)
* @v password Password (or NULL to use empty string)
* @v challenge Authenticator challenge
* @v peer Peer challenge
* @v response Challenge response to fill in
*
* This is essentially the GenerateNTResponse() function as documented
* in RFC 2759 section 8.1.
*/
void mschapv2_response ( const char *username, const char *password,
const struct mschapv2_challenge *challenge,
const struct mschapv2_challenge *peer,
struct mschapv2_response *response ) {
union mschapv2_context ctx;
union mschapv2_challenge_hash chash;
union mschapv2_password_hash phash;
/* Zero reserved fields */
memset ( response, 0, sizeof ( *response ) );
/* Copy peer challenge to response */
memcpy ( &response->peer, peer, sizeof ( response->peer ) );
/* Construct challenge hash */
mschapv2_challenge_hash ( &ctx, challenge, peer, username, &chash );
/* Construct expanded password hash */
mschapv2_password_hash ( &ctx, password, &phash );
mschapv2_expand_hash ( &ctx, &phash );
/* Construct NT response */
mschapv2_challenge_response ( &ctx, &chash, &phash, &response->nt );
DBGC ( &ctx, "MSCHAPv2 challenge response:\n" );
DBGC_HDA ( &ctx, 0, response, sizeof ( *response ) );
}
/**
* Calculate MS-CHAPv2 authenticator response
*
* @v username User name (or NULL to use empty string)
* @v password Password (or NULL to use empty string)
* @v challenge Authenticator challenge
* @v response Challenge response
* @v auth Authenticator response to fill in
*
* This is essentially the GenerateAuthenticatorResponse() function as
* documented in RFC 2759 section 8.7.
*/
void mschapv2_auth ( const char *username, const char *password,
const struct mschapv2_challenge *challenge,
const struct mschapv2_response *response,
struct mschapv2_auth *auth ) {
struct digest_algorithm *sha1 = &sha1_algorithm;
union mschapv2_context ctx;
union mschapv2_challenge_hash chash;
union mschapv2_password_hash phash;
char tmp[3];
char *wtf;
unsigned int i;
/* Construct hash of password hash */
mschapv2_password_hash ( &ctx, password, &phash );
mschapv2_hash_hash ( &ctx, &phash );
/* Construct unnamed intermediate hash */
digest_init ( sha1, ctx.sha1 );
digest_update ( sha1, ctx.sha1, phash.md4, sizeof ( phash.md4 ) );
digest_update ( sha1, ctx.sha1, &response->nt,
sizeof ( response->nt ) );
digest_update ( sha1, ctx.sha1, mschapv2_magic1,
sizeof ( mschapv2_magic1 ) );
digest_final ( sha1, ctx.sha1, phash.sha1 );
DBGC ( &ctx, "MSCHAPv2 NT response:\n" );
DBGC_HDA ( &ctx, 0, &response->nt, sizeof ( response->nt ) );
DBGC ( &ctx, "MSCHAPv2 unnamed intermediate hash:\n" );
DBGC_HDA ( &ctx, 0, phash.sha1, sizeof ( phash.sha1 ) );
/* Construct challenge hash */
mschapv2_challenge_hash ( &ctx, challenge, &response->peer,
username, &chash );
/* Construct authenticator response hash */
digest_init ( sha1, ctx.sha1 );
digest_update ( sha1, ctx.sha1, phash.sha1, sizeof ( phash.sha1 ) );
digest_update ( sha1, ctx.sha1, chash.des, sizeof ( chash.des ) );
digest_update ( sha1, ctx.sha1, mschapv2_magic2,
sizeof ( mschapv2_magic2 ) );
digest_final ( sha1, ctx.sha1, phash.sha1 );
DBGC ( &ctx, "MSCHAPv2 authenticator response hash:\n" );
DBGC_HDA ( &ctx, 0, phash.sha1, sizeof ( phash.sha1 ) );
/* Encode authenticator response hash */
wtf = auth->wtf;
*(wtf++) = 'S';
*(wtf++) = '=';
DBGC ( &ctx, "MSCHAPv2 authenticator response: S=" );
for ( i = 0 ; i < sizeof ( phash.sha1 ) ; i++ ) {
snprintf ( tmp, sizeof ( tmp ), "%02X", phash.sha1[i] );
*(wtf++) = tmp[0];
*(wtf++) = tmp[1];
DBGC ( &ctx, "%s", tmp );
}
DBGC ( &ctx, "\n" );
}
+9 -23
View File
@@ -1603,12 +1603,19 @@ int x509_check_name ( struct x509_certificate *cert, const char *name ) {
static void x509_free_chain ( struct refcnt *refcnt ) {
struct x509_chain *chain =
container_of ( refcnt, struct x509_chain, refcnt );
struct x509_link *link;
struct x509_link *tmp;
DBGC2 ( chain, "X509 chain %p freed\n", chain );
/* Free each link in the chain */
list_for_each_entry_safe ( link, tmp, &chain->links, list ) {
x509_put ( link->cert );
list_del ( &link->list );
free ( link );
}
/* Free chain */
x509_truncate ( chain, NULL );
assert ( list_empty ( &chain->links ) );
free ( chain );
}
@@ -1689,27 +1696,6 @@ int x509_append_raw ( struct x509_chain *chain, const void *data,
return rc;
}
/**
* Truncate X.509 certificate chain
*
* @v chain X.509 certificate chain
* @v link Link after which to truncate chain, or NULL
*/
void x509_truncate ( struct x509_chain *chain, struct x509_link *link ) {
struct x509_link *tmp;
/* Truncate entire chain if no link is specified */
if ( ! link )
link = list_entry ( &chain->links, struct x509_link, list );
/* Free each link in the chain */
list_for_each_entry_safe_continue ( link, tmp, &chain->links, list ) {
x509_put ( link->cert );
list_del ( &link->list );
free ( link );
}
}
/**
* Identify X.509 certificate by subject
*
+1 -1
View File
@@ -3139,8 +3139,8 @@ static void arbel_remove ( struct pci_device *pci ) {
}
static struct pci_device_id arbel_nics[] = {
PCI_ROM ( 0x15b3, 0x6274, "mt25204", "MT25204 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6282, "mt25218", "MT25218 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6274, "mt25204", "MT25204 HCA driver", 0 ),
};
struct pci_driver arbel_driver __pci_driver = {
+1 -1
View File
@@ -2502,7 +2502,7 @@ static mlx_status shomron_fill_eth_send_wqe ( struct ib_device *ibdev,
}
#define SHOMRON_GENERATE_CQE 0x3
#define SHOMRON_INLINE_HEADERS_SIZE ETH_HLEN
#define SHOMRON_INLINE_HEADERS_SIZE 18
#define SHOMRON_INLINE_HEADERS_OFFSET 32
MLX_FILL_2 ( &eth_wqe->ctrl, 0, opcode, FLEXBOOT_NODNIC_OPCODE_SEND,
wqe_index, wqe_index & 0xFFFF);
+5 -4
View File
@@ -4214,9 +4214,6 @@ static void hermon_bofm_remove ( struct pci_device *pci ) {
}
static struct pci_device_id hermon_nics[] = {
/* Mellanox ConnectX-3 VPI (ethernet + infiniband) */
PCI_ROM ( 0x15b3, 0x1003, "mt4099", "ConnectX-3 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x1007, "mt4103", "ConnectX-3 Pro HCA driver", 0 ),
/* Mellanox ConnectX VPI (ethernet + infiniband) */
PCI_ROM ( 0x15b3, 0x6340, "mt25408", "MT25408 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x634a, "mt25418", "MT25418 HCA driver", 0 ),
@@ -4229,13 +4226,17 @@ static struct pci_device_id hermon_nics[] = {
PCI_ROM ( 0x15b3, 0x6732, "mt26418", "MT26418 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x673c, "mt26428", "MT26428 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6746, "mt26438", "MT26438 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6778, "mt26488", "MT26488 HCA driver", 0 ),
/* Mellanox ConnectX-2 EN (ethernet only) */
PCI_ROM ( 0x15b3, 0x6750, "mt26448", "MT26448 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x675a, "mt26458", "MT26458 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6764, "mt26468", "MT26468 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x676e, "mt26478", "MT26478 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x6778, "mt26488", "MT26488 HCA driver", 0 ),
/* Mellanox ConnectX-3 VPI (ethernet + infiniband) */
PCI_ROM ( 0x15b3, 0x1003, "mt4099", "ConnectX-3 HCA driver", 0 ),
PCI_ROM ( 0x15b3, 0x1007, "mt4103", "ConnectX-3 Pro HCA driver", 0 ),
};
struct pci_driver hermon_driver __pci_driver = {
+2 -2
View File
@@ -523,12 +523,10 @@ static struct nic_operations t595_operations = {
};
static struct pci_device_id t595_nics[] = {
PCI_ROM(0x10b7, 0x4500, "3c450-1", "3Com450 HomePNA Tornado", 0),
PCI_ROM(0x10b7, 0x5900, "3c590", "3Com590", 0), /* Vortex 10Mbps */
PCI_ROM(0x10b7, 0x5950, "3c595", "3Com595", 0), /* Vortex 100baseTx */
PCI_ROM(0x10b7, 0x5951, "3c595-1", "3Com595", 0), /* Vortex 100baseT4 */
PCI_ROM(0x10b7, 0x5952, "3c595-2", "3Com595", 0), /* Vortex 100base-MII */
PCI_ROM(0x10b7, 0x7646, "3csoho100-tx-1", "3CSOHO100-TX", 0), /* Hurricane */
PCI_ROM(0x10b7, 0x9000, "3c900-tpo", "3Com900-TPO", 0), /* 10 Base TPO */
PCI_ROM(0x10b7, 0x9001, "3c900-t4", "3Com900-Combo", 0), /* 10/100 T4 */
PCI_ROM(0x10b7, 0x9004, "3c900b-tpo", "3Com900B-TPO", 0), /* 10 Base TPO */
@@ -537,6 +535,8 @@ PCI_ROM(0x10b7, 0x9006, "3c900b-tpb2", "3Com900B-2/T", 0), /* 10 Base TP and
PCI_ROM(0x10b7, 0x900a, "3c900b-fl", "3Com900B-FL", 0), /* 10 Base F */
PCI_ROM(0x10b7, 0x9800, "3c980-cyclone-1", "3Com980-Cyclone", 0), /* Cyclone */
PCI_ROM(0x10b7, 0x9805, "3c9805-1", "3Com9805", 0), /* Dual Port Server Cyclone */
PCI_ROM(0x10b7, 0x7646, "3csoho100-tx-1", "3CSOHO100-TX", 0), /* Hurricane */
PCI_ROM(0x10b7, 0x4500, "3c450-1", "3Com450 HomePNA Tornado", 0),
};
PCI_DRIVER ( t595_driver, t595_nics, PCI_NO_CLASS );
+6 -6
View File
@@ -955,20 +955,16 @@ static int a3c90x_probe(struct pci_device *pci)
static struct pci_device_id a3c90x_nics[] = {
/* Original 90x revisions: */
PCI_ROM(0x10b7, 0x1201, "3c982a", "3Com982A", 0),
PCI_ROM(0x10b7, 0x1202, "3c982b", "3Com982B", 0),
PCI_ROM(0x10b7, 0x4500, "3c450", "3Com450 HomePNA Tornado", 0),
PCI_ROM(0x10b7, 0x6055, "3c556", "3C556", 0), /* Huricane */
PCI_ROM(0x10b7, 0x7646, "3csoho100-tx", "3CSOHO100-TX", 0), /* Hurricane */
PCI_ROM(0x10b7, 0x9000, "3c905-tpo", "3Com900-TPO", 0), /* 10 Base TPO */
PCI_ROM(0x10b7, 0x9001, "3c905-t4", "3Com900-Combo", 0), /* 10/100 T4 */
PCI_ROM(0x10b7, 0x9050, "3c905-tpo100", "3Com905-TX", 0), /* 100 Base TX / 10/100 TPO */
PCI_ROM(0x10b7, 0x9051, "3c905-combo", "3Com905-T4", 0), /* 100 Base T4 / 10 Base Combo */
/* Newer 90xB revisions: */
PCI_ROM(0x10b7, 0x9004, "3c905b-tpo", "3Com900B-TPO", 0), /* 10 Base TPO */
PCI_ROM(0x10b7, 0x9005, "3c905b-combo", "3Com900B-Combo", 0), /* 10 Base Combo */
PCI_ROM(0x10b7, 0x9006, "3c905b-tpb2", "3Com900B-2/T", 0), /* 10 Base TP and Base2 */
PCI_ROM(0x10b7, 0x900a, "3c905b-fl", "3Com900B-FL", 0), /* 10 Base FL */
PCI_ROM(0x10b7, 0x9050, "3c905-tpo100", "3Com905-TX", 0), /* 100 Base TX / 10/100 TPO */
PCI_ROM(0x10b7, 0x9051, "3c905-combo", "3Com905-T4", 0), /* 100 Base T4 / 10 Base Combo */
PCI_ROM(0x10b7, 0x9055, "3c905b-tpo100", "3Com905B-TX", 0), /* 10/100 TPO */
PCI_ROM(0x10b7, 0x9056, "3c905b-t4", "3Com905B-T4", 0), /* 10/100 T4 */
PCI_ROM(0x10b7, 0x9058, "3c905b-9058", "3Com905B-9058", 0), /* Cyclone 10/100/BNC */
@@ -979,6 +975,10 @@ static struct pci_device_id a3c90x_nics[] = {
PCI_ROM(0x10b7, 0x9210, "3c920b-emb-wnm", "3Com20B-EMB WNM", 0),
PCI_ROM(0x10b7, 0x9800, "3c980", "3Com980-Cyclone", 0), /* Cyclone */
PCI_ROM(0x10b7, 0x9805, "3c9805", "3Com9805", 0), /* Dual Port Server Cyclone */
PCI_ROM(0x10b7, 0x7646, "3csoho100-tx", "3CSOHO100-TX", 0), /* Hurricane */
PCI_ROM(0x10b7, 0x4500, "3c450", "3Com450 HomePNA Tornado", 0),
PCI_ROM(0x10b7, 0x1201, "3c982a", "3Com982A", 0),
PCI_ROM(0x10b7, 0x1202, "3c982b", "3Com982B", 0),
};
struct pci_driver a3c90x_driver __pci_driver = {
+4 -4
View File
@@ -65,11 +65,14 @@ FILE_LICENCE ( BSD3 );
/* Known PCI ids */
static struct pci_device_id ath5k_nics[] = {
PCI_ROM(0x10b7, 0x0013, "rdag675", "3com 3CRDAG675", AR5K_AR5212),
PCI_ROM(0x168c, 0x0207, "ath5210e", "Atheros 5210 early", AR5K_AR5210),
PCI_ROM(0x168c, 0x0007, "ath5210", "Atheros 5210", AR5K_AR5210),
PCI_ROM(0x168c, 0x0011, "ath5311", "Atheros 5311 (AHB)", AR5K_AR5211),
PCI_ROM(0x168c, 0x0012, "ath5211", "Atheros 5211", AR5K_AR5211),
PCI_ROM(0x168c, 0x0013, "ath5212", "Atheros 5212", AR5K_AR5212),
PCI_ROM(0xa727, 0x0013, "ath5212c","3com Ath 5212", AR5K_AR5212),
PCI_ROM(0x10b7, 0x0013, "rdag675", "3com 3CRDAG675", AR5K_AR5212),
PCI_ROM(0x168c, 0x1014, "ath5212m", "Ath 5212 miniPCI", AR5K_AR5212),
PCI_ROM(0x168c, 0x0014, "ath5212x14", "Atheros 5212 x14", AR5K_AR5212),
PCI_ROM(0x168c, 0x0015, "ath5212x15", "Atheros 5212 x15", AR5K_AR5212),
PCI_ROM(0x168c, 0x0016, "ath5212x16", "Atheros 5212 x16", AR5K_AR5212),
@@ -80,9 +83,6 @@ static struct pci_device_id ath5k_nics[] = {
PCI_ROM(0x168c, 0x001b, "ath5413", "Atheros 5413 Eagle", AR5K_AR5212),
PCI_ROM(0x168c, 0x001c, "ath5212e", "Atheros 5212 PCI-E", AR5K_AR5212),
PCI_ROM(0x168c, 0x001d, "ath2417", "Atheros 2417 Nala", AR5K_AR5212),
PCI_ROM(0x168c, 0x0207, "ath5210e", "Atheros 5210 early", AR5K_AR5210),
PCI_ROM(0x168c, 0x1014, "ath5212m", "Ath 5212 miniPCI", AR5K_AR5212),
PCI_ROM(0xa727, 0x0013, "ath5212c","3com Ath 5212", AR5K_AR5212),
};
#define ATH5K_SPMBL_NO 1
+1 -1
View File
@@ -945,8 +945,8 @@ static struct net_device_operations b44_operations = {
static struct pci_device_id b44_nics[] = {
PCI_ROM(0x14e4, 0x170c, "BCM4401-B0", "BCM4401-B0", 0),
PCI_ROM(0x14e4, 0x4401, "BCM4401", "BCM4401", 0),
PCI_ROM(0x14e4, 0x170c, "BCM4401-B0", "BCM4401-B0", 0),
PCI_ROM(0x14e4, 0x4402, "BCM4401-B1", "BCM4401-B1", 0),
};
+95 -306
View File
@@ -24,11 +24,6 @@ static int bnxt_rx_complete ( struct net_device *dev, struct rx_pkt_cmpl *rx );
void bnxt_link_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt );
static struct pci_device_id bnxt_nics[] = {
PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "14e4-1604", 0 ),
PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "14e4-1605", 0 ),
PCI_ROM( 0x14e4, 0x1606, "14e4-1606", "14e4-1606", 0 ),
PCI_ROM( 0x14e4, 0x1609, "14e4-1609", "14e4-1609", 0 ),
PCI_ROM( 0x14e4, 0x1614, "14e4-1614", "14e4-1614", 0 ),
PCI_ROM( 0x14e4, 0x16c0, "14e4-16C0", "14e4-16C0", 0 ),
PCI_ROM( 0x14e4, 0x16c1, "14e4-16C1", "14e4-16C1", BNXT_FLAG_PCI_VF ),
PCI_ROM( 0x14e4, 0x16c8, "14e4-16C8", "14e4-16C8", 0 ),
@@ -67,22 +62,26 @@ static struct pci_device_id bnxt_nics[] = {
PCI_ROM( 0x14e4, 0x16ef, "14e4-16EF", "14e4-16EF", 0 ),
PCI_ROM( 0x14e4, 0x16f0, "14e4-16F0", "14e4-16F0", 0 ),
PCI_ROM( 0x14e4, 0x16f1, "14e4-16F1", "14e4-16F1", 0 ),
PCI_ROM( 0x14e4, 0x1604, "14e4-1604", "14e4-1604", 0 ),
PCI_ROM( 0x14e4, 0x1605, "14e4-1605", "14e4-1605", 0 ),
PCI_ROM( 0x14e4, 0x1606, "14e4-1606", "14e4-1606", 0 ),
PCI_ROM( 0x14e4, 0x1609, "14e4-1609", "14e4-1609", 0 ),
PCI_ROM( 0x14e4, 0x1614, "14e4-1614", "14e4-1614", 0 ),
PCI_ROM( 0x14e4, 0xd802, "14e4-D802", "14e4-D802", 0 ),
PCI_ROM( 0x14e4, 0xd804, "14e4-D804", "14e4-D804", 0 ),
PCI_ROM( 0x14e4, 0x1750, "14e4-1750", "14e4-1750", 0 ),
PCI_ROM( 0x14e4, 0x1751, "14e4-1751", "14e4-1751", 0 ),
PCI_ROM( 0x14e4, 0x1752, "14e4-1752", "14e4-1752", 0 ),
PCI_ROM( 0x14e4, 0x1760, "14e4-1760", "14e4-1760", 0 ),
PCI_ROM( 0x14e4, 0x1800, "14e4-1800", "14e4-1800", 0 ),
PCI_ROM( 0x14e4, 0x1801, "14e4-1801", "14e4-1801", 0 ),
PCI_ROM( 0x14e4, 0x1802, "14e4-1802", "14e4-1802", 0 ),
PCI_ROM( 0x14e4, 0x1803, "14e4-1803", "14e4-1803", 0 ),
PCI_ROM( 0x14e4, 0x1804, "14e4-1804", "14e4-1804", 0 ),
PCI_ROM( 0x14e4, 0x1805, "14e4-1805", "14e4-1805", 0 ),
PCI_ROM( 0x14e4, 0x1751, "14e4-1751", "14e4-1751", 0 ),
PCI_ROM( 0x14e4, 0x1801, "14e4-1801", "14e4-1801", 0 ),
PCI_ROM( 0x14e4, 0x1804, "14e4-1804", "14e4-1804", 0 ),
PCI_ROM( 0x14e4, 0x1752, "14e4-1752", "14e4-1752", 0 ),
PCI_ROM( 0x14e4, 0x1800, "14e4-1800", "14e4-1800", 0 ),
PCI_ROM( 0x14e4, 0x1803, "14e4-1803", "14e4-1803", 0 ),
PCI_ROM( 0x14e4, 0x1806, "14e4-1806", "14e4-1806", BNXT_FLAG_PCI_VF ),
PCI_ROM( 0x14e4, 0x1807, "14e4-1807", "14e4-1807", BNXT_FLAG_PCI_VF ),
PCI_ROM( 0x14e4, 0x1808, "14e4-1808", "14e4-1808", BNXT_FLAG_PCI_VF ),
PCI_ROM( 0x14e4, 0x1809, "14e4-1809", "14e4-1809", BNXT_FLAG_PCI_VF ),
PCI_ROM( 0x14e4, 0xd802, "14e4-D802", "14e4-D802", 0 ),
PCI_ROM( 0x14e4, 0xd804, "14e4-D804", "14e4-D804", 0 ),
};
/**
@@ -182,7 +181,7 @@ static void bnxt_set_link ( struct bnxt *bp )
netdev_link_down ( bp->dev );
}
static void dev_p5_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag )
static void thor_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag )
{
void *off;
u64 val;
@@ -197,28 +196,10 @@ static void dev_p5_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag )
write64 ( val, off );
}
static void dev_p7_db ( struct bnxt *bp, u32 idx, u32 xid, u32 flag, u32 epoch, u32 toggle )
{
void *off;
u64 val;
off = ( void * ) ( bp->bar1 );
val = ( ( u64 )DBC_MSG_XID ( xid, flag ) << 32 ) |
( u64 )DBC_MSG_IDX ( idx ) |
( u64 )DBC_MSG_EPCH ( epoch ) |
( u64 )DBC_MSG_TOGGLE ( toggle );
write64 ( val, off );
}
static void bnxt_db_nq ( struct bnxt *bp )
{
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) )
dev_p7_db ( bp, ( u32 )bp->nq.cons_id,
( u32 )bp->nq_ring_id, DBC_DBC_TYPE_NQ_ARM,
( u32 )bp->nq.epoch, 0 );
else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) )
dev_p5_db ( bp, ( u32 )bp->nq.cons_id,
if ( bp->thor )
thor_db ( bp, ( u32 )bp->nq.cons_id,
( u32 )bp->nq_ring_id, DBC_DBC_TYPE_NQ_ARM );
else
write32 ( CMPL_DOORBELL_KEY_CMPL, ( bp->bar1 + 0 ) );
@@ -226,12 +207,8 @@ static void bnxt_db_nq ( struct bnxt *bp )
static void bnxt_db_cq ( struct bnxt *bp )
{
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) )
dev_p7_db ( bp, ( u32 )bp->cq.cons_id,
( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL,
( u32 )bp->cq.epoch, ( u32 )bp->nq.toggle );
else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) )
dev_p5_db ( bp, ( u32 )bp->cq.cons_id,
if ( bp->thor )
thor_db ( bp, ( u32 )bp->cq.cons_id,
( u32 )bp->cq_ring_id, DBC_DBC_TYPE_CQ_ARMALL );
else
write32 ( CQ_DOORBELL_KEY_IDX ( bp->cq.cons_id ),
@@ -240,22 +217,16 @@ static void bnxt_db_cq ( struct bnxt *bp )
static void bnxt_db_rx ( struct bnxt *bp, u32 idx )
{
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) )
dev_p7_db ( bp, idx, ( u32 )bp->rx_ring_id, DBC_DBC_TYPE_SRQ,
( u32 )bp->rx.epoch, 0 );
else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) )
dev_p5_db ( bp, idx, ( u32 )bp->rx_ring_id, DBC_DBC_TYPE_SRQ );
if ( bp->thor )
thor_db ( bp, idx, ( u32 )bp->rx_ring_id, DBC_DBC_TYPE_SRQ );
else
write32 ( RX_DOORBELL_KEY_RX | idx, ( bp->bar1 + 0 ) );
}
static void bnxt_db_tx ( struct bnxt *bp, u32 idx )
{
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) )
dev_p7_db ( bp, idx, ( u32 )bp->tx_ring_id, DBC_DBC_TYPE_SQ,
( u32 )bp->tx.epoch, 0 );
else if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5 ) )
dev_p5_db ( bp, idx, ( u32 )bp->tx_ring_id, DBC_DBC_TYPE_SQ );
if ( bp->thor )
thor_db ( bp, idx, ( u32 )bp->tx_ring_id, DBC_DBC_TYPE_SQ );
else
write32 ( ( u32 ) ( TX_DOORBELL_KEY_TX | idx ),
( bp->bar1 + 0 ) );
@@ -282,31 +253,6 @@ static u16 bnxt_get_pkt_vlan ( char *src )
return 0;
}
static u16 bnxt_get_rx_vlan ( struct rx_pkt_cmpl *rx_cmp, struct rx_pkt_cmpl_hi *rx_cmp_hi )
{
struct rx_pkt_v3_cmpl *rx_cmp_v3 = ( struct rx_pkt_v3_cmpl * )rx_cmp;
struct rx_pkt_v3_cmpl_hi *rx_cmp_hi_v3 = ( struct rx_pkt_v3_cmpl_hi * )rx_cmp_hi;
u16 rx_vlan;
/* Get VLAN ID from RX completion ring */
if ( ( rx_cmp_v3->flags_type & RX_PKT_V3_CMPL_TYPE_MASK ) ==
RX_PKT_V3_CMPL_TYPE_RX_L2_V3 ) {
if ( rx_cmp_hi_v3->flags2 & RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_ACT_REC_PTR )
rx_vlan = ( rx_cmp_hi_v3->metadata0 &
RX_PKT_V3_CMPL_HI_METADATA0_VID_MASK );
else
rx_vlan = 0;
} else {
if ( rx_cmp_hi->flags2 & RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN )
rx_vlan = ( rx_cmp_hi->metadata &
RX_PKT_CMPL_METADATA_VID_MASK );
else
rx_vlan = 0;
}
return rx_vlan;
}
int bnxt_vlan_drop ( struct bnxt *bp, u16 rx_vlan )
{
if ( rx_vlan ) {
@@ -436,9 +382,6 @@ int bnxt_post_rx_buffers ( struct bnxt *bp )
}
}
cons_id = NEXT_IDX ( cons_id, bp->rx.ring_cnt );
/* If the ring has wrapped, flip the epoch bit */
if ( iob_idx > cons_id )
bp->rx.epoch ^= 1;
bp->rx.iob_cnt++;
}
@@ -453,21 +396,14 @@ int bnxt_post_rx_buffers ( struct bnxt *bp )
}
u8 bnxt_rx_drop ( struct bnxt *bp, struct io_buffer *iob,
struct rx_pkt_cmpl *rx_cmp,
struct rx_pkt_cmpl_hi *rx_cmp_hi, u16 rx_len )
{
struct rx_pkt_v3_cmpl *rx_cmp_v3 = ( struct rx_pkt_v3_cmpl * )rx_cmp;
struct rx_pkt_v3_cmpl_hi *rx_cmp_hi_v3 = ( struct rx_pkt_v3_cmpl_hi * )rx_cmp_hi;
u8 *rx_buf = ( u8 * )iob->data;
u16 err_flags, rx_vlan;
u8 ignore_chksum_err = 0;
int i;
if ( ( rx_cmp_v3->flags_type & RX_PKT_V3_CMPL_TYPE_MASK ) ==
RX_PKT_V3_CMPL_TYPE_RX_L2_V3 ) {
err_flags = rx_cmp_hi_v3->errors_v2 >> RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_SFT;
} else
err_flags = rx_cmp_hi->errors_v2 >> RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT;
err_flags = rx_cmp_hi->errors_v2 >> RX_PKT_CMPL_ERRORS_BUFFER_ERROR_SFT;
if ( rx_cmp_hi->errors_v2 == 0x20 || rx_cmp_hi->errors_v2 == 0x21 )
ignore_chksum_err = 1;
@@ -487,7 +423,13 @@ u8 bnxt_rx_drop ( struct bnxt *bp, struct io_buffer *iob,
return 2;
}
rx_vlan = bnxt_get_rx_vlan ( rx_cmp, rx_cmp_hi );
/* Get VLAN ID from RX completion ring */
if ( rx_cmp_hi->flags2 & RX_PKT_CMPL_FLAGS2_META_FORMAT_VLAN )
rx_vlan = ( rx_cmp_hi->metadata &
RX_PKT_CMPL_METADATA_VID_MASK );
else
rx_vlan = 0;
dbg_rx_vlan ( bp, rx_cmp_hi->metadata, rx_cmp_hi->flags2, rx_vlan );
if ( bnxt_vlan_drop ( bp, rx_vlan ) ) {
bp->rx.drop_vlan++;
@@ -507,11 +449,10 @@ static void bnxt_adv_cq_index ( struct bnxt *bp, u16 cnt )
u16 cons_id;
cons_id = bp->cq.cons_id + cnt;
if ( cons_id >= bp->cq.ring_cnt) {
if ( cons_id >= MAX_CQ_DESC_CNT ) {
/* Toggle completion bit when the ring wraps. */
bp->cq.completion_bit ^= 1;
bp->cq.epoch ^= 1;
cons_id = cons_id - bp->cq.ring_cnt;
cons_id = cons_id - MAX_CQ_DESC_CNT;
}
bp->cq.cons_id = cons_id;
}
@@ -525,7 +466,7 @@ void bnxt_rx_process ( struct net_device *dev, struct bnxt *bp,
dump_rx_bd ( rx_cmp, rx_cmp_hi, desc_idx );
assert ( !iob );
drop = bnxt_rx_drop ( bp, iob, rx_cmp, rx_cmp_hi, rx_cmp->len );
drop = bnxt_rx_drop ( bp, iob, rx_cmp_hi, rx_cmp->len );
dbg_rxp ( iob->data, rx_cmp->len, drop );
if ( drop )
netdev_rx_err ( dev, iob, -EINVAL );
@@ -590,17 +531,12 @@ void bnxt_mm_nic ( struct bnxt *bp )
memset ( bp->nq.bd_virt, 0, NQ_RING_BUFFER_SIZE );
bp->nq.cons_id = 0;
bp->nq.completion_bit = 0x1;
bp->nq.epoch = 0;
bp->nq.toggle = 0;
bp->cq.cons_id = 0;
bp->cq.completion_bit = 0x1;
bp->cq.epoch = 0;
bp->tx.prod_id = 0;
bp->tx.cons_id = 0;
bp->tx.epoch = 0;
bp->rx.cons_id = 0;
bp->rx.iob_cnt = 0;
bp->rx.epoch = 0;
bp->link_status = STATUS_LINK_DOWN;
bp->wait_link_timeout = LINK_DEFAULT_TIMEOUT;
@@ -788,14 +724,8 @@ static int bnxt_hwrm_ver_get ( struct bnxt *bp )
bp->hwrm_max_ext_req_len = resp->max_ext_req_len;
if ( ( bp->chip_num == CHIP_NUM_57508 ) ||
( bp->chip_num == CHIP_NUM_57504 ) ||
( bp->chip_num == CHIP_NUM_57502 ) ) {
FLAG_SET ( bp->flags, BNXT_FLAG_IS_CHIP_P5 );
FLAG_SET ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS );
}
if ( bp->chip_num == CHIP_NUM_57608 ) {
FLAG_SET ( bp->flags, BNXT_FLAG_IS_CHIP_P7 );
FLAG_SET ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS );
}
( bp->chip_num == CHIP_NUM_57502 ) )
bp->thor = 1;
dbg_fw_ver ( resp, bp->hwrm_cmd_timeout );
return STATUS_SUCCESS;
}
@@ -987,30 +917,6 @@ static int bnxt_hwrm_func_qcfg_req ( struct bnxt *bp )
return STATUS_SUCCESS;
}
static int bnxt_hwrm_port_phy_qcaps_req ( struct bnxt *bp )
{
u16 cmd_len = ( u16 )sizeof ( struct hwrm_port_phy_qcaps_input );
struct hwrm_port_phy_qcaps_input *req;
struct hwrm_port_phy_qcaps_output *resp;
int rc;
DBGP ( "%s\n", __func__ );
req = ( struct hwrm_port_phy_qcaps_input * )bp->hwrm_addr_req;
resp = ( struct hwrm_port_phy_qcaps_output * )bp->hwrm_addr_resp;
hwrm_init ( bp, ( void * )req, ( u16 )HWRM_PORT_PHY_QCAPS, cmd_len );
rc = wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
if ( rc ) {
DBGP ( "-s %s ( ): Failed\n", __func__ );
return STATUS_FAILURE;
}
if ( resp->flags2 & PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED )
FLAG_SET ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 );
return STATUS_SUCCESS;
}
static int bnxt_hwrm_func_reset_req ( struct bnxt *bp )
{
u16 cmd_len = ( u16 )sizeof ( struct hwrm_func_reset_input );
@@ -1038,7 +944,7 @@ static int bnxt_hwrm_func_cfg_req ( struct bnxt *bp )
hwrm_init ( bp, ( void * )req, ( u16 )HWRM_FUNC_CFG, cmd_len );
req->fid = ( u16 )HWRM_NA_SIGNATURE;
bnxt_hwrm_assign_resources ( bp );
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) {
if ( bp->thor ) {
req->enables |= ( FUNC_CFG_REQ_ENABLES_NUM_MSIX |
FUNC_CFG_REQ_ENABLES_NUM_VNICS |
FUNC_CFG_REQ_ENABLES_EVB_MODE );
@@ -1105,7 +1011,7 @@ static int bnxt_hwrm_set_async_event ( struct bnxt *bp )
u16 idx;
DBGP ( "%s\n", __func__ );
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) )
if ( bp->thor )
idx = bp->nq_ring_id;
else
idx = bp->cq_ring_id;
@@ -1256,10 +1162,6 @@ static int bnxt_hwrm_port_phy_qcfg ( struct bnxt *bp, u16 idx )
if ( idx & SUPPORT_SPEEDS )
bp->support_speeds = resp->support_speeds;
if ( idx & SUPPORT_SPEEDS2 )
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) )
bp->auto_link_speeds2_mask = resp->auto_link_speeds2;
if ( idx & DETECT_MEDIA )
bp->media_detect = resp->module_status;
@@ -1299,24 +1201,22 @@ static int bnxt_get_link_speed ( struct bnxt *bp )
u32 *ptr32 = ( u32 * )bp->hwrm_addr_dma;
DBGP ( "%s\n", __func__ );
if ( ! ( FLAG_TEST (bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) ) {
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4,
( u16 )LINK_SPEED_DRV_NUM,
1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->link_set = SET_LINK ( *ptr32, SPEED_DRV_MASK, SPEED_DRV_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4,
( u16 )D3_LINK_SPEED_FW_NUM, 1,
( u16 )bp->port_idx ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->link_set |= SET_LINK ( *ptr32, D3_SPEED_FW_MASK,
D3_SPEED_FW_SHIFT );
}
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4,
( u16 )LINK_SPEED_DRV_NUM,
1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->link_set = SET_LINK ( *ptr32, SPEED_DRV_MASK, SPEED_DRV_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4,
( u16 )LINK_SPEED_FW_NUM,
1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->link_set |= SET_LINK ( *ptr32, SPEED_FW_MASK, SPEED_FW_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 4,
( u16 )D3_LINK_SPEED_FW_NUM, 1,
( u16 )bp->port_idx ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->link_set |= SET_LINK ( *ptr32, D3_SPEED_FW_MASK,
D3_SPEED_FW_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1,
( u16 )PORT_CFG_LINK_SETTINGS_MEDIA_AUTO_DETECT_NUM,
1, ( u16 )bp->port_idx ) != STATUS_SUCCESS )
@@ -1324,51 +1224,32 @@ static int bnxt_get_link_speed ( struct bnxt *bp )
bp->link_set |= SET_LINK ( *ptr32,
MEDIA_AUTO_DETECT_MASK, MEDIA_AUTO_DETECT_SHIFT );
/* Use LINK_SPEED_FW_xxx which is valid for CHIP_P7 and earlier devices */
switch ( bp->link_set & LINK_SPEED_FW_MASK ) {
case LINK_SPEED_FW_1G:
switch ( bp->link_set & LINK_SPEED_DRV_MASK ) {
case LINK_SPEED_DRV_1G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_1000MBPS );
break;
case LINK_SPEED_FW_2_5G:
case LINK_SPEED_DRV_2_5G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_2500MBPS );
break;
case LINK_SPEED_FW_10G:
case LINK_SPEED_DRV_10G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_10GBPS );
break;
case LINK_SPEED_FW_25G:
case LINK_SPEED_DRV_25G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_25GBPS );
break;
case LINK_SPEED_FW_40G:
case LINK_SPEED_DRV_40G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_40GBPS );
break;
case LINK_SPEED_FW_50G:
case LINK_SPEED_DRV_50G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_50GBPS );
break;
case LINK_SPEED_FW_50G_PAM4:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_50PAM4GBPS );
break;
case LINK_SPEED_FW_100G:
case LINK_SPEED_DRV_100G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_100GBPS );
break;
case LINK_SPEED_FW_100G_PAM4:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_100PAM4GBPS );
break;
case LINK_SPEED_FW_100G_PAM4_112:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_100PAM4_112GBPS );
break;
case LINK_SPEED_FW_200G:
case LINK_SPEED_DRV_200G:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_200GBPS );
break;
case LINK_SPEED_FW_200G_PAM4_112:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_200PAM4_112GBPS );
break;
case LINK_SPEED_FW_400G_PAM4:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_400PAM4GBPS );
break;
case LINK_SPEED_FW_400G_PAM4_112:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_400PAM4_112GBPS );
break;
case LINK_SPEED_FW_AUTONEG:
case LINK_SPEED_DRV_AUTONEG:
bp->medium = SET_MEDIUM_SPEED ( bp, MEDIUM_SPEED_AUTONEG );
break;
default:
@@ -1387,29 +1268,27 @@ static int bnxt_get_vlan ( struct bnxt *bp )
if ( bp->vf )
return STATUS_SUCCESS;
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ) ) {
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1,
( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_NUM, 1,
( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
return STATUS_FAILURE;
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 1,
( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_NUM, 1,
( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->mba_cfg2 = SET_MBA ( *ptr32, VLAN_MASK, VLAN_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 16,
( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_VALUE_NUM, 1,
( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->mba_cfg2 = SET_MBA ( *ptr32, VLAN_MASK, VLAN_SHIFT );
test_if ( bnxt_hwrm_nvm_get_variable_req ( bp, 16,
( u16 )FUNC_CFG_PRE_BOOT_MBA_VLAN_VALUE_NUM, 1,
( u16 )bp->ordinal_value ) != STATUS_SUCCESS )
return STATUS_FAILURE;
bp->mba_cfg2 |= SET_MBA ( *ptr32, VLAN_VALUE_MASK, VLAN_VALUE_SHIFT );
if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
bp->vlan_id = bp->mba_cfg2 & VLAN_VALUE_MASK;
else
bp->vlan_id = 0;
bp->mba_cfg2 |= SET_MBA ( *ptr32, VLAN_VALUE_MASK, VLAN_VALUE_SHIFT );
if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
bp->vlan_id = bp->mba_cfg2 & VLAN_VALUE_MASK;
else
bp->vlan_id = 0;
if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
DBGP ( "VLAN MBA Enabled ( %d )\n",
( bp->mba_cfg2 & VLAN_VALUE_MASK ) );
if ( bp->mba_cfg2 & FUNC_CFG_PRE_BOOT_MBA_VLAN_ENABLED )
DBGP ( "VLAN MBA Enabled ( %d )\n",
( bp->mba_cfg2 & VLAN_VALUE_MASK ) );
}
return STATUS_SUCCESS;
}
@@ -1419,7 +1298,7 @@ static int bnxt_hwrm_backing_store_qcfg ( struct bnxt *bp )
struct hwrm_func_backing_store_qcfg_input *req;
DBGP ( "%s\n", __func__ );
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return STATUS_SUCCESS;
req = ( struct hwrm_func_backing_store_qcfg_input * )bp->hwrm_addr_req;
@@ -1434,7 +1313,7 @@ static int bnxt_hwrm_backing_store_cfg ( struct bnxt *bp )
struct hwrm_func_backing_store_cfg_input *req;
DBGP ( "%s\n", __func__ );
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return STATUS_SUCCESS;
req = ( struct hwrm_func_backing_store_cfg_input * )bp->hwrm_addr_req;
@@ -1453,7 +1332,7 @@ static int bnxt_hwrm_queue_qportcfg ( struct bnxt *bp )
int rc;
DBGP ( "%s\n", __func__ );
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return STATUS_SUCCESS;
req = ( struct hwrm_queue_qportcfg_input * )bp->hwrm_addr_req;
@@ -1493,10 +1372,7 @@ static int bnxt_hwrm_port_phy_cfg ( struct bnxt *bp )
u32 flags;
u32 enables = 0;
u16 force_link_speed = 0;
u16 force_link_speeds2 = 0;
u16 force_pam4_link_speed = 0;
u16 auto_link_speed_mask = 0;
u16 auto_link_speeds2_mask = 0;
u8 auto_mode = 0;
u8 auto_pause = 0;
u8 auto_duplex = 0;
@@ -1511,111 +1387,34 @@ static int bnxt_hwrm_port_phy_cfg ( struct bnxt *bp )
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_1GB;
break;
case MEDIUM_SPEED_10GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_10GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_10GB;
break;
case MEDIUM_SPEED_25GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_25GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_25GB;
break;
case MEDIUM_SPEED_40GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_40GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_40GB;
break;
case MEDIUM_SPEED_50GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB;
}
break;
case MEDIUM_SPEED_50PAM4GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB_PAM4_56;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_pam4_link_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_50GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_50GB;
break;
case MEDIUM_SPEED_100GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB;
}
break;
case MEDIUM_SPEED_100PAM4GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_56;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_pam4_link_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_100GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED;
}
break;
case MEDIUM_SPEED_100PAM4_112GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_112;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100GB;
break;
case MEDIUM_SPEED_200GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_56;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
} else {
force_pam4_link_speed = PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_200GB;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED;
}
force_link_speed = PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_200GB;
break;
case MEDIUM_SPEED_200PAM4_112GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_112;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
}
break;
case MEDIUM_SPEED_400PAM4GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_56;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
}
break;
case MEDIUM_SPEED_400PAM4_112GBPS:
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) ) {
force_link_speeds2 = PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_112;
enables |= PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2;
}
break;
default:
auto_mode = PORT_PHY_CFG_REQ_AUTO_MODE_SPEED_MASK;
flags &= ~PORT_PHY_CFG_REQ_FLAGS_FORCE;
enables |= PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE |
PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK |
PORT_PHY_CFG_REQ_ENABLES_AUTO_DUPLEX |
PORT_PHY_CFG_REQ_ENABLES_AUTO_PAUSE;
if ( FLAG_TEST (bp->flags, BNXT_FLAG_LINK_SPEEDS2 ) )
enables |= PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEEDS2_MASK;
else
enables |= PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEED_MASK;
auto_pause = PORT_PHY_CFG_REQ_AUTO_PAUSE_TX |
PORT_PHY_CFG_REQ_AUTO_PAUSE_RX;
auto_duplex = PORT_PHY_CFG_REQ_AUTO_DUPLEX_BOTH;
auto_link_speed_mask = bp->support_speeds;
auto_link_speeds2_mask = bp->auto_link_speeds2_mask;
break;
}
@@ -1624,13 +1423,10 @@ static int bnxt_hwrm_port_phy_cfg ( struct bnxt *bp )
req->enables = enables;
req->port_id = bp->port_idx;
req->force_link_speed = force_link_speed;
req->force_pam4_link_speed = force_pam4_link_speed;
req->force_link_speeds2 = force_link_speeds2;
req->auto_mode = auto_mode;
req->auto_duplex = auto_duplex;
req->auto_pause = auto_pause;
req->auto_link_speed_mask = auto_link_speed_mask;
req->auto_link_speeds2_mask = auto_link_speeds2_mask;
return wait_resp ( bp, bp->hwrm_cmd_timeout, cmd_len, __func__ );
}
@@ -1769,7 +1565,7 @@ static int bnxt_hwrm_ring_alloc_grp ( struct bnxt *bp )
int rc;
DBGP ( "%s\n", __func__ );
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) )
if ( bp->thor )
return STATUS_SUCCESS;
req = ( struct hwrm_ring_grp_alloc_input * )bp->hwrm_addr_req;
@@ -1820,7 +1616,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type )
switch ( type ) {
case RING_ALLOC_REQ_RING_TYPE_NQ:
req->page_size = LM_PAGE_BITS ( 12 );
req->int_mode = BNXT_CQ_INTR_MODE ( ( (FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7) ) || bp->vf ) );
req->int_mode = BNXT_CQ_INTR_MODE ( bp->vf );
req->length = ( u32 )bp->nq.ring_cnt;
req->logical_id = 0xFFFF; // Required value for Thor FW?
req->page_tbl_addr = virt_to_bus ( bp->nq.bd_virt );
@@ -1830,7 +1626,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type )
req->int_mode = BNXT_CQ_INTR_MODE ( bp->vf );
req->length = ( u32 )bp->cq.ring_cnt;
req->page_tbl_addr = virt_to_bus ( bp->cq.bd_virt );
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
break;
req->enables = RING_ALLOC_REQ_ENABLES_NQ_RING_ID_VALID;
req->nq_ring_id = bp->nq_ring_id;
@@ -1852,7 +1648,7 @@ static int bnxt_hwrm_ring_alloc ( struct bnxt *bp, u8 type )
req->stat_ctx_id = ( u32 )STAT_CTX_ID;
req->cmpl_ring_id = bp->cq_ring_id;
req->page_tbl_addr = virt_to_bus ( bp->rx.bd_virt );
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
break;
req->queue_id = ( u16 )RX_RING_QID;
req->rx_buf_size = MAX_ETHERNET_PACKET_BUFFER_SIZE;
@@ -1948,7 +1744,7 @@ static int bnxt_hwrm_ring_free_rx ( struct bnxt *bp )
static int bnxt_hwrm_ring_alloc_nq ( struct bnxt *bp )
{
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return STATUS_SUCCESS;
return bnxt_hwrm_ring_alloc ( bp, RING_ALLOC_REQ_RING_TYPE_NQ );
}
@@ -1957,7 +1753,7 @@ static int bnxt_hwrm_ring_free_nq ( struct bnxt *bp )
{
int ret = STATUS_SUCCESS;
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return STATUS_SUCCESS;
DBGP ( "%s\n", __func__ );
@@ -2028,7 +1824,7 @@ static int bnxt_hwrm_vnic_cfg ( struct bnxt *bp )
req->enables = VNIC_CFG_REQ_ENABLES_MRU;
req->mru = bp->mtu;
if ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) {
if ( bp->thor ) {
req->enables |= ( VNIC_CFG_REQ_ENABLES_DEFAULT_RX_RING_ID |
VNIC_CFG_REQ_ENABLES_DEFAULT_CMPL_RING_ID );
req->default_rx_ring_id = bp->rx_ring_id;
@@ -2082,7 +1878,6 @@ hwrm_func_t bring_up_chip[] = {
bnxt_hwrm_backing_store_cfg, /* HWRM_FUNC_BACKING_STORE_CFG */
bnxt_hwrm_backing_store_qcfg, /* HWRM_FUNC_BACKING_STORE_QCFG */
bnxt_hwrm_func_resource_qcaps, /* HWRM_FUNC_RESOURCE_QCAPS */
bnxt_hwrm_port_phy_qcaps_req, /* HWRM_PORT_PHY_QCAPS */
bnxt_hwrm_func_qcfg_req, /* HWRM_FUNC_QCFG */
bnxt_get_vlan, /* HWRM_NVM_GET_VARIABLE - vlan */
bnxt_hwrm_port_mac_cfg, /* HWRM_PORT_MAC_CFG */
@@ -2175,9 +1970,6 @@ static int bnxt_tx ( struct net_device *dev, struct io_buffer *iob )
bp->tx.iob[entry] = iob;
bnxt_set_txq ( bp, entry, mapping, len );
entry = NEXT_IDX ( entry, bp->tx.ring_cnt );
/* If the ring has wrapped, toggle the epoch bit */
if ( bp->tx.prod_id > entry )
bp->tx.epoch ^= 1;
dump_tx_pkt ( ( u8 * )iob->data, len, bp->tx.prod_id );
/* Packets are ready, update Tx producer idx local and on card. */
bnxt_db_tx ( bp, ( u32 )entry );
@@ -2196,7 +1988,6 @@ static void bnxt_adv_nq_index ( struct bnxt *bp, u16 cnt )
if ( cons_id >= bp->nq.ring_cnt ) {
/* Toggle completion bit when the ring wraps. */
bp->nq.completion_bit ^= 1;
bp->nq.epoch ^= 1;
cons_id = cons_id - bp->nq.ring_cnt;
}
bp->nq.cons_id = cons_id;
@@ -2237,7 +2028,7 @@ static void bnxt_service_cq ( struct net_device *dev )
cq_type = cmp->type & CMPL_BASE_TYPE_MASK;
dump_evt ( ( u8 * )cmp, cq_type, bp->cq.cons_id, 0 );
dump_cq ( cmp, bp->cq.cons_id, bp->nq.toggle );
dump_cq ( cmp, bp->cq.cons_id );
switch ( cq_type ) {
case CMPL_BASE_TYPE_TX_L2:
@@ -2248,7 +2039,6 @@ static void bnxt_service_cq ( struct net_device *dev )
bnxt_adv_cq_index ( bp, 1 );
break;
case CMPL_BASE_TYPE_RX_L2:
case CMPL_BASE_TYPE_RX_L2_V3:
done = bnxt_rx_complete ( dev,
( struct rx_pkt_cmpl * )cmp );
break;
@@ -2275,7 +2065,7 @@ static void bnxt_service_nq ( struct net_device *dev )
int done = SERVICE_NEXT_NQ_BD;
u32 nq_type;
if ( ! ( FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS ) ) )
if ( !bp->thor )
return;
while ( done == SERVICE_NEXT_NQ_BD ) {
@@ -2284,7 +2074,6 @@ static void bnxt_service_nq ( struct net_device *dev )
if ( ( nqp->v & NQ_CN_V ) ^ bp->nq.completion_bit )
break;
nq_type = ( nqp->type & NQ_CN_TYPE_MASK );
bp->nq.toggle = ( ( nqp->type & NQ_CN_TOGGLE_MASK ) >> NQ_CN_TOGGLE_SFT );
dump_evt ( ( u8 * )nqp, nq_type, bp->nq.cons_id, 1 );
dump_nq ( nqp, bp->nq.cons_id );
@@ -2309,8 +2098,8 @@ static void bnxt_service_nq ( struct net_device *dev )
static void bnxt_poll ( struct net_device *dev )
{
mb ( );
bnxt_service_nq ( dev );
bnxt_service_cq ( dev );
bnxt_service_nq ( dev );
}
static void bnxt_close ( struct net_device *dev )
+8 -203
View File
@@ -52,10 +52,6 @@ union dma_addr64_t {
#define BNXT_FLAG_NPAR_MODE 0x0010
#define BNXT_FLAG_ATOMICS_ENABLE 0x0020
#define BNXT_FLAG_PCI_VF 0x0040
#define BNXT_FLAG_LINK_SPEEDS2 0x0080
#define BNXT_FLAG_IS_CHIP_P5 0x0100
#define BNXT_FLAG_IS_CHIP_P5_PLUS 0x0200
#define BNXT_FLAG_IS_CHIP_P7 0x0400
/*******************************************************************************
* Status codes.
******************************************************************************/
@@ -110,12 +106,6 @@ union dma_addr64_t {
#define MEDIUM_SPEED_50GBPS 0x0a00L
#define MEDIUM_SPEED_100GBPS 0x0b00L
#define MEDIUM_SPEED_200GBPS 0x0c00L
#define MEDIUM_SPEED_50PAM4GBPS 0x0d00L
#define MEDIUM_SPEED_100PAM4GBPS 0x0e00L
#define MEDIUM_SPEED_100PAM4_112GBPS 0x0f00L
#define MEDIUM_SPEED_200PAM4_112GBPS 0x1000L
#define MEDIUM_SPEED_400PAM4GBPS 0x2000L
#define MEDIUM_SPEED_400PAM4_112GBPS 0x3000L
#define MEDIUM_SPEED_AUTONEG_1G_FALLBACK 0x8000L /* Serdes */
#define MEDIUM_SPEED_AUTONEG_2_5G_FALLBACK 0x8100L /* Serdes */
#define MEDIUM_SPEED_HARDWARE_DEFAULT 0xff00L /* Serdes nvram def.*/
@@ -178,9 +168,9 @@ union dma_addr64_t {
RX_MASK_ACCEPT_MULTICAST)
#define MAX_NQ_DESC_CNT 64
#define NQ_RING_BUFFER_SIZE (MAX_NQ_DESC_CNT * sizeof(struct cmpl_base))
#define TX_RING_QID (FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS) ? (u16)bp->queue_id : ((u16)bp->port_idx * 10))
#define RX_RING_QID (FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS) ? bp->queue_id : 0)
#define STAT_CTX_ID ((bp->vf || FLAG_TEST(bp->flags, BNXT_FLAG_IS_CHIP_P5_PLUS)) ? bp->stat_ctx_id : 0)
#define TX_RING_QID (bp->thor ? (u16)bp->queue_id : ((u16)bp->port_idx * 10))
#define RX_RING_QID (bp->thor ? bp->queue_id : 0)
#define STAT_CTX_ID ((bp->vf || bp->thor) ? bp->stat_ctx_id : 0)
#define TX_AVAIL(r) (r - 1)
#define TX_IN_USE(a, b, c) ((a - b) & (c - 1))
#define NO_MORE_NQ_BD_TO_SERVICE 1
@@ -199,19 +189,13 @@ union dma_addr64_t {
((idx) << DBC_DBC_INDEX_SFT) & DBC_DBC_INDEX_MASK)
#define DBC_MSG_XID(xid, flg) (\
(((xid) << DBC_DBC_XID_SFT) & DBC_DBC_XID_MASK) | \
DBC_DBC_PATH_L2 | (FLAG_TEST ( bp->flags, BNXT_FLAG_IS_CHIP_P7 ) ? DBC_DBC_VALID : 0) | (flg))
#define DBC_MSG_EPCH(idx) (\
((idx) << DBC_DBC_EPOCH_SFT))
#define DBC_MSG_TOGGLE(idx) (\
((idx) << DBC_DBC_TOGGLE_SFT) & DBC_DBC_TOGGLE_MASK)
DBC_DBC_PATH_L2 | (flg))
#define PHY_STATUS 0x0001
#define PHY_SPEED 0x0002
#define DETECT_MEDIA 0x0004
#define SUPPORT_SPEEDS 0x0008
#define SUPPORT_SPEEDS2 0x0010
#define QCFG_PHY_ALL (\
SUPPORT_SPEEDS | SUPPORT_SPEEDS2 | \
DETECT_MEDIA | PHY_SPEED | PHY_STATUS)
SUPPORT_SPEEDS | DETECT_MEDIA | PHY_SPEED | PHY_STATUS)
#define str_mbps "Mbps"
#define str_gbps "Gbps"
/*
@@ -303,18 +287,6 @@ union dma_addr64_t {
#define NS_LINK_SPEED_FW_100G (0x6)
#define LINK_SPEED_FW_200G (0x7L << 7)
#define NS_LINK_SPEED_FW_200G (0x7)
#define LINK_SPEED_FW_50G_PAM4 (0x8L << 7)
#define NS_LINK_SPEED_FW_50G_PAM4 (0x8)
#define LINK_SPEED_FW_100G_PAM4 (0x9L << 7)
#define NS_LINK_SPEED_FW_100G_PAM4 (0x9)
#define LINK_SPEED_FW_100G_PAM4_112 (0xAL << 7)
#define NS_LINK_SPEED_FW_100G_PAM4_112 (0xA)
#define LINK_SPEED_FW_200G_PAM4_112 (0xBL << 7)
#define NS_LINK_SPEED_FW_200G_PAM4_112 (0xB)
#define LINK_SPEED_FW_400G_PAM4 (0xCL << 7)
#define NS_LINK_SPEED_FW_400G_PAM4 (0xC)
#define LINK_SPEED_FW_400G_PAM4_112 (0xDL << 7)
#define NS_LINK_SPEED_FW_400G_PAM4_112 (0xD)
#define LINK_SPEED_FW_2_5G (0xEL << 7)
#define NS_LINK_SPEED_FW_2_5G (0xE)
#define LINK_SPEED_FW_100M (0xFL << 7)
@@ -415,10 +387,6 @@ struct dbc_dbc {
__le32 index;
#define DBC_DBC_INDEX_MASK 0xffffffUL
#define DBC_DBC_INDEX_SFT 0
#define DBC_DBC_EPOCH 0x1000000UL
#define DBC_DBC_EPOCH_SFT 24
#define DBC_DBC_TOGGLE_MASK 0x6000000UL
#define DBC_DBC_TOGGLE_SFT 25
__le32 type_path_xid;
#define DBC_DBC_XID_MASK 0xfffffUL
#define DBC_DBC_XID_SFT 0
@@ -428,7 +396,6 @@ struct dbc_dbc {
#define DBC_DBC_PATH_L2 (0x1UL << 24)
#define DBC_DBC_PATH_ENGINE (0x2UL << 24)
#define DBC_DBC_PATH_LAST DBC_DBC_PATH_ENGINE
#define DBC_DBC_VALID 0x4000000UL
#define DBC_DBC_DEBUG_TRACE 0x8000000UL
#define DBC_DBC_TYPE_MASK 0xf0000000UL
#define DBC_DBC_TYPE_SFT 28
@@ -514,8 +481,6 @@ struct tx_info {
u16 ring_cnt;
u32 cnt; /* Tx statistics. */
u32 cnt_req;
u8 epoch;
u8 res[3];
};
struct cmpl_base {
@@ -527,7 +492,6 @@ struct cmpl_base {
#define CMPL_BASE_TYPE_RX_AGG 0x12UL
#define CMPL_BASE_TYPE_RX_TPA_START 0x13UL
#define CMPL_BASE_TYPE_RX_TPA_END 0x15UL
#define CMPL_BASE_TYPE_RX_L2_V3 0x17UL
#define CMPL_BASE_TYPE_STAT_EJECT 0x1aUL
#define CMPL_BASE_TYPE_HWRM_DONE 0x20UL
#define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
@@ -553,8 +517,7 @@ struct cmp_info {
u16 cons_id;
u16 ring_cnt;
u8 completion_bit;
u8 epoch;
u8 res[2];
u8 res[3];
};
/* Completion Queue Notification */
@@ -570,8 +533,6 @@ struct nq_base {
*/
#define NQ_CN_TYPE_MASK 0x3fUL
#define NQ_CN_TYPE_SFT 0
#define NQ_CN_TOGGLE_MASK 0xc0UL
#define NQ_CN_TOGGLE_SFT 6
/* CQ Notification */
#define NQ_CN_TYPE_CQ_NOTIFICATION 0x30UL
#define NQ_CN_TYPE_LAST NQ_CN_TYPE_CQ_NOTIFICATION
@@ -600,9 +561,7 @@ struct nq_info {
u16 cons_id;
u16 ring_cnt;
u8 completion_bit;
u8 epoch;
u8 toggle;
u8 res[1];
u8 res[3];
};
struct rx_pkt_cmpl {
@@ -716,156 +675,6 @@ struct rx_pkt_cmpl_hi {
#define RX_PKT_CMPL_REORDER_SFT 0
};
struct rx_pkt_v3_cmpl {
u16 flags_type;
#define RX_PKT_V3_CMPL_TYPE_MASK 0x3fUL
#define RX_PKT_V3_CMPL_TYPE_SFT 0
/*
* RX L2 V3 completion:
* Completion of and L2 RX packet. Length = 32B
* This is the new version of the RX_L2 completion used in Thor2
* and later chips.
*/
#define RX_PKT_V3_CMPL_TYPE_RX_L2_V3 0x17UL
#define RX_PKT_V3_CMPL_TYPE_LAST RX_PKT_V3_CMPL_TYPE_RX_L2_V3
#define RX_PKT_V3_CMPL_FLAGS_MASK 0xffc0UL
#define RX_PKT_V3_CMPL_FLAGS_SFT 6
#define RX_PKT_V3_CMPL_FLAGS_ERROR 0x40UL
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_MASK 0x380UL
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_SFT 7
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_NORMAL (0x0UL << 7)
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_JUMBO (0x1UL << 7)
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_HDS (0x2UL << 7)
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_TRUNCATION (0x3UL << 7)
#define RX_PKT_V3_CMPL_FLAGS_PLACEMENT_LAST RX_PKT_V3_CMPL_FLAGS_PLACEMENT_TRUNCATION
#define RX_PKT_V3_CMPL_FLAGS_RSS_VALID 0x400UL
#define RX_PKT_V3_CMPL_FLAGS_PKT_METADATA_PRESENT 0x800UL
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_MASK 0xf000UL
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_SFT 12
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_NOT_KNOWN (0x0UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_IP (0x1UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_TCP (0x2UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_UDP (0x3UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_FCOE (0x4UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_ROCE (0x5UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_ICMP (0x7UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_WO_TIMESTAMP (0x8UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP (0x9UL << 12)
#define RX_PKT_V3_CMPL_FLAGS_ITYPE_LAST RX_PKT_V3_CMPL_FLAGS_ITYPE_PTP_W_TIMESTAMP
u16 len;
u32 opaque;
u16 rss_hash_type_agg_bufs_v1;
#define RX_PKT_V3_CMPL_V1 0x1UL
#define RX_PKT_V3_CMPL_AGG_BUFS_MASK 0x3eUL
#define RX_PKT_V3_CMPL_AGG_BUFS_SFT 1
#define RX_PKT_V3_CMPL_UNUSED1 0x40UL
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_MASK 0xff80UL
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_SFT 7
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_0 (0x0UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_1 (0x1UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_3 (0x3UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_4 (0x4UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_5 (0x5UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_6 (0x6UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_7 (0x7UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_8 (0x8UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_9 (0x9UL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_10 (0xaUL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_11 (0xbUL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_12 (0xcUL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_13 (0xdUL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_14 (0xeUL << 7)
#define RX_PKT_V3_CMPL_RSS_HASH_TYPE_LAST RX_PKT_V3_CMPL_RSS_HASH_TYPE_ENUM_14
u16 metadata1_payload_offset;
#define RX_PKT_V3_CMPL_PAYLOAD_OFFSET_MASK 0x1ffUL
#define RX_PKT_V3_CMPL_PAYLOAD_OFFSET_SFT 0
#define RX_PKT_V3_CMPL_METADATA1_MASK 0xf000UL
#define RX_PKT_V3_CMPL_METADATA1_SFT 12
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_MASK 0x7000UL
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_SFT 12
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID88A8 (0x0UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID8100 (0x1UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9100 (0x2UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9200 (0x3UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPID9300 (0x4UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG (0x5UL << 12)
#define RX_PKT_V3_CMPL_METADATA1_TPID_SEL_LAST RX_PKT_V3_CMPL_METADATA1_TPID_SEL_TPIDCFG
#define RX_PKT_V3_CMPL_METADATA1_VALID 0x8000UL
u32 rss_hash;
};
struct rx_pkt_v3_cmpl_hi {
u32 flags2;
#define RX_PKT_V3_CMPL_HI_FLAGS2_IP_CS_CALC 0x1UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_L4_CS_CALC 0x2UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_CS_CALC 0x4UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_L4_CS_CALC 0x8UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_MASK 0xf0UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_SFT 4
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_NONE (0x0UL << 4)
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_ACT_REC_PTR (0x1UL << 4)
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_TUNNEL_ID (0x2UL << 4)
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_CHDR_DATA (0x3UL << 4)
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_HDR_OFFSET (0x4UL << 4)
#define RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_LAST RX_PKT_V3_CMPL_HI_FLAGS2_META_FORMAT_HDR_OFFSET
#define RX_PKT_V3_CMPL_HI_FLAGS2_IP_TYPE 0x100UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_CALC 0x200UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE 0x400UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV4 (0x0UL << 10)
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV6 (0x1UL << 10)
#define RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_LAST RX_PKT_V3_CMPL_HI_FLAGS2_T_IP_TYPE_IPV6
#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_MASK 0xffff0000UL
#define RX_PKT_V3_CMPL_HI_FLAGS2_COMPLETE_CHECKSUM_SFT 16
u32 metadata2;
u16 errors_v2;
#define RX_PKT_V3_CMPL_HI_V2 0x1UL
#define RX_PKT_V3_CMPL_HI_ERRORS_MASK 0xfffeUL
#define RX_PKT_V3_CMPL_HI_ERRORS_SFT 1
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_MASK 0xeUL
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_SFT 1
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_NO_BUFFER (0x0UL << 1)
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_DID_NOT_FIT (0x1UL << 1)
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_NOT_ON_CHIP (0x2UL << 1)
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_BAD_FORMAT (0x3UL << 1)
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_FLUSH (0x5UL << 1)
#define RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_LAST RX_PKT_V3_CMPL_HI_ERRORS_BUFFER_ERROR_FLUSH
#define RX_PKT_V3_CMPL_HI_ERRORS_IP_CS_ERROR 0x10UL
#define RX_PKT_V3_CMPL_HI_ERRORS_L4_CS_ERROR 0x20UL
#define RX_PKT_V3_CMPL_HI_ERRORS_T_IP_CS_ERROR 0x40UL
#define RX_PKT_V3_CMPL_HI_ERRORS_T_L4_CS_ERROR 0x80UL
#define RX_PKT_V3_CMPL_HI_ERRORS_CRC_ERROR 0x100UL
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_MASK 0xe00UL
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_SFT 9
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_NO_ERROR (0x0UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_VERSION (0x1UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_HDR_LEN (0x2UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_IP_TOTAL_ERROR (0x3UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_UDP_TOTAL_ERROR (0x4UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_L3_BAD_TTL (0x5UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR (0x6UL << 9)
#define RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_LAST RX_PKT_V3_CMPL_HI_ERRORS_T_PKT_ERROR_T_TOTAL_ERROR
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_MASK 0xf000UL
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_SFT 12
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_NO_ERROR (0x0UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_VERSION (0x1UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_HDR_LEN (0x2UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L3_BAD_TTL (0x3UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_IP_TOTAL_ERROR (0x4UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_UDP_TOTAL_ERROR (0x5UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN (0x6UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_HDR_LEN_TOO_SMALL (0x7UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN (0x8UL << 12)
#define RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_LAST RX_PKT_V3_CMPL_HI_ERRORS_PKT_ERROR_L4_BAD_OPT_LEN
u16 metadata0;
#define RX_PKT_V3_CMPL_HI_METADATA0_VID_MASK 0xfffUL
#define RX_PKT_V3_CMPL_HI_METADATA0_VID_SFT 0
#define RX_PKT_V3_CMPL_HI_METADATA0_DE 0x1000UL
/* When meta_format=1, this value is the VLAN PRI. */
#define RX_PKT_V3_CMPL_HI_METADATA0_PRI_MASK 0xe000UL
#define RX_PKT_V3_CMPL_HI_METADATA0_PRI_SFT 13
u32 timestamp;
};
struct rx_prod_pkt_bd {
u16 flags_type;
#define RX_PROD_PKT_BD_TYPE_MASK 0x3fUL
@@ -896,8 +705,6 @@ struct rx_info {
u32 drop_err;
u32 drop_lb;
u32 drop_vlan;
u8 epoch;
u8 res[3];
};
#define VALID_DRIVER_REG 0x0001
@@ -943,6 +750,7 @@ struct bnxt {
struct nq_info nq; /* completion info. */
u16 nq_ring_id;
u8 queue_id;
u8 thor;
u16 last_resp_code;
u16 seq_id;
u32 flag_hwrm;
@@ -984,7 +792,6 @@ struct bnxt {
u32 mba_cfg2;
u32 medium;
u16 support_speeds;
u16 auto_link_speeds2_mask;
u32 link_set;
u8 media_detect;
u8 rsvd;
@@ -1064,5 +871,3 @@ struct bnxt {
#define CHIP_NUM_57508 0x1750
#define CHIP_NUM_57504 0x1751
#define CHIP_NUM_57502 0x1752
#define CHIP_NUM_57608 0x1760
+3 -3
View File
@@ -475,7 +475,7 @@ void dbg_rx_stat(struct bnxt *bp)
#endif
#if defined(DEBUG_CQ)
static void dump_cq(struct cmpl_base *cmp, u16 cid, u8 toggle)
static void dump_cq(struct cmpl_base *cmp, u16 cid)
{
dbg_prn("- CQ Type ");
switch (cmp->type & CMPL_BASE_TYPE_MASK) {
@@ -495,7 +495,7 @@ static void dump_cq(struct cmpl_base *cmp, u16 cid, u8 toggle)
dbg_prn("%04x", (u16)(cmp->type & CMPL_BASE_TYPE_MASK));
break;
}
dbg_prn(" cid %d, tog %d", cid, toggle);
dbg_prn(" cid %d", cid);
#if defined(DEBUG_CQ_DUMP)
dump_mem((u8 *)cmp, (u32)sizeof(struct cmpl_base), DISP_U8);
#else
@@ -513,7 +513,7 @@ static void dump_nq(struct nq_base *nqp, u16 cid)
#endif
}
#else
#define dump_cq(cq, id, toggle)
#define dump_cq(cq, id)
#define dump_nq(nq, id)
#endif
+8 -221
View File
@@ -2929,7 +2929,7 @@ struct hwrm_func_drv_if_change_output {
u8 valid;
};
/* hwrm_port_phy_cfg_input (size:512b/64B) */
/* hwrm_port_phy_cfg_input (size:448b/56B) */
struct hwrm_port_phy_cfg_input {
__le16 req_type;
__le16 cmpl_ring;
@@ -2952,15 +2952,6 @@ struct hwrm_port_phy_cfg_input {
#define PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_ENABLE 0x1000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_CLAUSE91_DISABLE 0x2000UL
#define PORT_PHY_CFG_REQ_FLAGS_FORCE_LINK_DWN 0x4000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_ENABLE 0x8000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_1XN_DISABLE 0x10000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_ENABLE 0x20000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS544_IEEE_DISABLE 0x40000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_ENABLE 0x80000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_1XN_DISABLE 0x100000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_ENABLE 0x200000UL
#define PORT_PHY_CFG_REQ_FLAGS_FEC_RS272_IEEE_DISABLE 0x400000UL
__le32 enables;
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_MODE 0x1UL
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_DUPLEX 0x2UL
@@ -2973,10 +2964,6 @@ struct hwrm_port_phy_cfg_input {
#define PORT_PHY_CFG_REQ_ENABLES_FORCE_PAUSE 0x100UL
#define PORT_PHY_CFG_REQ_ENABLES_EEE_LINK_SPEED_MASK 0x200UL
#define PORT_PHY_CFG_REQ_ENABLES_TX_LPI_TIMER 0x400UL
#define PORT_PHY_CFG_REQ_ENABLES_FORCE_PAM4_LINK_SPEED 0x800UL
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_PAM4_LINK_SPEED_MASK 0x1000UL
#define PORT_PHY_CFG_REQ_ENABLES_FORCE_LINK_SPEEDS2 0x2000UL
#define PORT_PHY_CFG_REQ_ENABLES_AUTO_LINK_SPEEDS2_MASK 0x4000UL
__le16 port_id;
__le16 force_link_speed;
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEED_100MB 0x1UL
@@ -3062,48 +3049,11 @@ struct hwrm_port_phy_cfg_input {
#define PORT_PHY_CFG_REQ_EEE_LINK_SPEED_MASK_RSVD3 0x10UL
#define PORT_PHY_CFG_REQ_EEE_LINK_SPEED_MASK_RSVD4 0x20UL
#define PORT_PHY_CFG_REQ_EEE_LINK_SPEED_MASK_10GB 0x40UL
__le16 force_pam4_link_speed;
#define PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_50GB 0x1f4UL
#define PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_100GB 0x3e8UL
#define PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_200GB 0x7d0UL
#define PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_LAST PORT_PHY_CFG_REQ_FORCE_PAM4_LINK_SPEED_200GB
u8 unused_2[2];
__le32 tx_lpi_timer;
#define PORT_PHY_CFG_REQ_TX_LPI_TIMER_MASK 0xffffffUL
#define PORT_PHY_CFG_REQ_TX_LPI_TIMER_SFT 0
__le16 auto_link_pam4_speed_mask;
#define PORT_PHY_CFG_REQ_AUTO_LINK_PAM4_SPEED_MASK_50G 0x1UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_PAM4_SPEED_MASK_100G 0x2UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_PAM4_SPEED_MASK_200G 0x4UL
__le16 force_link_speeds2;
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_1GB 0xaUL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_10GB 0x64UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_25GB 0xfaUL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_40GB 0x190UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB 0x1f4UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB 0x3e8UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_50GB_PAM4_56 0x1f5UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_56 0x3e9UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_56 0x7d1UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_56 0xfa1UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_100GB_PAM4_112 0x3eaUL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_200GB_PAM4_112 0x7d2UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_112 0xfa2UL
#define PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_LAST PORT_PHY_CFG_REQ_FORCE_LINK_SPEEDS2_400GB_PAM4_112
__le16 auto_link_speeds2_mask;
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_1GB 0x1UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_10GB 0x2UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_25GB 0x4UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_40GB 0x8UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_50GB 0x10UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_100GB 0x20UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_50GB_PAM4_56 0x40UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_100GB_PAM4_56 0x80UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_200GB_PAM4_56 0x100UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_400GB_PAM4_56 0x200UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_100GB_PAM4_112 0x400UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_200GB_PAM4_112 0x800UL
#define PORT_PHY_CFG_REQ_AUTO_LINK_SPEEDS2_MASK_400GB_PAM4_112 0x1000UL
u8 unused_2[6];
__le32 unused_3;
};
/* hwrm_port_phy_cfg_output (size:128b/16B) */
@@ -3137,7 +3087,7 @@ struct hwrm_port_phy_qcfg_input {
u8 unused_0[6];
};
/* hwrm_port_phy_qcfg_output (size:832b/104B) */
/* hwrm_port_phy_qcfg_output (size:768b/96B) */
struct hwrm_port_phy_qcfg_output {
__le16 error_code;
__le16 req_type;
@@ -3148,23 +3098,7 @@ struct hwrm_port_phy_qcfg_output {
#define PORT_PHY_QCFG_RESP_LINK_SIGNAL 0x1UL
#define PORT_PHY_QCFG_RESP_LINK_LINK 0x2UL
#define PORT_PHY_QCFG_RESP_LINK_LAST PORT_PHY_QCFG_RESP_LINK_LINK
u8 active_fec_signal_mode;
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_MASK 0xfUL
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_SFT 0
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_NRZ 0x0UL
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4 0x1UL
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4_112 0x2UL
#define PORT_PHY_QCFG_RESP_SIGNAL_MODE_LAST HWRM_PORT_PHY_QCFG_RESP_SIGNAL_MODE_PAM4_112
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_MASK 0xf0UL
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_SFT 4
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_NONE_ACTIVE (0x0UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_CLAUSE74_ACTIVE (0x1UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_CLAUSE91_ACTIVE (0x2UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_RS544_1XN_ACTIVE (0x3UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_RS544_IEEE_ACTIVE (0x4UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_RS272_1XN_ACTIVE (0x5UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE (0x6UL << 4)
#define PORT_PHY_QCFG_RESP_ACTIVE_FEC_LAST PORT_PHY_QCFG_RESP_ACTIVE_FEC_FEC_RS272_IEEE_ACTIVE
u8 unused_0;
__le16 link_speed;
#define PORT_PHY_QCFG_RESP_LINK_SPEED_100MB 0x1UL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_1GB 0xaUL
@@ -3177,7 +3111,6 @@ struct hwrm_port_phy_qcfg_output {
#define PORT_PHY_QCFG_RESP_LINK_SPEED_50GB 0x1f4UL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_100GB 0x3e8UL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_200GB 0x7d0UL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_400GB 0xfa0UL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_10MB 0xffffUL
#define PORT_PHY_QCFG_RESP_LINK_SPEED_LAST PORT_PHY_QCFG_RESP_LINK_SPEED_10MB
u8 duplex_cfg;
@@ -3316,31 +3249,7 @@ struct hwrm_port_phy_qcfg_output {
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASESR4 0x1dUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASELR4 0x1eUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASEER4 0x1fUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_50G_BASECR 0x20UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_50G_BASESR 0x21UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_50G_BASELR 0x22UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_50G_BASEER 0x23UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASECR2 0x24UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASESR2 0x25UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASELR2 0x26UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASEER2 0x27UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASECR 0x28UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASESR 0x29UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASELR 0x2aUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_100G_BASEER 0x2bUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASECR2 0x2cUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASESR2 0x2dUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASELR2 0x2eUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASEER2 0x2fUL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASECR8 0x30UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASESR8 0x31UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASELR8 0x32UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASEER8 0x33UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASECR4 0x34UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASESR4 0x35UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASELR4 0x36UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASEER4 0x37UL
#define PORT_PHY_QCFG_RESP_PHY_TYPE_LAST PORT_PHY_QCFG_RESP_PHY_TYPE_400G_BASEER4
#define PORT_PHY_QCFG_RESP_PHY_TYPE_LAST PORT_PHY_QCFG_RESP_PHY_TYPE_200G_BASEER4
u8 media_type;
#define PORT_PHY_QCFG_RESP_MEDIA_TYPE_UNKNOWN 0x0UL
#define PORT_PHY_QCFG_RESP_MEDIA_TYPE_TP 0x1UL
@@ -3421,90 +3330,15 @@ struct hwrm_port_phy_qcfg_output {
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE74_ENABLED 0x10UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_SUPPORTED 0x20UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_CLAUSE91_ENABLED 0x40UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_1XN_SUPPORTED 0x80UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_1XN_ENABLED 0x100UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_IEEE_SUPPORTED 0x200UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS544_IEEE_ENABLED 0x400UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_SUPPORTED 0x800UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_1XN_ENABLED 0x1000UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_SUPPORTED 0x2000UL
#define PORT_PHY_QCFG_RESP_FEC_CFG_FEC_RS272_IEEE_ENABLED 0x4000UL
u8 duplex_state;
#define PORT_PHY_QCFG_RESP_DUPLEX_STATE_HALF 0x0UL
#define PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL 0x1UL
#define PORT_PHY_QCFG_RESP_DUPLEX_STATE_LAST PORT_PHY_QCFG_RESP_DUPLEX_STATE_FULL
u8 option_flags;
#define PORT_PHY_QCFG_RESP_OPTION_FLAGS_MEDIA_AUTO_DETECT 0x1UL
#define PORT_PHY_QCFG_RESP_OPTION_FLAGS_SIGNAL_MODE_KNOWN 0x2UL
#define PORT_PHY_QCFG_RESP_OPTION_FLAGS_SPEEDS2_SUPPORTED 0x4UL
char phy_vendor_name[16];
char phy_vendor_partnumber[16];
__le16 support_pam4_speeds;
#define PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_50G 0x1UL
#define PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_100G 0x2UL
#define PORT_PHY_QCFG_RESP_SUPPORT_PAM4_SPEEDS_200G 0x4UL
__le16 force_pam4_link_speed;
#define PORT_PHY_QCFG_RESP_FORCE_PAM4_LINK_SPEED_50GB 0x1f4UL
#define PORT_PHY_QCFG_RESP_FORCE_PAM4_LINK_SPEED_100GB 0x3e8UL
#define PORT_PHY_QCFG_RESP_FORCE_PAM4_LINK_SPEED_200GB 0x7d0UL
#define PORT_PHY_QCFG_RESP_FORCE_PAM4_LINK_SPEED_LAST PORT_PHY_QCFG_RESP_FORCE_PAM4_LINK_SPEED_200GB
__le16 auto_pam4_link_speed_mask;
#define PORT_PHY_QCFG_RESP_AUTO_PAM4_LINK_SPEED_MASK_50G 0x1UL
#define PORT_PHY_QCFG_RESP_AUTO_PAM4_LINK_SPEED_MASK_100G 0x2UL
#define PORT_PHY_QCFG_RESP_AUTO_PAM4_LINK_SPEED_MASK_200G 0x4UL
u8 link_partner_pam4_adv_speeds;
#define PORT_PHY_QCFG_RESP_LINK_PARTNER_PAM4_ADV_SPEEDS_50GB 0x1UL
#define PORT_PHY_QCFG_RESP_LINK_PARTNER_PAM4_ADV_SPEEDS_100GB 0x2UL
#define PORT_PHY_QCFG_RESP_LINK_PARTNER_PAM4_ADV_SPEEDS_200GB 0x4UL
u8 link_down_reason;
#define PORT_PHY_QCFG_RESP_LINK_DOWN_REASON_RF 0x1UL
__le16 support_speeds2;
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_1GB 0x1UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_10GB 0x2UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_25GB 0x4UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_40GB 0x8UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB 0x10UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB 0x20UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_50GB_PAM4_56 0x40UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_56 0x80UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_56 0x100UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_56 0x200UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_100GB_PAM4_112 0x400UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_200GB_PAM4_112 0x800UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_400GB_PAM4_112 0x1000UL
#define PORT_PHY_QCFG_RESP_SUPPORT_SPEEDS2_800GB_PAM4_112 0x2000UL
__le16 force_link_speeds2;
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_1GB 0xaUL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_10GB 0x64UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_25GB 0xfaUL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_40GB 0x190UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_50GB 0x1f4UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_100GB 0x3e8UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_50GB_PAM4_56 0x1f5UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_100GB_PAM4_56 0x3e9UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_200GB_PAM4_56 0x7d1UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_400GB_PAM4_56 0xfa1UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_100GB_PAM4_112 0x3eaUL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_200GB_PAM4_112 0x7d2UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_400GB_PAM4_112 0xfa2UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_800GB_PAM4_112 0x1f42UL
#define PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_LAST PORT_PHY_QCFG_RESP_FORCE_LINK_SPEEDS2_800GB_PAM4_112
__le16 auto_link_speeds2;
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_1GB 0x1UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_10GB 0x2UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_25GB 0x4UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_40GB 0x8UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_50GB 0x10UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_100GB 0x20UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_50GB_PAM4_56 0x40UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_100GB_PAM4_56 0x80UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_200GB_PAM4_56 0x100UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_400GB_PAM4_56 0x200UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_100GB_PAM4_112 0x400UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_200GB_PAM4_112 0x800UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_400GB_PAM4_112 0x1000UL
#define PORT_PHY_QCFG_RESP_AUTO_LINK_SPEEDS2_800GB_PAM4_112 0x2000UL
u8 active_lanes;
u8 unused_2[7];
u8 valid;
};
@@ -4054,7 +3888,7 @@ struct hwrm_port_phy_qcaps_input {
u8 unused_0[6];
};
/* hwrm_port_phy_qcaps_output (size:320b/40B) */
/* hwrm_port_phy_qcaps_output (size:192b/24B) */
struct hwrm_port_phy_qcaps_output {
__le16 error_code;
__le16 req_type;
@@ -4120,53 +3954,6 @@ struct hwrm_port_phy_qcaps_output {
#define PORT_PHY_QCAPS_RESP_TX_LPI_TIMER_HIGH_SFT 0
#define PORT_PHY_QCAPS_RESP_VALID_MASK 0xff000000UL
#define PORT_PHY_QCAPS_RESP_VALID_SFT 24
__le16 supported_pam4_speeds_auto_mode;
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_50G 0x1UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_100G 0x2UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_AUTO_MODE_200G 0x4UL
__le16 supported_pam4_speeds_force_mode;
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_50G 0x1UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_100G 0x2UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_PAM4_SPEEDS_FORCE_MODE_200G 0x4UL
__le16 flags2;
#define PORT_PHY_QCAPS_RESP_FLAGS2_PAUSE_UNSUPPORTED 0x1UL
#define PORT_PHY_QCAPS_RESP_FLAGS2_PFC_UNSUPPORTED 0x2UL
#define PORT_PHY_QCAPS_RESP_FLAGS2_BANK_ADDR_SUPPORTED 0x4UL
#define PORT_PHY_QCAPS_RESP_FLAGS2_SPEEDS2_SUPPORTED 0x8UL
u8 internal_port_cnt;
u8 unused_0;
__le16 supported_speeds2_force_mode;
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_1GB 0x1UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_10GB 0x2UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_25GB 0x4UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_40GB 0x8UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_50GB 0x10UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_100GB 0x20UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_50GB_PAM4_56 0x40UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_100GB_PAM4_56 0x80UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_200GB_PAM4_56 0x100UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_400GB_PAM4_56 0x200UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_100GB_PAM4_112 0x400UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_200GB_PAM4_112 0x800UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_400GB_PAM4_112 0x1000UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_FORCE_MODE_800GB_PAM4_112 0x2000UL
__le16 supported_speeds2_auto_mode;
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_1GB 0x1UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_10GB 0x2UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_25GB 0x4UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_40GB 0x8UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_50GB 0x10UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_100GB 0x20UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_50GB_PAM4_56 0x40UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_100GB_PAM4_56 0x80UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_200GB_PAM4_56 0x100UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_400GB_PAM4_56 0x200UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_100GB_PAM4_112 0x400UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_200GB_PAM4_112 0x800UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_400GB_PAM4_112 0x1000UL
#define PORT_PHY_QCAPS_RESP_SUPPORTED_SPEEDS2_AUTO_MODE_800GB_PAM4_112 0x2000UL
u8 unused_1[3];
u8 valid;
};
/* hwrm_port_phy_i2c_write_input (size:832b/104B) */
+1 -1
View File
@@ -689,9 +689,9 @@ static struct nic_operations davicom_operations = {
};
static struct pci_device_id davicom_nics[] = {
PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9100, "davicom9100", "Davicom 9100", 0),
PCI_ROM(0x1282, 0x9102, "davicom9102", "Davicom 9102", 0),
PCI_ROM(0x1282, 0x9009, "davicom9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9132, "davicom9132", "Davicom 9132", 0), /* Needs probably some fixing */
};
+1 -1
View File
@@ -1208,9 +1208,9 @@ static struct nic_operations dmfe_operations = {
};
static struct pci_device_id dmfe_nics[] = {
PCI_ROM(0x1282, 0x9009, "dmfe9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9100, "dmfe9100", "Davicom 9100", 0),
PCI_ROM(0x1282, 0x9102, "dmfe9102", "Davicom 9102", 0),
PCI_ROM(0x1282, 0x9009, "dmfe9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9132, "dmfe9132", "Davicom 9132", 0), /* Needs probably some fixing */
};
+5 -5
View File
@@ -1126,12 +1126,8 @@ PCI_ROM(0x8086, 0x103b, "82562etb", "Intel PRO100 VE 82562ETB", 0),
PCI_ROM(0x8086, 0x103c, "eepro100-103c", "Intel PRO/100 VM Network Connection", 0),
PCI_ROM(0x8086, 0x103d, "eepro100-103d", "Intel PRO/100 VE Network Connection", 0),
PCI_ROM(0x8086, 0x103e, "eepro100-103e", "Intel PRO/100 VM Network Connection", 0),
PCI_ROM(0x8086, 0x1050, "82562ez", "Intel 82562EZ Network Connection", 0),
PCI_ROM(0x8086, 0x1051, "prove", "Intel PRO/100 VE Network Connection", 0),
PCI_ROM(0x8086, 0x1059, "82551qm", "Intel PRO/100 M Mobile Connection", 0),
PCI_ROM(0x8086, 0x1065, "82562-3", "Intel 82562 based Fast Ethernet Connection", 0),
PCI_ROM(0x8086, 0x1092, "82562-3", "Intel Pro/100 VE Network", 0),
PCI_ROM(0x8086, 0x10fe, "82552", "Intel 82552 10/100 Network Connection", 0),
PCI_ROM(0x8086, 0x1209, "82559er", "Intel EtherExpressPro100 82559ER", 0),
PCI_ROM(0x8086, 0x1227, "82865", "Intel 82865 EtherExpress PRO/100A", 0),
PCI_ROM(0x8086, 0x1228, "82556", "Intel 82556 EtherExpress PRO/100 Smart", 0),
@@ -1139,9 +1135,13 @@ PCI_ROM(0x8086, 0x1229, "eepro100", "Intel EtherExpressPro100", 0),
PCI_ROM(0x8086, 0x2449, "82562em", "Intel EtherExpressPro100 82562EM", 0),
PCI_ROM(0x8086, 0x2459, "82562-1", "Intel 82562 based Fast Ethernet Connection", 0),
PCI_ROM(0x8086, 0x245d, "82562-2", "Intel 82562 based Fast Ethernet Connection", 0),
PCI_ROM(0x8086, 0x27dc, "eepro100-27dc", "Intel 82801G (ICH7) Chipset Ethernet Controller", 0),
PCI_ROM(0x8086, 0x1050, "82562ez", "Intel 82562EZ Network Connection", 0),
PCI_ROM(0x8086, 0x1065, "82562-3", "Intel 82562 based Fast Ethernet Connection", 0),
PCI_ROM(0x8086, 0x5200, "eepro100-5200", "Intel EtherExpress PRO/100 Intelligent Server", 0),
PCI_ROM(0x8086, 0x5201, "eepro100-5201", "Intel EtherExpress PRO/100 Intelligent Server", 0),
PCI_ROM(0x8086, 0x1092, "82562-3", "Intel Pro/100 VE Network", 0),
PCI_ROM(0x8086, 0x27dc, "eepro100-27dc", "Intel 82801G (ICH7) Chipset Ethernet Controller", 0),
PCI_ROM(0x8086, 0x10fe, "82552", "Intel 82552 10/100 Network Connection", 0),
};
/* Cards with device ids 0x1030 to 0x103F, 0x2449, 0x2459 or 0x245D might need
-56
View File
@@ -1,56 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* MNP driver
*
*/
#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/mnpnet.h>
#include "snpnet.h"
/**
* Check to see if driver supports a device
*
* @v device EFI device handle
* @ret rc Return status code
*/
static int mnp_supported ( EFI_HANDLE device ) {
EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
return snpnet_supported ( device, binding );
}
/** EFI MNP driver */
struct efi_driver mnp_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
.name = "MNP",
.supported = mnp_supported,
.start = mnpnet_start,
.stop = mnpnet_stop,
};
-563
View File
@@ -1,563 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* MNP NIC driver
*
*/
#include <string.h>
#include <errno.h>
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/cachedhcp.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_service.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/mnpnet.h>
#include <ipxe/efi/Protocol/ManagedNetwork.h>
/** An MNP transmit or receive token */
struct mnp_token {
/** MNP completion token */
EFI_MANAGED_NETWORK_COMPLETION_TOKEN token;
/** Token is owned by MNP */
int busy;
};
/** An MNP NIC */
struct mnp_nic {
/** EFI device */
struct efi_device *efidev;
/** Managed network protocol */
EFI_MANAGED_NETWORK_PROTOCOL *mnp;
/** Generic device */
struct device dev;
/** Transmit token */
struct mnp_token tx;
/** Transmit descriptor */
EFI_MANAGED_NETWORK_TRANSMIT_DATA txdata;
/** Transmit I/O buffer */
struct io_buffer *txbuf;
/** Receive token */
struct mnp_token rx;
};
/**
* Transmit or receive token event
*
* @v event Event
* @v context Event context
*/
static VOID EFIAPI mnpnet_event ( EFI_EVENT event __unused, VOID *context ) {
struct mnp_token *token = context;
/* Sanity check */
assert ( token->busy );
/* Mark token as no longer owned by MNP */
token->busy = 0;
}
/**
* Transmit packet
*
* @v netdev Network device
* @v iobuf I/O buffer
* @ret rc Return status code
*/
static int mnpnet_transmit ( struct net_device *netdev,
struct io_buffer *iobuf ) {
struct mnp_nic *mnp = netdev->priv;
struct ll_protocol *ll_protocol = netdev->ll_protocol;
EFI_STATUS efirc;
int rc;
/* Do nothing if shutdown is in progress */
if ( efi_shutdown_in_progress )
return -ECANCELED;
/* Defer the packet if there is already a transmission in progress */
if ( mnp->txbuf ) {
netdev_tx_defer ( netdev, iobuf );
return 0;
}
/* Construct transmit token */
mnp->txdata.DataLength =
( iob_len ( iobuf ) - ll_protocol->ll_header_len );
mnp->txdata.HeaderLength = ll_protocol->ll_header_len;
mnp->txdata.FragmentCount = 1;
mnp->txdata.FragmentTable[0].FragmentLength = iob_len ( iobuf );
mnp->txdata.FragmentTable[0].FragmentBuffer = iobuf->data;
mnp->tx.token.Packet.TxData = &mnp->txdata;
/* Record as in use */
mnp->tx.busy = 1;
/* Transmit packet */
if ( ( efirc = mnp->mnp->Transmit ( mnp->mnp, &mnp->tx.token ) ) != 0 ){
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not transmit: %s\n",
netdev->name, strerror ( rc ) );
mnp->tx.busy = 0;
return rc;
}
/* Record I/O buffer */
mnp->txbuf = iobuf;
return 0;
}
/**
* Refill receive token
*
* @v netdev Network device
*/
static void mnpnet_refill_rx ( struct net_device *netdev ) {
struct mnp_nic *mnp = netdev->priv;
EFI_STATUS efirc;
int rc;
/* Do nothing if receive token is still in use */
if ( mnp->rx.busy )
return;
/* Mark as in use */
mnp->rx.busy = 1;
/* Queue receive token */
if ( ( efirc = mnp->mnp->Receive ( mnp->mnp, &mnp->rx.token ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not receive: %s\n",
netdev->name, strerror ( rc ) );
/* Wait for next refill */
mnp->rx.busy = 0;
return;
}
}
/**
* Poll for completed packets
*
* @v netdev Network device
*/
static void mnpnet_poll_tx ( struct net_device *netdev ) {
struct mnp_nic *mnp = netdev->priv;
struct io_buffer *iobuf;
EFI_STATUS efirc;
int rc;
/* Do nothing if transmit token is still in use */
if ( mnp->tx.busy )
return;
/* Do nothing unless we have a completion */
if ( ! mnp->txbuf )
return;
/* Get completion status */
efirc = mnp->tx.token.Status;
rc = ( efirc ? -EEFI ( efirc ) : 0 );
/* Complete transmission */
iobuf = mnp->txbuf;
mnp->txbuf = NULL;
netdev_tx_complete_err ( netdev, iobuf, rc );
}
/**
* Poll for received packets
*
* @v netdev Network device
*/
static void mnpnet_poll_rx ( struct net_device *netdev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
struct mnp_nic *mnp = netdev->priv;
EFI_MANAGED_NETWORK_RECEIVE_DATA *rxdata;
struct io_buffer *iobuf;
size_t len;
EFI_STATUS efirc;
int rc;
/* Do nothing unless we have a completion */
if ( mnp->rx.busy )
return;
rxdata = mnp->rx.token.Packet.RxData;
/* Get completion status */
if ( ( efirc = mnp->rx.token.Status ) != 0 ) {
rc = -EEFI ( efirc );
netdev_rx_err ( netdev, NULL, rc );
goto recycle;
}
/* Allocate and fill I/O buffer */
len = rxdata->PacketLength;
iobuf = alloc_iob ( len );
if ( ! iobuf ) {
netdev_rx_err ( netdev, NULL, -ENOMEM );
goto recycle;
}
memcpy ( iob_put ( iobuf, len ), rxdata->MediaHeader, len );
/* Hand off to network stack */
netdev_rx ( netdev, iobuf );
recycle:
/* Recycle token */
bs->SignalEvent ( rxdata->RecycleEvent );
}
/**
* Poll for completed packets
*
* @v netdev Network device
*/
static void mnpnet_poll ( struct net_device *netdev ) {
struct mnp_nic *mnp = netdev->priv;
/* Do nothing if shutdown is in progress */
if ( efi_shutdown_in_progress )
return;
/* Poll interface */
mnp->mnp->Poll ( mnp->mnp );
/* Process any transmit completions */
mnpnet_poll_tx ( netdev );
/* Process any receive completions */
mnpnet_poll_rx ( netdev );
/* Refill receive token */
mnpnet_refill_rx ( netdev );
}
/**
* Open network device
*
* @v netdev Network device
* @ret rc Return status code
*/
static int mnpnet_open ( struct net_device *netdev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
static EFI_MANAGED_NETWORK_CONFIG_DATA config = {
.EnableUnicastReceive = TRUE,
.EnableMulticastReceive = TRUE,
.EnableBroadcastReceive = TRUE,
.EnablePromiscuousReceive = TRUE,
.FlushQueuesOnReset = TRUE,
.DisableBackgroundPolling = TRUE,
};
struct mnp_nic *mnp = netdev->priv;
EFI_STATUS efirc;
int rc;
/* Create transmit event */
if ( ( efirc = bs->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
mnpnet_event, &mnp->tx,
&mnp->tx.token.Event ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not create TX event: %s\n",
netdev->name, strerror ( rc ) );
goto err_tx_event;
}
/* Create receive event */
if ( ( efirc = bs->CreateEvent ( EVT_NOTIFY_SIGNAL, TPL_NOTIFY,
mnpnet_event, &mnp->rx,
&mnp->rx.token.Event ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not create RX event: %s\n",
netdev->name, strerror ( rc ) );
goto err_rx_event;
}
/* Configure MNP */
if ( ( efirc = mnp->mnp->Configure ( mnp->mnp, &config ) ) != 0 ) {
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not configure: %s\n",
netdev->name, strerror ( rc ) );
goto err_configure;
}
/* Refill receive token */
mnpnet_refill_rx ( netdev );
return 0;
mnp->mnp->Configure ( mnp->mnp, NULL );
err_configure:
bs->CloseEvent ( mnp->rx.token.Event );
err_rx_event:
bs->CloseEvent ( mnp->tx.token.Event );
err_tx_event:
return rc;
}
/**
* Close network device
*
* @v netdev Network device
*/
static void mnpnet_close ( struct net_device *netdev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
struct mnp_nic *mnp = netdev->priv;
/* Reset MNP (unless whole system shutdown is in progress) */
if ( ! efi_shutdown_in_progress )
mnp->mnp->Configure ( mnp->mnp, NULL );
/* Close events */
bs->CloseEvent ( mnp->rx.token.Event );
bs->CloseEvent ( mnp->tx.token.Event );
/* Reset tokens */
mnp->tx.busy = 0;
mnp->rx.busy = 0;
/* Discard any incomplete I/O buffer */
if ( mnp->txbuf ) {
netdev_tx_complete_err ( netdev, mnp->txbuf, -ECANCELED );
mnp->txbuf = NULL;
}
}
/** MNP network device operations */
static struct net_device_operations mnpnet_operations = {
.open = mnpnet_open,
.close = mnpnet_close,
.transmit = mnpnet_transmit,
.poll = mnpnet_poll,
};
/**
* Attach driver to device
*
* @v efidev EFI device
* @ret rc Return status code
*/
int mnpnet_start ( struct efi_device *efidev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE device = efidev->device;
EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
EFI_SIMPLE_NETWORK_MODE mode;
union {
EFI_MANAGED_NETWORK_PROTOCOL *mnp;
void *interface;
} u;
struct net_device *netdev;
struct mnp_nic *mnp;
EFI_STATUS efirc;
int rc;
/* Allocate and initalise structure */
netdev = alloc_etherdev ( sizeof ( *mnp ) );
if ( ! netdev ) {
rc = -ENOMEM;
goto err_alloc;
}
netdev_init ( netdev, &mnpnet_operations );
mnp = netdev->priv;
mnp->efidev = efidev;
efidev_set_drvdata ( efidev, netdev );
/* Populate underlying device information */
efi_device_info ( device, "MNP", &mnp->dev );
mnp->dev.driver_name = "MNP";
mnp->dev.parent = &efidev->dev;
list_add ( &mnp->dev.siblings, &efidev->dev.children );
INIT_LIST_HEAD ( &mnp->dev.children );
netdev->dev = &mnp->dev;
/* Create MNP child */
if ( ( rc = efi_service_add ( device, binding,
&efidev->child ) ) != 0 ) {
DBGC ( mnp, "MNP %s could not create child: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
goto err_service;
}
/* Open MNP protocol */
if ( ( efirc = bs->OpenProtocol ( efidev->child,
&efi_managed_network_protocol_guid,
&u.interface, efi_image_handle,
efidev->child,
( EFI_OPEN_PROTOCOL_BY_DRIVER |
EFI_OPEN_PROTOCOL_EXCLUSIVE )))!=0){
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not open MNP protocol: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
goto err_open;
}
mnp->mnp = u.mnp;
/* Get configuration */
efirc = mnp->mnp->GetModeData ( mnp->mnp, NULL, &mode );
if ( ( efirc != 0 ) && ( efirc != EFI_NOT_STARTED ) ) {
rc = -EEFI ( efirc );
DBGC ( mnp, "MNP %s could not get mode data: %s\n",
efi_handle_name ( device ), strerror ( rc ) );
goto err_mode;
}
/* Populate network device parameters */
if ( mode.HwAddressSize != netdev->ll_protocol->hw_addr_len ) {
DBGC ( device, "MNP %s has invalid hardware address length "
"%d\n", efi_handle_name ( device ), mode.HwAddressSize );
rc = -ENOTSUP;
goto err_hw_addr_len;
}
memcpy ( netdev->hw_addr, &mode.PermanentAddress,
netdev->ll_protocol->hw_addr_len );
if ( mode.HwAddressSize != netdev->ll_protocol->ll_addr_len ) {
DBGC ( device, "MNP %s has invalid link-layer address length "
"%d\n", efi_handle_name ( device ), mode.HwAddressSize );
rc = -ENOTSUP;
goto err_ll_addr_len;
}
memcpy ( netdev->ll_addr, &mode.CurrentAddress,
netdev->ll_protocol->ll_addr_len );
/* Register network device */
if ( ( rc = register_netdev ( netdev ) ) != 0 )
goto err_register;
DBGC ( mnp, "MNP %s registered as %s\n",
efi_handle_name ( device ), netdev->name );
/* Mark as link up: we don't handle link state */
netdev_link_up ( netdev );
return 0;
unregister_netdev ( netdev );
err_register:
err_ll_addr_len:
err_hw_addr_len:
err_mode:
bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid,
efi_image_handle, efidev->child );
err_open:
efi_service_del ( device, binding, efidev->child );
err_service:
list_del ( &mnp->dev.siblings );
netdev_nullify ( netdev );
netdev_put ( netdev );
err_alloc:
return rc;
}
/**
* Detach driver from device
*
* @v efidev EFI device
*/
void mnpnet_stop ( struct efi_device *efidev ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_GUID *binding = &efi_managed_network_service_binding_protocol_guid;
struct net_device *netdev = efidev_get_drvdata ( efidev );
struct mnp_nic *mnp = netdev->priv;
/* Unregister network device */
unregister_netdev ( netdev );
/* Close MNP protocol */
bs->CloseProtocol ( efidev->child, &efi_managed_network_protocol_guid,
efi_image_handle, efidev->child );
/* Remove MNP child (unless whole system shutdown is in progress) */
if ( ! efi_shutdown_in_progress )
efi_service_del ( efidev->device, binding, efidev->child );
/* Free network device */
list_del ( &mnp->dev.siblings );
netdev_nullify ( netdev );
netdev_put ( netdev );
}
/**
* Create temporary MNP network device
*
* @v handle MNP service binding handle
* @v netdev Network device to fill in
* @ret rc Return status code
*/
int mnptemp_create ( EFI_HANDLE handle, struct net_device **netdev ) {
struct efi_device *efidev;
int rc;
/* Create temporary EFI device */
efidev = efidev_alloc ( handle );
if ( ! efidev ) {
DBGC ( handle, "MNP %s could not create temporary device\n",
efi_handle_name ( handle ) );
rc = -ENOMEM;
goto err_alloc;
}
/* Start temporary network device */
if ( ( rc = mnpnet_start ( efidev ) ) != 0 ) {
DBGC ( handle, "MNP %s could not start MNP: %s\n",
efi_handle_name ( handle ), strerror ( rc ) );
goto err_start;
}
/* Fill in network device */
*netdev = efidev_get_drvdata ( efidev );
return 0;
mnpnet_stop ( efidev );
err_start:
efidev_free ( efidev );
err_alloc:
return rc;
}
/**
* Destroy temporary MNP network device
*
* @v netdev Network device
*/
void mnptemp_destroy ( struct net_device *netdev ) {
struct mnp_nic *mnp = netdev->priv;
struct efi_device *efidev = mnp->efidev;
/* Recycle any cached DHCP packet */
cachedhcp_recycle ( netdev );
/* Stop temporary network device */
mnpnet_stop ( efidev );
/* Free temporary EFI device */
efidev_free ( efidev );
}
-7
View File
@@ -30,7 +30,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <errno.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/umalloc.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
@@ -999,12 +998,6 @@ static int nii_transmit ( struct net_device *netdev,
return 0;
}
/* Pad to minimum Ethernet length, to work around underlying
* drivers that do not correctly handle frame padding
* themselves.
*/
iob_pad ( iobuf, ETH_ZLEN );
/* Construct parameter block */
memset ( &cpb, 0, sizeof ( cpb ) );
cpb.FrameAddr = ( ( intptr_t ) iobuf->data );
+52 -2
View File
@@ -23,8 +23,11 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <errno.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_snp.h>
#include <ipxe/efi/efi_utils.h>
#include "snpnet.h"
#include "nii.h"
@@ -34,6 +37,53 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
*/
/**
* Check to see if driver supports a device
*
* @v device EFI device handle
* @v protocol Protocol GUID
* @ret rc Return status code
*/
static int snp_nii_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE parent;
EFI_STATUS efirc;
int rc;
/* Check that this is not a device we are providing ourselves */
if ( find_snpdev ( device ) != NULL ) {
DBGCP ( device, "HANDLE %s is provided by this binary\n",
efi_handle_name ( device ) );
return -ENOTTY;
}
/* Test for presence of protocol */
if ( ( efirc = bs->OpenProtocol ( device, protocol,
NULL, efi_image_handle, device,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
DBGCP ( device, "HANDLE %s is not a %s device\n",
efi_handle_name ( device ),
efi_guid_ntoa ( protocol ) );
return -EEFI ( efirc );
}
/* Check that there are no instances of this protocol further
* up this device path.
*/
if ( ( rc = efi_locate_device ( device, protocol,
&parent, 1 ) ) == 0 ) {
DBGC2 ( device, "HANDLE %s has %s-supporting parent ",
efi_handle_name ( device ),
efi_guid_ntoa ( protocol ) );
DBGC2 ( device, "%s\n", efi_handle_name ( parent ) );
return -ENOTTY;
}
DBGC ( device, "HANDLE %s is a %s device\n",
efi_handle_name ( device ), efi_guid_ntoa ( protocol ) );
return 0;
}
/**
* Check to see if driver supports a device
*
@@ -42,7 +92,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*/
static int snp_supported ( EFI_HANDLE device ) {
return snpnet_supported ( device, &efi_simple_network_protocol_guid );
return snp_nii_supported ( device, &efi_simple_network_protocol_guid );
}
/**
@@ -53,7 +103,7 @@ static int snp_supported ( EFI_HANDLE device ) {
*/
static int nii_supported ( EFI_HANDLE device ) {
return snpnet_supported ( device, &efi_nii31_protocol_guid );
return snp_nii_supported ( device, &efi_nii31_protocol_guid );
}
/** EFI SNP driver */
+1 -69
View File
@@ -26,14 +26,12 @@ FILE_LICENCE ( GPL2_OR_LATER );
#include <ipxe/iobuf.h>
#include <ipxe/netdevice.h>
#include <ipxe/ethernet.h>
#include <ipxe/if_ether.h>
#include <ipxe/vsprintf.h>
#include <ipxe/timer.h>
#include <ipxe/efi/efi.h>
#include <ipxe/efi/Protocol/SimpleNetwork.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/efi_snp.h>
#include "snpnet.h"
/** @file
@@ -73,19 +71,6 @@ struct snp_nic {
/** Delay between each initialisation retry */
#define SNP_INITIALIZE_RETRY_DELAY_MS 10
/** Additional padding for receive buffers
*
* Some SNP implementations seem to require additional space in the
* allocated receive buffers, otherwise full-length packets will be
* silently dropped.
*
* The EDK2 MnpDxe driver happens to allocate an additional 8 bytes of
* padding (4 for a VLAN tag, 4 for the Ethernet frame checksum).
* Match this behaviour since drivers are very likely to have been
* tested against MnpDxe.
*/
#define SNP_RX_PAD 8
/**
* Format SNP MAC address (for debugging)
*
@@ -189,12 +174,6 @@ static int snpnet_transmit ( struct net_device *netdev,
return 0;
}
/* Pad to minimum Ethernet length, to work around underlying
* drivers that do not correctly handle frame padding
* themselves.
*/
iob_pad ( iobuf, ETH_ZLEN );
/* Transmit packet */
if ( ( efirc = snp->snp->Transmit ( snp->snp, 0, iob_len ( iobuf ),
iobuf->data, NULL, NULL,
@@ -267,7 +246,7 @@ static void snpnet_poll_rx ( struct net_device *netdev ) {
/* Allocate buffer, if required */
if ( ! snp->rxbuf ) {
snp->rxbuf = alloc_iob ( snp->mtu + SNP_RX_PAD );
snp->rxbuf = alloc_iob ( snp->mtu );
if ( ! snp->rxbuf ) {
/* Leave for next poll */
break;
@@ -485,53 +464,6 @@ static struct net_device_operations snpnet_operations = {
.poll = snpnet_poll,
};
/**
* Check to see if driver supports a device
*
* @v device EFI device handle
* @v protocol Protocol GUID
* @ret rc Return status code
*/
int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE parent;
EFI_STATUS efirc;
int rc;
/* Check that this is not a device we are providing ourselves */
if ( find_snpdev ( device ) != NULL ) {
DBGCP ( device, "HANDLE %s is provided by this binary\n",
efi_handle_name ( device ) );
return -ENOTTY;
}
/* Test for presence of protocol */
if ( ( efirc = bs->OpenProtocol ( device, protocol,
NULL, efi_image_handle, device,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL))!=0){
DBGCP ( device, "HANDLE %s is not a %s device\n",
efi_handle_name ( device ),
efi_guid_ntoa ( protocol ) );
return -EEFI ( efirc );
}
/* Check that there are no instances of this protocol further
* up this device path.
*/
if ( ( rc = efi_locate_device ( device, protocol,
&parent, 1 ) ) == 0 ) {
DBGC2 ( device, "HANDLE %s has %s-supporting parent ",
efi_handle_name ( device ),
efi_guid_ntoa ( protocol ) );
DBGC2 ( device, "%s\n", efi_handle_name ( parent ) );
return -ENOTTY;
}
DBGC ( device, "HANDLE %s is a %s device\n",
efi_handle_name ( device ), efi_guid_ntoa ( protocol ) );
return 0;
}
/**
* Attach driver to device
*
-1
View File
@@ -11,7 +11,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
struct efi_device;
extern int snpnet_supported ( EFI_HANDLE device, EFI_GUID *protocol );
extern int snpnet_start ( struct efi_device *efidev );
extern void snpnet_stop ( struct efi_device *efidev );
+41 -95
View File
@@ -29,7 +29,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/efi/efi.h>
#include <ipxe/efi/efi_driver.h>
#include <ipxe/efi/efi_utils.h>
#include <ipxe/efi/mnpnet.h>
#include <ipxe/efi/Protocol/SimpleNetwork.h>
#include <ipxe/efi/Protocol/NetworkInterfaceIdentifier.h>
#include "snpnet.h"
@@ -46,23 +45,14 @@ struct chained_protocol {
/** Protocol GUID */
EFI_GUID *protocol;
/**
* Target device handle
*
* This is the uppermost handle on which the same protocol
* instance is installed as we find on the loaded image's
* device handle.
* Protocol instance installed on the loaded image's device handle
*
* We match against the protocol instance (rather than simply
* matching against the device handle itself) because some
* systems load us via a child of the underlying device, with
* a duplicate protocol installed on the child handle.
*
* We record the handle rather than the protocol instance
* pointer since the calls to DisconnectController() and
* ConnectController() may end up uninstalling and
* reinstalling the protocol instance.
*/
EFI_HANDLE device;
void *interface;
};
/** Chainloaded SNP protocol */
@@ -75,74 +65,50 @@ static struct chained_protocol chained_nii = {
.protocol = &efi_nii31_protocol_guid,
};
/** Chainloaded MNP protocol */
static struct chained_protocol chained_mnp = {
.protocol = &efi_managed_network_service_binding_protocol_guid,
};
/**
* Locate chainloaded protocol
* Locate chainloaded protocol instance
*
* @v chained Chainloaded protocol
* @ret rc Return status code
*/
static void chained_locate ( struct chained_protocol *chained ) {
static int chained_locate ( struct chained_protocol *chained ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
EFI_HANDLE device = efi_loaded_image->DeviceHandle;
EFI_HANDLE handle;
void *match = NULL;
void *interface;
unsigned int skip;
EFI_HANDLE parent;
EFI_STATUS efirc;
int rc;
/* Identify target device handle */
for ( skip = 0 ; ; skip++ ) {
/* Locate handle supporting this protocol */
if ( ( rc = efi_locate_device ( device, chained->protocol,
&parent, 0 ) ) != 0 ) {
DBGC ( device, "CHAINED %s does not support %s: %s\n",
efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ), strerror ( rc ) );
goto err_locate_device;
}
DBGC ( device, "CHAINED %s found %s on ", efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ) );
DBGC ( device, "%s\n", efi_handle_name ( parent ) );
/* Locate handle supporting this protocol */
if ( ( rc = efi_locate_device ( device, chained->protocol,
&handle, skip ) ) != 0 ) {
if ( skip == 0 ) {
DBGC ( device, "CHAINED %s does not support "
"%s: %s\n", efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ),
strerror ( rc ) );
}
break;
}
/* Get protocol instance */
if ( ( efirc = bs->OpenProtocol (
handle, chained->protocol, &interface,
efi_image_handle, handle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL )) != 0){
rc = -EEFI ( efirc );
DBGC ( device, "CHAINED %s could not open %s on ",
efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ) );
DBGC ( device, "%s: %s\n",
efi_handle_name ( handle ), strerror ( rc ) );
break;
}
bs->CloseProtocol ( handle, chained->protocol,
efi_image_handle, handle );
/* Stop if we reach a non-matching protocol instance */
if ( match && ( match != interface ) ) {
DBGC ( device, "CHAINED %s found non-matching %s on ",
efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ) );
DBGC ( device, "%s\n", efi_handle_name ( handle ) );
break;
}
/* Record this handle */
chained->device = handle;
match = interface;
DBGC ( device, "CHAINED %s found %s on ",
/* Get protocol instance */
if ( ( efirc = bs->OpenProtocol ( parent, chained->protocol,
&chained->interface, efi_image_handle,
device,
EFI_OPEN_PROTOCOL_GET_PROTOCOL ))!=0){
rc = -EEFI ( efirc );
DBGC ( device, "CHAINED %s could not open %s on ",
efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ) );
DBGC ( device, "%s\n", efi_handle_name ( chained->device ) );
DBGC ( device, "%s: %s\n",
efi_handle_name ( parent ), strerror ( rc ) );
goto err_open_protocol;
}
err_locate_device:
bs->CloseProtocol ( parent, chained->protocol, efi_image_handle,
device );
err_open_protocol:
return rc;
}
/**
@@ -155,8 +121,8 @@ static void chained_locate ( struct chained_protocol *chained ) {
static int chained_supported ( EFI_HANDLE device,
struct chained_protocol *chained ) {
EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
void *interface;
EFI_STATUS efirc;
void *interface;
int rc;
/* Get protocol */
@@ -170,19 +136,19 @@ static int chained_supported ( EFI_HANDLE device,
goto err_open_protocol;
}
/* Ignore non-matching handles */
if ( device != chained->device ) {
DBGC2 ( device, "CHAINED %s is not the chainloaded %s\n",
efi_handle_name ( device ),
efi_guid_ntoa ( chained->protocol ) );
/* Test for a match against the chainloading device */
if ( interface != chained->interface ) {
DBGC ( device, "CHAINED %s %p is not the chainloaded %s\n",
efi_handle_name ( device ), interface,
efi_guid_ntoa ( chained->protocol ) );
rc = -ENOTTY;
goto err_no_match;
}
/* Success */
rc = 0;
DBGC ( device, "CHAINED %s is the chainloaded %s\n",
efi_handle_name ( device ),
DBGC ( device, "CHAINED %s %p is the chainloaded %s\n",
efi_handle_name ( device ), interface,
efi_guid_ntoa ( chained->protocol ) );
err_no_match:
@@ -214,17 +180,6 @@ static int niionly_supported ( EFI_HANDLE device ) {
return chained_supported ( device, &chained_nii );
}
/**
* Check to see if driver supports a device
*
* @v device EFI device handle
* @ret rc Return status code
*/
static int mnponly_supported ( EFI_HANDLE device ) {
return chained_supported ( device, &chained_mnp );
}
/** EFI SNP chainloading-device-only driver */
struct efi_driver snponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
.name = "SNPONLY",
@@ -241,14 +196,6 @@ struct efi_driver niionly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
.stop = nii_stop,
};
/** EFI MNP chainloading-device-only driver */
struct efi_driver mnponly_driver __efi_driver ( EFI_DRIVER_NORMAL ) = {
.name = "MNPONLY",
.supported = mnponly_supported,
.start = mnpnet_start,
.stop = mnpnet_stop,
};
/**
* Initialise EFI chainloaded-device-only driver
*
@@ -257,7 +204,6 @@ static void chained_init ( void ) {
chained_locate ( &chained_snp );
chained_locate ( &chained_nii );
chained_locate ( &chained_mnp );
}
/** EFI chainloaded-device-only initialisation function */
+11 -11
View File
@@ -1928,17 +1928,17 @@ forcedeth_remove ( struct pci_device *pdev )
}
static struct pci_device_id forcedeth_nics[] = {
PCI_ROM(0x10DE, 0x0037, "MCP04", "MCP04 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0038, "MCP04", "MCP04 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0056, "CK804", "CK804 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0057, "CK804", "CK804 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x01C3, "nForce", "nForce Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER),
PCI_ROM(0x10DE, 0x0066, "nForce2", "nForce2 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER),
PCI_ROM(0x10DE, 0x00D6, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER),
PCI_ROM(0x10DE, 0x0086, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC| DEV_HAS_CHECKSUM),
PCI_ROM(0x10DE, 0x008C, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC| DEV_HAS_CHECKSUM),
PCI_ROM(0x10DE, 0x00D6, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER),
PCI_ROM(0x10DE, 0x00DF, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC| DEV_HAS_CHECKSUM),
PCI_ROM(0x10DE, 0x00E6, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC| DEV_HAS_CHECKSUM),
PCI_ROM(0x10DE, 0x01C3, "nForce", "nForce Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER),
PCI_ROM(0x10DE, 0x00DF, "nForce3", "nForce3 Ethernet Controller", DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC| DEV_HAS_CHECKSUM),
PCI_ROM(0x10DE, 0x0056, "CK804", "CK804 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0057, "CK804", "CK804 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0037, "MCP04", "MCP04 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0038, "MCP04", "MCP04 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_STATISTICS_V1|DEV_NEED_TX_LIMIT),
PCI_ROM(0x10DE, 0x0268, "MCP51", "MCP51 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_STATISTICS_V1|DEV_NEED_LOW_POWER_FIX),
PCI_ROM(0x10DE, 0x0269, "MCP51", "MCP51 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_STATISTICS_V1|DEV_NEED_LOW_POWER_FIX),
PCI_ROM(0x10DE, 0x0372, "MCP55", "MCP55 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_VLAN|DEV_HAS_MSI|DEV_HAS_MSI_X| DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V1| DEV_HAS_STATISTICS_V2|DEV_HAS_TEST_EXTENDED| DEV_HAS_MGMT_UNIT|DEV_NEED_TX_LIMIT|DEV_NEED_MSI_FIX),
@@ -1955,14 +1955,14 @@ static struct pci_device_id forcedeth_nics[] = {
PCI_ROM(0x10DE, 0x054D, "MCP67", "MCP67 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x054E, "MCP67", "MCP67 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x054F, "MCP67", "MCP67 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0760, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0761, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0762, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0763, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x07DC, "MCP73", "MCP73 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x07DD, "MCP73", "MCP73 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x07DE, "MCP73", "MCP73 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x07DF, "MCP73", "MCP73 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_HIGH_DMA|DEV_HAS_POWER_CNTRL| DEV_HAS_MSI|DEV_HAS_PAUSEFRAME_TX_V1|DEV_HAS_STATISTICS_V2| DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_HAS_GEAR_MODE|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0760, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0761, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0762, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0763, "MCP77", "MCP77 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_CHECKSUM|DEV_HAS_HIGH_DMA| DEV_HAS_MSI|DEV_HAS_POWER_CNTRL|DEV_HAS_PAUSEFRAME_TX_V2| DEV_HAS_STATISTICS_V3|DEV_HAS_TEST_EXTENDED|DEV_HAS_MGMT_UNIT| DEV_HAS_CORRECT_MACADDR|DEV_HAS_COLLISION_FIX| DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE|DEV_NEED_PHY_INIT_FIX| DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0AB0, "MCP79", "MCP79 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL| DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3| DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE| DEV_NEED_PHY_INIT_FIX|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0AB1, "MCP79", "MCP79 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL| DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3| DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE| DEV_NEED_PHY_INIT_FIX|DEV_NEED_MSI_FIX),
PCI_ROM(0x10DE, 0x0AB2, "MCP79", "MCP79 Ethernet Controller", DEV_NEED_LINKTIMER|DEV_HAS_LARGEDESC|DEV_HAS_CHECKSUM| DEV_HAS_HIGH_DMA|DEV_HAS_MSI|DEV_HAS_POWER_CNTRL| DEV_HAS_PAUSEFRAME_TX_V3|DEV_HAS_STATISTICS_V3| DEV_HAS_TEST_EXTENDED|DEV_HAS_CORRECT_MACADDR| DEV_HAS_COLLISION_FIX|DEV_NEED_TX_LIMIT2|DEV_HAS_GEAR_MODE| DEV_NEED_PHY_INIT_FIX|DEV_NEED_MSI_FIX),
+6 -6
View File
@@ -1006,17 +1006,17 @@ ISA_ROM("ne","NE1000/2000 and clones");
#ifdef INCLUDE_NS8390
static struct pci_device_id nepci_nics[] = {
/* A few NE2000 PCI clones, list not exhaustive */
PCI_ROM(0x10ec, 0x8029, "rtl8029", "Realtek 8029", 0),
PCI_ROM(0x1186, 0x0300, "dlink-528", "D-Link DE-528", 0),
PCI_ROM(0x1050, 0x0940, "winbond940", "Winbond NE2000-PCI", 0), /* Winbond 86C940 / 89C940 */
PCI_ROM(0x1050, 0x5a5a, "winbond940f", "Winbond W89c940F", 0), /* Winbond 89C940F */
PCI_ROM(0x10bd, 0x0e34, "surecom-ne34", "Surecom NE34", 0),
PCI_ROM(0x10ec, 0x8029, "rtl8029", "Realtek 8029", 0),
PCI_ROM(0x1106, 0x0926, "via86c926", "Via 86c926", 0),
PCI_ROM(0x1186, 0x0300, "dlink-528", "D-Link DE-528", 0),
PCI_ROM(0x11f6, 0x1401, "compexrl2000", "Compex ReadyLink 2000", 0),
PCI_ROM(0x8e2e, 0x3000, "ktiet32p2", "KTI ET32P2", 0),
PCI_ROM(0x4a14, 0x5000, "nv5000sc", "NetVin NV5000SC", 0),
PCI_ROM(0x12c3, 0x0058, "holtek80232", "Holtek HT80232", 0),
PCI_ROM(0x12c3, 0x5598, "holtek80229", "Holtek HT80229", 0),
PCI_ROM(0x4a14, 0x5000, "nv5000sc", "NetVin NV5000SC", 0),
PCI_ROM(0x8e2e, 0x3000, "ktiet32p2", "KTI ET32P2", 0),
PCI_ROM(0x10bd, 0x0e34, "surecom-ne34", "Surecom NE34", 0),
PCI_ROM(0x1106, 0x0926, "via86c926", "Via 86c926", 0),
};
PCI_DRIVER ( nepci_driver, nepci_nics, PCI_NO_CLASS );
+1 -1
View File
@@ -1149,8 +1149,8 @@ pcnet32_remove ( struct pci_device *pdev )
static struct pci_device_id pcnet32_nics[] = {
PCI_ROM(0x1022, 0x2000, "pcnet32", "AMD PCnet/PCI", 0),
PCI_ROM(0x1022, 0x2001, "amdhomepna", "AMD PCnet/HomePNA", 0),
PCI_ROM(0x1022, 0x2625, "pcnetfastiii", "AMD PCNet FAST III", 0),
PCI_ROM(0x1022, 0x2001, "amdhomepna", "AMD PCnet/HomePNA", 0),
};
struct pci_driver pcnet32_driver __pci_driver = {
+2 -2
View File
@@ -104,10 +104,9 @@ static void prism2_plx_disable ( struct nic *nic ) {
}
static struct pci_device_id prism2_plx_nics[] = {
PCI_ROM(0x1385, 0x4100, "ma301", "Netgear MA301", 0),
PCI_ROM(0x10b7, 0x7770, "3c-airconnect", "3Com AirConnect", 0),
PCI_ROM(0x111a, 0x1023, "ss1023", "Siemens SpeedStream SS1023", 0),
PCI_ROM(0x126c, 0x8030, "emobility", "Nortel emobility", 0),
PCI_ROM(0x1385, 0x4100, "ma301", "Netgear MA301", 0),
PCI_ROM(0x15e8, 0x0130, "correga", "Correga", 0),
PCI_ROM(0x1638, 0x1100, "smc2602w", "SMC EZConnect SMC2602W", 0), /* or Eumitcom PCI WL11000, Addtron AWA-100 */
PCI_ROM(0x16ab, 0x1100, "gl24110p", "Global Sun Tech GL24110P", 0),
@@ -115,6 +114,7 @@ PCI_ROM(0x16ab, 0x1101, "16ab-1101", "Unknown", 0),
PCI_ROM(0x16ab, 0x1102, "wdt11", "Linksys WDT11", 0),
PCI_ROM(0x16ec, 0x3685, "usr2415", "USR 2415", 0),
PCI_ROM(0xec80, 0xec00, "f5d6000", "Belkin F5D6000", 0),
PCI_ROM(0x126c, 0x8030, "emobility", "Nortel emobility", 0),
};
PCI_DRIVER ( prism2_plx_driver, prism2_plx_nics, PCI_NO_CLASS );
+2 -2
View File
@@ -775,10 +775,10 @@ static void rhine_remove ( struct pci_device *pci ) {
/** Rhine PCI device IDs */
static struct pci_device_id rhine_nics[] = {
PCI_ROM ( 0x1106, 0x3043, "dlink-530tx-old", "VIA VT3043", 0 ),
PCI_ROM ( 0x1106, 0x3053, "vt6105m", "VIA VT6105M", 0 ),
PCI_ROM ( 0x1106, 0x3065, "dlink-530tx", "VIA VT6102", 0 ),
PCI_ROM ( 0x1106, 0x3106, "vt6105", "VIA VT6105", 0 ),
PCI_ROM ( 0x1106, 0x3043, "dlink-530tx-old", "VIA VT3043", 0 ),
PCI_ROM ( 0x1106, 0x3053, "vt6105m", "VIA VT6105M", 0 ),
PCI_ROM ( 0x1106, 0x6100, "via-rhine-old", "VIA 86C100A", 0 )
};
+1 -1
View File
@@ -7,9 +7,9 @@ FILE_LICENCE(GPL2_OR_LATER);
static struct pci_device_id rtl8180_nics[] = {
PCI_ROM(0x10ec, 0x8180, "rtl8180", "Realtek 8180", 0),
PCI_ROM(0x1186, 0x3300, "dwl510", "D-Link DWL-510", 0),
PCI_ROM(0x1799, 0x6001, "f5d6001", "Belkin F5D6001", 0),
PCI_ROM(0x1799, 0x6020, "f5d6020", "Belkin F5D6020", 0),
PCI_ROM(0x1186, 0x3300, "dwl510", "D-Link DWL-510", 0),
};
struct pci_driver rtl8180_driver __pci_driver = {
+1 -1
View File
@@ -81,8 +81,8 @@ FILE_LICENCE ( GPL2_ONLY );
static struct pci_device_id sky2_id_table[] = {
PCI_ROM(0x1148, 0x9000, "sk9sxx", "Syskonnect SK-9Sxx", 0),
PCI_ROM(0x1148, 0x9e00, "sk9exx", "Syskonnect SK-9Exx", 0),
PCI_ROM(0x1186, 0x4001, "dge550sx", "D-Link DGE-550SX", 0),
PCI_ROM(0x1186, 0x4b00, "dge560t", "D-Link DGE-560T", 0),
PCI_ROM(0x1186, 0x4001, "dge550sx", "D-Link DGE-550SX", 0),
PCI_ROM(0x1186, 0x4b02, "dge560sx", "D-Link DGE-560SX", 0),
PCI_ROM(0x1186, 0x4b03, "dge550t", "D-Link DGE-550T", 0),
PCI_ROM(0x11ab, 0x4340, "m88e8021", "Marvell 88E8021", 0),
+1 -1
View File
@@ -880,9 +880,9 @@ static void set_rx_mode(struct nic *nic __unused)
}
static struct pci_device_id sundance_nics[] = {
PCI_ROM(0x13f0, 0x0201, "sundance", "ST201 Sundance 'Alta' based Adaptor", 0),
PCI_ROM(0x1186, 0x1002, "dfe530txs", "D-Link DFE530TXS (Sundance ST201 Alta)", 0),
PCI_ROM(0x13f0, 0x0200, "ip100a", "IC+ IP100A", 0),
PCI_ROM(0x13f0, 0x0201, "sundance", "ST201 Sundance 'Alta' based Adaptor", 0),
};
PCI_DRIVER ( sundance_driver, sundance_nics, PCI_NO_CLASS );
+59 -59
View File
@@ -856,88 +856,88 @@ static void tg3_remove_one(struct pci_device *pci)
}
static struct pci_device_id tg3_nics[] = {
PCI_ROM(0x106b, 0x1645, "106b-1645", "106b-1645", 0),
PCI_ROM(0x1148, 0x4400, "1148-4400", "1148-4400", 0),
PCI_ROM(0x1148, 0x4500, "1148-4500", "1148-4500", 0),
PCI_ROM(0x14e4, 0x1600, "14e4-1600", "14e4-1600", 0),
PCI_ROM(0x14e4, 0x1601, "14e4-1601", "14e4-1601", 0),
PCI_ROM(0x14e4, 0x1644, "14e4-1644", "14e4-1644", 0),
PCI_ROM(0x14e4, 0x1645, "14e4-1645", "14e4-1645", 0),
PCI_ROM(0x14e4, 0x1646, "14e4-1646", "14e4-1646", 0),
PCI_ROM(0x14e4, 0x1647, "14e4-1647", "14e4-1647", 0),
PCI_ROM(0x14e4, 0x1648, "14e4-1648", "14e4-1648", 0),
PCI_ROM(0x14e4, 0x1649, "14e4-1649", "14e4-1649", 0),
PCI_ROM(0x14e4, 0x164d, "14e4-164d", "14e4-164d", 0),
PCI_ROM(0x14e4, 0x1653, "14e4-1653", "14e4-1653", 0),
PCI_ROM(0x14e4, 0x1654, "14e4-1654", "14e4-1654", 0),
PCI_ROM(0x14e4, 0x1655, "14e4-1655", "14e4-1655", 0),
PCI_ROM(0x14e4, 0x1656, "14e4-1656", "14e4-1656", 0),
PCI_ROM(0x14e4, 0x1657, "14e4-1657", "14e4-1657", 0),
PCI_ROM(0x14e4, 0x1659, "14e4-1659", "14e4-1659", 0),
PCI_ROM(0x14e4, 0x165a, "14e4-165a", "14e4-165a", 0),
PCI_ROM(0x14e4, 0x165b, "14e4-165b", "14e4-165b", 0),
PCI_ROM(0x14e4, 0x165d, "14e4-165d", "14e4-165d", 0),
PCI_ROM(0x14e4, 0x165e, "14e4-165e", "14e4-165e", 0),
PCI_ROM(0x14e4, 0x165f, "14e4-165f", "14e4-165f", 0),
PCI_ROM(0x14e4, 0x1668, "14e4-1668", "14e4-1668", 0),
PCI_ROM(0x14e4, 0x1669, "14e4-1669", "14e4-1669", 0),
PCI_ROM(0x14e4, 0x166a, "14e4-166a", "14e4-166a", 0),
PCI_ROM(0x14e4, 0x166b, "14e4-166b", "14e4-166b", 0),
PCI_ROM(0x14e4, 0x166e, "14e4-166e", "14e4-166e", 0),
PCI_ROM(0x14e4, 0x1672, "14e4-1672", "14e4-1672", 0),
PCI_ROM(0x14e4, 0x1673, "14e4-1673", "14e4-1673", 0),
PCI_ROM(0x14e4, 0x1674, "14e4-1674", "14e4-1674", 0),
PCI_ROM(0x14e4, 0x1677, "14e4-1677", "14e4-1677", 0),
PCI_ROM(0x14e4, 0x1678, "14e4-1678", "14e4-1678", 0),
PCI_ROM(0x14e4, 0x1679, "14e4-1679", "14e4-1679", 0),
PCI_ROM(0x14e4, 0x167a, "14e4-167a", "14e4-167a", 0),
PCI_ROM(0x14e4, 0x167b, "14e4-167b", "14e4-167b", 0),
PCI_ROM(0x14e4, 0x167d, "14e4-167d", "14e4-167d", 0),
PCI_ROM(0x14e4, 0x167e, "14e4-167e", "14e4-167e", 0),
PCI_ROM(0x14e4, 0x167f, "14e4-167f", "14e4-167f", 0),
PCI_ROM(0x14e4, 0x1680, "14e4-1680", "14e4-1680", 0),
PCI_ROM(0x14e4, 0x1681, "14e4-1681", "14e4-1681", 0),
PCI_ROM(0x14e4, 0x1682, "14e4-1682", "14e4-1682", 0),
PCI_ROM(0x14e4, 0x1684, "14e4-1684", "14e4-1684", 0),
PCI_ROM(0x14e4, 0x1686, "14e4-1686", "14e4-1686", 0),
PCI_ROM(0x14e4, 0x1688, "14e4-1688", "14e4-1688", 0),
PCI_ROM(0x14e4, 0x1689, "14e4-1689", "14e4-1689", 0),
PCI_ROM(0x14e4, 0x1690, "14e4-1690", "14e4-1690", 0),
PCI_ROM(0x14e4, 0x1691, "14e4-1691", "14e4-1691", 0),
PCI_ROM(0x14e4, 0x1692, "14e4-1692", "14e4-1692", 0),
PCI_ROM(0x14e4, 0x1693, "14e4-1693", "14e4-1693", 0),
PCI_ROM(0x14e4, 0x1694, "14e4-1694", "14e4-1694", 0),
PCI_ROM(0x14e4, 0x1696, "14e4-1696", "14e4-1696", 0),
PCI_ROM(0x14e4, 0x1698, "14e4-1698", "14e4-1698", 0),
PCI_ROM(0x14e4, 0x1699, "14e4-1699", "14e4-1699", 0),
PCI_ROM(0x14e4, 0x169a, "14e4-169a", "14e4-169a", 0),
PCI_ROM(0x14e4, 0x169b, "14e4-169b", "14e4-169b", 0),
PCI_ROM(0x14e4, 0x169c, "14e4-169c", "14e4-169c", 0),
PCI_ROM(0x14e4, 0x169d, "14e4-169d", "14e4-169d", 0),
PCI_ROM(0x14e4, 0x16a0, "14e4-16a0", "14e4-16a0", 0),
PCI_ROM(0x14e4, 0x16a6, "14e4-16a6", "14e4-16a6", 0),
PCI_ROM(0x14e4, 0x16a7, "14e4-16a7", "14e4-16a7", 0),
PCI_ROM(0x14e4, 0x16a8, "14e4-16a8", "14e4-16a8", 0),
PCI_ROM(0x14e4, 0x16b0, "14e4-16b0", "14e4-16b0", 0),
PCI_ROM(0x14e4, 0x16b1, "14e4-16b1", "14e4-16b1", 0),
PCI_ROM(0x14e4, 0x16b2, "14e4-16b2", "14e4-16b2", 0),
PCI_ROM(0x14e4, 0x16b4, "14e4-16b4", "14e4-16b4", 0),
PCI_ROM(0x14e4, 0x16b5, "14e4-16b5", "14e4-16b5", 0),
PCI_ROM(0x14e4, 0x16b6, "14e4-16b6", "14e4-16b6", 0),
PCI_ROM(0x14e4, 0x16c6, "14e4-16c6", "14e4-16c6", 0),
PCI_ROM(0x14e4, 0x16c7, "14e4-16c7", "14e4-16c7", 0),
PCI_ROM(0x14e4, 0x16dd, "14e4-16dd", "14e4-16dd", 0),
PCI_ROM(0x14e4, 0x1696, "14e4-1696", "14e4-1696", 0),
PCI_ROM(0x14e4, 0x169c, "14e4-169c", "14e4-169c", 0),
PCI_ROM(0x14e4, 0x169d, "14e4-169d", "14e4-169d", 0),
PCI_ROM(0x14e4, 0x170d, "14e4-170d", "14e4-170d", 0),
PCI_ROM(0x14e4, 0x170e, "14e4-170e", "14e4-170e", 0),
PCI_ROM(0x14e4, 0x1649, "14e4-1649", "14e4-1649", 0),
PCI_ROM(0x14e4, 0x166e, "14e4-166e", "14e4-166e", 0),
PCI_ROM(0x14e4, 0x1659, "14e4-1659", "14e4-1659", 0),
PCI_ROM(0x14e4, 0x165a, "14e4-165a", "14e4-165a", 0),
PCI_ROM(0x14e4, 0x1677, "14e4-1677", "14e4-1677", 0),
PCI_ROM(0x14e4, 0x167d, "14e4-167d", "14e4-167d", 0),
PCI_ROM(0x14e4, 0x167e, "14e4-167e", "14e4-167e", 0),
PCI_ROM(0x14e4, 0x1600, "14e4-1600", "14e4-1600", 0),
PCI_ROM(0x14e4, 0x1601, "14e4-1601", "14e4-1601", 0),
PCI_ROM(0x14e4, 0x16f7, "14e4-16f7", "14e4-16f7", 0),
PCI_ROM(0x14e4, 0x16fd, "14e4-16fd", "14e4-16fd", 0),
PCI_ROM(0x14e4, 0x16fe, "14e4-16fe", "14e4-16fe", 0),
PCI_ROM(0x14e4, 0x170d, "14e4-170d", "14e4-170d", 0),
PCI_ROM(0x14e4, 0x170e, "14e4-170e", "14e4-170e", 0),
PCI_ROM(0x14e4, 0x167a, "14e4-167a", "14e4-167a", 0),
PCI_ROM(0x14e4, 0x1672, "14e4-1672", "14e4-1672", 0),
PCI_ROM(0x14e4, 0x167b, "14e4-167b", "14e4-167b", 0),
PCI_ROM(0x14e4, 0x1673, "14e4-1673", "14e4-1673", 0),
PCI_ROM(0x14e4, 0x1674, "14e4-1674", "14e4-1674", 0),
PCI_ROM(0x14e4, 0x169a, "14e4-169a", "14e4-169a", 0),
PCI_ROM(0x14e4, 0x169b, "14e4-169b", "14e4-169b", 0),
PCI_ROM(0x14e4, 0x1693, "14e4-1693", "14e4-1693", 0),
PCI_ROM(0x14e4, 0x167f, "14e4-167f", "14e4-167f", 0),
PCI_ROM(0x14e4, 0x1668, "14e4-1668", "14e4-1668", 0),
PCI_ROM(0x14e4, 0x1669, "14e4-1669", "14e4-1669", 0),
PCI_ROM(0x14e4, 0x1678, "14e4-1678", "14e4-1678", 0),
PCI_ROM(0x14e4, 0x1679, "14e4-1679", "14e4-1679", 0),
PCI_ROM(0x14e4, 0x166a, "14e4-166a", "14e4-166a", 0),
PCI_ROM(0x14e4, 0x166b, "14e4-166b", "14e4-166b", 0),
PCI_ROM(0x14e4, 0x16dd, "14e4-16dd", "14e4-16dd", 0),
PCI_ROM(0x14e4, 0x1712, "14e4-1712", "14e4-1712", 0),
PCI_ROM(0x14e4, 0x1713, "14e4-1713", "14e4-1713", 0),
PCI_ROM(0x14e4, 0x1698, "14e4-1698", "14e4-1698", 0),
PCI_ROM(0x14e4, 0x1684, "14e4-1684", "14e4-1684", 0),
PCI_ROM(0x14e4, 0x165b, "14e4-165b", "14e4-165b", 0),
PCI_ROM(0x14e4, 0x1681, "14e4-1681", "14e4-1681", 0),
PCI_ROM(0x14e4, 0x1682, "14e4-1682", "14e4-1682", 0),
PCI_ROM(0x14e4, 0x1680, "14e4-1680", "14e4-1680", 0),
PCI_ROM(0x14e4, 0x1688, "14e4-1688", "14e4-1688", 0),
PCI_ROM(0x14e4, 0x1689, "14e4-1689", "14e4-1689", 0),
PCI_ROM(0x14e4, 0x1699, "14e4-1699", "14e4-1699", 0),
PCI_ROM(0x14e4, 0x16a0, "14e4-16a0", "14e4-16a0", 0),
PCI_ROM(0x14e4, 0x1692, "14e4-1692", "14e4-1692", 0),
PCI_ROM(0x14e4, 0x1690, "14e4-1690", "14e4-1690", 0),
PCI_ROM(0x14e4, 0x1694, "14e4-1694", "14e4-1694", 0),
PCI_ROM(0x14e4, 0x1691, "14e4-1691", "14e4-1691", 0),
PCI_ROM(0x14e4, 0x1655, "14e4-1655", "14e4-1655", 0),
PCI_ROM(0x14e4, 0x1656, "14e4-1656", "14e4-1656", 0),
PCI_ROM(0x14e4, 0x16b1, "14e4-16b1", "14e4-16b1", 0),
PCI_ROM(0x14e4, 0x16b5, "14e4-16b5", "14e4-16b5", 0),
PCI_ROM(0x14e4, 0x16b0, "14e4-16b0", "14e4-16b0", 0),
PCI_ROM(0x14e4, 0x16b4, "14e4-16b4", "14e4-16b4", 0),
PCI_ROM(0x14e4, 0x16b2, "14e4-16b2", "14e4-16b2", 0),
PCI_ROM(0x14e4, 0x16b6, "14e4-16b6", "14e4-16b6", 0),
PCI_ROM(0x14e4, 0x1657, "14e4-1657", "14e4-1657", 0),
PCI_ROM(0x14e4, 0x165f, "14e4-165f", "14e4-165f", 0),
PCI_ROM(0x14e4, 0x1686, "14e4-1686", "14e4-1686", 0),
PCI_ROM(0x1148, 0x4400, "1148-4400", "1148-4400", 0),
PCI_ROM(0x1148, 0x4500, "1148-4500", "1148-4500", 0),
PCI_ROM(0x173b, 0x03e8, "173b-03e8", "173b-03e8", 0),
PCI_ROM(0x173b, 0x03e9, "173b-03e9", "173b-03e9", 0),
PCI_ROM(0x173b, 0x03ea, "173b-03ea", "173b-03ea", 0),
PCI_ROM(0x173b, 0x03eb, "173b-03eb", "173b-03eb", 0),
PCI_ROM(0x173b, 0x03ea, "173b-03ea", "173b-03ea", 0),
PCI_ROM(0x106b, 0x1645, "106b-1645", "106b-1645", 0),
};
struct pci_driver tg3_pci_driver __pci_driver = {
+7 -7
View File
@@ -1697,19 +1697,19 @@ void TLan_PhyMonitor(struct net_device *dev)
#endif /* MONITOR */
static struct pci_device_id tlan_nics[] = {
PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP", 0),
PCI_ROM(0x0e11, 0xae34, "netel10", "Compaq Netelligent 10 T PCI UTP", 0),
PCI_ROM(0x0e11, 0xae32, "netel100","Compaq Netelligent 10/100 TX PCI UTP", 0),
PCI_ROM(0x0e11, 0xae35, "netflex3i", "Compaq Integrated NetFlex-3/P", 0),
PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP", 0),
PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP", 0),
PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP", 0),
PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax", 0),
PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP", 0),
PCI_ROM(0x0e11, 0xf130, "thunder", "Compaq NetFlex-3/P", 0),
PCI_ROM(0x0e11, 0xf150, "netflex3b", "Compaq NetFlex-3/P", 0),
PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325", 0),
PCI_ROM(0x0e11, 0xae43, "netel100pi", "Compaq Netelligent Integrated 10/100 TX UTP", 0),
PCI_ROM(0x0e11, 0xae40, "netel100d", "Compaq Netelligent Dual 10/100 TX PCI UTP", 0),
PCI_ROM(0x0e11, 0xb011, "netel100i", "Compaq Netelligent 10/100 TX Embedded UTP", 0),
PCI_ROM(0x108d, 0x0013, "oc2183", "Olicom OC-2183/2185", 0),
PCI_ROM(0x108d, 0x0012, "oc2325", "Olicom OC-2325", 0),
PCI_ROM(0x108d, 0x0014, "oc2326", "Olicom OC-2326", 0),
PCI_ROM(0x0e11, 0xb030, "netelligent_10_100_ws_5100", "Compaq Netelligent 10/100 TX UTP", 0),
PCI_ROM(0x0e11, 0xb012, "netelligent_10_t2", "Compaq Netelligent 10 T/2 PCI UTP/Coax", 0),
};
PCI_DRIVER ( tlan_driver, tlan_nics, PCI_NO_CLASS );
+14 -14
View File
@@ -1921,30 +1921,31 @@ PCI_ROM(0x1011, 0x0002, "dc21040", "Digital Tulip", 0),
PCI_ROM(0x1011, 0x0009, "ds21140", "Digital Tulip Fast", 0),
PCI_ROM(0x1011, 0x0014, "dc21041", "Digital Tulip+", 0),
PCI_ROM(0x1011, 0x0019, "ds21142", "Digital Tulip 21142", 0),
PCI_ROM(0x104a, 0x0981, "tulip-0981", "Tulip 0x104a 0x0981", 0),
PCI_ROM(0x104a, 0x2774, "SGThomson-STE10100A", "Tulip 0x104a 0x2774", 0), /*Modified by Ramesh Chander*/
PCI_ROM(0x10b7, 0x9300, "3csoho100b-tx","3ComSOHO100B-TX", 0),
PCI_ROM(0x10b9, 0x5261, "ali1563", "ALi 1563 integrated ethernet", 0),
PCI_ROM(0x10d9, 0x0512, "mx98713", "Macronix MX987x3", 0),
PCI_ROM(0x10d9, 0x0531, "mx98715", "Macronix MX987x5", 0),
PCI_ROM(0x1113, 0x1216, "an983", "ADMTek AN983 Comet", 0),
PCI_ROM(0x1113, 0x1217, "mxic-98715", "Macronix MX987x5", 0),
PCI_ROM(0x1113, 0x9511, "tulip-9511", "Tulip 0x1113 0x9511", 0),
PCI_ROM(0x115d, 0x0003, "xircomtulip", "Xircom Tulip", 0),
PCI_ROM(0x1186, 0x1561, "tulip-1561", "Tulip 0x1186 0x1561", 0),
PCI_ROM(0x11ad, 0x0002, "82c168", "Netgear FA310TX", 0),
PCI_ROM(0x11ad, 0xc115, "lc82c115", "LinkSys LNE100TX", 0),
PCI_ROM(0x11f6, 0x9881, "rl100tx", "Compex RL100-TX", 0),
PCI_ROM(0x1259, 0xa120, "tulip-a120", "Tulip 0x1259 0xa120", 0),
PCI_ROM(0x125b, 0x1400, "ax88140", "ASIX AX88140", 0),
PCI_ROM(0x1282, 0x9009, "dm9009", "Davicom 9009", 0),
PCI_ROM(0x11ad, 0x0002, "82c168", "Netgear FA310TX", 0),
PCI_ROM(0x1282, 0x9100, "dm9100", "Davicom 9100", 0),
PCI_ROM(0x1282, 0x9102, "dm9102", "Davicom 9102", 0),
PCI_ROM(0x1282, 0x9009, "dm9009", "Davicom 9009", 0),
PCI_ROM(0x1282, 0x9132, "dm9132", "Davicom 9132", 0),
PCI_ROM(0x1317, 0x0981, "an981", "ADMtek AN981 Comet", 0), /* ADMTek Centaur-P (stmicro) */
PCI_ROM(0x1317, 0x0985, "centaur-p", "ADMtek Centaur-P", 0),
PCI_ROM(0x1317, 0x1985, "centaur-c", "ADMTek Centaur-C", 0),
PCI_ROM(0x1317, 0x0981, "an981", "ADMtek AN981 Comet", 0), /* ADMTek Centaur-P (stmicro) */
PCI_ROM(0x1113, 0x1216, "an983", "ADMTek AN983 Comet", 0),
PCI_ROM(0x1317, 0x9511, "an983b", "ADMTek Comet 983b", 0),
PCI_ROM(0x1317, 0x1985, "centaur-c", "ADMTek Centaur-C", 0),
PCI_ROM(0x8086, 0x0039, "intel21145", "Intel Tulip", 0),
PCI_ROM(0x125b, 0x1400, "ax88140", "ASIX AX88140", 0),
PCI_ROM(0x11f6, 0x9881, "rl100tx", "Compex RL100-TX", 0),
PCI_ROM(0x115d, 0x0003, "xircomtulip", "Xircom Tulip", 0),
PCI_ROM(0x104a, 0x0981, "tulip-0981", "Tulip 0x104a 0x0981", 0),
PCI_ROM(0x104a, 0x2774, "SGThomson-STE10100A", "Tulip 0x104a 0x2774", 0), /*Modified by Ramesh Chander*/
PCI_ROM(0x1113, 0x9511, "tulip-9511", "Tulip 0x1113 0x9511", 0),
PCI_ROM(0x1186, 0x1561, "tulip-1561", "Tulip 0x1186 0x1561", 0),
PCI_ROM(0x1259, 0xa120, "tulip-a120", "Tulip 0x1259 0xa120", 0),
PCI_ROM(0x13d1, 0xab02, "tulip-ab02", "Tulip 0x13d1 0xab02", 0),
PCI_ROM(0x13d1, 0xab03, "tulip-ab03", "Tulip 0x13d1 0xab03", 0),
PCI_ROM(0x13d1, 0xab08, "tulip-ab08", "Tulip 0x13d1 0xab08", 0),
@@ -1952,7 +1953,6 @@ PCI_ROM(0x14f1, 0x1803, "lanfinity", "Conexant LANfinity", 0),
PCI_ROM(0x1626, 0x8410, "tulip-8410", "Tulip 0x1626 0x8410", 0),
PCI_ROM(0x1737, 0xab08, "tulip-1737-ab08","Tulip 0x1737 0xab08", 0),
PCI_ROM(0x1737, 0xab09, "tulip-ab09", "Tulip 0x1737 0xab09", 0),
PCI_ROM(0x8086, 0x0039, "intel21145", "Intel Tulip", 0),
};
PCI_DRIVER ( tulip_driver, tulip_nics, PCI_NO_CLASS );
@@ -25,7 +25,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Dynamic user interface commands
* Menu commands
*
*/
@@ -34,7 +34,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <ipxe/dynui.h>
#include <ipxe/menu.h>
#include <ipxe/command.h>
#include <ipxe/parseopt.h>
#include <ipxe/settings.h>
@@ -42,42 +42,42 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
FEATURE ( FEATURE_MISC, "Menu", DHCP_EB_FEATURE_MENU, 1 );
/** "dynui" options */
struct dynui_options {
/** "menu" options */
struct menu_options {
/** Name */
char *name;
/** Delete */
int delete;
};
/** "dynui" option list */
static struct option_descriptor dynui_opts[] = {
/** "menu" option list */
static struct option_descriptor menu_opts[] = {
OPTION_DESC ( "name", 'n', required_argument,
struct dynui_options, name, parse_string ),
struct menu_options, name, parse_string ),
OPTION_DESC ( "delete", 'd', no_argument,
struct dynui_options, delete, parse_flag ),
struct menu_options, delete, parse_flag ),
};
/** "dynui" command descriptor */
static struct command_descriptor dynui_cmd =
COMMAND_DESC ( struct dynui_options, dynui_opts, 0, MAX_ARGUMENTS,
/** "menu" command descriptor */
static struct command_descriptor menu_cmd =
COMMAND_DESC ( struct menu_options, menu_opts, 0, MAX_ARGUMENTS,
"[<title>]" );
/**
* The "dynui" command
* The "menu" command
*
* @v argc Argument count
* @v argv Argument list
* @ret rc Return status code
*/
static int dynui_exec ( int argc, char **argv ) {
struct dynui_options opts;
struct dynamic_ui *dynui;
static int menu_exec ( int argc, char **argv ) {
struct menu_options opts;
struct menu *menu;
char *title;
int rc;
/* Parse options */
if ( ( rc = parse_options ( argc, argv, &dynui_cmd, &opts ) ) != 0 )
if ( ( rc = parse_options ( argc, argv, &menu_cmd, &opts ) ) != 0 )
goto err_parse_options;
/* Parse title */
@@ -87,21 +87,21 @@ static int dynui_exec ( int argc, char **argv ) {
goto err_parse_title;
}
/* Create dynamic user interface */
dynui = create_dynui ( opts.name, title );
if ( ! dynui ) {
/* Create menu */
menu = create_menu ( opts.name, title );
if ( ! menu ) {
rc = -ENOMEM;
goto err_create_dynui;
goto err_create_menu;
}
/* Destroy dynamic user interface, if applicable */
/* Destroy menu, if applicable */
if ( opts.delete )
destroy_dynui ( dynui );
destroy_menu ( menu );
/* Success */
rc = 0;
err_create_dynui:
err_create_menu:
free ( title );
err_parse_title:
err_parse_options:
@@ -110,14 +110,12 @@ static int dynui_exec ( int argc, char **argv ) {
/** "item" options */
struct item_options {
/** Dynamic user interface name */
char *dynui;
/** Menu name */
char *menu;
/** Shortcut key */
unsigned int key;
/** Use as default */
int is_default;
/** Value is a secret */
int is_secret;
/** Use as a separator */
int is_gap;
};
@@ -125,15 +123,11 @@ struct item_options {
/** "item" option list */
static struct option_descriptor item_opts[] = {
OPTION_DESC ( "menu", 'm', required_argument,
struct item_options, dynui, parse_string ),
OPTION_DESC ( "form", 'f', required_argument,
struct item_options, dynui, parse_string ),
struct item_options, menu, parse_string ),
OPTION_DESC ( "key", 'k', required_argument,
struct item_options, key, parse_key ),
OPTION_DESC ( "default", 'd', no_argument,
struct item_options, is_default, parse_flag ),
OPTION_DESC ( "secret", 's', no_argument,
struct item_options, is_secret, parse_flag ),
OPTION_DESC ( "gap", 'g', no_argument,
struct item_options, is_gap, parse_flag ),
};
@@ -141,7 +135,7 @@ static struct option_descriptor item_opts[] = {
/** "item" command descriptor */
static struct command_descriptor item_cmd =
COMMAND_DESC ( struct item_options, item_opts, 0, MAX_ARGUMENTS,
"[<name> [<text>]]" );
"[<label> [<text>]]" );
/**
* The "item" command
@@ -152,10 +146,9 @@ static struct command_descriptor item_cmd =
*/
static int item_exec ( int argc, char **argv ) {
struct item_options opts;
struct dynamic_ui *dynui;
struct dynamic_item *item;
unsigned int flags = 0;
char *name = NULL;
struct menu *menu;
struct menu_item *item;
char *label = NULL;
char *text = NULL;
int rc;
@@ -163,9 +156,9 @@ static int item_exec ( int argc, char **argv ) {
if ( ( rc = parse_options ( argc, argv, &item_cmd, &opts ) ) != 0 )
goto err_parse_options;
/* Parse name, if present */
/* Parse label, if present */
if ( ! opts.is_gap )
name = argv[optind++]; /* May be NULL */
label = argv[optind++]; /* May be NULL */
/* Parse text, if present */
if ( optind < argc ) {
@@ -176,27 +169,23 @@ static int item_exec ( int argc, char **argv ) {
}
}
/* Identify dynamic user interface */
if ( ( rc = parse_dynui ( opts.dynui, &dynui ) ) != 0 )
goto err_parse_dynui;
/* Identify menu */
if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
goto err_parse_menu;
/* Add dynamic user interface item */
if ( opts.is_default )
flags |= DYNUI_DEFAULT;
if ( opts.is_secret )
flags |= DYNUI_SECRET;
item = add_dynui_item ( dynui, name, ( text ? text : "" ), flags,
opts.key );
/* Add menu item */
item = add_menu_item ( menu, label, ( text ? text : "" ),
opts.key, opts.is_default );
if ( ! item ) {
rc = -ENOMEM;
goto err_add_dynui_item;
goto err_add_menu_item;
}
/* Success */
rc = 0;
err_add_dynui_item:
err_parse_dynui:
err_add_menu_item:
err_parse_menu:
free ( text );
err_parse_text:
err_parse_options:
@@ -205,20 +194,20 @@ static int item_exec ( int argc, char **argv ) {
/** "choose" options */
struct choose_options {
/** Dynamic user interface name */
char *dynui;
/** Menu name */
char *menu;
/** Timeout */
unsigned long timeout;
/** Default selection */
char *select;
/** Keep dynamic user interface */
/** Keep menu */
int keep;
};
/** "choose" option list */
static struct option_descriptor choose_opts[] = {
OPTION_DESC ( "menu", 'm', required_argument,
struct choose_options, dynui, parse_string ),
struct choose_options, menu, parse_string ),
OPTION_DESC ( "default", 'd', required_argument,
struct choose_options, select, parse_string ),
OPTION_DESC ( "timeout", 't', required_argument,
@@ -241,8 +230,8 @@ static struct command_descriptor choose_cmd =
static int choose_exec ( int argc, char **argv ) {
struct choose_options opts;
struct named_setting setting;
struct dynamic_ui *dynui;
struct dynamic_item *item;
struct menu *menu;
struct menu_item *item;
int rc;
/* Parse options */
@@ -254,13 +243,12 @@ static int choose_exec ( int argc, char **argv ) {
&setting ) ) != 0 )
goto err_parse_setting;
/* Identify dynamic user interface */
if ( ( rc = parse_dynui ( opts.dynui, &dynui ) ) != 0 )
goto err_parse_dynui;
/* Identify menu */
if ( ( rc = parse_menu ( opts.menu, &menu ) ) != 0 )
goto err_parse_menu;
/* Show as menu */
if ( ( rc = show_menu ( dynui, opts.timeout, opts.select,
&item ) ) != 0 )
/* Show menu */
if ( ( rc = show_menu ( menu, opts.timeout, opts.select, &item ) ) != 0)
goto err_show_menu;
/* Apply default type if necessary */
@@ -269,7 +257,7 @@ static int choose_exec ( int argc, char **argv ) {
/* Store setting */
if ( ( rc = storef_setting ( setting.settings, &setting.setting,
item->name ) ) != 0 ) {
item->label ) ) != 0 ) {
printf ( "Could not store \"%s\": %s\n",
setting.setting.name, strerror ( rc ) );
goto err_store;
@@ -280,80 +268,20 @@ static int choose_exec ( int argc, char **argv ) {
err_store:
err_show_menu:
/* Destroy dynamic user interface, if applicable */
/* Destroy menu, if applicable */
if ( ! opts.keep )
destroy_dynui ( dynui );
err_parse_dynui:
destroy_menu ( menu );
err_parse_menu:
err_parse_setting:
err_parse_options:
return rc;
}
/** "present" options */
struct present_options {
/** Dynamic user interface name */
char *dynui;
/** Keep dynamic user interface */
int keep;
};
/** "present" option list */
static struct option_descriptor present_opts[] = {
OPTION_DESC ( "form", 'f', required_argument,
struct present_options, dynui, parse_string ),
OPTION_DESC ( "keep", 'k', no_argument,
struct present_options, keep, parse_flag ),
};
/** "present" command descriptor */
static struct command_descriptor present_cmd =
COMMAND_DESC ( struct present_options, present_opts, 0, 0, NULL );
/**
* The "present" command
*
* @v argc Argument count
* @v argv Argument list
* @ret rc Return status code
*/
static int present_exec ( int argc, char **argv ) {
struct present_options opts;
struct dynamic_ui *dynui;
int rc;
/* Parse options */
if ( ( rc = parse_options ( argc, argv, &present_cmd, &opts ) ) != 0 )
goto err_parse_options;
/* Identify dynamic user interface */
if ( ( rc = parse_dynui ( opts.dynui, &dynui ) ) != 0 )
goto err_parse_dynui;
/* Show as form */
if ( ( rc = show_form ( dynui ) ) != 0 )
goto err_show_form;
/* Success */
rc = 0;
err_show_form:
/* Destroy dynamic user interface, if applicable */
if ( ! opts.keep )
destroy_dynui ( dynui );
err_parse_dynui:
err_parse_options:
return rc;
}
/** Dynamic user interface commands */
struct command dynui_commands[] __command = {
/** Menu commands */
struct command menu_commands[] __command = {
{
.name = "menu",
.exec = dynui_exec,
},
{
.name = "form",
.exec = dynui_exec,
.exec = menu_exec,
},
{
.name = "item",
@@ -363,8 +291,4 @@ struct command dynui_commands[] __command = {
.name = "choose",
.exec = choose_exec,
},
{
.name = "present",
.exec = present_exec,
},
};
+5 -23
View File
@@ -47,20 +47,14 @@ struct sanboot_options {
int no_describe;
/** Keep SAN device */
int keep;
/** Boot filename */
/** Filename */
char *filename;
/** Required extra filename */
char *extra;
/** Volume label */
char *label;
/** UUID */
struct uuid_option uuid;
};
/** "sanboot" option list */
static union {
/* "sanboot" takes all options */
struct option_descriptor sanboot[7];
/* "sanboot" takes all four options */
struct option_descriptor sanboot[4];
/* "sanhook" takes only --drive and --no-describe */
struct option_descriptor sanhook[2];
/* "sanunhook" takes only --drive */
@@ -75,15 +69,10 @@ static union {
struct sanboot_options, keep, parse_flag ),
OPTION_DESC ( "filename", 'f', required_argument,
struct sanboot_options, filename, parse_string ),
OPTION_DESC ( "extra", 'e', required_argument,
struct sanboot_options, extra, parse_string ),
OPTION_DESC ( "label", 'l', required_argument,
struct sanboot_options, label, parse_string ),
OPTION_DESC ( "uuid", 'u', required_argument,
struct sanboot_options, uuid, parse_uuid ),
},
};
/** "sanhook" command descriptor */
static struct command_descriptor sanhook_cmd =
COMMAND_DESC ( struct sanboot_options, opts.sanhook, 1, MAX_ARGUMENTS,
@@ -111,7 +100,6 @@ static int sanboot_core_exec ( int argc, char **argv,
struct command_descriptor *cmd,
int default_flags, int no_root_path_flags ) {
struct sanboot_options opts;
struct san_boot_config config;
struct uri *uris[argc];
int count;
int flags;
@@ -136,12 +124,6 @@ static int sanboot_core_exec ( int argc, char **argv,
}
}
/* Construct configuration parameters */
config.filename = opts.filename;
config.extra = opts.extra;
config.label = opts.label;
config.uuid = opts.uuid.value;
/* Construct flags */
flags = default_flags;
if ( opts.no_describe )
@@ -152,7 +134,7 @@ static int sanboot_core_exec ( int argc, char **argv,
flags |= no_root_path_flags;
/* Boot from root path */
if ( ( rc = uriboot ( NULL, uris, count, opts.drive, &config,
if ( ( rc = uriboot ( NULL, uris, count, opts.drive, opts.filename,
flags ) ) != 0 )
goto err_uriboot;
+48 -109
View File
@@ -24,10 +24,8 @@
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <assert.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <ipxe/keys.h>
#include <ipxe/editstring.h>
@@ -37,17 +35,17 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
*/
static __attribute__ (( nonnull ( 1 ) )) int
insert_delete ( struct edit_string *string, size_t delete_len,
const char *insert_text );
static __nonnull int insert_character ( struct edit_string *string,
unsigned int character );
static __nonnull void delete_character ( struct edit_string *string );
static __nonnull void backspace ( struct edit_string *string );
static __nonnull void previous_word ( struct edit_string *string );
static __nonnull void kill_word ( struct edit_string *string );
static __nonnull void kill_sol ( struct edit_string *string );
static __nonnull void kill_eol ( struct edit_string *string );
static void insert_delete ( struct edit_string *string, size_t delete_len,
const char *insert_text )
__attribute__ (( nonnull (1) ));
static void insert_character ( struct edit_string *string,
unsigned int character ) __nonnull;
static void delete_character ( struct edit_string *string ) __nonnull;
static void backspace ( struct edit_string *string ) __nonnull;
static void previous_word ( struct edit_string *string ) __nonnull;
static void kill_word ( struct edit_string *string ) __nonnull;
static void kill_sol ( struct edit_string *string ) __nonnull;
static void kill_eol ( struct edit_string *string ) __nonnull;
/**
* Insert and/or delete text within an editable string
@@ -55,57 +53,35 @@ static __nonnull void kill_eol ( struct edit_string *string );
* @v string Editable string
* @v delete_len Length of text to delete from current cursor position
* @v insert_text Text to insert at current cursor position, or NULL
* @ret rc Return status code
*/
static int insert_delete ( struct edit_string *string, size_t delete_len,
const char *insert_text ) {
size_t old_len, max_delete_len, move_len, insert_len, new_len;
char *buf;
char *tmp;
/* Prepare edit history */
string->mod_start = string->cursor;
string->mod_end = string->cursor;
static void insert_delete ( struct edit_string *string, size_t delete_len,
const char *insert_text ) {
size_t old_len, max_delete_len, insert_len, max_insert_len, new_len;
/* Calculate lengths */
buf = *(string->buf);
old_len = ( buf ? strlen ( buf ) : 0 );
old_len = strlen ( string->buf );
assert ( string->cursor <= old_len );
max_delete_len = ( old_len - string->cursor );
if ( delete_len > max_delete_len )
delete_len = max_delete_len;
move_len = ( max_delete_len - delete_len );
insert_len = ( insert_text ? strlen ( insert_text ) : 0 );
max_insert_len = ( ( string->len - 1 ) - ( old_len - delete_len ) );
if ( insert_len > max_insert_len )
insert_len = max_insert_len;
new_len = ( old_len - delete_len + insert_len );
/* Delete existing text */
memmove ( ( buf + string->cursor ),
( buf + string->cursor + delete_len ), move_len );
/* Reallocate string, ignoring failures if shrinking */
tmp = realloc ( buf, ( new_len + 1 /* NUL */ ) );
if ( tmp ) {
buf = tmp;
*(string->buf) = buf;
} else if ( ( new_len > old_len ) || ( ! buf ) ) {
return -ENOMEM;
}
/* Create space for inserted text */
memmove ( ( buf + string->cursor + insert_len ),
( buf + string->cursor ), move_len );
/* Copy inserted text to cursor position */
memcpy ( ( buf + string->cursor ), insert_text, insert_len );
string->cursor += insert_len;
/* Terminate string */
buf[new_len] = '\0';
/* Update edit history */
/* Fill in edit history */
string->mod_start = string->cursor;
string->mod_end = ( ( new_len > old_len ) ? new_len : old_len );
return 0;
/* Move data following the cursor */
memmove ( ( string->buf + string->cursor + insert_len ),
( string->buf + string->cursor + delete_len ),
( max_delete_len + 1 - delete_len ) );
/* Copy inserted text to cursor position */
memcpy ( ( string->buf + string->cursor ), insert_text, insert_len );
string->cursor += insert_len;
}
/**
@@ -113,13 +89,11 @@ static int insert_delete ( struct edit_string *string, size_t delete_len,
*
* @v string Editable string
* @v character Character to insert
* @ret rc Return status code
*/
static int insert_character ( struct edit_string *string,
static void insert_character ( struct edit_string *string,
unsigned int character ) {
char insert_text[2] = { character, '\0' };
return insert_delete ( string, 0, insert_text );
insert_delete ( string, 0, insert_text );
}
/**
@@ -128,10 +102,7 @@ static int insert_character ( struct edit_string *string,
* @v string Editable string
*/
static void delete_character ( struct edit_string *string ) {
int rc;
rc = insert_delete ( string, 1, NULL );
assert ( ( rc == 0 ) || ( *(string->buf) == NULL ) );
insert_delete ( string, 1, NULL );
}
/**
@@ -140,7 +111,6 @@ static void delete_character ( struct edit_string *string ) {
* @v string Editable string
*/
static void backspace ( struct edit_string *string ) {
if ( string->cursor > 0 ) {
string->cursor--;
delete_character ( string );
@@ -153,16 +123,14 @@ static void backspace ( struct edit_string *string ) {
* @v string Editable string
*/
static void previous_word ( struct edit_string *string ) {
const char *buf = *(string->buf);
size_t cursor = string->cursor;
while ( cursor && isspace ( buf[ cursor - 1 ] ) ) {
cursor--;
while ( string->cursor &&
isspace ( string->buf[ string->cursor - 1 ] ) ) {
string->cursor--;
}
while ( cursor && ( ! isspace ( buf[ cursor - 1 ] ) ) ) {
cursor--;
while ( string->cursor &&
( ! isspace ( string->buf[ string->cursor - 1 ] ) ) ) {
string->cursor--;
}
string->cursor = cursor;
}
/**
@@ -172,11 +140,8 @@ static void previous_word ( struct edit_string *string ) {
*/
static void kill_word ( struct edit_string *string ) {
size_t old_cursor = string->cursor;
int rc;
previous_word ( string );
rc = insert_delete ( string, ( old_cursor - string->cursor ), NULL );
assert ( ( rc == 0 ) || ( *(string->buf) == NULL ) );
insert_delete ( string, ( old_cursor - string->cursor ), NULL );
}
/**
@@ -186,11 +151,8 @@ static void kill_word ( struct edit_string *string ) {
*/
static void kill_sol ( struct edit_string *string ) {
size_t old_cursor = string->cursor;
int rc;
string->cursor = 0;
rc = insert_delete ( string, old_cursor, NULL );
assert ( ( rc == 0 ) || ( *(string->buf) == NULL ) );
insert_delete ( string, old_cursor, NULL );
}
/**
@@ -199,36 +161,18 @@ static void kill_sol ( struct edit_string *string ) {
* @v string Editable string
*/
static void kill_eol ( struct edit_string *string ) {
int rc;
rc = insert_delete ( string, ~( ( size_t ) 0 ), NULL );
assert ( ( rc == 0 ) || ( *(string->buf) == NULL ) );
insert_delete ( string, ~( ( size_t ) 0 ), NULL );
}
/**
* Replace editable string
*
* @v string Editable string
* @v replacement Replacement string, or NULL to empty the string
* @ret rc Return status code
*
* Replace the entire content of the editable string and update the
* edit history to allow the caller to bring the display into sync
* with the string content.
*
* This function does not itself update the display in any way.
*
* Upon success, the string buffer is guaranteed to be non-NULL (even
* if the replacement string is NULL or empty).
*
* Errors may safely be ignored if it is deemed that subsequently
* failing to update the display will provide sufficient feedback to
* the user.
* @v replacement Replacement string
*/
int replace_string ( struct edit_string *string, const char *replacement ) {
void replace_string ( struct edit_string *string, const char *replacement ) {
string->cursor = 0;
return insert_delete ( string, ~( ( size_t ) 0 ), replacement );
insert_delete ( string, ~( ( size_t ) 0 ), replacement );
}
/**
@@ -236,26 +180,21 @@ int replace_string ( struct edit_string *string, const char *replacement ) {
*
* @v string Editable string
* @v key Key pressed by user
* @ret key Key returned to application, zero, or negative error
* @ret key Key returned to application, or zero
*
* Handles keypresses and updates the content of the editable string.
* Basic line editing facilities (delete/insert/cursor) are supported.
* If edit_string() understands and uses the keypress it will return
* zero, otherwise it will return the original key.
*
* This function does not update the display in any way.
*
* The string's edit history will be updated to allow the caller to
* efficiently bring the display into sync with the string content.
*
* This function does not itself update the display in any way.
*
* Errors may safely be ignored if it is deemed that subsequently
* failing to update the display will provide sufficient feedback to
* the user.
*/
int edit_string ( struct edit_string *string, int key ) {
const char *buf = *(string->buf);
size_t len = ( buf ? strlen ( buf ) : 0 );
int retval = 0;
size_t len = strlen ( string->buf );
/* Prepare edit history */
string->last_cursor = string->cursor;
@@ -265,7 +204,7 @@ int edit_string ( struct edit_string *string, int key ) {
/* Interpret key */
if ( ( key >= 0x20 ) && ( key <= 0x7e ) ) {
/* Printable character; insert at current position */
retval = insert_character ( string, key );
insert_character ( string, key );
} else switch ( key ) {
case KEY_BACKSPACE:
/* Backspace */
+28 -49
View File
@@ -39,9 +39,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
* @v key Key pressed by user
* @ret move Scroller movement, or zero
*/
unsigned int jump_scroll_key ( struct jump_scroller *scroll, int key ) {
unsigned int flags = 0;
int16_t delta;
int jump_scroll_key ( struct jump_scroller *scroll, int key ) {
/* Sanity checks */
assert ( scroll->rows != 0 );
@@ -54,32 +52,20 @@ unsigned int jump_scroll_key ( struct jump_scroller *scroll, int key ) {
/* Handle key, if applicable */
switch ( key ) {
case KEY_UP:
delta = -1;
break;
case TAB:
flags = SCROLL_WRAP;
/* fall through */
return -1;
case KEY_DOWN:
delta = +1;
break;
return +1;
case KEY_PPAGE:
delta = ( scroll->first - scroll->current - 1 );
break;
return ( scroll->first - scroll->current - 1 );
case KEY_NPAGE:
delta = ( scroll->first - scroll->current + scroll->rows );
break;
return ( scroll->first - scroll->current + scroll->rows );
case KEY_HOME:
delta = -( scroll->count );
break;
return -( scroll->count );
case KEY_END:
delta = +( scroll->count );
break;
return +( scroll->count );
default:
delta = 0;
break;
return 0;
}
return ( SCROLL ( delta ) | flags );
}
/**
@@ -89,9 +75,7 @@ unsigned int jump_scroll_key ( struct jump_scroller *scroll, int key ) {
* @v move Scroller movement
* @ret move Continuing scroller movement (if applicable)
*/
unsigned int jump_scroll_move ( struct jump_scroller *scroll,
unsigned int move ) {
int16_t delta = SCROLL_DELTA ( move );
int jump_scroll_move ( struct jump_scroller *scroll, int move ) {
int current = scroll->current;
int last = ( scroll->count - 1 );
@@ -100,35 +84,30 @@ unsigned int jump_scroll_move ( struct jump_scroller *scroll,
assert ( scroll->count != 0 );
/* Move to the new current item */
current += delta;
/* Default to continuing movement in the same direction */
delta = ( ( delta >= 0 ) ? +1 : -1 );
current += move;
/* Check for start/end of list */
if ( ( current >= 0 ) && ( current <= last ) ) {
/* We are still within the list. Update the current
* item and continue moving in the same direction (if
* applicable).
if ( current < 0 ) {
/* We have attempted to move before the start of the
* list. Move to the start of the list and continue
* moving forwards (if applicable).
*/
scroll->current = 0;
return +1;
} else if ( current > last ) {
/* We have attempted to move after the end of the
* list. Move to the end of the list and continue
* moving backwards (if applicable).
*/
scroll->current = last;
return -1;
} else {
/* Update the current item and continue moving in the
* same direction (if applicable).
*/
scroll->current = current;
} else {
/* We have attempted to move outside the list. If we
* are wrapping around, then continue in the same
* direction (if applicable), otherwise reverse.
*/
if ( ! ( move & SCROLL_WRAP ) )
delta = -delta;
/* Move to start or end of list as appropriate */
if ( delta >= 0 ) {
scroll->current = 0;
} else {
scroll->current = last;
}
return ( ( move > 0 ) ? +1 : -1 );
}
return ( SCROLL ( delta ) | ( move & SCROLL_FLAGS ) );
}
/**
+36 -32
View File
@@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <string.h>
#include <assert.h>
#include <ipxe/ansicol.h>
#include <ipxe/editbox.h>
/** @file
@@ -36,15 +35,39 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#define EDITBOX_MIN_CHARS 3
/**
* Initialise text box widget
*
* @v box Editable text box widget
* @v buf Text buffer
* @v len Size of text buffer
* @v win Containing window
* @v row Row
* @v col Starting column
* @v width Width
* @v flags Flags
*/
void init_editbox ( struct edit_box *box, char *buf, size_t len,
WINDOW *win, unsigned int row, unsigned int col,
unsigned int width, unsigned int flags ) {
memset ( box, 0, sizeof ( *box ) );
init_editstring ( &box->string, buf, len );
box->string.cursor = strlen ( buf );
box->win = ( win ? win : stdscr );
box->row = row;
box->col = col;
box->width = width;
box->flags = flags;
}
/**
* Draw text box widget
*
* @v widget Text widget
* @v box Editable text box widget
*
*/
static void draw_editbox ( struct widget *widget ) {
struct edit_box *box = container_of ( widget, struct edit_box, widget );
const char *content = *(box->string.buf);
size_t width = widget->width;
void draw_editbox ( struct edit_box *box ) {
size_t width = box->width;
char buf[ width + 1 ];
signed int cursor_offset, underflow, overflow, first;
size_t len;
@@ -67,37 +90,18 @@ static void draw_editbox ( struct widget *widget ) {
/* Construct underscore-padded string portion */
memset ( buf, '_', width );
buf[width] = '\0';
len = ( content ? ( strlen ( content ) - first ) : 0 );
len = ( strlen ( box->string.buf ) - first );
if ( len > width )
len = width;
if ( widget->flags & WIDGET_SECRET ) {
if ( box->flags & EDITBOX_STARS ) {
memset ( buf, '*', len );
} else {
memcpy ( buf, ( content + first ), len );
memcpy ( buf, ( box->string.buf + first ), len );
}
/* Print box content and move cursor */
color_set ( CPAIR_EDIT, NULL );
mvprintw ( widget->row, widget->col, "%s", buf );
move ( widget->row, ( widget->col + cursor_offset ) );
color_set ( CPAIR_NORMAL, NULL );
if ( ! box->win )
box->win = stdscr;
mvwprintw ( box->win, box->row, box->col, "%s", buf );
wmove ( box->win, box->row, ( box->col + cursor_offset ) );
}
/**
* Edit text box widget
*
* @v widget Text widget
* @v key Key pressed by user
* @ret key Key returned to application, or zero
*/
static int edit_editbox ( struct widget *widget, int key ) {
struct edit_box *box = container_of ( widget, struct edit_box, widget );
return edit_string ( &box->string, key );
}
/** Text box widget operations */
struct widget_operations editbox_operations = {
.draw = draw_editbox,
.edit = edit_editbox,
};
+31 -17
View File
@@ -38,6 +38,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
*/
#define READLINE_MAX 1024
/**
* Synchronise console with edited string
*
@@ -47,8 +49,7 @@ static void sync_console ( struct edit_string *string ) {
unsigned int mod_start = string->mod_start;
unsigned int mod_end = string->mod_end;
unsigned int cursor = string->last_cursor;
const char *buf = *(string->buf);
size_t len = strlen ( buf );
size_t len = strlen ( string->buf );
/* Expand region back to old cursor position if applicable */
if ( mod_start > string->last_cursor )
@@ -66,7 +67,7 @@ static void sync_console ( struct edit_string *string ) {
/* Print modified region */
while ( cursor < mod_end ) {
putchar ( ( cursor >= len ) ? ' ' : buf[cursor] );
putchar ( ( cursor >= len ) ? ' ' : string->buf[cursor] );
cursor++;
}
@@ -258,11 +259,15 @@ int readline_history ( const char *prompt, const char *prefill,
struct readline_history *history, unsigned long timeout,
char **line ) {
struct edit_string string;
char *buf;
int key;
int move_by;
const char *new_string;
int rc;
/* Avoid returning uninitialised data on error */
*line = NULL;
/* Display prompt, if applicable */
if ( prompt )
printf ( "%s", prompt );
@@ -270,15 +275,20 @@ int readline_history ( const char *prompt, const char *prefill,
/* Ensure cursor is visible */
printf ( "\033[?25h" );
/* Initialise editable string */
*line = NULL;
/* Allocate buffer and initialise editable string */
buf = zalloc ( READLINE_MAX );
if ( ! buf ) {
rc = -ENOMEM;
goto done;
}
memset ( &string, 0, sizeof ( string ) );
init_editstring ( &string, line );
init_editstring ( &string, buf, READLINE_MAX );
/* Prefill string */
if ( ( rc = replace_string ( &string, prefill ) ) != 0 )
goto error;
sync_console ( &string );
/* Prefill string, if applicable */
if ( prefill ) {
replace_string ( &string, prefill );
sync_console ( &string );
}
while ( 1 ) {
@@ -286,7 +296,7 @@ int readline_history ( const char *prompt, const char *prefill,
key = getkey ( timeout );
if ( key < 0 ) {
rc = -ETIMEDOUT;
goto error;
goto done;
}
timeout = 0;
@@ -297,11 +307,17 @@ int readline_history ( const char *prompt, const char *prefill,
switch ( key ) {
case CR:
case LF:
/* Shrink string (ignoring failures) */
*line = realloc ( buf,
( strlen ( buf ) + 1 /* NUL */ ) );
if ( ! *line )
*line = buf;
buf = NULL;
rc = 0;
goto done;
case CTRL_C:
rc = -ECANCELED;
goto error;
goto done;
case KEY_UP:
move_by = 1;
break;
@@ -309,13 +325,13 @@ int readline_history ( const char *prompt, const char *prefill,
move_by = -1;
break;
default:
/* Do nothing for unrecognised keys or edit errors */
/* Do nothing */
break;
}
/* Handle history movement, if applicable */
if ( move_by && history ) {
new_string = history_move ( history, move_by, *line );
new_string = history_move ( history, move_by, buf );
if ( new_string ) {
replace_string ( &string, new_string );
sync_console ( &string );
@@ -323,11 +339,9 @@ int readline_history ( const char *prompt, const char *prefill,
}
}
error:
free ( *line );
*line = NULL;
done:
putchar ( '\n' );
free ( buf );
if ( history ) {
if ( *line && (*line)[0] )
history_append ( history, *line );
-544
View File
@@ -1,544 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Text widget forms
*
*/
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ipxe/ansicol.h>
#include <ipxe/dynui.h>
#include <ipxe/jumpscroll.h>
#include <ipxe/settings.h>
#include <ipxe/editbox.h>
#include <ipxe/message.h>
/** Form title row */
#define TITLE_ROW 1U
/** Starting control row */
#define START_ROW 3U
/** Ending control row */
#define END_ROW ( LINES - 3U )
/** Instructions row */
#define INSTRUCTION_ROW ( LINES - 2U )
/** Padding between instructions */
#define INSTRUCTION_PAD " "
/** Input field width */
#define INPUT_WIDTH ( COLS / 2U )
/** Input field column */
#define INPUT_COL ( ( COLS - INPUT_WIDTH ) / 2U )
/** A form */
struct form {
/** Dynamic user interface */
struct dynamic_ui *dynui;
/** Jump scroller */
struct jump_scroller scroll;
/** Array of form controls */
struct form_control *controls;
};
/** A form control */
struct form_control {
/** Dynamic user interface item */
struct dynamic_item *item;
/** Settings block */
struct settings *settings;
/** Setting */
struct setting setting;
/** Label row */
unsigned int row;
/** Editable text box */
struct edit_box editbox;
/** Modifiable setting name */
char *name;
/** Modifiable setting value */
char *value;
/** Most recent error in saving */
int rc;
};
/**
* Allocate form
*
* @v dynui Dynamic user interface
* @ret form Form, or NULL on error
*/
static struct form * alloc_form ( struct dynamic_ui *dynui ) {
struct form *form;
struct form_control *control;
struct dynamic_item *item;
char *name;
size_t len;
/* Calculate total length */
len = sizeof ( *form );
list_for_each_entry ( item, &dynui->items, list ) {
len += sizeof ( *control );
if ( item->name )
len += ( strlen ( item->name ) + 1 /* NUL */ );
}
/* Allocate and initialise structure */
form = zalloc ( len );
if ( ! form )
return NULL;
control = ( ( ( void * ) form ) + sizeof ( *form ) );
name = ( ( ( void * ) control ) +
( dynui->count * sizeof ( *control ) ) );
form->dynui = dynui;
form->controls = control;
list_for_each_entry ( item, &dynui->items, list ) {
control->item = item;
if ( item->name ) {
control->name = name;
name = ( stpcpy ( name, item->name ) + 1 /* NUL */ );
}
control++;
}
assert ( ( ( void * ) name ) == ( ( ( void * ) form ) + len ) );
return form;
}
/**
* Free form
*
* @v form Form
*/
static void free_form ( struct form *form ) {
unsigned int i;
/* Free input value buffers */
for ( i = 0 ; i < form->dynui->count ; i++ )
free ( form->controls[i].value );
/* Free form */
free ( form );
}
/**
* Assign form rows
*
* @v form Form
* @ret rc Return status code
*/
static int layout_form ( struct form *form ) {
struct form_control *control;
struct dynamic_item *item;
unsigned int labels = 0;
unsigned int inputs = 0;
unsigned int pad_control = 0;
unsigned int pad_label = 0;
unsigned int minimum;
unsigned int remaining;
unsigned int between;
unsigned int row;
unsigned int flags;
unsigned int i;
/* Count labels and inputs */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
item = control->item;
if ( item->text[0] )
labels++;
if ( item->name ) {
if ( ! inputs )
form->scroll.current = i;
inputs++;
if ( item->flags & DYNUI_DEFAULT )
form->scroll.current = i;
form->scroll.count = ( i + 1 );
}
}
form->scroll.rows = form->scroll.count;
DBGC ( form, "FORM %p has %d controls (%d labels, %d inputs)\n",
form, form->dynui->count, labels, inputs );
/* Refuse to create forms with no inputs */
if ( ! inputs )
return -EINVAL;
/* Calculate minimum number of rows */
minimum = ( labels + ( inputs * 2 /* edit box and error message */ ) );
remaining = ( END_ROW - START_ROW );
DBGC ( form, "FORM %p has %d (of %d) usable rows\n",
form, remaining, LINES );
if ( minimum > remaining )
return -ERANGE;
remaining -= minimum;
/* Insert blank row between controls, if space exists */
between = ( form->dynui->count - 1 );
if ( between <= remaining ) {
pad_control = 1;
remaining -= between;
DBGC ( form, "FORM %p padding between controls\n", form );
}
/* Insert blank row after label, if space exists */
if ( labels <= remaining ) {
pad_label = 1;
remaining -= labels;
DBGC ( form, "FORM %p padding after labels\n", form );
}
/* Centre on screen */
DBGC ( form, "FORM %p has %d spare rows\n", form, remaining );
row = ( START_ROW + ( remaining / 2 ) );
/* Position each control */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
item = control->item;
if ( item->text[0] ) {
control->row = row;
row++; /* Label text */
row += pad_label;
}
if ( item->name ) {
flags = ( ( item->flags & DYNUI_SECRET ) ?
WIDGET_SECRET : 0 );
init_editbox ( &control->editbox, row, INPUT_COL,
INPUT_WIDTH, flags, &control->value );
row++; /* Edit box */
row++; /* Error message (if any) */
}
row += pad_control;
}
assert ( row <= END_ROW );
return 0;
}
/**
* Draw form
*
* @v form Form
*/
static void draw_form ( struct form *form ) {
struct form_control *control;
unsigned int i;
/* Clear screen */
color_set ( CPAIR_NORMAL, NULL );
erase();
/* Draw title, if any */
attron ( A_BOLD );
if ( form->dynui->title )
msg ( TITLE_ROW, "%s", form->dynui->title );
attroff ( A_BOLD );
/* Draw controls */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
/* Draw label, if any */
if ( control->row )
msg ( control->row, "%s", control->item->text );
/* Draw input, if any */
if ( control->name )
draw_widget ( &control->editbox.widget );
}
/* Draw instructions */
msg ( INSTRUCTION_ROW, "%s", "Ctrl-X - save changes"
INSTRUCTION_PAD "Ctrl-C - discard changes" );
}
/**
* Draw (or clear) error messages
*
* @v form Form
*/
static void draw_errors ( struct form *form ) {
struct form_control *control;
unsigned int row;
unsigned int i;
/* Draw (or clear) errors */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
/* Skip non-input controls */
if ( ! control->name )
continue;
/* Draw or clear error message as appropriate */
row = ( control->editbox.widget.row + 1 );
if ( control->rc != 0 ) {
color_set ( CPAIR_ALERT, NULL );
msg ( row, " %s ", strerror ( control->rc ) );
color_set ( CPAIR_NORMAL, NULL );
} else {
clearmsg ( row );
}
}
}
/**
* Parse setting names
*
* @v form Form
* @ret rc Return status code
*/
static int parse_names ( struct form *form ) {
struct form_control *control;
unsigned int i;
int rc;
/* Parse all setting names */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
/* Skip labels */
if ( ! control->name ) {
DBGC ( form, "FORM %p item %d is a label\n", form, i );
continue;
}
/* Parse setting name */
DBGC ( form, "FORM %p item %d is for %s\n",
form, i, control->name );
if ( ( rc = parse_setting_name ( control->name,
autovivify_child_settings,
&control->settings,
&control->setting ) ) != 0 )
return rc;
/* Apply default type if necessary */
if ( ! control->setting.type )
control->setting.type = &setting_type_string;
}
return 0;
}
/**
* Load current input values
*
* @v form Form
*/
static void load_values ( struct form *form ) {
struct form_control *control;
unsigned int i;
/* Fetch all current setting values */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
if ( ! control->name )
continue;
fetchf_setting_copy ( control->settings, &control->setting,
NULL, &control->setting,
&control->value );
}
}
/**
* Store current input values
*
* @v form Form
* @ret rc Return status code
*/
static int save_values ( struct form *form ) {
struct form_control *control;
unsigned int i;
int rc = 0;
/* Store all current setting values */
for ( i = 0 ; i < form->dynui->count ; i++ ) {
control = &form->controls[i];
if ( ! control->name )
continue;
control->rc = storef_setting ( control->settings,
&control->setting,
control->value );
if ( control->rc != 0 )
rc = control->rc;
}
return rc;
}
/**
* Submit form
*
* @v form Form
* @ret rc Return status code
*/
static int submit_form ( struct form *form ) {
int rc;
/* Attempt to save values */
rc = save_values ( form );
/* Draw (or clear) errors */
draw_errors ( form );
return rc;
}
/**
* Form main loop
*
* @v form Form
* @ret rc Return status code
*/
static int form_loop ( struct form *form ) {
struct jump_scroller *scroll = &form->scroll;
struct form_control *control;
struct dynamic_item *item;
unsigned int move;
unsigned int i;
int key;
int rc;
/* Main loop */
while ( 1 ) {
/* Draw current input */
control = &form->controls[scroll->current];
draw_widget ( &control->editbox.widget );
/* Process keypress */
key = edit_widget ( &control->editbox.widget, getkey ( 0 ) );
/* Handle scroll keys */
move = jump_scroll_key ( &form->scroll, key );
/* Handle special keys */
switch ( key ) {
case CTRL_C:
case ESC:
/* Cancel form */
return -ECANCELED;
case KEY_ENTER:
/* Attempt to do the most intuitive thing when
* Enter is pressed. If we are on the last
* input, then submit the form. If we are
* editing an input which failed, then
* resubmit the form. Otherwise, move to the
* next input.
*/
if ( ( control->rc == 0 ) &&
( scroll->current < ( scroll->count - 1 ) ) ) {
move = SCROLL_DOWN;
break;
}
/* fall through */
case CTRL_X:
/* Submit form */
if ( ( rc = submit_form ( form ) ) == 0 )
return 0;
/* If current input is not the problem, move
* to the first input that needs fixing.
*/
if ( control->rc == 0 ) {
for ( i = 0 ; i < form->dynui->count ; i++ ) {
if ( form->controls[i].rc != 0 ) {
scroll->current = i;
break;
}
}
}
break;
default:
/* Move to input with matching shortcut key, if any */
item = dynui_shortcut ( form->dynui, key );
if ( item ) {
scroll->current = item->index;
if ( ! item->name )
move = SCROLL_DOWN;
}
break;
}
/* Move selection, if applicable */
while ( move ) {
move = jump_scroll_move ( &form->scroll, move );
control = &form->controls[scroll->current];
if ( control->name )
break;
}
}
}
/**
* Show form
*
* @v dynui Dynamic user interface
* @ret rc Return status code
*/
int show_form ( struct dynamic_ui *dynui ) {
struct form *form;
int rc;
/* Allocate and initialise structure */
form = alloc_form ( dynui );
if ( ! form ) {
rc = -ENOMEM;
goto err_alloc;
}
/* Parse setting names and load current values */
if ( ( rc = parse_names ( form ) ) != 0 )
goto err_parse_names;
load_values ( form );
/* Lay out form on screen */
if ( ( rc = layout_form ( form ) ) != 0 )
goto err_layout;
/* Draw initial form */
initscr();
start_color();
draw_form ( form );
/* Run main loop */
if ( ( rc = form_loop ( form ) ) != 0 )
goto err_loop;
err_loop:
color_set ( CPAIR_NORMAL, NULL );
endwin();
err_layout:
err_parse_names:
free_form ( form );
err_alloc:
return rc;
}
+100 -33
View File
@@ -29,42 +29,109 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
*
*/
#include <ipxe/dynui.h>
#include <string.h>
#include <errno.h>
#include <curses.h>
#include <ipxe/console.h>
#include <ipxe/settings.h>
#include <ipxe/editbox.h>
#include <ipxe/keys.h>
#include <ipxe/ansicol.h>
#include <ipxe/login_ui.h>
static struct dynamic_item username;
static struct dynamic_item password;
static struct dynamic_ui login = {
.items = {
.prev = &password.list,
.next = &username.list,
},
.count = 2,
};
static struct dynamic_item username = {
.list = {
.prev = &login.items,
.next = &password.list,
},
.name = "username",
.text = "Username",
.index = 0,
};
static struct dynamic_item password = {
.list = {
.prev = &username.list,
.next = &login.items,
},
.name = "password",
.text = "Password",
.index = 1,
.flags = DYNUI_SECRET,
};
/* Screen layout */
#define USERNAME_LABEL_ROW ( ( LINES / 2U ) - 4U )
#define USERNAME_ROW ( ( LINES / 2U ) - 2U )
#define PASSWORD_LABEL_ROW ( ( LINES / 2U ) + 2U )
#define PASSWORD_ROW ( ( LINES / 2U ) + 4U )
#define LABEL_COL ( ( COLS / 2U ) - 4U )
#define EDITBOX_COL ( ( COLS / 2U ) - 10U )
#define EDITBOX_WIDTH 20U
int login_ui ( void ) {
char username[64];
char password[64];
struct edit_box username_box;
struct edit_box password_box;
struct edit_box *current_box = &username_box;
int key;
int rc = -EINPROGRESS;
return show_form ( &login );
/* Fetch current setting values */
fetch_string_setting ( NULL, &username_setting, username,
sizeof ( username ) );
fetch_string_setting ( NULL, &password_setting, password,
sizeof ( password ) );
/* Initialise UI */
initscr();
start_color();
init_editbox ( &username_box, username, sizeof ( username ), NULL,
USERNAME_ROW, EDITBOX_COL, EDITBOX_WIDTH, 0 );
init_editbox ( &password_box, password, sizeof ( password ), NULL,
PASSWORD_ROW, EDITBOX_COL, EDITBOX_WIDTH,
EDITBOX_STARS );
/* Draw initial UI */
color_set ( CPAIR_NORMAL, NULL );
erase();
attron ( A_BOLD );
mvprintw ( USERNAME_LABEL_ROW, LABEL_COL, "Username:" );
mvprintw ( PASSWORD_LABEL_ROW, LABEL_COL, "Password:" );
attroff ( A_BOLD );
color_set ( CPAIR_EDIT, NULL );
draw_editbox ( &username_box );
draw_editbox ( &password_box );
/* Main loop */
while ( rc == -EINPROGRESS ) {
draw_editbox ( current_box );
key = getkey ( 0 );
switch ( key ) {
case KEY_DOWN:
current_box = &password_box;
break;
case KEY_UP:
current_box = &username_box;
break;
case TAB:
current_box = ( ( current_box == &username_box ) ?
&password_box : &username_box );
break;
case KEY_ENTER:
if ( current_box == &username_box ) {
current_box = &password_box;
} else {
rc = 0;
}
break;
case CTRL_C:
case ESC:
rc = -ECANCELED;
break;
default:
edit_editbox ( current_box, key );
break;
}
}
/* Terminate UI */
color_set ( CPAIR_NORMAL, NULL );
erase();
endwin();
if ( rc != 0 )
return rc;
/* Store settings */
if ( ( rc = store_setting ( NULL, &username_setting, username,
strlen ( username ) ) ) != 0 )
return rc;
if ( ( rc = store_setting ( NULL, &password_setting, password,
strlen ( password ) ) ) != 0 )
return rc;
return 0;
}
+61 -36
View File
@@ -37,7 +37,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/console.h>
#include <ipxe/ansicol.h>
#include <ipxe/jumpscroll.h>
#include <ipxe/dynui.h>
#include <ipxe/menu.h>
/* Screen layout */
#define TITLE_ROW 1U
@@ -49,14 +49,32 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** A menu user interface */
struct menu_ui {
/** Dynamic user interface */
struct dynamic_ui *dynui;
/** Menu */
struct menu *menu;
/** Jump scroller */
struct jump_scroller scroll;
/** Timeout (0=indefinite) */
unsigned long timeout;
};
/**
* Return a numbered menu item
*
* @v menu Menu
* @v index Index
* @ret item Menu item, or NULL
*/
static struct menu_item * menu_item ( struct menu *menu, unsigned int index ) {
struct menu_item *item;
list_for_each_entry ( item, &menu->items, list ) {
if ( index-- == 0 )
return item;
}
return NULL;
}
/**
* Draw a numbered menu item
*
@@ -64,7 +82,7 @@ struct menu_ui {
* @v index Index
*/
static void draw_menu_item ( struct menu_ui *ui, unsigned int index ) {
struct dynamic_item *item;
struct menu_item *item;
unsigned int row_offset;
char buf[ MENU_COLS + 1 /* NUL */ ];
char timeout_buf[6]; /* "(xxx)" + NUL */
@@ -77,11 +95,11 @@ static void draw_menu_item ( struct menu_ui *ui, unsigned int index ) {
move ( ( MENU_ROW + row_offset ), MENU_COL );
/* Get menu item */
item = dynui_item ( ui->dynui, index );
item = menu_item ( ui->menu, index );
if ( item ) {
/* Draw separators in a different colour */
if ( ! item->name )
if ( ! item->label )
color_set ( CPAIR_SEPARATOR, NULL );
/* Highlight if this is the selected item */
@@ -153,12 +171,13 @@ static void draw_menu_items ( struct menu_ui *ui ) {
* @ret selected Selected item
* @ret rc Return status code
*/
static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
struct dynamic_item *item;
static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
struct menu_item *item;
unsigned long timeout;
unsigned int previous;
unsigned int move;
int key;
int i;
int move;
int chosen = 0;
int rc = 0;
@@ -173,7 +192,7 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
ui->timeout -= timeout;
/* Get key */
move = SCROLL_NONE;
move = 0;
key = getkey ( timeout );
if ( key < 0 ) {
/* Choose default if we finally time out */
@@ -197,13 +216,19 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
chosen = 1;
break;
default:
item = dynui_shortcut ( ui->dynui, key );
if ( item ) {
ui->scroll.current = item->index;
if ( item->name ) {
i = 0;
list_for_each_entry ( item, &ui->menu->items,
list ) {
if ( ! ( item->shortcut &&
( item->shortcut == key ) ) ) {
i++;
continue;
}
ui->scroll.current = i;
if ( item->label ) {
chosen = 1;
} else {
move = SCROLL_DOWN;
move = +1;
}
}
break;
@@ -213,8 +238,8 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
/* Move selection, if applicable */
while ( move ) {
move = jump_scroll_move ( &ui->scroll, move );
item = dynui_item ( ui->dynui, ui->scroll.current );
if ( item->name )
item = menu_item ( ui->menu, ui->scroll.current );
if ( item->label )
break;
}
@@ -227,9 +252,9 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
}
/* Record selection */
item = dynui_item ( ui->dynui, ui->scroll.current );
item = menu_item ( ui->menu, ui->scroll.current );
assert ( item != NULL );
assert ( item->name != NULL );
assert ( item->label != NULL );
*selected = item;
} while ( ( rc == 0 ) && ! chosen );
@@ -240,43 +265,43 @@ static int menu_loop ( struct menu_ui *ui, struct dynamic_item **selected ) {
/**
* Show menu
*
* @v dynui Dynamic user interface
* @v menu Menu
* @v timeout Timeout period, in ticks (0=indefinite)
* @ret selected Selected item
* @ret rc Return status code
*/
int show_menu ( struct dynamic_ui *dynui, unsigned long timeout,
const char *select, struct dynamic_item **selected ) {
struct dynamic_item *item;
int show_menu ( struct menu *menu, unsigned long timeout,
const char *select, struct menu_item **selected ) {
struct menu_item *item;
struct menu_ui ui;
char buf[ MENU_COLS + 1 /* NUL */ ];
int named_count = 0;
int labelled_count = 0;
int rc;
/* Initialise UI */
memset ( &ui, 0, sizeof ( ui ) );
ui.dynui = dynui;
ui.menu = menu;
ui.scroll.rows = MENU_ROWS;
ui.timeout = timeout;
list_for_each_entry ( item, &dynui->items, list ) {
if ( item->name ) {
if ( ! named_count )
list_for_each_entry ( item, &menu->items, list ) {
if ( item->label ) {
if ( ! labelled_count )
ui.scroll.current = ui.scroll.count;
named_count++;
labelled_count++;
if ( select ) {
if ( strcmp ( select, item->name ) == 0 )
if ( strcmp ( select, item->label ) == 0 )
ui.scroll.current = ui.scroll.count;
} else {
if ( item->flags & DYNUI_DEFAULT )
if ( item->is_default )
ui.scroll.current = ui.scroll.count;
}
}
ui.scroll.count++;
}
if ( ! named_count ) {
/* Menus with no named items cannot be selected from,
* and will seriously confuse the navigation logic.
* Refuse to display any such menus.
if ( ! labelled_count ) {
/* Menus with no labelled items cannot be selected
* from, and will seriously confuse the navigation
* logic. Refuse to display any such menus.
*/
return -ENOENT;
}
@@ -290,7 +315,7 @@ int show_menu ( struct dynamic_ui *dynui, unsigned long timeout,
/* Draw initial content */
attron ( A_BOLD );
snprintf ( buf, sizeof ( buf ), "%s", ui.dynui->title );
snprintf ( buf, sizeof ( buf ), "%s", ui.menu->title );
mvprintw ( TITLE_ROW, ( ( COLS - strlen ( buf ) ) / 2 ), "%s", buf );
attroff ( A_BOLD );
jump_scroll ( &ui.scroll );
-109
View File
@@ -1,109 +0,0 @@
/*
* Copyright (C) 2024 Michael Brown <mbrown@fensystems.co.uk>.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*
* You can also choose to distribute this program under the terms of
* the Unmodified Binary Distribution Licence (as given in the file
* COPYING.UBDL), provided that you have satisfied its requirements.
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** @file
*
* Message printing
*
*/
#include <stddef.h>
#include <stdint.h>
#include <stdarg.h>
#include <unistd.h>
#include <ipxe/ansicol.h>
#include <ipxe/message.h>
/**
* Print message centred on specified row
*
* @v row Row
* @v fmt printf() format string
* @v args printf() argument list
*/
static void vmsg ( unsigned int row, const char *fmt, va_list args ) {
char buf[COLS];
size_t len;
len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
mvprintw ( row, ( ( COLS - len ) / 2 ), "%s", buf );
}
/**
* Print message centred on specified row
*
* @v row Row
* @v fmt printf() format string
* @v .. printf() arguments
*/
void msg ( unsigned int row, const char *fmt, ... ) {
va_list args;
va_start ( args, fmt );
vmsg ( row, fmt, args );
va_end ( args );
}
/**
* Clear message on specified row
*
* @v row Row
*/
void clearmsg ( unsigned int row ) {
move ( row, 0 );
clrtoeol();
}
/**
* Show alert message
*
* @v row Row
* @v fmt printf() format string
* @v args printf() argument list
*/
static void valert ( unsigned int row, const char *fmt, va_list args ) {
clearmsg ( row );
color_set ( CPAIR_ALERT, NULL );
vmsg ( row, fmt, args );
sleep ( 2 );
color_set ( CPAIR_NORMAL, NULL );
clearmsg ( row );
}
/**
* Show alert message
*
* @v row Row
* @v fmt printf() format string
* @v ... printf() arguments
*/
void alert ( unsigned int row, const char *fmt, ... ) {
va_list args;
va_start ( args, fmt );
valert ( row, fmt, args );
va_end ( args );
}
+106 -43
View File
@@ -25,7 +25,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <curses.h>
@@ -35,7 +34,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/keys.h>
#include <ipxe/ansicol.h>
#include <ipxe/jumpscroll.h>
#include <ipxe/message.h>
#include <ipxe/settings_ui.h>
#include <config/branding.h>
@@ -60,15 +58,12 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
char start[0]; \
char pad1[1]; \
union { \
struct { \
char name[ cols - 1 - 1 - 1 - 1 - 1 ]; \
char pad2[1]; \
} __attribute__ (( packed )) settings; \
char settings[ cols - 1 - 1 - 1 - 1 ]; \
struct { \
char name[15]; \
char pad2[1]; \
char value[ cols - 1 - 15 - 1 - 1 - 1 - 1 ]; \
} __attribute__ (( packed )) setting; \
} setting; \
} u; \
char pad3[1]; \
char nul; \
@@ -97,8 +92,8 @@ struct settings_ui_row {
struct edit_box editbox;
/** Editing in progress flag */
int editing;
/** Dynamically allocated buffer for setting's value */
char *buf;
/** Buffer for setting's value */
char value[256]; /* enough size for a DHCP string */
};
/** A settings user interface */
@@ -126,22 +121,24 @@ static unsigned int select_setting_row ( struct settings_ui *ui,
struct setting *previous = NULL;
unsigned int count = 0;
/* Free any previous setting value */
free ( ui->row.buf );
ui->row.buf = NULL;
/* Initialise structure */
memset ( &ui->row, 0, sizeof ( ui->row ) );
ui->row.row = ( SETTINGS_LIST_ROW + index - ui->scroll.first );
/* Include parent settings block, if applicable */
if ( ui->settings->parent && ( count++ == index ) )
if ( ui->settings->parent && ( count++ == index ) ) {
ui->row.settings = ui->settings->parent;
snprintf ( ui->row.value, sizeof ( ui->row.value ),
"../" );
}
/* Include any child settings blocks, if applicable */
list_for_each_entry ( settings, &ui->settings->children, siblings ) {
if ( count++ == index )
if ( count++ == index ) {
ui->row.settings = settings;
snprintf ( ui->row.value, sizeof ( ui->row.value ),
"%s/", settings->name );
}
}
/* Include any applicable settings */
@@ -158,18 +155,18 @@ static unsigned int select_setting_row ( struct settings_ui *ui,
/* Read current setting value and origin */
if ( count++ == index ) {
fetchf_setting_copy ( ui->settings, setting,
&ui->row.origin,
&ui->row.setting, &ui->row.buf );
fetchf_setting ( ui->settings, setting, &ui->row.origin,
&ui->row.setting, ui->row.value,
sizeof ( ui->row.value ) );
}
}
/* Initialise edit box */
memset ( &ui->row.editbox, 0, sizeof ( ui->row.editbox ) );
init_editbox ( &ui->row.editbox, ui->row.row,
init_editbox ( &ui->row.editbox, ui->row.value,
sizeof ( ui->row.value ), NULL, ui->row.row,
( SETTINGS_LIST_COL +
offsetof ( typeof ( *text ), u.setting.value ) ),
sizeof ( text->u.setting.value ), 0, &ui->row.buf );
sizeof ( text->u.setting.value ), 0 );
return count;
}
@@ -200,7 +197,7 @@ static size_t string_copy ( char *dest, const char *src, size_t len ) {
static void draw_setting_row ( struct settings_ui *ui ) {
SETTING_ROW_TEXT ( COLS ) text;
unsigned int curs_offset;
const char *value;
char *value;
/* Fill row with spaces */
memset ( &text, ' ', sizeof ( text ) );
@@ -210,12 +207,10 @@ static void draw_setting_row ( struct settings_ui *ui ) {
if ( ui->row.settings ) {
/* Construct space-padded name */
value = ( ( ui->row.settings == ui->settings->parent ) ?
".." : ui->row.settings->name );
curs_offset = string_copy ( text.u.settings.name, value,
sizeof ( text.u.settings.name ) );
text.u.settings.name[curs_offset] = '/';
curs_offset += offsetof ( typeof ( text ), u.settings );
curs_offset = ( offsetof ( typeof ( text ), u.settings ) +
string_copy ( text.u.settings,
ui->row.value,
sizeof ( text.u.settings ) ) );
} else {
@@ -226,12 +221,12 @@ static void draw_setting_row ( struct settings_ui *ui ) {
sizeof ( text.u.setting.name ) );
/* Construct space-padded value */
value = ui->row.buf;
if ( ! ( value && value[0] ) )
value = ui->row.value;
if ( ! *value )
value = "<not specified>";
curs_offset = string_copy ( text.u.setting.value, value,
sizeof ( text.u.setting.value ) );
curs_offset += offsetof ( typeof ( text ), u.setting.value );
curs_offset = ( offsetof ( typeof ( text ), u.setting.value ) +
string_copy ( text.u.setting.value, value,
sizeof ( text.u.setting.value )));
}
/* Print row */
@@ -252,7 +247,7 @@ static void draw_setting_row ( struct settings_ui *ui ) {
static int edit_setting ( struct settings_ui *ui, int key ) {
assert ( ui->row.setting.name != NULL );
ui->row.editing = 1;
return edit_widget ( &ui->row.editbox.widget, key );
return edit_editbox ( &ui->row.editbox, key );
}
/**
@@ -262,7 +257,76 @@ static int edit_setting ( struct settings_ui *ui, int key ) {
*/
static int save_setting ( struct settings_ui *ui ) {
assert ( ui->row.setting.name != NULL );
return storef_setting ( ui->settings, &ui->row.setting, ui->row.buf );
return storef_setting ( ui->settings, &ui->row.setting, ui->row.value );
}
/**
* Print message centred on specified row
*
* @v row Row
* @v fmt printf() format string
* @v args printf() argument list
*/
static void vmsg ( unsigned int row, const char *fmt, va_list args ) {
char buf[COLS];
size_t len;
len = vsnprintf ( buf, sizeof ( buf ), fmt, args );
mvprintw ( row, ( ( COLS - len ) / 2 ), "%s", buf );
}
/**
* Print message centred on specified row
*
* @v row Row
* @v fmt printf() format string
* @v .. printf() arguments
*/
static void msg ( unsigned int row, const char *fmt, ... ) {
va_list args;
va_start ( args, fmt );
vmsg ( row, fmt, args );
va_end ( args );
}
/**
* Clear message on specified row
*
* @v row Row
*/
static void clearmsg ( unsigned int row ) {
move ( row, 0 );
clrtoeol();
}
/**
* Print alert message
*
* @v fmt printf() format string
* @v args printf() argument list
*/
static void valert ( const char *fmt, va_list args ) {
clearmsg ( ALERT_ROW );
color_set ( CPAIR_ALERT, NULL );
vmsg ( ALERT_ROW, fmt, args );
sleep ( 2 );
color_set ( CPAIR_NORMAL, NULL );
clearmsg ( ALERT_ROW );
}
/**
* Print alert message
*
* @v fmt printf() format string
* @v ... printf() arguments
*/
static void alert ( const char *fmt, ... ) {
va_list args;
va_start ( args, fmt );
valert ( fmt, args );
va_end ( args );
}
/**
@@ -379,8 +443,8 @@ static void select_settings ( struct settings_ui *ui,
static int main_loop ( struct settings *settings ) {
struct settings_ui ui;
unsigned int previous;
unsigned int move;
int redraw = 1;
int move;
int key;
int rc;
@@ -410,17 +474,17 @@ static int main_loop ( struct settings *settings ) {
assert ( ui.row.setting.name != NULL );
/* Redraw edit box */
draw_widget ( &ui.row.editbox.widget );
color_set ( CPAIR_EDIT, NULL );
draw_editbox ( &ui.row.editbox );
color_set ( CPAIR_NORMAL, NULL );
/* Process keypress */
key = edit_setting ( &ui, getkey ( 0 ) );
switch ( key ) {
case CR:
case LF:
if ( ( rc = save_setting ( &ui ) ) != 0 ) {
alert ( ALERT_ROW, " %s ",
strerror ( rc ) );
}
if ( ( rc = save_setting ( &ui ) ) != 0 )
alert ( " %s ", strerror ( rc ) );
/* Fall through */
case CTRL_C:
select_setting_row ( &ui, ui.scroll.current );
@@ -457,13 +521,12 @@ static int main_loop ( struct settings *settings ) {
break;
if ( ( rc = delete_setting ( ui.settings,
&ui.row.setting ) ) != 0 ){
alert ( ALERT_ROW, " %s ", strerror ( rc ) );
alert ( " %s ", strerror ( rc ) );
}
select_setting_row ( &ui, ui.scroll.current );
redraw = 1;
break;
case CTRL_X:
select_setting_row ( &ui, -1U );
return 0;
case CR:
case LF:
+1 -1
View File
@@ -76,7 +76,7 @@ assert_printf ( const char *fmt, ... ) asm ( "printf" );
#define build_assert( condition ) \
do { \
if ( ! (condition) ) { \
extern void __attribute__ (( warning ( \
extern void __attribute__ (( error ( \
"build_assert(" #condition ") failed" \
) )) _C2 ( build_assert_, __LINE__ ) ( void ); \
_C2 ( build_assert_, __LINE__ ) (); \
-3
View File
@@ -12,9 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stdint.h>
#include <string.h>
/** Treat separator as optional while decoding */
#define HEX_DECODE_OPTIONAL 0x80
/**
* Calculate length of base16-encoded data
*
-2
View File
@@ -12,7 +12,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <stddef.h>
#include <ipxe/uaccess.h>
struct net_device;
struct cached_dhcp_packet;
extern struct cached_dhcp_packet cached_dhcpack;
@@ -22,6 +21,5 @@ extern struct cached_dhcp_packet cached_pxebs;
extern int cachedhcp_record ( struct cached_dhcp_packet *cache,
unsigned int vlan, userptr_t data,
size_t max_len );
extern void cachedhcp_recycle ( struct net_device *netdev );
#endif /* _IPXE_CACHEDHCP_H */
+3 -3
View File
@@ -77,19 +77,19 @@ static void _cbc_name ## _setiv ( void *ctx, const void *iv, \
size_t ivlen ) { \
struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
cbc_setiv ( &_cbc_name ## _ctx->raw_ctx, iv, ivlen, \
&_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
&_raw_cipher, &aes_cbc_ctx->cbc_ctx ); \
} \
static void _cbc_name ## _encrypt ( void *ctx, const void *src, \
void *dst, size_t len ) { \
struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
cbc_encrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \
&_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
&_raw_cipher, &aes_cbc_ctx->cbc_ctx ); \
} \
static void _cbc_name ## _decrypt ( void *ctx, const void *src, \
void *dst, size_t len ) { \
struct _cbc_name ## _context * _cbc_name ## _ctx = ctx; \
cbc_decrypt ( &_cbc_name ## _ctx->raw_ctx, src, dst, len, \
&_raw_cipher, &_cbc_name ## _ctx->cbc_ctx ); \
&_raw_cipher, &aes_cbc_ctx->cbc_ctx ); \
} \
struct cipher_algorithm _cbc_cipher = { \
.name = #_cbc_name, \
+44 -55
View File
@@ -212,37 +212,34 @@ struct elliptic_curve {
void *result );
};
static inline __attribute__ (( always_inline )) void
digest_init ( struct digest_algorithm *digest, void *ctx ) {
static inline void digest_init ( struct digest_algorithm *digest,
void *ctx ) {
digest->init ( ctx );
}
static inline __attribute__ (( always_inline )) void
digest_update ( struct digest_algorithm *digest, void *ctx,
const void *data, size_t len ) {
static inline void digest_update ( struct digest_algorithm *digest,
void *ctx, const void *data, size_t len ) {
digest->update ( ctx, data, len );
}
static inline __attribute__ (( always_inline )) void
digest_final ( struct digest_algorithm *digest, void *ctx, void *out ) {
static inline void digest_final ( struct digest_algorithm *digest,
void *ctx, void *out ) {
digest->final ( ctx, out );
}
static inline __attribute__ (( always_inline )) int
cipher_setkey ( struct cipher_algorithm *cipher, void *ctx,
const void *key, size_t keylen ) {
static inline int cipher_setkey ( struct cipher_algorithm *cipher,
void *ctx, const void *key, size_t keylen ) {
return cipher->setkey ( ctx, key, keylen );
}
static inline __attribute__ (( always_inline )) void
cipher_setiv ( struct cipher_algorithm *cipher, void *ctx,
const void *iv, size_t ivlen ) {
static inline void cipher_setiv ( struct cipher_algorithm *cipher,
void *ctx, const void *iv, size_t ivlen ) {
cipher->setiv ( ctx, iv, ivlen );
}
static inline __attribute__ (( always_inline )) void
cipher_encrypt ( struct cipher_algorithm *cipher, void *ctx,
const void *src, void *dst, size_t len ) {
static inline void cipher_encrypt ( struct cipher_algorithm *cipher,
void *ctx, const void *src, void *dst,
size_t len ) {
cipher->encrypt ( ctx, src, dst, len );
}
#define cipher_encrypt( cipher, ctx, src, dst, len ) do { \
@@ -250,9 +247,9 @@ cipher_encrypt ( struct cipher_algorithm *cipher, void *ctx,
cipher_encrypt ( (cipher), (ctx), (src), (dst), (len) ); \
} while ( 0 )
static inline __attribute__ (( always_inline )) void
cipher_decrypt ( struct cipher_algorithm *cipher, void *ctx,
const void *src, void *dst, size_t len ) {
static inline void cipher_decrypt ( struct cipher_algorithm *cipher,
void *ctx, const void *src, void *dst,
size_t len ) {
cipher->decrypt ( ctx, src, dst, len );
}
#define cipher_decrypt( cipher, ctx, src, dst, len ) do { \
@@ -260,79 +257,71 @@ cipher_decrypt ( struct cipher_algorithm *cipher, void *ctx,
cipher_decrypt ( (cipher), (ctx), (src), (dst), (len) ); \
} while ( 0 )
static inline __attribute__ (( always_inline )) void
cipher_auth ( struct cipher_algorithm *cipher, void *ctx, void *auth ) {
static inline void cipher_auth ( struct cipher_algorithm *cipher, void *ctx,
void *auth ) {
cipher->auth ( ctx, auth );
}
static inline __attribute__ (( always_inline )) int
is_stream_cipher ( struct cipher_algorithm *cipher ) {
static inline int is_stream_cipher ( struct cipher_algorithm *cipher ) {
return ( cipher->blocksize == 1 );
}
static inline __attribute__ (( always_inline )) int
is_block_cipher ( struct cipher_algorithm *cipher ) {
static inline int is_block_cipher ( struct cipher_algorithm *cipher ) {
return ( cipher->blocksize > 1 );
}
static inline __attribute__ (( always_inline )) int
is_auth_cipher ( struct cipher_algorithm *cipher ) {
static inline int is_auth_cipher ( struct cipher_algorithm *cipher ) {
return cipher->authsize;
}
static inline __attribute__ (( always_inline )) int
pubkey_init ( struct pubkey_algorithm *pubkey, void *ctx,
const void *key, size_t key_len ) {
static inline int pubkey_init ( struct pubkey_algorithm *pubkey, void *ctx,
const void *key, size_t key_len ) {
return pubkey->init ( ctx, key, key_len );
}
static inline __attribute__ (( always_inline )) size_t
pubkey_max_len ( struct pubkey_algorithm *pubkey, void *ctx ) {
static inline size_t pubkey_max_len ( struct pubkey_algorithm *pubkey,
void *ctx ) {
return pubkey->max_len ( ctx );
}
static inline __attribute__ (( always_inline )) int
pubkey_encrypt ( struct pubkey_algorithm *pubkey, void *ctx,
const void *data, size_t len, void *out ) {
static inline int pubkey_encrypt ( struct pubkey_algorithm *pubkey, void *ctx,
const void *data, size_t len, void *out ) {
return pubkey->encrypt ( ctx, data, len, out );
}
static inline __attribute__ (( always_inline )) int
pubkey_decrypt ( struct pubkey_algorithm *pubkey, void *ctx,
const void *data, size_t len, void *out ) {
static inline int pubkey_decrypt ( struct pubkey_algorithm *pubkey, void *ctx,
const void *data, size_t len, void *out ) {
return pubkey->decrypt ( ctx, data, len, out );
}
static inline __attribute__ (( always_inline )) int
pubkey_sign ( struct pubkey_algorithm *pubkey, void *ctx,
struct digest_algorithm *digest, const void *value,
void *signature ) {
static inline int pubkey_sign ( struct pubkey_algorithm *pubkey, void *ctx,
struct digest_algorithm *digest,
const void *value, void *signature ) {
return pubkey->sign ( ctx, digest, value, signature );
}
static inline __attribute__ (( always_inline )) int
pubkey_verify ( struct pubkey_algorithm *pubkey, void *ctx,
struct digest_algorithm *digest, const void *value,
const void *signature, size_t signature_len ) {
static inline int pubkey_verify ( struct pubkey_algorithm *pubkey, void *ctx,
struct digest_algorithm *digest,
const void *value, const void *signature,
size_t signature_len ) {
return pubkey->verify ( ctx, digest, value, signature, signature_len );
}
static inline __attribute__ (( always_inline )) void
pubkey_final ( struct pubkey_algorithm *pubkey, void *ctx ) {
static inline void pubkey_final ( struct pubkey_algorithm *pubkey, void *ctx ) {
pubkey->final ( ctx );
}
static inline __attribute__ (( always_inline )) int
pubkey_match ( struct pubkey_algorithm *pubkey,
const void *private_key, size_t private_key_len,
const void *public_key, size_t public_key_len ) {
static inline int pubkey_match ( struct pubkey_algorithm *pubkey,
const void *private_key,
size_t private_key_len, const void *public_key,
size_t public_key_len ) {
return pubkey->match ( private_key, private_key_len, public_key,
public_key_len );
}
static inline __attribute__ (( always_inline )) int
elliptic_multiply ( struct elliptic_curve *curve,
const void *base, const void *scalar, void *result ) {
static inline int elliptic_multiply ( struct elliptic_curve *curve,
const void *base, const void *scalar,
void *result ) {
return curve->multiply ( base, scalar, result );
}
-91
View File
@@ -1,91 +0,0 @@
#ifndef _IPXE_DES_H
#define _IPXE_DES_H
/** @file
*
* DES algorithm
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/crypto.h>
/** A DES 32-bit dword value
*
* DES views data as 64-bit big-endian values, typically handled as a
* most-significant "left" half and a least-significant "right" half.
*/
union des_dword {
/** Raw bytes */
uint8_t byte[4];
/** 32-bit big-endian dword */
uint32_t dword;
};
/** A DES 64-bit block */
union des_block {
/** Raw bytes */
uint8_t byte[8];
/** 32-bit big-endian dwords */
uint32_t dword[2];
/** Named left and right halves */
struct {
/** Left (most significant) half */
union des_dword left;
/** Right (least significant) half */
union des_dword right;
};
/** Named "C" and "D" halves */
struct {
/** "C" (most significant) half */
union des_dword c;
/** "D" (least significant) half */
union des_dword d;
};
};
/** DES blocksize */
#define DES_BLOCKSIZE sizeof ( union des_block )
/** A DES round key
*
* A DES round key is a 48-bit value, consumed as 8 groups of 6 bits.
* We store these as 8 separate bytes, for simplicity of consumption.
*/
union des_round_key {
/** Raw bytes */
uint8_t byte[8];
/** 32-bit big-endian dwords */
uint32_t dword[2];
/** 6-bit step key byte
*
* There are 8 steps within a DES round (one step per S-box).
* Each step requires six bits of the round key.
*
* As an optimisation, we store the least significant of the 6
* bits in the sign bit of a signed 8-bit value, and the
* remaining 5 bits in the least significant 5 bits of the
* 8-bit value. See the comments in des_sbox() for further
* details.
*/
int8_t step[8];
};
/** Number of DES rounds */
#define DES_ROUNDS 16
/** DES context */
struct des_context {
/** Round keys */
union des_round_key rkey[DES_ROUNDS];
};
/** DES context size */
#define DES_CTX_SIZE sizeof ( struct des_context )
extern struct cipher_algorithm des_algorithm;
extern struct cipher_algorithm des_ecb_algorithm;
extern struct cipher_algorithm des_cbc_algorithm;
#endif /* _IPXE_DES_H */
+1 -1
View File
@@ -276,6 +276,6 @@ static inline void ipv6_all_dhcp_relay_and_servers ( struct in6_addr *addr ) {
}
extern int start_dhcpv6 ( struct interface *job, struct net_device *netdev,
struct in6_addr *router, int stateful );
int stateful );
#endif /* _IPXE_DHCPV6_H */
-66
View File
@@ -1,66 +0,0 @@
#ifndef _IPXE_DYNUI_H
#define _IPXE_DYNUI_H
/** @file
*
* Dynamic user interfaces
*
*/
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <ipxe/list.h>
/** A dynamic user interface */
struct dynamic_ui {
/** List of dynamic user interfaces */
struct list_head list;
/** Name */
const char *name;
/** Title */
const char *title;
/** Dynamic user interface items */
struct list_head items;
/** Number of user interface items */
unsigned int count;
};
/** A dynamic user interface item */
struct dynamic_item {
/** List of dynamic user interface items */
struct list_head list;
/** Name */
const char *name;
/** Text */
const char *text;
/** Index */
unsigned int index;
/** Flags */
unsigned int flags;
/** Shortcut key */
int shortcut;
};
/** Dynamic user interface item is default selection */
#define DYNUI_DEFAULT 0x0001
/** Dynamic user interface item represents a secret */
#define DYNUI_SECRET 0x0002
extern struct dynamic_ui * create_dynui ( const char *name, const char *title );
extern struct dynamic_item * add_dynui_item ( struct dynamic_ui *dynui,
const char *name,
const char *text,
unsigned int flags,
int shortcut );
extern void destroy_dynui ( struct dynamic_ui *dynui );
extern struct dynamic_ui * find_dynui ( const char *name );
extern struct dynamic_item * dynui_item ( struct dynamic_ui *dynui,
unsigned int index );
extern struct dynamic_item * dynui_shortcut ( struct dynamic_ui *dynui,
int key );
extern int show_menu ( struct dynamic_ui *dynui, unsigned long timeout,
const char *select, struct dynamic_item **selected );
extern int show_form ( struct dynamic_ui *dynui );
#endif /* _IPXE_DYNUI_H */
-31
View File
@@ -60,35 +60,6 @@ struct eap_md5 {
uint8_t value[0];
} __attribute__ (( packed ));
/** EAP MS-CHAPv2 request/response */
#define EAP_TYPE_MSCHAPV2 26
/** EAP MS-CHAPv2 request/response type data */
struct eap_mschapv2 {
/** Code
*
* This is in the same namespace as the EAP header's code
* field, but is used to extend the handshake by allowing for
* "success request" and "success response" packets.
*/
uint8_t code;
/** Identifier
*
* This field serves no purposes: it always has the same value
* as the EAP header's identifier field (located 5 bytes
* earlier in the same packet).
*/
uint8_t id;
/** Length
*
* This field serves no purpose: it always has the same value
* as the EAP header's length field (located 5 bytes earlier
* in the same packet), minus the 5 byte length of the EAP
* header.
*/
uint16_t len;
} __attribute__ (( packed ));
/** EAP success */
#define EAP_CODE_SUCCESS 3
@@ -195,8 +166,6 @@ struct eap_method {
/** Declare an EAP method */
#define __eap_method __table_entry ( EAP_METHODS, 01 )
extern int eap_tx_response ( struct eap_supplicant *supplicant,
const void *rsp, size_t rsp_len );
extern int eap_rx ( struct eap_supplicant *supplicant,
const void *data, size_t len );
+31 -19
View File
@@ -11,39 +11,51 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
#include <curses.h>
#include <ipxe/editstring.h>
#include <ipxe/widget.h>
/** An editable text box widget */
struct edit_box {
/** Text widget */
struct widget widget;
/** Editable string */
struct edit_string string;
/** Containing window */
WINDOW *win;
/** Row */
unsigned int row;
/** Starting column */
unsigned int col;
/** Width */
unsigned int width;
/** First displayed character */
unsigned int first;
/** Flags */
unsigned int flags;
};
extern struct widget_operations editbox_operations;
/** Editable text box widget flags */
enum edit_box_flags {
/** Show stars instead of contents (for password widgets) */
EDITBOX_STARS = 0x0001,
};
extern void init_editbox ( struct edit_box *box, char *buf, size_t len,
WINDOW *win, unsigned int row, unsigned int col,
unsigned int width, unsigned int flags )
__attribute__ (( nonnull (1, 2) ));
extern void draw_editbox ( struct edit_box *box ) __nonnull;
static inline int edit_editbox ( struct edit_box *box, int key ) __nonnull;
/**
* Initialise text box widget
* Edit text box widget
*
* @v box Editable text box widget
* @v row Row
* @v col Starting column
* @v width Width
* @v flags Flags
* @v buf Dynamically allocated string buffer
* @v key Key pressed by user
* @ret key Key returned to application, or zero
*
* You must call draw_editbox() to update the display after calling
* edit_editbox().
*
*/
static inline __attribute__ (( always_inline )) void
init_editbox ( struct edit_box *box, unsigned int row, unsigned int col,
unsigned int width, unsigned int flags, char **buf ) {
init_widget ( &box->widget, &editbox_operations, row, col,
width, ( flags | WIDGET_EDITABLE ) );
init_editstring ( &box->string, buf );
if ( *buf )
box->string.cursor = strlen ( *buf );
static inline int edit_editbox ( struct edit_box *box, int key ) {
return edit_string ( &box->string, key );
}
#endif /* _IPXE_EDITBOX_H */
+12 -21
View File
@@ -11,8 +11,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
/** An editable string */
struct edit_string {
/** Dynamically allocated string buffer */
char **buf;
/** Buffer for string */
char *buf;
/** Size of buffer (including terminating NUL) */
size_t len;
/** Cursor position */
unsigned int cursor;
@@ -30,28 +32,17 @@ struct edit_string {
* Initialise editable string
*
* @v string Editable string
* @v buf Dynamically allocated string buffer
*
* The @c buf parameter must be the address of a caller-provided
* pointer to a NUL-terminated string allocated using malloc() (or
* equivalent, such as strdup()). Any edits made to the string will
* realloc() the string buffer as needed.
*
* The caller may choose leave the initial string buffer pointer as @c
* NULL, in which case it will be allocated upon the first attempt to
* insert a character into the buffer. If the caller does this, then
* it must be prepared to find the pointer still @c NULL after
* editing, since the user may never attempt to insert any characters.
* @v buf Buffer for string
* @v len Length of buffer
*/
static inline __nonnull void init_editstring ( struct edit_string *string,
char **buf ) {
static inline void init_editstring ( struct edit_string *string, char *buf,
size_t len ) {
string->buf = buf;
string->len = len;
}
extern __attribute__ (( nonnull ( 1 ) )) int
replace_string ( struct edit_string *string, const char *replacement );
extern __nonnull int edit_string ( struct edit_string *string, int key );
extern void replace_string ( struct edit_string *string,
const char *replacement ) __nonnull;
extern int edit_string ( struct edit_string *string, int key ) __nonnull;
#endif /* _IPXE_EDITSTRING_H */
-1
View File
@@ -49,7 +49,6 @@ typedef struct {
UINT64 Attribute;
///
/// The Null-terminated name of the file.
/// For a root directory, the name is an empty string.
///
CHAR16 FileName[1];
} EFI_FILE_INFO;

Some files were not shown because too many files have changed in this diff Show More