Compare commits
67
Commits
nosyslinux
..
x25519
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0dc80d20d3 | ||
|
|
8f6a9399b3 | ||
|
|
a881a26061 | ||
|
|
b234226dbc | ||
|
|
8e2469c861 | ||
|
|
989dbe0bc4 | ||
|
|
6f70e8be83 | ||
|
|
17135c83fb | ||
|
|
27398f1360 | ||
|
|
de8a0821c7 | ||
|
|
2eea04c02c | ||
|
|
908174ec7e | ||
|
|
bac13ba1f6 | ||
|
|
13e390d54e | ||
|
|
26d3ef062b | ||
|
|
4b7d9a6af0 | ||
|
|
6d29415c89 | ||
|
|
6ca597eee9 | ||
|
|
e66552eeed | ||
|
|
08fcb0e8fb | ||
|
|
c6226f104e | ||
|
|
0abb3e85e5 | ||
|
|
4ed7a5718f | ||
|
|
fa62213231 | ||
|
|
119c415ee4 | ||
|
|
9e92c39894 | ||
|
|
3fc1b407d2 | ||
|
|
0958e01463 | ||
|
|
337880deaa | ||
|
|
f22879ca99 | ||
|
|
98dd25a3bb | ||
|
|
a147245f1a | ||
|
|
c3dd3168c9 | ||
|
|
b829b1750d | ||
|
|
03ff1bb99a | ||
|
|
18582a05fc | ||
|
|
6714b20ea2 | ||
|
|
b37d89db90 | ||
|
|
cc858acd32 | ||
|
|
b30a0987e2 | ||
|
|
3d8a614657 | ||
|
|
a9e89787d0 | ||
|
|
678a60f61d | ||
|
|
8c8ead2530 | ||
|
|
77b07ea4fd | ||
|
|
d8f9c221ed | ||
|
|
595b1796f6 | ||
|
|
1bd01b761f | ||
|
|
5524bb9832 | ||
|
|
36e1a559a2 | ||
|
|
1f3a37e342 | ||
|
|
74ec00a9f3 | ||
|
|
f883203132 | ||
|
|
115707c0ed | ||
|
|
ff0f860483 | ||
|
|
8b14652e50 | ||
|
|
56cc61a168 | ||
|
|
cac3a584dc | ||
|
|
8cbf248198 | ||
|
|
8b1d34badf | ||
|
|
cc1e27e525 | ||
|
|
ae4e85bde9 | ||
|
|
eeb7cd56e5 | ||
|
|
0aa2e4ec96 | ||
|
|
9e99a55b31 | ||
|
|
c1834f323f | ||
|
|
d5c08f78bd |
@@ -46,11 +46,19 @@ def create_snapshot(region, description, image):
|
||||
return snapshot_id
|
||||
|
||||
|
||||
def import_image(region, name, architecture, image, public):
|
||||
def import_image(region, name, architecture, image, public, overwrite):
|
||||
"""Import an AMI image"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
description = '%s (%s)' % (name, architecture)
|
||||
images = client.describe_images(Filters=[{'Name': 'name',
|
||||
'Values': [description]}])
|
||||
if overwrite and images['Images']:
|
||||
images = images['Images'][0]
|
||||
image_id = images['ImageId']
|
||||
snapshot_id = images['BlockDeviceMappings'][0]['Ebs']['SnapshotId']
|
||||
resource.Image(image_id).deregister()
|
||||
resource.Snapshot(snapshot_id).delete()
|
||||
snapshot_id = create_snapshot(region=region, description=description,
|
||||
image=image)
|
||||
client.get_waiter('snapshot_completed').wait(SnapshotIds=[snapshot_id])
|
||||
@@ -88,6 +96,8 @@ parser.add_argument('--name', '-n',
|
||||
help="Image name")
|
||||
parser.add_argument('--public', '-p', action='store_true',
|
||||
help="Make image public")
|
||||
parser.add_argument('--overwrite', action='store_true',
|
||||
help="Overwrite any existing image with same name")
|
||||
parser.add_argument('--region', '-r', action='append',
|
||||
help="AWS region(s)")
|
||||
parser.add_argument('--wiki', '-w', metavar='FILE',
|
||||
@@ -115,7 +125,8 @@ with ThreadPoolExecutor(max_workers=len(imports)) as executor:
|
||||
name=args.name,
|
||||
architecture=architectures[image],
|
||||
image=image,
|
||||
public=args.public): (region, image)
|
||||
public=args.public,
|
||||
overwrite=args.overwrite): (region, image)
|
||||
for region, image in imports}
|
||||
results = {futures[future]: future.result()
|
||||
for future in as_completed(futures)}
|
||||
|
||||
Executable
+68
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
|
||||
import boto3
|
||||
|
||||
BLOCKSIZE = 512 * 1024
|
||||
|
||||
IPXELOG_OFFSET = 16 * 1024
|
||||
|
||||
IPXELOG_MAGIC = b'iPXE LOG'
|
||||
|
||||
|
||||
def create_snapshot(region, instance_id):
|
||||
"""Create root volume snapshot"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
instance = resource.Instance(instance_id)
|
||||
volumes = list(instance.volumes.all())
|
||||
snapshot = volumes[0].create_snapshot()
|
||||
snapshot.wait_until_completed()
|
||||
return snapshot.id
|
||||
|
||||
|
||||
def get_snapshot_block(region, snapshot_id, index):
|
||||
"""Get block content from snapshot"""
|
||||
client = boto3.client('ebs', region_name=region)
|
||||
blocks = client.list_snapshot_blocks(SnapshotId=snapshot_id,
|
||||
StartingBlockIndex=index)
|
||||
token = blocks['Blocks'][0]['BlockToken']
|
||||
block = client.get_snapshot_block(SnapshotId=snapshot_id,
|
||||
BlockIndex=index,
|
||||
BlockToken=token)
|
||||
return block['BlockData'].read()
|
||||
|
||||
|
||||
def get_block0_content(region, instance_id):
|
||||
"""Get content of root volume block zero from instance"""
|
||||
client = boto3.client('ec2', region_name=region)
|
||||
resource = boto3.resource('ec2', region_name=region)
|
||||
snapshot_id = create_snapshot(region, instance_id)
|
||||
block = get_snapshot_block(region, snapshot_id, 0)
|
||||
resource.Snapshot(snapshot_id).delete()
|
||||
return block
|
||||
|
||||
|
||||
def get_int13con_output(region, instance_id):
|
||||
"""Get INT13 console output"""
|
||||
block = get_block0_content(region, instance_id)
|
||||
logpart = block[IPXELOG_OFFSET:]
|
||||
magic = logpart[:len(IPXELOG_MAGIC)]
|
||||
if magic != IPXELOG_MAGIC:
|
||||
raise ValueError("Invalid log magic signature")
|
||||
log = logpart[len(IPXELOG_MAGIC):].split(b'\0')[0]
|
||||
return log.decode()
|
||||
|
||||
|
||||
# Parse command-line arguments
|
||||
parser = argparse.ArgumentParser(description="Get AWS INT13 console output")
|
||||
parser.add_argument('--region', '-r', help="AWS region")
|
||||
parser.add_argument('id', help="Instance ID")
|
||||
args = parser.parse_args()
|
||||
|
||||
# Get console output from INT13CON partition
|
||||
output = get_int13con_output(args.region, args.id)
|
||||
|
||||
# Print console output
|
||||
print(output)
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
.toolcheck
|
||||
.echocheck
|
||||
TAGS*
|
||||
bin*
|
||||
bin-*
|
||||
|
||||
@@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint32_t multiplicand_element;
|
||||
@@ -62,9 +66,9 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@@ -73,7 +77,7 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "umull %1, %2, %5, %6\n\t"
|
||||
"ldr %3, [%0]\n\t"
|
||||
|
||||
@@ -310,7 +310,9 @@ bigint_done_raw ( const uint32_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", %progbits
|
||||
.text
|
||||
.thumb
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", %progbits
|
||||
.text
|
||||
.arm
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint64_t multiplicand_element;
|
||||
@@ -63,9 +67,9 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@@ -74,7 +78,7 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mul %1, %6, %7\n\t"
|
||||
"umulh %2, %6, %7\n\t"
|
||||
|
||||
@@ -311,7 +311,9 @@ bigint_done_raw ( const uint64_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@@ -2,8 +2,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code32
|
||||
.arch i386
|
||||
|
||||
/* Must match jmp_buf structure layout */
|
||||
.struct 0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code32
|
||||
.arch i386
|
||||
|
||||
.section ".data", "aw", @progbits
|
||||
|
||||
@@ -37,19 +37,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint64_t multiplicand_element;
|
||||
@@ -64,9 +68,9 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@@ -75,7 +79,7 @@ void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mul.d %1, %6, %7\n\t"
|
||||
"mulh.du %2, %6, %7\n\t"
|
||||
|
||||
@@ -53,34 +53,37 @@ bigint_add_raw ( const uint64_t *addend0, uint64_t *value0,
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_addend_i;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
__asm__ __volatile__ ( "move $t0, $zero\n"
|
||||
"1:\n\t"
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load addend[i] and value[i] */
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
/* Add carry flag and addend */
|
||||
"add.d %4, %4, %5\n\t"
|
||||
"sltu %6, %4, %5\n\t"
|
||||
"add.d %4, %4, %3\n\t"
|
||||
"sltu %5, %4, %3\n\t"
|
||||
"or %5, %5, %6\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %4, %1, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
|
||||
"add.d %4, %4, $t0\n\t"
|
||||
"sltu $t0, %4, $t0\n\t"
|
||||
|
||||
"add.d %4, %4, %3\n\t"
|
||||
"sltu $t1, %4, %3\n\t"
|
||||
|
||||
"or $t0, $t0, $t1\n\t"
|
||||
"st.d %4, %1, 0\n\t"
|
||||
"addi.d %1, %1, 8\n\t"
|
||||
"addi.w %2, %2, -1\n\t"
|
||||
"bnez %2, 1b"
|
||||
"bnez %2, 1b\n\t"
|
||||
: "=r" ( discard_addend ),
|
||||
"=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_addend_i ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( addend0 ),
|
||||
"1" ( value0 ),
|
||||
"2" ( size )
|
||||
: "t0", "t1" );
|
||||
: "0" ( addend0 ), "1" ( value0 ),
|
||||
"2" ( size ), "5" ( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,35 +96,43 @@ bigint_add_raw ( const uint64_t *addend0, uint64_t *value0,
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
|
||||
unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_subtrahend;
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_subtrahend_i;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
unsigned int flag = 0;
|
||||
|
||||
discard_subtrahend = (uint64_t*) subtrahend0;
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
|
||||
do {
|
||||
discard_subtrahend_i = *discard_subtrahend;
|
||||
discard_subtrahend++;
|
||||
discard_value_i = *discard_value;
|
||||
|
||||
discard_value_i = discard_value_i - discard_subtrahend_i - flag;
|
||||
|
||||
if ( *discard_value < (discard_subtrahend_i + flag)) {
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
*discard_value = discard_value_i;
|
||||
|
||||
discard_value++;
|
||||
discard_size -= 1;
|
||||
} while (discard_size != 0);
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load subtrahend[i] and value[i] */
|
||||
"ld.d %3, %0, 0\n\t"
|
||||
"ld.d %4, %1, 0\n\t"
|
||||
/* Subtract carry flag and subtrahend */
|
||||
"sltu %6, %4, %5\n\t"
|
||||
"sub.d %4, %4, %5\n\t"
|
||||
"sltu %5, %4, %3\n\t"
|
||||
"sub.d %4, %4, %3\n\t"
|
||||
"or %5, %5, %6\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %4, %1, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"addi.d %1, %1, 8\n\t"
|
||||
"addi.w %2, %2, -1\n\t"
|
||||
"bnez %2, 1b\n\t"
|
||||
: "=r" ( discard_subtrahend ),
|
||||
"=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_subtrahend_i ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( subtrahend0 ), "1" ( value0 ),
|
||||
"2" ( size ), "5" ( 0 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,30 +143,37 @@ bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_rol_raw ( uint64_t *value0, unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
uint64_t current_value_i;
|
||||
unsigned int flag = 0;
|
||||
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
do {
|
||||
discard_value_i = *discard_value;
|
||||
current_value_i = discard_value_i;
|
||||
|
||||
discard_value_i += discard_value_i + flag;
|
||||
|
||||
if (discard_value_i < current_value_i) {
|
||||
flag = 1;
|
||||
} else {
|
||||
flag = 0;
|
||||
}
|
||||
|
||||
*discard_value = discard_value_i;
|
||||
discard_value++;
|
||||
discard_size -= 1;
|
||||
} while ( discard_size != 0 );
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load value[i] */
|
||||
"ld.d %2, %0, 0\n\t"
|
||||
/* Shift left */
|
||||
"rotri.d %2, %2, 63\n\t"
|
||||
"andi %4, %2, 1\n\t"
|
||||
"xor %2, %2, %4\n\t"
|
||||
"or %2, %2, %3\n\t"
|
||||
"move %3, %4\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %2, %0, 0\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, 8\n\t"
|
||||
"addi.w %1, %1, -1\n\t"
|
||||
"bnez %1, 1b\n\t"
|
||||
: "=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( value0 ), "1" ( size ), "3" ( 0 )
|
||||
: "cc" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,27 +184,37 @@ bigint_rol_raw ( uint64_t *value0, unsigned int size ) {
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
bigint_ror_raw ( uint64_t *value0, unsigned int size ) {
|
||||
bigint_t ( size ) __attribute__ (( may_alias )) *value =
|
||||
( ( void * ) value0 );
|
||||
uint64_t *discard_value;
|
||||
uint64_t discard_value_i;
|
||||
uint64_t discard_value_j;
|
||||
uint64_t discard_carry;
|
||||
uint64_t discard_temp;
|
||||
unsigned int discard_size;
|
||||
|
||||
discard_value = value0;
|
||||
discard_size = size;
|
||||
|
||||
discard_value_j = 0;
|
||||
|
||||
do {
|
||||
discard_size -= 1;
|
||||
|
||||
discard_value_i = *(discard_value + discard_size);
|
||||
|
||||
discard_value_j = (discard_value_j << 63) | (discard_value_i >> 1);
|
||||
|
||||
*(discard_value + discard_size) = discard_value_j;
|
||||
|
||||
discard_value_j = discard_value_i;
|
||||
} while ( discard_size > 0 );
|
||||
__asm__ __volatile__ ( "\n1:\n\t"
|
||||
/* Load value[i] */
|
||||
"ld.d %2, %0, -8\n\t"
|
||||
/* Shift right */
|
||||
"andi %4, %2, 1\n\t"
|
||||
"xor %2, %2, %4\n\t"
|
||||
"or %2, %2, %3\n\t"
|
||||
"move %3, %4\n\t"
|
||||
"rotri.d %2, %2, 1\n\t"
|
||||
/* Store value[i] */
|
||||
"st.d %2, %0, -8\n\t"
|
||||
/* Loop */
|
||||
"addi.d %0, %0, -8\n\t"
|
||||
"addi.w %1, %1, -1\n\t"
|
||||
"bnez %1, 1b\n\t"
|
||||
: "=r" ( discard_value ),
|
||||
"=r" ( discard_size ),
|
||||
"=r" ( discard_value_i ),
|
||||
"=r" ( discard_carry ),
|
||||
"=r" ( discard_temp ),
|
||||
"+m" ( *value )
|
||||
: "0" ( value0 + size ), "1" ( size ), "3" ( 0 )
|
||||
: "cc" );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,7 +358,9 @@ bigint_done_raw ( const uint64_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint64_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint64_t *multiplier0,
|
||||
uint64_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint64_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
* Set/clear CF on the stack as appropriate, assumes stack is as it should
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.arch i386
|
||||
|
||||
#ifdef __x86_64__
|
||||
#define STACK_SIZE 8192
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
* Internal stack
|
||||
|
||||
@@ -36,19 +36,23 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* Multiply big integers
|
||||
*
|
||||
* @v multiplicand0 Element 0 of big integer to be multiplied
|
||||
* @v multiplicand_size Number of elements in multiplicand
|
||||
* @v multiplier0 Element 0 of big integer to be multiplied
|
||||
* @v multiplier_size Number of elements in multiplier
|
||||
* @v result0 Element 0 of big integer to hold result
|
||||
* @v size Number of elements
|
||||
*/
|
||||
void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *result0, unsigned int size ) {
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplicand =
|
||||
( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( size ) __attribute__ (( may_alias )) *multiplier =
|
||||
( ( const void * ) multiplier0 );
|
||||
bigint_t ( size * 2 ) __attribute__ (( may_alias )) *result =
|
||||
( ( void * ) result0 );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *result0 ) {
|
||||
unsigned int result_size = ( multiplicand_size + multiplier_size );
|
||||
const bigint_t ( multiplicand_size ) __attribute__ (( may_alias ))
|
||||
*multiplicand = ( ( const void * ) multiplicand0 );
|
||||
const bigint_t ( multiplier_size ) __attribute__ (( may_alias ))
|
||||
*multiplier = ( ( const void * ) multiplier0 );
|
||||
bigint_t ( result_size ) __attribute__ (( may_alias ))
|
||||
*result = ( ( void * ) result0 );
|
||||
unsigned int i;
|
||||
unsigned int j;
|
||||
uint32_t multiplicand_element;
|
||||
@@ -62,9 +66,9 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
memset ( result, 0, sizeof ( *result ) );
|
||||
|
||||
/* Multiply integers one element at a time */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
for ( i = 0 ; i < multiplicand_size ; i++ ) {
|
||||
multiplicand_element = multiplicand->element[i];
|
||||
for ( j = 0 ; j < size ; j++ ) {
|
||||
for ( j = 0 ; j < multiplier_size ; j++ ) {
|
||||
multiplier_element = multiplier->element[j];
|
||||
result_elements = &result->element[ i + j ];
|
||||
/* Perform a single multiply, and add the
|
||||
@@ -73,7 +77,7 @@ void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
* never overflow beyond the end of the
|
||||
* result, since:
|
||||
*
|
||||
* a < 2^{n}, b < 2^{n} => ab < 2^{2n}
|
||||
* a < 2^{n}, b < 2^{m} => ab < 2^{n+m}
|
||||
*/
|
||||
__asm__ __volatile__ ( "mull %5\n\t"
|
||||
"addl %%eax, (%6,%2,4)\n\t"
|
||||
|
||||
@@ -11,9 +11,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
||||
#define PIC2_ICR 0xa0
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
.section ".text16", "ax", @progbits
|
||||
.globl undiisr
|
||||
|
||||
@@ -323,7 +323,9 @@ bigint_done_raw ( const uint32_t *value0, unsigned int size __unused,
|
||||
}
|
||||
|
||||
extern void bigint_multiply_raw ( const uint32_t *multiplicand0,
|
||||
unsigned int multiplicand_size,
|
||||
const uint32_t *multiplier0,
|
||||
uint32_t *value0, unsigned int size );
|
||||
unsigned int multiplier_size,
|
||||
uint32_t *value0 );
|
||||
|
||||
#endif /* _BITS_BIGINT_H */
|
||||
|
||||
@@ -250,8 +250,10 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
/* CODE_DEFAULT: restore default .code32/.code64 directive */
|
||||
#ifdef __x86_64__
|
||||
#define CODE_DEFAULT ".code64"
|
||||
#define STACK_DEFAULT "q"
|
||||
#else
|
||||
#define CODE_DEFAULT ".code32"
|
||||
#define STACK_DEFAULT "l"
|
||||
#endif
|
||||
|
||||
/* LINE_SYMBOL: declare a symbol for the current source code line */
|
||||
@@ -268,7 +270,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
/* REAL_CODE: declare a fragment of code that executes in real mode */
|
||||
#define REAL_CODE( asm_code_str ) \
|
||||
"push $1f\n\t" \
|
||||
"push" STACK_DEFAULT " $1f\n\t" \
|
||||
"call real_call\n\t" \
|
||||
TEXT16_CODE ( "\n1:\n\t" \
|
||||
asm_code_str \
|
||||
@@ -277,7 +279,7 @@ extern void remove_user_from_rm_stack ( userptr_t data, size_t size );
|
||||
|
||||
/* PHYS_CODE: declare a fragment of code that executes in flat physical mode */
|
||||
#define PHYS_CODE( asm_code_str ) \
|
||||
"push $1f\n\t" \
|
||||
"push" STACK_DEFAULT " $1f\n\t" \
|
||||
"call phys_call\n\t" \
|
||||
".section \".text.phys\", \"ax\", @progbits\n\t"\
|
||||
"\n" LINE_SYMBOL "\n\t" \
|
||||
|
||||
@@ -44,11 +44,11 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
static int bios_find_smbios2 ( struct smbios *smbios ) {
|
||||
struct smbios_entry entry;
|
||||
int rc;
|
||||
|
||||
/* Scan through BIOS segment to find SMBIOS entry point */
|
||||
/* Scan through BIOS segment to find SMBIOS 32-bit entry point */
|
||||
if ( ( rc = find_smbios_entry ( real_to_user ( BIOS_SEG, 0 ), 0x10000,
|
||||
&entry ) ) != 0 )
|
||||
return rc;
|
||||
@@ -62,4 +62,55 @@ static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find SMBIOS
|
||||
*
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios3 ( struct smbios *smbios ) {
|
||||
struct smbios3_entry entry;
|
||||
int rc;
|
||||
|
||||
/* Scan through BIOS segment to find SMBIOS 64-bit entry point */
|
||||
if ( ( rc = find_smbios3_entry ( real_to_user ( BIOS_SEG, 0 ), 0x10000,
|
||||
&entry ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Check that address is accessible */
|
||||
if ( entry.smbios_address > ~( ( physaddr_t ) 0 ) ) {
|
||||
DBG ( "SMBIOS3 at %08llx is inaccessible\n",
|
||||
( ( unsigned long long ) entry.smbios_address ) );
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Fill in entry point descriptor structure */
|
||||
smbios->address = phys_to_user ( entry.smbios_address );
|
||||
smbios->len = entry.smbios_len;
|
||||
smbios->count = 0;
|
||||
smbios->version = SMBIOS_VERSION ( entry.major, entry.minor );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find SMBIOS
|
||||
*
|
||||
* @v smbios SMBIOS entry point descriptor structure to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int bios_find_smbios ( struct smbios *smbios ) {
|
||||
int rc;
|
||||
|
||||
/* Use 32-bit table if present */
|
||||
if ( ( rc = bios_find_smbios2 ( smbios ) ) == 0 )
|
||||
return 0;
|
||||
|
||||
/* Otherwise, use 64-bit table if present and accessible */
|
||||
if ( ( rc = bios_find_smbios3 ( smbios ) ) == 0 )
|
||||
return 0;
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
PROVIDE_SMBIOS ( pcbios, find_smbios, bios_find_smbios );
|
||||
|
||||
@@ -24,9 +24,8 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
#define SMAP 0x534d4150
|
||||
|
||||
|
||||
@@ -165,24 +165,27 @@ static void pcicloud_init ( void ) {
|
||||
static struct pci_api *apis[] = {
|
||||
&ecam_api, &pcibios_api, &pcidirect_api
|
||||
};
|
||||
struct pci_range range;
|
||||
struct pci_device pci;
|
||||
uint32_t busdevfn;
|
||||
unsigned int i;
|
||||
int rc;
|
||||
|
||||
/* Select first API that successfully discovers an address range */
|
||||
/* Select first API that successfully discovers a PCI device */
|
||||
for ( i = 0 ; i < ( sizeof ( apis ) / sizeof ( apis[0] ) ) ; i++ ) {
|
||||
pcicloud = apis[i];
|
||||
pcicloud_discover ( 0, &range );
|
||||
if ( range.count != 0 ) {
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API\n",
|
||||
pcicloud->name );
|
||||
break;
|
||||
busdevfn = 0;
|
||||
if ( ( rc = pci_find_next ( &pci, &busdevfn ) ) == 0 ) {
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API (found "
|
||||
PCI_FMT ")\n", pcicloud->name,
|
||||
PCI_ARGS ( &pci ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* The PCI direct API can never fail discovery since the range
|
||||
* is hardcoded.
|
||||
*/
|
||||
assert ( range.count != 0 );
|
||||
/* Fall back to using final attempted API if no devices found */
|
||||
pcicloud = apis[ i - 1 ];
|
||||
DBGC ( pcicloud, "PCICLOUD selected %s API (nothing detected)\n",
|
||||
pcicloud->name );
|
||||
}
|
||||
|
||||
/** Cloud VM PCI configuration space access initialisation function */
|
||||
|
||||
@@ -375,9 +375,10 @@ int pxe_start_nbp ( void ) {
|
||||
* Notify BIOS of existence of network device
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int pxe_notify ( struct net_device *netdev ) {
|
||||
static int pxe_notify ( struct net_device *netdev, void *priv __unused ) {
|
||||
|
||||
/* Do nothing if we already have a network device */
|
||||
if ( pxe_netdev )
|
||||
|
||||
@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -207,65 +207,35 @@ struct init_fn guestinfo_init_fn __init_fn ( INIT_NORMAL ) = {
|
||||
* Create per-netdevice GuestInfo settings
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int guestinfo_net_probe ( struct net_device *netdev ) {
|
||||
struct settings *settings;
|
||||
static int guestinfo_net_probe ( struct net_device *netdev, void *priv ) {
|
||||
struct settings *settings = priv;
|
||||
int rc;
|
||||
|
||||
/* Do nothing unless we have a GuestInfo channel available */
|
||||
if ( guestinfo_channel < 0 )
|
||||
return 0;
|
||||
|
||||
/* Allocate and initialise settings block */
|
||||
settings = zalloc ( sizeof ( *settings ) );
|
||||
if ( ! settings ) {
|
||||
rc = -ENOMEM;
|
||||
goto err_alloc;
|
||||
}
|
||||
settings_init ( settings, &guestinfo_settings_operations, NULL, NULL );
|
||||
|
||||
/* Register settings */
|
||||
/* Initialise and register settings */
|
||||
settings_init ( settings, &guestinfo_settings_operations,
|
||||
&netdev->refcnt, NULL );
|
||||
if ( ( rc = register_settings ( settings, netdev_settings ( netdev ),
|
||||
"vmware" ) ) != 0 ) {
|
||||
DBGC ( settings, "GuestInfo %p could not register for %s: %s\n",
|
||||
settings, netdev->name, strerror ( rc ) );
|
||||
goto err_register;
|
||||
return rc;
|
||||
}
|
||||
DBGC ( settings, "GuestInfo %p registered for %s\n",
|
||||
settings, netdev->name );
|
||||
|
||||
return 0;
|
||||
|
||||
err_register:
|
||||
free ( settings );
|
||||
err_alloc:
|
||||
return rc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove per-netdevice GuestInfo settings
|
||||
*
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void guestinfo_net_remove ( struct net_device *netdev ) {
|
||||
struct settings *parent = netdev_settings ( netdev );
|
||||
struct settings *settings;
|
||||
|
||||
list_for_each_entry ( settings, &parent->children, siblings ) {
|
||||
if ( settings->op == &guestinfo_settings_operations ) {
|
||||
DBGC ( settings, "GuestInfo %p unregistered for %s\n",
|
||||
settings, netdev->name );
|
||||
unregister_settings ( settings );
|
||||
free ( settings );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** GuestInfo per-netdevice driver */
|
||||
struct net_driver guestinfo_net_driver __net_driver = {
|
||||
.name = "GuestInfo",
|
||||
.priv_len = sizeof ( struct settings ),
|
||||
.probe = guestinfo_net_probe,
|
||||
.remove = guestinfo_net_remove,
|
||||
};
|
||||
|
||||
@@ -6,10 +6,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define STACK_SIZE 0x2000
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
|
||||
/*
|
||||
* Find active partition
|
||||
|
||||
@@ -26,10 +26,9 @@ FILE_LICENCE ( GPL2_ONLY )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.org 0
|
||||
.arch i386
|
||||
.text
|
||||
.section ".prefix", "ax", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.globl _dsk_start
|
||||
_dsk_start:
|
||||
|
||||
|
||||
@@ -37,10 +37,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define PSP_CMDLINE_START 0x81
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
.section ".prefix", "awx", @progbits
|
||||
|
||||
signature:
|
||||
|
||||
@@ -3,10 +3,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
.globl _hd_start
|
||||
_hd_start:
|
||||
|
||||
@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/* Image compression enabled */
|
||||
|
||||
@@ -5,9 +5,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define BZI_LOAD_HIGH_ADDR 0x100000
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.globl _lkrn_start
|
||||
_lkrn_start:
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
|
||||
.globl mbr
|
||||
|
||||
@@ -42,9 +42,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include "pciromprefix.S"
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/* Obtain access to payload by exposing the expansion ROM BAR at the
|
||||
* address currently used by a suitably large memory BAR on the same
|
||||
|
||||
@@ -3,9 +3,8 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.arch i386
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
.org 0
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.org 0
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
.section ".prefix", "ax", @progbits
|
||||
.code16
|
||||
_prefix:
|
||||
|
||||
.section ".text16", "ax", @progbits
|
||||
|
||||
@@ -12,10 +12,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define PXE_HACK_EB54 0x0001
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
|
||||
#include <librm.h>
|
||||
#include <undi.h>
|
||||
|
||||
@@ -9,10 +9,9 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.org 0
|
||||
.code16
|
||||
|
||||
#include <librm.h>
|
||||
|
||||
|
||||
@@ -55,7 +55,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#endif
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
|
||||
@@ -3,7 +3,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <librm.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "ax", @progbits
|
||||
|
||||
@@ -44,7 +44,7 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
*/
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code32
|
||||
.arch i486
|
||||
.section ".prefix.lib", "ax", @progbits
|
||||
|
||||
|
||||
@@ -3,10 +3,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#include <config/console.h>
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".prefix", "awx", @progbits
|
||||
.code16
|
||||
.org 0
|
||||
|
||||
#include "mbr.S"
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.code16
|
||||
.arch i386
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -32,10 +32,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )
|
||||
#define BOCHSBP xchgw %bx, %bx
|
||||
|
||||
.section ".note.GNU-stack", "", @progbits
|
||||
.text
|
||||
.code16
|
||||
.arch i386
|
||||
.section ".text16", "awx", @progbits
|
||||
.code16
|
||||
|
||||
/****************************************************************************
|
||||
* init_libkir (real-mode or 16:xx protected-mode far call)
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
||||
@@ -83,6 +83,11 @@ REQUIRE_OBJECT ( oid_sha512_224 );
|
||||
REQUIRE_OBJECT ( oid_sha512_256 );
|
||||
#endif
|
||||
|
||||
/* X25519 */
|
||||
#if defined ( CRYPTO_CURVE_X25519 )
|
||||
REQUIRE_OBJECT ( oid_x25519 );
|
||||
#endif
|
||||
|
||||
/* RSA and MD5 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_DIGEST_MD5 )
|
||||
REQUIRE_OBJECT ( rsa_md5 );
|
||||
@@ -114,25 +119,79 @@ REQUIRE_OBJECT ( rsa_sha512 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_CBC ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA1 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_CBC ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA256 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_GCM ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA256 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_PUBKEY_RSA ) && defined ( CRYPTO_CIPHER_AES_GCM ) && \
|
||||
defined ( CRYPTO_DIGEST_SHA384 )
|
||||
#if defined ( CRYPTO_EXCHANGE_PUBKEY ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* DHE, RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_DHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( dhe_rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-1 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA1 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha1 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha256 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-CBC, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_CBC ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_cbc_sha384 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-GCM, and SHA-256 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA256 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_gcm_sha256 );
|
||||
#endif
|
||||
|
||||
/* ECDHE, RSA, AES-GCM, and SHA-384 */
|
||||
#if defined ( CRYPTO_EXCHANGE_ECDHE ) && defined ( CRYPTO_PUBKEY_RSA ) && \
|
||||
defined ( CRYPTO_CIPHER_AES_GCM ) && defined ( CRYPTO_DIGEST_SHA384 )
|
||||
REQUIRE_OBJECT ( ecdhe_rsa_aes_gcm_sha384 );
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,15 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** Minimum TLS version */
|
||||
#define TLS_VERSION_MIN TLS_VERSION_TLS_1_1
|
||||
|
||||
/** Public-key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_PUBKEY
|
||||
|
||||
/** DHE key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_DHE
|
||||
|
||||
/** ECDHE key exchange algorithm */
|
||||
#define CRYPTO_EXCHANGE_ECDHE
|
||||
|
||||
/** RSA public-key algorithm */
|
||||
#define CRYPTO_PUBKEY_RSA
|
||||
|
||||
@@ -48,6 +57,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
/** SHA-512/256 digest algorithm */
|
||||
//#define CRYPTO_DIGEST_SHA512_256
|
||||
|
||||
/** X25519 elliptic curve */
|
||||
#define CRYPTO_CURVE_X25519
|
||||
|
||||
/** Margin of error (in seconds) allowed in signed timestamps
|
||||
*
|
||||
* We default to allowing a reasonable margin of error: 12 hours to
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
||||
@@ -295,9 +295,10 @@ struct startup_fn cachedhcp_startup_fn __startup_fn ( STARTUP_LATE ) = {
|
||||
* Apply cached DHCPACK to network device, if applicable
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int cachedhcp_probe ( struct net_device *netdev ) {
|
||||
static int cachedhcp_probe ( struct net_device *netdev, void *priv __unused ) {
|
||||
|
||||
/* Apply cached DHCPACK to network device, if applicable */
|
||||
return cachedhcp_apply ( &cached_dhcpack, netdev );
|
||||
|
||||
+5
-3
@@ -6,8 +6,9 @@
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <ipxe/timer.h>
|
||||
#include <time.h>
|
||||
|
||||
static int32_t rnd_seed = 0;
|
||||
|
||||
@@ -30,8 +31,9 @@ void srandom ( unsigned int seed ) {
|
||||
long int random ( void ) {
|
||||
int32_t q;
|
||||
|
||||
if ( ! rnd_seed ) /* Initialize linear congruential generator */
|
||||
srandom ( currticks() );
|
||||
/* Initialize linear congruential generator */
|
||||
if ( ! rnd_seed )
|
||||
srandom ( time ( NULL ) );
|
||||
|
||||
/* simplified version of the LCG given in Bruce Schneier's
|
||||
"Applied Cryptography" */
|
||||
|
||||
@@ -50,6 +50,31 @@ static struct profiler bigint_mod_multiply_rescale_profiler __profiler =
|
||||
static struct profiler bigint_mod_multiply_subtract_profiler __profiler =
|
||||
{ .name = "bigint_mod_multiply.subtract" };
|
||||
|
||||
/**
|
||||
* Conditionally swap big integers (in constant time)
|
||||
*
|
||||
* @v first0 Element 0 of big integer to be conditionally swapped
|
||||
* @v second0 Element 0 of big integer to be conditionally swapped
|
||||
* @v size Number of elements in big integers
|
||||
* @v swap Swap first and second big integers
|
||||
*/
|
||||
void bigint_swap_raw ( bigint_element_t *first0, bigint_element_t *second0,
|
||||
unsigned int size, int swap ) {
|
||||
bigint_element_t mask;
|
||||
bigint_element_t xor;
|
||||
unsigned int i;
|
||||
|
||||
/* Construct mask */
|
||||
mask = ( ( bigint_element_t ) ( ! swap ) - 1 );
|
||||
|
||||
/* Conditionally swap elements */
|
||||
for ( i = 0 ; i < size ; i++ ) {
|
||||
xor = ( mask & ( first0[i] ^ second0[i] ) );
|
||||
first0[i] ^= xor;
|
||||
second0[i] ^= xor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform modular multiplication of big integers
|
||||
*
|
||||
|
||||
+4
-4
@@ -472,10 +472,10 @@ void gcm_setiv ( struct gcm_context *context, const void *iv, size_t ivlen ) {
|
||||
union gcm_block *check = ( ( void * ) context );
|
||||
|
||||
/* Sanity checks */
|
||||
linker_assert ( &context->hash == check, gcm_bad_layout );
|
||||
linker_assert ( &context->len == check + 1, gcm_bad_layout );
|
||||
linker_assert ( &context->ctr == check + 2, gcm_bad_layout );
|
||||
linker_assert ( &context->key == check + 3, gcm_bad_layout );
|
||||
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, offsetof ( typeof ( *context ), key ) );
|
||||
|
||||
+5
-5
@@ -155,11 +155,11 @@ static void md4_digest ( struct md4_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, md4_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, md4_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "MD4 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
+5
-5
@@ -178,11 +178,11 @@ static void md5_digest ( struct md5_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, md5_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, md5_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "MD5 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 16 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2015 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 14 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 11 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2022 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 12 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha1.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 05 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 06 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 03 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_cbc_sha384 __tls_cipher_suite ( 04 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA384_DIGEST_SIZE,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 01 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/rsa.h>
|
||||
#include <ipxe/aes.h>
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_ecdhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 02 ) = {
|
||||
.code = htons ( TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_ecdhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 (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 <byteswap.h>
|
||||
#include <ipxe/x25519.h>
|
||||
#include <ipxe/asn1.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** "x25519" object identifier */
|
||||
static uint8_t oid_x25519[] = { ASN1_OID_X25519 };
|
||||
|
||||
/** "x25519" OID-identified algorithm */
|
||||
struct asn1_algorithm x25519_algorithm __asn1_algorithm = {
|
||||
.name = "x25519",
|
||||
.curve = &x25519_curve,
|
||||
.oid = ASN1_CURSOR ( oid_x25519 ),
|
||||
};
|
||||
|
||||
/** X25519 named curve */
|
||||
struct tls_named_curve tls_x25519_named_curve __tls_named_curve ( 01 ) = {
|
||||
.curve = &x25519_curve,
|
||||
.code = htons ( TLS_NAMED_CURVE_X25519 ),
|
||||
};
|
||||
@@ -30,39 +30,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 05 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 06 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA1_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha1_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 25 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_CBC_SHA ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
@@ -77,7 +47,7 @@ tls_rsa_with_aes_128_cbc_sha __tls_cipher_suite ( 15 ) = {
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_CBC_SHA cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 16 ) = {
|
||||
tls_rsa_with_aes_256_cbc_sha __tls_cipher_suite ( 26 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_CBC_SHA ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
|
||||
@@ -29,39 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 03 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 04 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
.record_iv_len = AES_BLOCKSIZE,
|
||||
.mac_len = SHA256_DIGEST_SIZE,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_cbc_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 23 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_CBC_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
@@ -76,7 +46,7 @@ tls_rsa_with_aes_128_cbc_sha256 __tls_cipher_suite ( 13 ) = {
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_CBC_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 14 ) = {
|
||||
tls_rsa_with_aes_256_cbc_sha256 __tls_cipher_suite ( 24 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_CBC_SHA256 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 0,
|
||||
|
||||
@@ -29,24 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha256.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 01 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha256_algorithm,
|
||||
.handshake = &sha256_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_128_GCM_SHA256 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 11 ) = {
|
||||
tls_rsa_with_aes_128_gcm_sha256 __tls_cipher_suite ( 21 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_128_GCM_SHA256 ),
|
||||
.key_len = ( 128 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
|
||||
@@ -29,24 +29,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
|
||||
#include <ipxe/sha512.h>
|
||||
#include <ipxe/tls.h>
|
||||
|
||||
/** TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_dhe_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 02 ) = {
|
||||
.code = htons ( TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
.record_iv_len = 8,
|
||||
.mac_len = 0,
|
||||
.exchange = &tls_dhe_exchange_algorithm,
|
||||
.pubkey = &rsa_algorithm,
|
||||
.cipher = &aes_gcm_algorithm,
|
||||
.digest = &sha384_algorithm,
|
||||
.handshake = &sha384_algorithm,
|
||||
};
|
||||
|
||||
/** TLS_RSA_WITH_AES_256_GCM_SHA384 cipher suite */
|
||||
struct tls_cipher_suite
|
||||
tls_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 12 ) = {
|
||||
tls_rsa_with_aes_256_gcm_sha384 __tls_cipher_suite ( 22 ) = {
|
||||
.code = htons ( TLS_RSA_WITH_AES_256_GCM_SHA384 ),
|
||||
.key_len = ( 256 / 8 ),
|
||||
.fixed_iv_len = 4,
|
||||
|
||||
+6
-6
@@ -145,12 +145,12 @@ static void sha1_digest ( struct sha1_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[4] == e, sha1_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, sha1_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA1 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
+9
-9
@@ -140,15 +140,15 @@ static void sha256_digest ( struct sha256_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddd.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddd.dd.digest.h[0] == a, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[1] == b, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[2] == c, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[3] == d, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[4] == e, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[5] == f, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[6] == g, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.digest.h[7] == h, sha256_bad_layout );
|
||||
linker_assert ( &u.ddd.dd.data.dword[0] == w, sha256_bad_layout );
|
||||
build_assert ( &u.ddd.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddd.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddd.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddd.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddd.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddd.dd.digest.h[5] == f );
|
||||
build_assert ( &u.ddd.dd.digest.h[6] == g );
|
||||
build_assert ( &u.ddd.dd.digest.h[7] == h );
|
||||
build_assert ( &u.ddd.dd.data.dword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA256 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddd.dd.digest,
|
||||
|
||||
+9
-9
@@ -156,15 +156,15 @@ static void sha512_digest ( struct sha512_context *context ) {
|
||||
|
||||
/* Sanity checks */
|
||||
assert ( ( context->len % sizeof ( context->ddq.dd.data ) ) == 0 );
|
||||
linker_assert ( &u.ddq.dd.digest.h[0] == a, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[1] == b, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[2] == c, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[3] == d, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[4] == e, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[5] == f, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[6] == g, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.digest.h[7] == h, sha512_bad_layout );
|
||||
linker_assert ( &u.ddq.dd.data.qword[0] == w, sha512_bad_layout );
|
||||
build_assert ( &u.ddq.dd.digest.h[0] == a );
|
||||
build_assert ( &u.ddq.dd.digest.h[1] == b );
|
||||
build_assert ( &u.ddq.dd.digest.h[2] == c );
|
||||
build_assert ( &u.ddq.dd.digest.h[3] == d );
|
||||
build_assert ( &u.ddq.dd.digest.h[4] == e );
|
||||
build_assert ( &u.ddq.dd.digest.h[5] == f );
|
||||
build_assert ( &u.ddq.dd.digest.h[6] == g );
|
||||
build_assert ( &u.ddq.dd.digest.h[7] == h );
|
||||
build_assert ( &u.ddq.dd.data.qword[0] == w );
|
||||
|
||||
DBGC ( context, "SHA512 digesting:\n" );
|
||||
DBGC_HDA ( context, 0, &context->ddq.dd.digest,
|
||||
|
||||
@@ -0,0 +1,844 @@
|
||||
/*
|
||||
* 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
|
||||
*
|
||||
* X25519 key exchange
|
||||
*
|
||||
* This implementation is inspired by and partially based upon the
|
||||
* paper "Implementing Curve25519/X25519: A Tutorial on Elliptic Curve
|
||||
* Cryptography" by Martin Kleppmann, available for download from
|
||||
* https://www.cl.cam.ac.uk/teaching/2122/Crypto/curve25519.pdf
|
||||
*
|
||||
* The underlying modular addition, subtraction, and multiplication
|
||||
* operations are completely redesigned for substantially improved
|
||||
* efficiency compared to the TweetNaCl implementation studied in that
|
||||
* paper.
|
||||
*
|
||||
* TweetNaCl iPXE
|
||||
* --------- ----
|
||||
*
|
||||
* Storage size of each big integer 128 40
|
||||
* (in bytes)
|
||||
*
|
||||
* Stack usage for key exchange 1144 360
|
||||
* (in bytes, large objects only)
|
||||
*
|
||||
* Cost of big integer addition 16 5
|
||||
* (in number of 64-bit additions)
|
||||
*
|
||||
* Cost of big integer multiplication 273 31
|
||||
* (in number of 64-bit multiplications)
|
||||
*
|
||||
* The implementation is constant-time (provided that the underlying
|
||||
* big integer operations are also constant-time).
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <ipxe/init.h>
|
||||
#include <ipxe/crypto.h>
|
||||
#include <ipxe/x25519.h>
|
||||
|
||||
/** X25519 reduction constant
|
||||
*
|
||||
* The X25519 field prime is p=2^255-19. This gives us:
|
||||
*
|
||||
* p = 2^255 - 19
|
||||
* 2^255 = p + 19
|
||||
* 2^255 = 19 (mod p)
|
||||
* k * 2^255 = k * 19 (mod p)
|
||||
*
|
||||
* We can therefore reduce a value modulo p by taking the high-order
|
||||
* bits of the value from bit 255 and above, multiplying by 19, and
|
||||
* adding this to the low-order 255 bits of the value.
|
||||
*
|
||||
* This would be cumbersome to do in practice since it would require
|
||||
* partitioning the value at a 255-bit boundary (and hence would
|
||||
* require some shifting and masking operations). However, we can
|
||||
* note that:
|
||||
*
|
||||
* k * 2^255 = k * 19 (mod p)
|
||||
* k * 2 * 2^255 = k * 2 * 19 (mod p)
|
||||
* k * 2^256 = k * 38 (mod p)
|
||||
*
|
||||
* We can therefore simplify the reduction to taking the high order
|
||||
* bits of the value from bit 256 and above, multiplying by 38, and
|
||||
* adding this to the low-order 256 bits of the value.
|
||||
*
|
||||
* Since 256 will inevitably be a multiple of the big integer element
|
||||
* size (typically 32 or 64 bits), this avoids the need to perform any
|
||||
* shifting or masking operations.
|
||||
*/
|
||||
#define X25519_REDUCE_256 38
|
||||
|
||||
/** X25519 multiplication step 1 result
|
||||
*
|
||||
* Step 1 of X25519 multiplication is to compute the product of two
|
||||
* X25519 unsigned 258-bit integers.
|
||||
*
|
||||
* Both multiplication inputs are limited to 258 bits, and so the
|
||||
* product will have at most 516 bits.
|
||||
*/
|
||||
union x25519_multiply_step1 {
|
||||
/** Raw product
|
||||
*
|
||||
* Big integer multiplication produces a result with a number
|
||||
* of elements equal to the sum of the number of elements in
|
||||
* each input.
|
||||
*/
|
||||
bigint_t ( X25519_SIZE + X25519_SIZE ) product;
|
||||
/** Partition into low-order and high-order bits
|
||||
*
|
||||
* Reduction modulo p requires separating the low-order 256
|
||||
* bits from the remaining high-order bits.
|
||||
*
|
||||
* Since the value will never exceed 516 bits (see above),
|
||||
* there will be at most 260 high-order bits.
|
||||
*/
|
||||
struct {
|
||||
/** Low-order 256 bits */
|
||||
bigint_t ( bigint_required_size ( ( 256 /* bits */ + 7 ) / 8 ) )
|
||||
low_256bit;
|
||||
/** High-order 260 bits */
|
||||
bigint_t ( bigint_required_size ( ( 260 /* bits */ + 7 ) / 8 ) )
|
||||
high_260bit;
|
||||
} __attribute__ (( packed )) parts;
|
||||
};
|
||||
|
||||
/** X25519 multiplication step 2 result
|
||||
*
|
||||
* Step 2 of X25519 multiplication is to multiply the high-order 260
|
||||
* bits from step 1 with the 6-bit reduction constant 38, and to add
|
||||
* this to the low-order 256 bits from step 1.
|
||||
*
|
||||
* The multiplication inputs are limited to 260 and 6 bits
|
||||
* respectively, and so the product will have at most 266 bits. After
|
||||
* adding the low-order 256 bits from step 1, the result will have at
|
||||
* most 267 bits.
|
||||
*/
|
||||
union x25519_multiply_step2 {
|
||||
/** Raw product
|
||||
*
|
||||
* Big integer multiplication produces a result with a number
|
||||
* of elements equal to the sum of the number of elements in
|
||||
* each input.
|
||||
*/
|
||||
bigint_t ( bigint_required_size ( ( 260 /* bits */ + 7 ) / 8 ) +
|
||||
bigint_required_size ( ( 6 /* bits */ + 7 ) / 8 ) ) product;
|
||||
/** Big integer value
|
||||
*
|
||||
* The value will never exceed 267 bits (see above), and so
|
||||
* may be consumed as a normal X25519 big integer.
|
||||
*/
|
||||
x25519_t value;
|
||||
/** Partition into low-order and high-order bits
|
||||
*
|
||||
* Reduction modulo p requires separating the low-order 256
|
||||
* bits from the remaining high-order bits.
|
||||
*
|
||||
* Since the value will never exceed 267 bits (see above),
|
||||
* there will be at most 11 high-order bits.
|
||||
*/
|
||||
struct {
|
||||
/** Low-order 256 bits */
|
||||
bigint_t ( bigint_required_size ( ( 256 /* bits */ + 7 ) / 8 ) )
|
||||
low_256bit;
|
||||
/** High-order 11 bits */
|
||||
bigint_t ( bigint_required_size ( ( 11 /* bits */ + 7 ) / 8 ) )
|
||||
high_11bit;
|
||||
} __attribute__ (( packed )) parts;
|
||||
};
|
||||
|
||||
/** X25519 multiplication step 3 result
|
||||
*
|
||||
* Step 3 of X25519 multiplication is to multiply the high-order 11
|
||||
* bits from step 2 with the 6-bit reduction constant 38, and to add
|
||||
* this to the low-order 256 bits from step 2.
|
||||
*
|
||||
* The multiplication inputs are limited to 11 and 6 bits
|
||||
* respectively, and so the product will have at most 17 bits. After
|
||||
* adding the low-order 256 bits from step 2, the result will have at
|
||||
* most 257 bits.
|
||||
*/
|
||||
union x25519_multiply_step3 {
|
||||
/** Raw product
|
||||
*
|
||||
* Big integer multiplication produces a result with a number
|
||||
* of elements equal to the sum of the number of elements in
|
||||
* each input.
|
||||
*/
|
||||
bigint_t ( bigint_required_size ( ( 11 /* bits */ + 7 ) / 8 ) +
|
||||
bigint_required_size ( ( 6 /* bits */ + 7 ) / 8 ) ) product;
|
||||
/** Big integer value
|
||||
*
|
||||
* The value will never exceed 267 bits (see above), and so
|
||||
* may be consumed as a normal X25519 big integer.
|
||||
*/
|
||||
x25519_t value;
|
||||
};
|
||||
|
||||
/** X25519 multiplication temporary working space
|
||||
*
|
||||
* We overlap the buffers used by each step of the multiplication
|
||||
* calculation to reduce the total stack space required:
|
||||
*
|
||||
* |--------------------------------------------------------|
|
||||
* | <- pad -> | <------------ step 1 result -------------> |
|
||||
* | | <- low 256 bits -> | <-- high 260 bits --> |
|
||||
* | <------- step 2 result ------> | <-- step 3 result --> |
|
||||
* |--------------------------------------------------------|
|
||||
*/
|
||||
union x25519_multiply_workspace {
|
||||
/** Step 1 result */
|
||||
struct {
|
||||
/** Padding to avoid collision between steps 1 and 2
|
||||
*
|
||||
* The step 2 multiplication consumes the high 260
|
||||
* bits of step 1, and so the step 2 multiplication
|
||||
* result must not overlap this portion of the step 1
|
||||
* result.
|
||||
*/
|
||||
uint8_t pad[ sizeof ( union x25519_multiply_step2 ) -
|
||||
offsetof ( union x25519_multiply_step1,
|
||||
parts.high_260bit ) ];
|
||||
/** Step 1 result */
|
||||
union x25519_multiply_step1 step1;
|
||||
} __attribute__ (( packed ));
|
||||
/** Steps 2 and 3 results */
|
||||
struct {
|
||||
/** Step 2 result */
|
||||
union x25519_multiply_step2 step2;
|
||||
/** Step 3 result */
|
||||
union x25519_multiply_step3 step3;
|
||||
} __attribute__ (( packed ));
|
||||
};
|
||||
|
||||
/** An X25519 elliptic curve point in projective coordinates
|
||||
*
|
||||
* A point (x,y) on the Montgomery curve used in X25519 is represented
|
||||
* using projective coordinates (X/Z,Y/Z) so that intermediate
|
||||
* calculations may be performed on both numerator and denominator
|
||||
* separately, with the division step performed only once at the end
|
||||
* of the calculation.
|
||||
*
|
||||
* The group operation calculation is performed using a Montgomery
|
||||
* ladder as:
|
||||
*
|
||||
* X[2i] = ( X[i]^2 - Z[i]^2 )^2
|
||||
* X[2i+1] = ( X[i] * X[i+1] - Z[i] * Z[i+1] )^2
|
||||
* Z[2i] = 4 * X[i] * Z[i] * ( X[i]^2 + A * X[i] * Z[i] + Z[i]^2 )
|
||||
* Z[2i+1] = X[0] * ( X[i] * Z[i+1] - X[i+1] * Z[i] ) ^ 2
|
||||
*
|
||||
* It is therefore not necessary to store (or use) the value of Y.
|
||||
*/
|
||||
struct x25519_projective {
|
||||
/** X coordinate */
|
||||
union x25519_quad257 X;
|
||||
/** Z coordinate */
|
||||
union x25519_quad257 Z;
|
||||
};
|
||||
|
||||
/** An X25519 Montgomery ladder step */
|
||||
struct x25519_step {
|
||||
/** X[n]/Z[n] */
|
||||
struct x25519_projective x_n;
|
||||
/** X[n+1]/Z[n+1] */
|
||||
struct x25519_projective x_n1;
|
||||
};
|
||||
|
||||
/** Constant p=2^255-19 (the finite field prime) */
|
||||
static const uint8_t x25519_p_raw[] = {
|
||||
0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xed
|
||||
};
|
||||
|
||||
/** Constant p=2^255-19 (the finite field prime) */
|
||||
static x25519_t x25519_p;
|
||||
|
||||
/** Constant 2p=2^256-38 */
|
||||
static x25519_t x25519_2p;
|
||||
|
||||
/** Constant 4p=2^257-76 */
|
||||
static x25519_t x25519_4p;
|
||||
|
||||
/** Reduction constant (used during multiplication) */
|
||||
static const uint8_t x25519_reduce_256_raw[] = { X25519_REDUCE_256 };
|
||||
|
||||
/** Reduction constant (used during multiplication) */
|
||||
static bigint_t ( bigint_required_size ( sizeof ( x25519_reduce_256_raw ) ) )
|
||||
x25519_reduce_256;
|
||||
|
||||
/** Constant 121665 (used in the Montgomery ladder) */
|
||||
static const uint8_t x25519_121665_raw[] = { 0x01, 0xdb, 0x41 };
|
||||
|
||||
/** Constant 121665 (used in the Montgomery ladder) */
|
||||
static union x25519_oct258 x25519_121665;
|
||||
|
||||
/** Constant g=9 (the group generator) */
|
||||
static struct x25519_value x25519_generator = {
|
||||
.raw = { 9, }
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialise constants
|
||||
*
|
||||
*/
|
||||
static void x25519_init_constants ( void ) {
|
||||
|
||||
/* Construct constant p */
|
||||
bigint_init ( &x25519_p, x25519_p_raw, sizeof ( x25519_p_raw ) );
|
||||
|
||||
/* Construct constant 2p */
|
||||
bigint_copy ( &x25519_p, &x25519_2p );
|
||||
bigint_add ( &x25519_p, &x25519_2p );
|
||||
|
||||
/* Construct constant 4p */
|
||||
bigint_copy ( &x25519_2p, &x25519_4p );
|
||||
bigint_add ( &x25519_2p, &x25519_4p );
|
||||
|
||||
/* Construct reduction constant */
|
||||
bigint_init ( &x25519_reduce_256, x25519_reduce_256_raw,
|
||||
sizeof ( x25519_reduce_256_raw ) );
|
||||
|
||||
/* Construct constant 121665 */
|
||||
bigint_init ( &x25519_121665.value, x25519_121665_raw,
|
||||
sizeof ( x25519_121665_raw ) );
|
||||
}
|
||||
|
||||
/** Initialisation function */
|
||||
struct init_fn x25519_init_fn __init_fn ( INIT_NORMAL ) = {
|
||||
.initialise = x25519_init_constants,
|
||||
};
|
||||
|
||||
/**
|
||||
* Add big integers modulo field prime
|
||||
*
|
||||
* @v augend Big integer to add
|
||||
* @v addend Big integer to add
|
||||
* @v result Big integer to hold result (may overlap augend)
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
x25519_add ( const union x25519_quad257 *augend,
|
||||
const union x25519_quad257 *addend,
|
||||
union x25519_oct258 *result ) {
|
||||
int copy;
|
||||
|
||||
/* Copy augend if necessary */
|
||||
copy = ( result != &augend->oct258 );
|
||||
build_assert ( __builtin_constant_p ( copy ) );
|
||||
if ( copy ) {
|
||||
build_assert ( result != &addend->oct258 );
|
||||
bigint_copy ( &augend->oct258.value, &result->value );
|
||||
}
|
||||
|
||||
/* Perform addition
|
||||
*
|
||||
* Both inputs are in the range [0,4p-1] and the resulting
|
||||
* sum is therefore in the range [0,8p-2].
|
||||
*
|
||||
* This range lies within the range [0,8p-1] and the result is
|
||||
* therefore a valid X25519 unsigned 258-bit integer, as
|
||||
* required.
|
||||
*/
|
||||
bigint_add ( &addend->value, &result->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract big integers modulo field prime
|
||||
*
|
||||
* @v minuend Big integer from which to subtract
|
||||
* @v subtrahend Big integer to subtract
|
||||
* @v result Big integer to hold result (may overlap minuend)
|
||||
*/
|
||||
static inline __attribute__ (( always_inline )) void
|
||||
x25519_subtract ( const union x25519_quad257 *minuend,
|
||||
const union x25519_quad257 *subtrahend,
|
||||
union x25519_oct258 *result ) {
|
||||
int copy;
|
||||
|
||||
/* Copy minuend if necessary */
|
||||
copy = ( result != &minuend->oct258 );
|
||||
build_assert ( __builtin_constant_p ( copy ) );
|
||||
if ( copy ) {
|
||||
build_assert ( result != &subtrahend->oct258 );
|
||||
bigint_copy ( &minuend->oct258.value, &result->value );
|
||||
}
|
||||
|
||||
/* Perform subtraction
|
||||
*
|
||||
* Both inputs are in the range [0,4p-1] and the resulting
|
||||
* difference is therefore in the range [1-4p,4p-1].
|
||||
*
|
||||
* This range lies partially outside the range [0,8p-1] and
|
||||
* the result is therefore not yet a valid X25519 unsigned
|
||||
* 258-bit integer.
|
||||
*/
|
||||
bigint_subtract ( &subtrahend->value, &result->value );
|
||||
|
||||
/* Add constant multiple of field prime p
|
||||
*
|
||||
* Add the constant 4p to the result. This brings the result
|
||||
* within the range [1,8p-1] (without changing the value
|
||||
* modulo p).
|
||||
*
|
||||
* This range lies within the range [0,8p-1] and the result is
|
||||
* therefore now a valid X25519 unsigned 258-bit integer, as
|
||||
* required.
|
||||
*/
|
||||
bigint_add ( &x25519_4p, &result->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply big integers modulo field prime
|
||||
*
|
||||
* @v multiplicand Big integer to be multiplied
|
||||
* @v multiplier Big integer to be multiplied
|
||||
* @v result Big integer to hold result (may overlap either input)
|
||||
*/
|
||||
void x25519_multiply ( const union x25519_oct258 *multiplicand,
|
||||
const union x25519_oct258 *multiplier,
|
||||
union x25519_quad257 *result ) {
|
||||
union x25519_multiply_workspace tmp;
|
||||
union x25519_multiply_step1 *step1 = &tmp.step1;
|
||||
union x25519_multiply_step2 *step2 = &tmp.step2;
|
||||
union x25519_multiply_step3 *step3 = &tmp.step3;
|
||||
|
||||
/* Step 1: perform raw multiplication
|
||||
*
|
||||
* step1 = multiplicand * multiplier
|
||||
*
|
||||
* Both inputs are 258-bit numbers and the step 1 result is
|
||||
* therefore 258+258=516 bits.
|
||||
*/
|
||||
static_assert ( sizeof ( step1->product ) >= sizeof ( step1->parts ) );
|
||||
bigint_multiply ( &multiplicand->value, &multiplier->value,
|
||||
&step1->product );
|
||||
|
||||
/* Step 2: reduce high-order 516-256=260 bits of step 1 result
|
||||
*
|
||||
* Use the identity 2^256=38 (mod p) to reduce the high-order
|
||||
* bits of the step 1 result. We split the 516-bit result
|
||||
* from step 1 into its low-order 256 bits and high-order 260
|
||||
* bits:
|
||||
*
|
||||
* step1 = step1(low 256 bits) + step1(high 260 bits) * 2^256
|
||||
*
|
||||
* and then perform the calculation:
|
||||
*
|
||||
* step2 = step1 (mod p)
|
||||
* = step1(low 256 bits) + step1(high 260 bits) * 2^256 (mod p)
|
||||
* = step1(low 256 bits) + step1(high 260 bits) * 38 (mod p)
|
||||
*
|
||||
* There are 6 bits in the constant value 38. The step 2
|
||||
* multiplication product will therefore have 260+6=266 bits,
|
||||
* and the step 2 result (after the addition) will therefore
|
||||
* have 267 bits.
|
||||
*/
|
||||
static_assert ( sizeof ( step2->product ) >= sizeof ( step2->value ) );
|
||||
static_assert ( sizeof ( step2->product ) >= sizeof ( step2->parts ) );
|
||||
bigint_grow ( &step1->parts.low_256bit, &result->value );
|
||||
bigint_multiply ( &step1->parts.high_260bit, &x25519_reduce_256,
|
||||
&step2->product );
|
||||
bigint_add ( &result->value, &step2->value );
|
||||
|
||||
/* Step 3: reduce high-order 267-256=11 bits of step 2 result
|
||||
*
|
||||
* Use the identity 2^256=38 (mod p) again to reduce the
|
||||
* high-order bits of the step 2 result. As before, we split
|
||||
* the 267-bit result from step 2 into its low-order 256 bits
|
||||
* and high-order 11 bits:
|
||||
*
|
||||
* step2 = step2(low 256 bits) + step2(high 11 bits) * 2^256
|
||||
*
|
||||
* and then perform the calculation:
|
||||
*
|
||||
* step3 = step2 (mod p)
|
||||
* = step2(low 256 bits) + step2(high 11 bits) * 2^256 (mod p)
|
||||
* = step2(low 256 bits) + step2(high 11 bits) * 38 (mod p)
|
||||
*
|
||||
* There are 6 bits in the constant value 38. The step 3
|
||||
* multiplication product will therefore have 11+6=19 bits,
|
||||
* and the step 3 result (after the addition) will therefore
|
||||
* have 257 bits.
|
||||
*
|
||||
* A loose upper bound for the step 3 result (after the
|
||||
* addition) is given by:
|
||||
*
|
||||
* step3 < ( 2^256 - 1 ) + ( 2^19 - 1 )
|
||||
* < ( 2^257 - 2^256 - 1 ) + ( 2^19 - 1 )
|
||||
* < ( 2^257 - 76 ) - 2^256 + 2^19 + 74
|
||||
* < 4 * ( 2^255 - 19 ) - 2^256 + 2^19 + 74
|
||||
* < 4p - 2^256 + 2^19 + 74
|
||||
*
|
||||
* and so the step 3 result is strictly less than 4p, and
|
||||
* therefore lies within the range [0,4p-1].
|
||||
*/
|
||||
memset ( &step3->value, 0, sizeof ( step3->value ) );
|
||||
bigint_grow ( &step2->parts.low_256bit, &result->value );
|
||||
bigint_multiply ( &step2->parts.high_11bit, &x25519_reduce_256,
|
||||
&step3->product );
|
||||
bigint_add ( &step3->value, &result->value );
|
||||
|
||||
/* Step 1 calculates the product of the input operands, and
|
||||
* each subsequent step reduces the number of bits in the
|
||||
* result while preserving this value (modulo p). The final
|
||||
* result is therefore equal to the product of the input
|
||||
* operands (modulo p), as required.
|
||||
*
|
||||
* The step 3 result lies within the range [0,4p-1] and the
|
||||
* final result is therefore a valid X25519 unsigned 257-bit
|
||||
* integer, as required.
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute multiplicative inverse
|
||||
*
|
||||
* @v invertend Big integer to be inverted
|
||||
* @v result Big integer to hold result (may not overlap input)
|
||||
*/
|
||||
void x25519_invert ( const union x25519_oct258 *invertend,
|
||||
union x25519_quad257 *result ) {
|
||||
int i;
|
||||
|
||||
/* Sanity check */
|
||||
assert ( invertend != &result->oct258 );
|
||||
|
||||
/* Calculate inverse as x^(-1)=x^(p-2) where p is the field prime
|
||||
*
|
||||
* The field prime is p=2^255-19 and so:
|
||||
*
|
||||
* p - 2 = 2^255 - 21
|
||||
* = (2^255 - 1) - 2^4 - 2^2
|
||||
*
|
||||
* i.e. p-2 is a 254-bit number in which all bits are set
|
||||
* apart from bit 2 and bit 4.
|
||||
*
|
||||
* We use the square-and-multiply method to compute x^(p-2).
|
||||
*/
|
||||
bigint_copy ( &invertend->value, &result->value );
|
||||
for ( i = 253 ; i >= 0 ; i-- ) {
|
||||
|
||||
/* Square running total */
|
||||
x25519_multiply ( &result->oct258, &result->oct258, result );
|
||||
|
||||
/* For each set bit in the exponent, multiply by invertend */
|
||||
if ( ( i != 2 ) && ( i != 4 ) ) {
|
||||
x25519_multiply ( invertend, &result->oct258, result );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce big integer via conditional subtraction
|
||||
*
|
||||
* @v subtrahend Big integer to subtract
|
||||
* @v value Big integer to be subtracted from, if possible
|
||||
*/
|
||||
static void x25519_reduce_by ( const x25519_t *subtrahend, x25519_t *value ) {
|
||||
unsigned int max_bit = ( ( 8 * sizeof ( *value ) ) - 1 );
|
||||
x25519_t tmp;
|
||||
|
||||
/* Conditionally subtract subtrahend
|
||||
*
|
||||
* Subtract the subtrahend, discarding the result (in constant
|
||||
* time) if the subtraction underflows.
|
||||
*/
|
||||
bigint_copy ( value, &tmp );
|
||||
bigint_subtract ( subtrahend, value );
|
||||
bigint_swap ( value, &tmp, bigint_bit_is_set ( value, max_bit ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reduce big integer to canonical range
|
||||
*
|
||||
* @v value Big integer to be reduced
|
||||
*/
|
||||
void x25519_reduce ( union x25519_quad257 *value ) {
|
||||
|
||||
/* Conditionally subtract 2p
|
||||
*
|
||||
* Subtract twice the field prime, discarding the result (in
|
||||
* constant time) if the subtraction underflows.
|
||||
*
|
||||
* The input value is in the range [0,4p-1]. After this
|
||||
* conditional subtraction, the value is in the range
|
||||
* [0,2p-1].
|
||||
*/
|
||||
x25519_reduce_by ( &x25519_2p, &value->value );
|
||||
|
||||
/* Conditionally subtract p
|
||||
*
|
||||
* Subtract the field prime, discarding the result (in
|
||||
* constant time) if the subtraction underflows.
|
||||
*
|
||||
* The value is already in the range [0,2p-1]. After this
|
||||
* conditional subtraction, the value is in the range [0,p-1]
|
||||
* and is therefore the canonical representation.
|
||||
*/
|
||||
x25519_reduce_by ( &x25519_p, &value->value );
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute next step of the Montgomery ladder
|
||||
*
|
||||
* @v base Base point
|
||||
* @v bit Bit value
|
||||
* @v step Ladder step
|
||||
*/
|
||||
static void x25519_step ( const union x25519_quad257 *base, int bit,
|
||||
struct x25519_step *step ) {
|
||||
union x25519_quad257 *a = &step->x_n.X;
|
||||
union x25519_quad257 *b = &step->x_n1.X;
|
||||
union x25519_quad257 *c = &step->x_n.Z;
|
||||
union x25519_quad257 *d = &step->x_n1.Z;
|
||||
union x25519_oct258 e;
|
||||
union x25519_quad257 f;
|
||||
union x25519_oct258 *v1_e;
|
||||
union x25519_oct258 *v2_a;
|
||||
union x25519_oct258 *v3_c;
|
||||
union x25519_oct258 *v4_b;
|
||||
union x25519_quad257 *v5_d;
|
||||
union x25519_quad257 *v6_f;
|
||||
union x25519_quad257 *v7_a;
|
||||
union x25519_quad257 *v8_c;
|
||||
union x25519_oct258 *v9_e;
|
||||
union x25519_oct258 *v10_a;
|
||||
union x25519_quad257 *v11_b;
|
||||
union x25519_oct258 *v12_c;
|
||||
union x25519_quad257 *v13_a;
|
||||
union x25519_oct258 *v14_a;
|
||||
union x25519_quad257 *v15_c;
|
||||
union x25519_quad257 *v16_a;
|
||||
union x25519_quad257 *v17_d;
|
||||
union x25519_quad257 *v18_b;
|
||||
|
||||
/* See the referenced paper "Implementing Curve25519/X25519: A
|
||||
* Tutorial on Elliptic Curve Cryptography" for the reasoning
|
||||
* behind this calculation.
|
||||
*/
|
||||
|
||||
/* Reuse storage locations for intermediate results where possible */
|
||||
v1_e = &e;
|
||||
v2_a = container_of ( &a->value, union x25519_oct258, value );
|
||||
v3_c = container_of ( &c->value, union x25519_oct258, value );
|
||||
v4_b = container_of ( &b->value, union x25519_oct258, value );
|
||||
v5_d = d;
|
||||
v6_f = &f;
|
||||
v7_a = a;
|
||||
v8_c = c;
|
||||
v9_e = &e;
|
||||
v10_a = container_of ( &a->value, union x25519_oct258, value );
|
||||
v11_b = b;
|
||||
v12_c = container_of ( &c->value, union x25519_oct258, value );
|
||||
v13_a = a;
|
||||
v14_a = container_of ( &a->value, union x25519_oct258, value );
|
||||
v15_c = c;
|
||||
v16_a = a;
|
||||
v17_d = d;
|
||||
v18_b = b;
|
||||
|
||||
/* Select inputs */
|
||||
bigint_swap ( &a->value, &b->value, bit );
|
||||
bigint_swap ( &c->value, &d->value, bit );
|
||||
|
||||
/* v1 = a + c */
|
||||
x25519_add ( a, c, v1_e );
|
||||
|
||||
/* v2 = a - c */
|
||||
x25519_subtract ( a, c, v2_a );
|
||||
|
||||
/* v3 = b + d */
|
||||
x25519_add ( b, d, v3_c );
|
||||
|
||||
/* v4 = b - d */
|
||||
x25519_subtract ( b, d, v4_b );
|
||||
|
||||
/* v5 = v1^2 = (a + c)^2 = a^2 + 2ac + c^2 */
|
||||
x25519_multiply ( v1_e, v1_e, v5_d );
|
||||
|
||||
/* v6 = v2^2 = (a - c)^2 = a^2 - 2ac + c^2 */
|
||||
x25519_multiply ( v2_a, v2_a, v6_f );
|
||||
|
||||
/* v7 = v3 * v2 = (b + d) * (a - c) = ab - bc + ad - cd */
|
||||
x25519_multiply ( v3_c, v2_a, v7_a );
|
||||
|
||||
/* v8 = v4 * v1 = (b - d) * (a + c) = ab + bc - ad - cd */
|
||||
x25519_multiply ( v4_b, v1_e, v8_c );
|
||||
|
||||
/* v9 = v7 + v8 = 2 * (ab - cd) */
|
||||
x25519_add ( v7_a, v8_c, v9_e );
|
||||
|
||||
/* v10 = v7 - v8 = 2 * (ad - bc) */
|
||||
x25519_subtract ( v7_a, v8_c, v10_a );
|
||||
|
||||
/* v11 = v10^2 = 4 * (ad - bc)^2 */
|
||||
x25519_multiply ( v10_a, v10_a, v11_b );
|
||||
|
||||
/* v12 = v5 - v6 = (a + c)^2 - (a - c)^2 = 4ac */
|
||||
x25519_subtract ( v5_d, v6_f, v12_c );
|
||||
|
||||
/* v13 = v12 * 121665 = 486660ac = (A-2) * ac */
|
||||
x25519_multiply ( v12_c, &x25519_121665, v13_a );
|
||||
|
||||
/* v14 = v13 + v5 = (A-2) * ac + a^2 + 2ac + c^2 = a^2 + A * ac + c^2 */
|
||||
x25519_add ( v13_a, v5_d, v14_a );
|
||||
|
||||
/* v15 = v12 * v14 = 4ac * (a^2 + A * ac + c^2) */
|
||||
x25519_multiply ( v12_c, v14_a, v15_c );
|
||||
|
||||
/* v16 = v5 * v6 = (a + c)^2 * (a - c)^2 = (a^2 - c^2)^2 */
|
||||
x25519_multiply ( &v5_d->oct258, &v6_f->oct258, v16_a );
|
||||
|
||||
/* v17 = v11 * base = 4 * base * (ad - bc)^2 */
|
||||
x25519_multiply ( &v11_b->oct258, &base->oct258, v17_d );
|
||||
|
||||
/* v18 = v9^2 = 4 * (ab - cd)^2 */
|
||||
x25519_multiply ( v9_e, v9_e, v18_b );
|
||||
|
||||
/* Select outputs */
|
||||
bigint_swap ( &a->value, &b->value, bit );
|
||||
bigint_swap ( &c->value, &d->value, bit );
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply X25519 elliptic curve point
|
||||
*
|
||||
* @v base Base point
|
||||
* @v scalar Scalar multiple
|
||||
* @v result Point to hold result (may overlap base point)
|
||||
*/
|
||||
static void x25519_ladder ( const union x25519_quad257 *base,
|
||||
struct x25519_value *scalar,
|
||||
union x25519_quad257 *result ) {
|
||||
static const uint8_t zero[] = { 0 };
|
||||
static const uint8_t one[] = { 1 };
|
||||
struct x25519_step step;
|
||||
union x25519_quad257 *tmp;
|
||||
int bit;
|
||||
int i;
|
||||
|
||||
/* Initialise ladder */
|
||||
bigint_init ( &step.x_n.X.value, one, sizeof ( one ) );
|
||||
bigint_init ( &step.x_n.Z.value, zero, sizeof ( zero ) );
|
||||
bigint_copy ( &base->value, &step.x_n1.X.value );
|
||||
bigint_init ( &step.x_n1.Z.value, one, sizeof ( one ) );
|
||||
|
||||
/* Use ladder */
|
||||
for ( i = 254 ; i >= 0 ; i-- ) {
|
||||
bit = ( ( scalar->raw[ i / 8 ] >> ( i % 8 ) ) & 1 );
|
||||
x25519_step ( base, bit, &step );
|
||||
}
|
||||
|
||||
/* Convert back to affine coordinate */
|
||||
tmp = &step.x_n1.X;
|
||||
x25519_invert ( &step.x_n.Z.oct258, tmp );
|
||||
x25519_multiply ( &step.x_n.X.oct258, &tmp->oct258, result );
|
||||
x25519_reduce ( result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse X25519 value endianness
|
||||
*
|
||||
* @v value Value to reverse
|
||||
*/
|
||||
static void x25519_reverse ( struct x25519_value *value ) {
|
||||
uint8_t *low = value->raw;
|
||||
uint8_t *high = &value->raw[ sizeof ( value->raw ) - 1 ];
|
||||
uint8_t tmp;
|
||||
|
||||
/* Reverse bytes */
|
||||
do {
|
||||
tmp = *low;
|
||||
*low = *high;
|
||||
*high = tmp;
|
||||
} while ( ++low < --high );
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate X25519 key
|
||||
*
|
||||
* @v base Base point
|
||||
* @v scalar Scalar multiple
|
||||
* @v result Point to hold result (may overlap base point)
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int x25519_key ( const struct x25519_value *base,
|
||||
const struct x25519_value *scalar,
|
||||
struct x25519_value *result ) {
|
||||
struct x25519_value *tmp = result;
|
||||
union x25519_quad257 point;
|
||||
|
||||
/* Reverse base point and clear high bit as required by RFC7748 */
|
||||
memcpy ( tmp, base, sizeof ( *tmp ) );
|
||||
x25519_reverse ( tmp );
|
||||
tmp->raw[0] &= 0x7f;
|
||||
bigint_init ( &point.value, tmp->raw, sizeof ( tmp->raw ) );
|
||||
|
||||
/* Clamp scalar as required by RFC7748 */
|
||||
memcpy ( tmp, scalar, sizeof ( *tmp ) );
|
||||
tmp->raw[0] &= 0xf8;
|
||||
tmp->raw[31] |= 0x40;
|
||||
|
||||
/* Multiply elliptic curve point */
|
||||
x25519_ladder ( &point, tmp, &point );
|
||||
|
||||
/* Reverse result */
|
||||
bigint_done ( &point.value, result->raw, sizeof ( result->raw ) );
|
||||
x25519_reverse ( result );
|
||||
|
||||
/* Fail if result was all zeros (as required by RFC8422) */
|
||||
return ( bigint_is_zero ( &point.value ) ? -EPERM : 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiply scalar by curve point
|
||||
*
|
||||
* @v base Base point (or NULL to use generator)
|
||||
* @v scalar Scalar multiple
|
||||
* @v result Result point to fill in
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int x25519_curve_multiply ( const void *base, const void *scalar,
|
||||
void *result ) {
|
||||
|
||||
/* Use base point if applicable */
|
||||
if ( ! base )
|
||||
base = &x25519_generator;
|
||||
|
||||
return x25519_key ( base, scalar, result );
|
||||
}
|
||||
|
||||
/** X25519 elliptic curve */
|
||||
struct elliptic_curve x25519_curve = {
|
||||
.name = "x25519",
|
||||
.keysize = sizeof ( struct x25519_value ),
|
||||
.multiply = x25519_curve_multiply,
|
||||
};
|
||||
+24
-3
@@ -127,7 +127,7 @@ static int ecam_access ( struct pci_device *pci ) {
|
||||
|
||||
/* Reuse mapping if possible */
|
||||
if ( ( pci->busdevfn - ecam.range.start ) < ecam.range.count )
|
||||
return 0;
|
||||
return ecam.rc;
|
||||
|
||||
/* Clear any existing mapping */
|
||||
if ( ecam.regs ) {
|
||||
@@ -145,12 +145,22 @@ static int ecam_access ( struct pci_device *pci ) {
|
||||
if ( ecam.range.start > pci->busdevfn ) {
|
||||
DBGC ( &ecam, "ECAM found no allocation for " PCI_FMT "\n",
|
||||
PCI_ARGS ( pci ) );
|
||||
rc = -ENOENT;
|
||||
goto err_find;
|
||||
}
|
||||
|
||||
/* Map configuration space for this allocation */
|
||||
base = le64_to_cpu ( ecam.alloc.base );
|
||||
base += ( ecam.alloc.start * ECAM_SIZE * PCI_BUSDEVFN ( 0, 1, 0, 0 ) );
|
||||
len = ( ecam.range.count * ECAM_SIZE );
|
||||
if ( base != ( ( unsigned long ) base ) ) {
|
||||
DBGC ( &ecam, "ECAM %04x:[%02x-%02x] could not map "
|
||||
"[%08llx,%08llx) outside CPU range\n",
|
||||
le16_to_cpu ( ecam.alloc.segment ), ecam.alloc.start,
|
||||
ecam.alloc.end, base, ( base + len ) );
|
||||
rc = -ERANGE;
|
||||
goto err_range;
|
||||
}
|
||||
ecam.regs = ioremap ( base, len );
|
||||
if ( ! ecam.regs ) {
|
||||
DBGC ( &ecam, "ECAM %04x:[%02x-%02x] could not map "
|
||||
@@ -164,12 +174,14 @@ static int ecam_access ( struct pci_device *pci ) {
|
||||
DBGC ( &ecam, "ECAM %04x:[%02x-%02x] mapped [%08llx,%08llx) -> %p\n",
|
||||
le16_to_cpu ( ecam.alloc.segment ), ecam.alloc.start,
|
||||
ecam.alloc.end, base, ( base + len ), ecam.regs );
|
||||
ecam.rc = 0;
|
||||
return 0;
|
||||
|
||||
iounmap ( ecam.regs );
|
||||
err_ioremap:
|
||||
err_range:
|
||||
err_find:
|
||||
ecam.range.count = 0;
|
||||
ecam.rc = rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -235,7 +247,7 @@ int ecam_write ( struct pci_device *pci, unsigned int location,
|
||||
if ( ( rc = ecam_access ( pci ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Read from address */
|
||||
/* Write to address */
|
||||
index = ( pci->busdevfn - ecam.range.start );
|
||||
addr = ( ecam.regs + ( index * ECAM_SIZE ) + where );
|
||||
switch ( len ) {
|
||||
@@ -252,6 +264,15 @@ int ecam_write ( struct pci_device *pci, unsigned int location,
|
||||
assert ( 0 );
|
||||
}
|
||||
|
||||
/* Read from address, to guarantee completion of the write
|
||||
*
|
||||
* PCIe configuration space registers may not have read side
|
||||
* effects. Reading back is therefore always safe to do, and
|
||||
* guarantees that the write has reached the device.
|
||||
*/
|
||||
mb();
|
||||
ecam_read ( pci, location, &value );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,10 +230,10 @@ u32 vpm_ioread32(struct virtio_pci_modern_device *vdev,
|
||||
uint32_t data;
|
||||
switch (region->flags & VIRTIO_PCI_REGION_TYPE_MASK) {
|
||||
case VIRTIO_PCI_REGION_MEMORY:
|
||||
data = readw(region->base + offset);
|
||||
data = readl(region->base + offset);
|
||||
break;
|
||||
case VIRTIO_PCI_REGION_PORT:
|
||||
data = inw(region->base + offset);
|
||||
data = inl(region->base + offset);
|
||||
break;
|
||||
case VIRTIO_PCI_REGION_PCI_CONFIG:
|
||||
prep_pci_cfg_cap(vdev, region, offset, 4);
|
||||
|
||||
@@ -545,8 +545,8 @@ static int arbel_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
|
||||
union arbelprm_mad mad_ifc;
|
||||
int rc;
|
||||
|
||||
linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
|
||||
mad_size_mismatch );
|
||||
/* Sanity check */
|
||||
static_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ) );
|
||||
|
||||
/* Copy in request packet */
|
||||
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
|
||||
|
||||
@@ -779,8 +779,8 @@ static int hermon_mad ( struct ib_device *ibdev, union ib_mad *mad ) {
|
||||
union hermonprm_mad mad_ifc;
|
||||
int rc;
|
||||
|
||||
linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
|
||||
mad_size_mismatch );
|
||||
/* Sanity check */
|
||||
static_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ) );
|
||||
|
||||
/* Copy in request packet */
|
||||
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
|
||||
|
||||
@@ -721,7 +721,7 @@ static int linda_init_recv ( struct linda *linda ) {
|
||||
eager_array_size_other = LINDA_EAGER_ARRAY_SIZE_17CTX_OTHER;
|
||||
break;
|
||||
default:
|
||||
linker_assert ( 0, invalid_LINDA_NUM_CONTEXTS );
|
||||
build_assert ( 0 );
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1108,7 +1108,7 @@ static int linda_post_recv ( struct ib_device *ibdev,
|
||||
case 16384: bufsize = LINDA_EAGER_BUFFER_16K; break;
|
||||
case 32768: bufsize = LINDA_EAGER_BUFFER_32K; break;
|
||||
case 65536: bufsize = LINDA_EAGER_BUFFER_64K; break;
|
||||
default: linker_assert ( 0, invalid_rx_payload_size );
|
||||
default: build_assert ( 0 );
|
||||
bufsize = LINDA_EAGER_BUFFER_NONE;
|
||||
}
|
||||
|
||||
|
||||
@@ -893,7 +893,7 @@ static int qib7322_init_recv ( struct qib7322 *qib7322 ) {
|
||||
eager_array_size_user = QIB7322_EAGER_ARRAY_SIZE_18CTX_USER;
|
||||
break;
|
||||
default:
|
||||
linker_assert ( 0, invalid_QIB7322_NUM_CONTEXTS );
|
||||
build_assert ( 0 );
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
@@ -1351,7 +1351,7 @@ static int qib7322_post_recv ( struct ib_device *ibdev,
|
||||
case 16384: bufsize = QIB7322_EAGER_BUFFER_16K; break;
|
||||
case 32768: bufsize = QIB7322_EAGER_BUFFER_32K; break;
|
||||
case 65536: bufsize = QIB7322_EAGER_BUFFER_64K; break;
|
||||
default: linker_assert ( 0, invalid_rx_payload_size );
|
||||
default: build_assert ( 0 );
|
||||
bufsize = QIB7322_EAGER_BUFFER_NONE;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -272,7 +272,7 @@ static int a3c90x_setup_tx_ring(struct INF_3C90X *p)
|
||||
*/
|
||||
static void a3c90x_process_tx_packets(struct net_device *netdev)
|
||||
{
|
||||
struct INF_3C90X *p = netdev_priv(netdev);
|
||||
struct INF_3C90X *p = netdev->priv;
|
||||
unsigned int downlist_ptr;
|
||||
|
||||
DBGP("a3c90x_process_tx_packets\n");
|
||||
@@ -320,7 +320,7 @@ static void a3c90x_free_tx_ring(struct INF_3C90X *p)
|
||||
static int a3c90x_transmit(struct net_device *netdev,
|
||||
struct io_buffer *iob)
|
||||
{
|
||||
struct INF_3C90X *inf_3c90x = netdev_priv(netdev);
|
||||
struct INF_3C90X *inf_3c90x = netdev->priv;
|
||||
struct TXD *tx_cur_desc;
|
||||
struct TXD *tx_prev_desc;
|
||||
|
||||
@@ -518,7 +518,7 @@ static void a3c90x_process_rx_packets(struct net_device *netdev)
|
||||
{
|
||||
int i;
|
||||
unsigned int rx_status;
|
||||
struct INF_3C90X *p = netdev_priv(netdev);
|
||||
struct INF_3C90X *p = netdev->priv;
|
||||
struct RXD *rx_cur_desc;
|
||||
|
||||
DBGP("a3c90x_process_rx_packets\n");
|
||||
@@ -567,7 +567,7 @@ static void a3c90x_process_rx_packets(struct net_device *netdev)
|
||||
*/
|
||||
static void a3c90x_poll(struct net_device *netdev)
|
||||
{
|
||||
struct INF_3C90X *p = netdev_priv(netdev);
|
||||
struct INF_3C90X *p = netdev->priv;
|
||||
uint16_t raw_status, int_status;
|
||||
|
||||
DBGP("a3c90x_poll\n");
|
||||
@@ -611,7 +611,7 @@ static void a3c90x_free_resources(struct INF_3C90X *p)
|
||||
static void a3c90x_remove(struct pci_device *pci)
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata(pci);
|
||||
struct INF_3C90X *inf_3c90x = netdev_priv(netdev);
|
||||
struct INF_3C90X *inf_3c90x = netdev->priv;
|
||||
|
||||
DBGP("a3c90x_remove\n");
|
||||
|
||||
@@ -628,7 +628,7 @@ static void a3c90x_remove(struct pci_device *pci)
|
||||
|
||||
static void a3c90x_irq(struct net_device *netdev, int enable)
|
||||
{
|
||||
struct INF_3C90X *p = netdev_priv(netdev);
|
||||
struct INF_3C90X *p = netdev->priv;
|
||||
|
||||
DBGP("a3c90x_irq\n");
|
||||
|
||||
@@ -657,7 +657,7 @@ static void a3c90x_hw_start(struct net_device *netdev)
|
||||
unsigned int cfg;
|
||||
unsigned int mopt;
|
||||
unsigned short linktype;
|
||||
struct INF_3C90X *inf_3c90x = netdev_priv(netdev);
|
||||
struct INF_3C90X *inf_3c90x = netdev->priv;
|
||||
|
||||
DBGP("a3c90x_hw_start\n");
|
||||
|
||||
@@ -796,7 +796,7 @@ static void a3c90x_hw_start(struct net_device *netdev)
|
||||
static int a3c90x_open(struct net_device *netdev)
|
||||
{
|
||||
int rc;
|
||||
struct INF_3C90X *inf_3c90x = netdev_priv(netdev);
|
||||
struct INF_3C90X *inf_3c90x = netdev->priv;
|
||||
|
||||
DBGP("a3c90x_open\n");
|
||||
|
||||
@@ -845,7 +845,7 @@ static int a3c90x_open(struct net_device *netdev)
|
||||
*/
|
||||
static void a3c90x_close(struct net_device *netdev)
|
||||
{
|
||||
struct INF_3C90X *inf_3c90x = netdev_priv(netdev);
|
||||
struct INF_3C90X *inf_3c90x = netdev->priv;
|
||||
|
||||
DBGP("a3c90x_close\n");
|
||||
|
||||
@@ -895,7 +895,7 @@ static int a3c90x_probe(struct pci_device *pci)
|
||||
pci_set_drvdata(pci, netdev);
|
||||
netdev->dev = &pci->dev;
|
||||
|
||||
inf_3c90x = netdev_priv(netdev);
|
||||
inf_3c90x = netdev->priv;
|
||||
memset(inf_3c90x, 0, sizeof(*inf_3c90x));
|
||||
|
||||
adjust_pci_device(pci);
|
||||
|
||||
@@ -173,7 +173,7 @@ static int atl1e_check_link(struct atl1e_adapter *adapter)
|
||||
static int atl1e_mdio_read(struct net_device *netdev, int phy_id __unused,
|
||||
int reg_num)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
u16 result;
|
||||
|
||||
atl1e_read_phy_reg(&adapter->hw, reg_num & MDIO_REG_ADDR_MASK, &result);
|
||||
@@ -183,7 +183,7 @@ static int atl1e_mdio_read(struct net_device *netdev, int phy_id __unused,
|
||||
static void atl1e_mdio_write(struct net_device *netdev, int phy_id __unused,
|
||||
int reg_num, int val)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
|
||||
atl1e_write_phy_reg(&adapter->hw, reg_num & MDIO_REG_ADDR_MASK, val);
|
||||
}
|
||||
@@ -841,7 +841,7 @@ fatal_err:
|
||||
*/
|
||||
static void atl1e_poll(struct net_device *netdev)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
struct atl1e_hw *hw = &adapter->hw;
|
||||
int max_ints = 64;
|
||||
u32 status;
|
||||
@@ -963,7 +963,7 @@ static void atl1e_tx_queue(struct atl1e_adapter *adapter, u16 count __unused,
|
||||
|
||||
static int atl1e_xmit_frame(struct net_device *netdev, struct io_buffer *iob)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
u16 tpd_req = 1;
|
||||
struct atl1e_tpd_desc *tpd;
|
||||
|
||||
@@ -1013,7 +1013,7 @@ int atl1e_up(struct atl1e_adapter *adapter)
|
||||
|
||||
void atl1e_irq(struct net_device *netdev, int enable)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
|
||||
if (enable)
|
||||
atl1e_irq_enable(adapter);
|
||||
@@ -1051,7 +1051,7 @@ void atl1e_down(struct atl1e_adapter *adapter)
|
||||
*/
|
||||
static int atl1e_open(struct net_device *netdev)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
int err;
|
||||
|
||||
/* allocate rx/tx dma buffer & descriptors */
|
||||
@@ -1086,7 +1086,7 @@ err_up:
|
||||
*/
|
||||
static void atl1e_close(struct net_device *netdev)
|
||||
{
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
|
||||
atl1e_down(adapter);
|
||||
atl1e_free_ring_resources(adapter);
|
||||
@@ -1138,7 +1138,7 @@ static int atl1e_probe(struct pci_device *pdev)
|
||||
|
||||
atl1e_init_netdev(netdev, pdev);
|
||||
|
||||
adapter = netdev_priv(netdev);
|
||||
adapter = netdev->priv;
|
||||
adapter->bd_number = cards_found;
|
||||
adapter->netdev = netdev;
|
||||
adapter->pdev = pdev;
|
||||
@@ -1227,7 +1227,7 @@ err:
|
||||
static void atl1e_remove(struct pci_device *pdev)
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata(pdev);
|
||||
struct atl1e_adapter *adapter = netdev_priv(netdev);
|
||||
struct atl1e_adapter *adapter = netdev->priv;
|
||||
|
||||
unregister_netdev(netdev);
|
||||
atl1e_free_ring_resources(adapter);
|
||||
|
||||
@@ -622,7 +622,7 @@ static void b44_load_mac_and_phy_addr(struct b44_private *bp)
|
||||
|
||||
static void b44_set_rx_mode(struct net_device *netdev)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
unsigned char zero[6] = { 0, 0, 0, 0, 0, 0 };
|
||||
u32 val;
|
||||
int i;
|
||||
@@ -667,7 +667,7 @@ static int b44_probe(struct pci_device *pci)
|
||||
netdev->dev = &pci->dev;
|
||||
|
||||
/* Set up private data */
|
||||
bp = netdev_priv(netdev);
|
||||
bp = netdev->priv;
|
||||
memset(bp, 0, sizeof(*bp));
|
||||
bp->netdev = netdev;
|
||||
bp->pci = pci;
|
||||
@@ -712,7 +712,7 @@ static int b44_probe(struct pci_device *pci)
|
||||
static void b44_remove(struct pci_device *pci)
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata(pci);
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
|
||||
ssb_core_disable(bp);
|
||||
unregister_netdev(netdev);
|
||||
@@ -729,7 +729,7 @@ static void b44_remove(struct pci_device *pci)
|
||||
*/
|
||||
static void b44_irq(struct net_device *netdev, int enable)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
|
||||
/* Interrupt mask specifies which events generate interrupts */
|
||||
bw32(bp, B44_IMASK, enable ? IMASK_DEF : IMASK_DISABLE);
|
||||
@@ -743,7 +743,7 @@ static void b44_irq(struct net_device *netdev, int enable)
|
||||
*/
|
||||
static int b44_open(struct net_device *netdev)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
int rc;
|
||||
|
||||
rc = b44_init_tx_ring(bp);
|
||||
@@ -769,7 +769,7 @@ static int b44_open(struct net_device *netdev)
|
||||
*/
|
||||
static void b44_close(struct net_device *netdev)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
|
||||
b44_chip_reset(bp, B44_FULL_RESET);
|
||||
b44_free_tx_ring(bp);
|
||||
@@ -785,7 +785,7 @@ static void b44_close(struct net_device *netdev)
|
||||
*/
|
||||
static int b44_transmit(struct net_device *netdev, struct io_buffer *iobuf)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
u32 cur = bp->tx_cur;
|
||||
u32 ctrl;
|
||||
|
||||
@@ -905,7 +905,7 @@ static void b44_process_rx_packets(struct b44_private *bp)
|
||||
*/
|
||||
static void b44_poll(struct net_device *netdev)
|
||||
{
|
||||
struct b44_private *bp = netdev_priv(netdev);
|
||||
struct b44_private *bp = netdev->priv;
|
||||
u32 istat;
|
||||
|
||||
/* Interrupt status */
|
||||
|
||||
+12
-10
@@ -307,7 +307,7 @@ void bnxt_set_txq ( struct bnxt *bp, int entry, dma_addr_t mapping, int len )
|
||||
|
||||
static void bnxt_tx_complete ( struct net_device *dev, u16 hw_idx )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
struct io_buffer *iob;
|
||||
|
||||
iob = bp->tx.iob[hw_idx];
|
||||
@@ -484,7 +484,7 @@ void bnxt_rx_process ( struct net_device *dev, struct bnxt *bp,
|
||||
static int bnxt_rx_complete ( struct net_device *dev,
|
||||
struct rx_pkt_cmpl *rx_cmp )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
struct rx_pkt_cmpl_hi *rx_cmp_hi;
|
||||
u8 cmpl_bit = bp->cq.completion_bit;
|
||||
|
||||
@@ -722,7 +722,9 @@ static int bnxt_hwrm_ver_get ( struct bnxt *bp )
|
||||
( resp->dev_caps_cfg & SHORT_CMD_REQUIRED ) )
|
||||
FLAG_SET ( bp->flags, BNXT_FLAG_HWRM_SHORT_CMD_SUPP );
|
||||
bp->hwrm_max_ext_req_len = resp->max_ext_req_len;
|
||||
if ( bp->chip_num == CHIP_NUM_57500 )
|
||||
if ( ( bp->chip_num == CHIP_NUM_57508 ) ||
|
||||
( bp->chip_num == CHIP_NUM_57504 ) ||
|
||||
( bp->chip_num == CHIP_NUM_57502 ) )
|
||||
bp->thor = 1;
|
||||
dbg_fw_ver ( resp, bp->hwrm_cmd_timeout );
|
||||
return STATUS_SUCCESS;
|
||||
@@ -1927,7 +1929,7 @@ int bnxt_hwrm_run ( hwrm_func_t cmds[], struct bnxt *bp )
|
||||
|
||||
static int bnxt_open ( struct net_device *dev )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
|
||||
DBGP ( "%s\n", __func__ );
|
||||
bnxt_mm_nic ( bp );
|
||||
@@ -1952,7 +1954,7 @@ static void bnxt_tx_adjust_pkt ( struct bnxt *bp, struct io_buffer *iob )
|
||||
|
||||
static int bnxt_tx ( struct net_device *dev, struct io_buffer *iob )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
u16 len, entry;
|
||||
dma_addr_t mapping;
|
||||
|
||||
@@ -2009,7 +2011,7 @@ void bnxt_link_evt ( struct bnxt *bp, struct hwrm_async_event_cmpl *evt )
|
||||
|
||||
static void bnxt_service_cq ( struct net_device *dev )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
struct cmpl_base *cmp;
|
||||
struct tx_cmpl *tx;
|
||||
u16 old_cid = bp->cq.cons_id;
|
||||
@@ -2057,7 +2059,7 @@ static void bnxt_service_cq ( struct net_device *dev )
|
||||
|
||||
static void bnxt_service_nq ( struct net_device *dev )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
struct nq_base *nqp;
|
||||
u16 old_cid = bp->nq.cons_id;
|
||||
int done = SERVICE_NEXT_NQ_BD;
|
||||
@@ -2102,7 +2104,7 @@ static void bnxt_poll ( struct net_device *dev )
|
||||
|
||||
static void bnxt_close ( struct net_device *dev )
|
||||
{
|
||||
struct bnxt *bp = netdev_priv ( dev );
|
||||
struct bnxt *bp = dev->priv;
|
||||
|
||||
DBGP ( "%s\n", __func__ );
|
||||
bnxt_down_nic (bp);
|
||||
@@ -2143,7 +2145,7 @@ static int bnxt_init_one ( struct pci_device *pci )
|
||||
netdev_init ( netdev, &bnxt_netdev_ops );
|
||||
|
||||
/* Driver private area for this device */
|
||||
bp = netdev_priv ( netdev );
|
||||
bp = netdev->priv;
|
||||
|
||||
/* Set PCI driver private data */
|
||||
pci_set_drvdata ( pci, netdev );
|
||||
@@ -2197,7 +2199,7 @@ disable_pdev:
|
||||
static void bnxt_remove_one ( struct pci_device *pci )
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata ( pci );
|
||||
struct bnxt *bp = netdev_priv ( netdev );
|
||||
struct bnxt *bp = netdev->priv;
|
||||
|
||||
DBGP ( "%s\n", __func__ );
|
||||
/* Unregister network device */
|
||||
|
||||
@@ -868,4 +868,6 @@ struct bnxt {
|
||||
FUNC_VF_CFG_REQ_ENABLES_ASYNC_EVENT_CR | \
|
||||
FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR)
|
||||
|
||||
#define CHIP_NUM_57500 0x1750
|
||||
#define CHIP_NUM_57508 0x1750
|
||||
#define CHIP_NUM_57504 0x1751
|
||||
#define CHIP_NUM_57502 0x1752
|
||||
|
||||
@@ -690,7 +690,7 @@ static void ifec_reset ( struct net_device *netdev )
|
||||
*/
|
||||
static void ifec_free ( struct net_device *netdev )
|
||||
{
|
||||
struct ifec_private *priv = netdev_priv ( netdev );
|
||||
struct ifec_private *priv = netdev->priv;
|
||||
int i;
|
||||
|
||||
DBGP ( "ifec_free\n" );
|
||||
|
||||
@@ -97,7 +97,7 @@ static const char * snpnet_mac_text ( EFI_MAC_ADDRESS *mac, size_t len ) {
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void snpnet_dump_mode ( struct net_device *netdev ) {
|
||||
struct snp_nic *snp = netdev_priv ( netdev );
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
|
||||
size_t mac_len = mode->HwAddressSize;
|
||||
unsigned int i;
|
||||
@@ -136,7 +136,7 @@ static void snpnet_dump_mode ( struct net_device *netdev ) {
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void snpnet_check_link ( struct net_device *netdev ) {
|
||||
struct snp_nic *snp = netdev_priv ( netdev );
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
|
||||
|
||||
/* Do nothing unless media presence detection is supported */
|
||||
@@ -160,7 +160,7 @@ static void snpnet_check_link ( struct net_device *netdev ) {
|
||||
*/
|
||||
static int snpnet_transmit ( struct net_device *netdev,
|
||||
struct io_buffer *iobuf ) {
|
||||
struct snp_nic *snp = netdev_priv ( netdev );
|
||||
struct snp_nic *snp = netdev->priv;
|
||||
EFI_STATUS efirc;
|
||||
int rc;
|
||||
|
||||
|
||||
@@ -3725,7 +3725,7 @@ efab_receive ( struct efab_nic *efab, unsigned int id, int len, int drop )
|
||||
static int
|
||||
efab_transmit ( struct net_device *netdev, struct io_buffer *iob )
|
||||
{
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
struct efab_tx_queue *tx_queue = &efab->tx_queue;
|
||||
int fill_level, space;
|
||||
falcon_tx_desc_t *txd;
|
||||
@@ -3844,7 +3844,7 @@ falcon_handle_event ( struct efab_nic *efab, falcon_event_t *evt )
|
||||
static void
|
||||
efab_poll ( struct net_device *netdev )
|
||||
{
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
struct efab_ev_queue *ev_queue = &efab->ev_queue;
|
||||
struct efab_rx_queue *rx_queue = &efab->rx_queue;
|
||||
falcon_event_t *evt;
|
||||
@@ -3883,7 +3883,7 @@ efab_poll ( struct net_device *netdev )
|
||||
static void
|
||||
efab_irq ( struct net_device *netdev, int enable )
|
||||
{
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
struct efab_ev_queue *ev_queue = &efab->ev_queue;
|
||||
|
||||
switch ( enable ) {
|
||||
@@ -4032,7 +4032,7 @@ efab_init_mac ( struct efab_nic *efab )
|
||||
static void
|
||||
efab_close ( struct net_device *netdev )
|
||||
{
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
|
||||
falcon_fini_resources ( efab );
|
||||
efab_free_resources ( efab );
|
||||
@@ -4043,7 +4043,7 @@ efab_close ( struct net_device *netdev )
|
||||
static int
|
||||
efab_open ( struct net_device *netdev )
|
||||
{
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
struct efab_rx_queue *rx_queue = &efab->rx_queue;
|
||||
int rc;
|
||||
|
||||
@@ -4104,7 +4104,7 @@ static void
|
||||
efab_remove ( struct pci_device *pci )
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata ( pci );
|
||||
struct efab_nic *efab = netdev_priv ( netdev );
|
||||
struct efab_nic *efab = netdev->priv;
|
||||
|
||||
if ( efab->membase ) {
|
||||
falcon_reset ( efab );
|
||||
@@ -4143,7 +4143,7 @@ efab_probe ( struct pci_device *pci )
|
||||
pci_set_drvdata ( pci, netdev );
|
||||
netdev->dev = &pci->dev;
|
||||
|
||||
efab = netdev_priv ( netdev );
|
||||
efab = netdev->priv;
|
||||
memset ( efab, 0, sizeof ( *efab ) );
|
||||
efab->netdev = netdev;
|
||||
|
||||
|
||||
@@ -677,7 +677,7 @@ set_speed:
|
||||
static int
|
||||
forcedeth_open ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
void *ioaddr = priv->mmio_addr;
|
||||
int i;
|
||||
int rc;
|
||||
@@ -794,7 +794,7 @@ err_init_rings:
|
||||
static int
|
||||
forcedeth_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
void *ioaddr = priv->mmio_addr;
|
||||
struct ring_desc *tx_curr_desc;
|
||||
u32 size = iob_len ( iobuf );
|
||||
@@ -853,7 +853,7 @@ forcedeth_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
|
||||
static void
|
||||
nv_process_tx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
struct ring_desc *tx_curr_desc;
|
||||
u32 flaglen;
|
||||
|
||||
@@ -899,7 +899,7 @@ nv_process_tx_packets ( struct net_device *netdev )
|
||||
static void
|
||||
nv_process_rx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
struct io_buffer *curr_iob;
|
||||
struct ring_desc *rx_curr_desc;
|
||||
u32 flags, len;
|
||||
@@ -960,7 +960,7 @@ nv_process_rx_packets ( struct net_device *netdev )
|
||||
static void
|
||||
forcedeth_link_status ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
void *ioaddr = priv->mmio_addr;
|
||||
|
||||
/* Clear the MII link change status by reading the MIIStatus register */
|
||||
@@ -981,7 +981,7 @@ forcedeth_link_status ( struct net_device *netdev )
|
||||
static void
|
||||
forcedeth_poll ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
void *ioaddr = priv->mmio_addr;
|
||||
u32 status;
|
||||
|
||||
@@ -1018,7 +1018,7 @@ forcedeth_poll ( struct net_device *netdev )
|
||||
static void
|
||||
forcedeth_close ( struct net_device *netdev )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
|
||||
DBGP ( "forcedeth_close\n" );
|
||||
|
||||
@@ -1045,7 +1045,7 @@ forcedeth_close ( struct net_device *netdev )
|
||||
static void
|
||||
forcedeth_irq ( struct net_device *netdev, int action )
|
||||
{
|
||||
struct forcedeth_private *priv = netdev_priv ( netdev );
|
||||
struct forcedeth_private *priv = netdev->priv;
|
||||
|
||||
DBGP ( "forcedeth_irq\n" );
|
||||
|
||||
@@ -1814,7 +1814,7 @@ forcedeth_probe ( struct pci_device *pdev )
|
||||
netdev->dev = &pdev->dev;
|
||||
|
||||
/* Get a reference to our private data */
|
||||
priv = netdev_priv ( netdev );
|
||||
priv = netdev->priv;
|
||||
|
||||
/* We'll need these set up for the rest of the routines */
|
||||
priv->pci_dev = pdev;
|
||||
|
||||
@@ -179,7 +179,7 @@ static void igbvf_irq_enable ( struct igbvf_adapter *adapter )
|
||||
**/
|
||||
static void igbvf_irq ( struct net_device *netdev, int enable )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
|
||||
DBG ( "igbvf_irq\n" );
|
||||
|
||||
@@ -197,7 +197,7 @@ static void igbvf_irq ( struct net_device *netdev, int enable )
|
||||
**/
|
||||
static void igbvf_process_tx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
uint32_t i;
|
||||
uint32_t tx_status;
|
||||
union e1000_adv_tx_desc *tx_curr_desc;
|
||||
@@ -243,7 +243,7 @@ static void igbvf_process_tx_packets ( struct net_device *netdev )
|
||||
**/
|
||||
static void igbvf_process_rx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
uint32_t i;
|
||||
uint32_t rx_status;
|
||||
@@ -306,7 +306,7 @@ static void igbvf_process_rx_packets ( struct net_device *netdev )
|
||||
*/
|
||||
static void igbvf_poll ( struct net_device *netdev )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
uint32_t rx_status;
|
||||
union e1000_adv_rx_desc *rx_curr_desc;
|
||||
|
||||
@@ -612,7 +612,7 @@ int igbvf_setup_rx_resources ( struct igbvf_adapter *adapter )
|
||||
**/
|
||||
static int igbvf_open ( struct net_device *netdev )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
int err;
|
||||
|
||||
DBG ("igbvf_open\n");
|
||||
@@ -667,7 +667,7 @@ err_setup_tx:
|
||||
**/
|
||||
static void igbvf_close ( struct net_device *netdev )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
uint32_t rxdctl;
|
||||
|
||||
@@ -698,7 +698,7 @@ static void igbvf_close ( struct net_device *netdev )
|
||||
*/
|
||||
static int igbvf_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
|
||||
{
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
struct e1000_hw *hw = &adapter->hw;
|
||||
uint32_t tx_curr = adapter->tx_tail;
|
||||
union e1000_adv_tx_desc *tx_curr_desc;
|
||||
@@ -810,7 +810,7 @@ int igbvf_probe ( struct pci_device *pdev )
|
||||
netdev->dev = &pdev->dev;
|
||||
|
||||
/* Initialize driver private storage */
|
||||
adapter = netdev_priv ( netdev );
|
||||
adapter = netdev->priv;
|
||||
memset ( adapter, 0, ( sizeof ( *adapter ) ) );
|
||||
|
||||
adapter->pdev = pdev;
|
||||
@@ -924,7 +924,7 @@ err_alloc_etherdev:
|
||||
void igbvf_remove ( struct pci_device *pdev )
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata ( pdev );
|
||||
struct igbvf_adapter *adapter = netdev_priv ( netdev );
|
||||
struct igbvf_adapter *adapter = netdev->priv;
|
||||
|
||||
DBG ( "igbvf_remove\n" );
|
||||
|
||||
|
||||
@@ -1043,6 +1043,7 @@ static struct pci_device_id intel_nics[] = {
|
||||
PCI_ROM ( 0x8086, 0x0d4f, "i219v-10", "I219-V (10)", INTEL_I219 ),
|
||||
PCI_ROM ( 0x8086, 0x0d53, "i219lm-12", "I219-LM (12)", INTEL_I219 ),
|
||||
PCI_ROM ( 0x8086, 0x0d55, "i219v-12", "I219-V (12)", INTEL_I219 ),
|
||||
PCI_ROM ( 0x8086, 0x0dc5, "i219lm-23", "I219-LM (23)", INTEL_I219 ),
|
||||
PCI_ROM ( 0x8086, 0x1000, "82542-f", "82542 (Fiber)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1001, "82543gc-f", "82543GC (Fiber)", 0 ),
|
||||
PCI_ROM ( 0x8086, 0x1004, "82543gc", "82543GC (Copper)", 0 ),
|
||||
|
||||
@@ -1304,7 +1304,9 @@ ipair_tx ( struct ipair *ipair, const char *fmt, ... ) {
|
||||
memset ( hdr, 0, sizeof ( *hdr ) );
|
||||
hdr->len = htonl ( len );
|
||||
msg = iob_put ( iobuf, len );
|
||||
va_start ( args, fmt );
|
||||
vsnprintf ( msg, len, fmt, args );
|
||||
va_end ( args );
|
||||
DBGC2 ( ipair, "IPAIR %p transmitting:\n%s\n", ipair, msg );
|
||||
|
||||
/* Transmit message */
|
||||
|
||||
@@ -1153,7 +1153,7 @@ jme_reload_eeprom(struct jme_adapter *jme)
|
||||
static void
|
||||
jme_load_macaddr(struct net_device *netdev)
|
||||
{
|
||||
struct jme_adapter *jme = netdev_priv(netdev);
|
||||
struct jme_adapter *jme = netdev->priv;
|
||||
unsigned char macaddr[6];
|
||||
u32 val;
|
||||
|
||||
|
||||
@@ -1056,9 +1056,11 @@ struct xen_driver netfront_driver __xen_driver = {
|
||||
* Inhibit emulated PCI devices
|
||||
*
|
||||
* @v netdev Network device
|
||||
* @v priv Private data
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int netfront_net_probe ( struct net_device *netdev ) {
|
||||
static int netfront_net_probe ( struct net_device *netdev,
|
||||
void *priv __unused ) {
|
||||
struct netfront_nic *netfront;
|
||||
|
||||
/* Inhibit emulated PCI devices matching an existing netfront device */
|
||||
|
||||
@@ -690,7 +690,7 @@ pcnet32_hw_start ( struct pcnet32_private *priv )
|
||||
static int
|
||||
pcnet32_open ( struct net_device *netdev )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
unsigned long ioaddr = priv->pci_dev->ioaddr;
|
||||
int rc;
|
||||
u16 val;
|
||||
@@ -754,7 +754,7 @@ err_setup_tx:
|
||||
static int
|
||||
pcnet32_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
unsigned long ioaddr = priv->pci_dev->ioaddr;
|
||||
uint32_t tx_len = iob_len ( iobuf );
|
||||
struct pcnet32_tx_desc *tx_curr_desc;
|
||||
@@ -802,7 +802,7 @@ pcnet32_transmit ( struct net_device *netdev, struct io_buffer *iobuf )
|
||||
static void
|
||||
pcnet32_process_tx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
struct pcnet32_tx_desc *tx_curr_desc;
|
||||
|
||||
DBGP ( "pcnet32_process_tx_packets\n" );
|
||||
@@ -848,7 +848,7 @@ pcnet32_process_tx_packets ( struct net_device *netdev )
|
||||
static void
|
||||
pcnet32_process_rx_packets ( struct net_device *netdev )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
struct pcnet32_rx_desc *rx_curr_desc;
|
||||
u16 status;
|
||||
u32 len;
|
||||
@@ -913,7 +913,7 @@ pcnet32_process_rx_packets ( struct net_device *netdev )
|
||||
static void
|
||||
pcnet32_poll ( struct net_device *netdev )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
unsigned long ioaddr = priv->pci_dev->ioaddr;
|
||||
u16 status;
|
||||
|
||||
@@ -946,7 +946,7 @@ pcnet32_poll ( struct net_device *netdev )
|
||||
static void
|
||||
pcnet32_close ( struct net_device *netdev )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
unsigned long ioaddr = priv->pci_dev->ioaddr;
|
||||
|
||||
DBGP ( "pcnet32_close\n" );
|
||||
@@ -1003,7 +1003,7 @@ static void pcnet32_irq_disable ( struct pcnet32_private *priv )
|
||||
static void
|
||||
pcnet32_irq ( struct net_device *netdev, int action )
|
||||
{
|
||||
struct pcnet32_private *priv = netdev_priv ( netdev );
|
||||
struct pcnet32_private *priv = netdev->priv;
|
||||
|
||||
DBGP ( "pcnet32_irq\n" );
|
||||
|
||||
@@ -1061,7 +1061,7 @@ pcnet32_probe ( struct pci_device *pdev )
|
||||
netdev->dev = &pdev->dev;
|
||||
|
||||
/* Get a reference to our private data */
|
||||
priv = netdev_priv ( netdev );
|
||||
priv = netdev->priv;
|
||||
|
||||
/* We'll need these set up for the rest of the routines */
|
||||
priv->pci_dev = pdev;
|
||||
|
||||
@@ -1062,7 +1062,7 @@ static inline int phantom_del_macaddr ( struct phantom_nic *phantom,
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void phantom_poll_link_state ( struct net_device *netdev ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
uint32_t xg_state_p3;
|
||||
unsigned int link;
|
||||
|
||||
@@ -1109,7 +1109,7 @@ static void phantom_poll_link_state ( struct net_device *netdev ) {
|
||||
* @v netdev Net device
|
||||
*/
|
||||
static void phantom_refill_rx_ring ( struct net_device *netdev ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
struct io_buffer *iobuf;
|
||||
struct phantom_rds rds;
|
||||
unsigned int handle;
|
||||
@@ -1160,7 +1160,7 @@ static void phantom_refill_rx_ring ( struct net_device *netdev ) {
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int phantom_open ( struct net_device *netdev ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
int rc;
|
||||
|
||||
/* Allocate and zero descriptor rings */
|
||||
@@ -1220,7 +1220,7 @@ static int phantom_open ( struct net_device *netdev ) {
|
||||
* @v netdev Net device
|
||||
*/
|
||||
static void phantom_close ( struct net_device *netdev ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
struct io_buffer *iobuf;
|
||||
unsigned int i;
|
||||
|
||||
@@ -1258,7 +1258,7 @@ static void phantom_close ( struct net_device *netdev ) {
|
||||
*/
|
||||
static int phantom_transmit ( struct net_device *netdev,
|
||||
struct io_buffer *iobuf ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
union phantom_cds cds;
|
||||
int index;
|
||||
|
||||
@@ -1297,7 +1297,7 @@ static int phantom_transmit ( struct net_device *netdev,
|
||||
* @v netdev Network device
|
||||
*/
|
||||
static void phantom_poll ( struct net_device *netdev ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
struct io_buffer *iobuf;
|
||||
unsigned int irq_vector;
|
||||
unsigned int irq_state;
|
||||
@@ -1434,7 +1434,7 @@ static void phantom_poll ( struct net_device *netdev ) {
|
||||
* @v enable Interrupts should be enabled
|
||||
*/
|
||||
static void phantom_irq ( struct net_device *netdev, int enable ) {
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
|
||||
phantom_writel ( phantom, ( enable ? 1 : 0 ),
|
||||
phantom->sds_irq_mask_crb );
|
||||
@@ -2070,7 +2070,7 @@ static int phantom_probe ( struct pci_device *pci ) {
|
||||
goto err_alloc_etherdev;
|
||||
}
|
||||
netdev_init ( netdev, &phantom_operations );
|
||||
phantom = netdev_priv ( netdev );
|
||||
phantom = netdev->priv;
|
||||
pci_set_drvdata ( pci, netdev );
|
||||
netdev->dev = &pci->dev;
|
||||
memset ( phantom, 0, sizeof ( *phantom ) );
|
||||
@@ -2161,7 +2161,7 @@ static int phantom_probe ( struct pci_device *pci ) {
|
||||
*/
|
||||
static void phantom_remove ( struct pci_device *pci ) {
|
||||
struct net_device *netdev = pci_get_drvdata ( pci );
|
||||
struct phantom_nic *phantom = netdev_priv ( netdev );
|
||||
struct phantom_nic *phantom = netdev->priv;
|
||||
|
||||
unregister_settings ( &phantom->settings );
|
||||
unregister_netdev ( netdev );
|
||||
|
||||
@@ -70,7 +70,7 @@ efx_readl(struct efx_nic *efx, efx_dword_t *value, unsigned int reg)
|
||||
******************************************************************************/
|
||||
void efx_probe(struct net_device *netdev, enum efx_revision revision)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct pci_device *pci = container_of(netdev->dev,
|
||||
struct pci_device, dev);
|
||||
unsigned int reg = PCI_BASE_ADDRESS_0;
|
||||
@@ -97,7 +97,7 @@ void efx_probe(struct net_device *netdev, enum efx_revision revision)
|
||||
|
||||
void efx_remove(struct net_device *netdev)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
|
||||
iounmap(efx->membase);
|
||||
efx->membase = NULL;
|
||||
|
||||
@@ -100,7 +100,7 @@ efx_hunt_notify_tx_desc(struct efx_nic *efx)
|
||||
int
|
||||
efx_hunt_transmit(struct net_device *netdev, struct io_buffer *iob)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_tx_queue *txq = &efx->txq;
|
||||
int fill_level, space;
|
||||
efx_tx_desc_t *txd;
|
||||
@@ -155,7 +155,7 @@ efx_hunt_transmit_done(struct efx_nic *efx, int id)
|
||||
|
||||
int efx_hunt_tx_init(struct net_device *netdev, dma_addr_t *dma_addr)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_tx_queue *txq = &efx->txq;
|
||||
size_t bytes;
|
||||
|
||||
@@ -270,7 +270,7 @@ efx_hunt_receive(struct efx_nic *efx, unsigned int id, int len, int drop)
|
||||
|
||||
int efx_hunt_rx_init(struct net_device *netdev, dma_addr_t *dma_addr)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_rx_queue *rxq = &efx->rxq;
|
||||
size_t bytes;
|
||||
|
||||
@@ -294,7 +294,7 @@ int efx_hunt_rx_init(struct net_device *netdev, dma_addr_t *dma_addr)
|
||||
******************************************************************************/
|
||||
int efx_hunt_ev_init(struct net_device *netdev, dma_addr_t *dma_addr)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_ev_queue *evq = &efx->evq;
|
||||
size_t bytes;
|
||||
|
||||
@@ -404,7 +404,7 @@ efx_hunt_handle_event(struct efx_nic *efx, efx_event_t *evt)
|
||||
|
||||
void efx_hunt_poll(struct net_device *netdev)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_ev_queue *evq = &efx->evq;
|
||||
efx_event_t *evt;
|
||||
int budget = 10;
|
||||
@@ -443,7 +443,7 @@ void efx_hunt_poll(struct net_device *netdev)
|
||||
|
||||
void efx_hunt_irq(struct net_device *netdev, int enable)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
|
||||
efx->int_en = enable;
|
||||
|
||||
@@ -465,7 +465,7 @@ void efx_hunt_irq(struct net_device *netdev, int enable)
|
||||
******************************************************************************/
|
||||
int efx_hunt_open(struct net_device *netdev)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
efx_dword_t cmd;
|
||||
|
||||
/* Set interrupt moderation to 0*/
|
||||
@@ -486,7 +486,7 @@ int efx_hunt_open(struct net_device *netdev)
|
||||
|
||||
void efx_hunt_close(struct net_device *netdev)
|
||||
{
|
||||
struct efx_nic *efx = netdev_priv(netdev);
|
||||
struct efx_nic *efx = netdev->priv;
|
||||
struct efx_rx_queue *rxq = &efx->rxq;
|
||||
struct efx_tx_queue *txq = &efx->txq;
|
||||
int i;
|
||||
|
||||
@@ -1043,7 +1043,7 @@ static void hunt_ev_fini(struct hunt_nic *hunt)
|
||||
static void
|
||||
hunt_poll(struct net_device *netdev)
|
||||
{
|
||||
struct hunt_nic *hunt = netdev_priv(netdev);
|
||||
struct hunt_nic *hunt = netdev->priv;
|
||||
|
||||
/* If called while already polling, return immediately */
|
||||
if (hunt->efx.state & EFX_STATE_POLLING)
|
||||
@@ -1071,7 +1071,7 @@ hunt_poll(struct net_device *netdev)
|
||||
******************************************************************************/
|
||||
static int hunt_open(struct net_device *netdev)
|
||||
{
|
||||
struct hunt_nic *hunt = netdev_priv(netdev);
|
||||
struct hunt_nic *hunt = netdev->priv;
|
||||
int rc;
|
||||
|
||||
/* Allocate VIs */
|
||||
@@ -1133,7 +1133,7 @@ fail2:
|
||||
|
||||
static void hunt_close(struct net_device *netdev)
|
||||
{
|
||||
struct hunt_nic *hunt = netdev_priv(netdev);
|
||||
struct hunt_nic *hunt = netdev->priv;
|
||||
|
||||
/* Stop datapath */
|
||||
efx_hunt_close(netdev);
|
||||
@@ -1187,7 +1187,7 @@ hunt_probe(struct pci_device *pci)
|
||||
netdev->dev = &pci->dev;
|
||||
netdev->state |= NETDEV_IRQ_UNSUPPORTED;
|
||||
|
||||
hunt = netdev_priv(netdev);
|
||||
hunt = netdev->priv;
|
||||
memset(hunt, 0, sizeof(*hunt));
|
||||
efx = &hunt->efx;
|
||||
|
||||
@@ -1290,7 +1290,7 @@ fail1:
|
||||
static void hunt_remove(struct pci_device *pci)
|
||||
{
|
||||
struct net_device *netdev = pci_get_drvdata(pci);
|
||||
struct hunt_nic *hunt = netdev_priv(netdev);
|
||||
struct hunt_nic *hunt = netdev->priv;
|
||||
|
||||
if (!(hunt->flags &
|
||||
(1 << MC_CMD_DRV_ATTACH_EXT_OUT_FLAG_NO_ACTIVE_PORT))) {
|
||||
|
||||
+19
-19
@@ -107,14 +107,14 @@ static int mdio_read(void *ioaddr, int phy_id, int reg)
|
||||
|
||||
static void __mdio_write(struct net_device *dev, int phy_id, int reg, int val)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
|
||||
mdio_write(tp->mmio_addr, phy_id, reg, val);
|
||||
}
|
||||
|
||||
static int __mdio_read(struct net_device *dev, int phy_id, int reg)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
|
||||
return mdio_read(tp->mmio_addr, phy_id, reg);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ static void sis190_process_tx(struct sis190_private *tp)
|
||||
*/
|
||||
static void sis190_poll(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
u32 status;
|
||||
|
||||
@@ -374,7 +374,7 @@ static inline void sis190_init_ring_indexes(struct sis190_private *tp)
|
||||
|
||||
static int sis190_init_ring(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
|
||||
sis190_init_ring_indexes(tp);
|
||||
|
||||
@@ -395,7 +395,7 @@ err:
|
||||
|
||||
static void sis190_set_rx_mode(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
u32 mc_filter[2]; /* Multicast hash filter */
|
||||
u16 rx_mode;
|
||||
@@ -419,7 +419,7 @@ static void sis190_soft_reset(void *ioaddr)
|
||||
|
||||
static void sis190_hw_start(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
|
||||
sis190_soft_reset(ioaddr);
|
||||
@@ -548,7 +548,7 @@ static void sis190_phy_task(struct sis190_private *tp)
|
||||
|
||||
static int sis190_open(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
int rc;
|
||||
|
||||
/* Allocate TX ring */
|
||||
@@ -587,7 +587,7 @@ error:
|
||||
|
||||
static void sis190_down(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
|
||||
do {
|
||||
@@ -597,7 +597,7 @@ static void sis190_down(struct net_device *dev)
|
||||
|
||||
static void sis190_free(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
int i;
|
||||
|
||||
free_phys(tp->TxDescRing, TX_RING_BYTES);
|
||||
@@ -630,7 +630,7 @@ static void sis190_close(struct net_device *dev)
|
||||
|
||||
static int sis190_transmit(struct net_device *dev, struct io_buffer *iob)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
u32 len, entry;
|
||||
struct TxDesc *desc;
|
||||
@@ -804,7 +804,7 @@ static void sis190_mii_probe_88e1111_fixup(struct sis190_private *tp)
|
||||
*/
|
||||
static int sis190_mii_probe(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
struct mii_if_info *mii_if = &tp->mii_if;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
int phy_id;
|
||||
@@ -858,7 +858,7 @@ out:
|
||||
|
||||
static void sis190_mii_remove(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
|
||||
sis190_free_phy(&tp->first_phy);
|
||||
}
|
||||
@@ -879,7 +879,7 @@ static int sis190_init_board(struct pci_device *pdev, struct net_device **netdev
|
||||
|
||||
dev->dev = &pdev->dev;
|
||||
|
||||
tp = netdev_priv(dev);
|
||||
tp = dev->priv;
|
||||
memset(tp, 0, sizeof(*tp));
|
||||
|
||||
tp->dev = dev;
|
||||
@@ -916,7 +916,7 @@ static void sis190_set_rgmii(struct sis190_private *tp, u8 reg)
|
||||
static int sis190_get_mac_addr_from_eeprom(struct pci_device *pdev __unused,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
u16 sig;
|
||||
int i;
|
||||
@@ -955,7 +955,7 @@ static int sis190_get_mac_addr_from_eeprom(struct pci_device *pdev __unused,
|
||||
static int sis190_get_mac_addr_from_apc(struct pci_device *pdev,
|
||||
struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
struct pci_device *isa_bridge = NULL;
|
||||
struct device *d;
|
||||
u8 reg, tmp8;
|
||||
@@ -1018,7 +1018,7 @@ static int sis190_get_mac_addr_from_apc(struct pci_device *pdev,
|
||||
*/
|
||||
static inline void sis190_init_rxfilter(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
u16 ctl;
|
||||
int i;
|
||||
@@ -1057,7 +1057,7 @@ static int sis190_get_mac_addr(struct pci_device *pdev,
|
||||
|
||||
static void sis190_set_speed_auto(struct net_device *dev)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
int phy_id = tp->mii_if.phy_id;
|
||||
int val;
|
||||
@@ -1082,7 +1082,7 @@ static void sis190_set_speed_auto(struct net_device *dev)
|
||||
|
||||
static void sis190_irq(struct net_device *dev, int enable)
|
||||
{
|
||||
struct sis190_private *tp = netdev_priv(dev);
|
||||
struct sis190_private *tp = dev->priv;
|
||||
void *ioaddr = tp->mmio_addr;
|
||||
|
||||
SIS_W32(IntrStatus, 0xffffffff);
|
||||
@@ -1116,7 +1116,7 @@ static int sis190_probe(struct pci_device *pdev)
|
||||
|
||||
pci_set_drvdata(pdev, dev);
|
||||
|
||||
tp = netdev_priv(dev);
|
||||
tp = dev->priv;
|
||||
|
||||
rc = sis190_get_mac_addr(pdev, dev);
|
||||
if (rc < 0)
|
||||
|
||||
+21
-21
@@ -213,7 +213,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
|
||||
*
|
||||
* static int skge_get_eeprom_len(struct net_device *dev)
|
||||
* {
|
||||
* struct skge_port *skge = netdev_priv(dev);
|
||||
* struct skge_port *skge = dev->priv;
|
||||
* u32 reg2;
|
||||
*
|
||||
* pci_read_config_dword(skge->hw->pdev, PCI_DEV_REG2, ®2);
|
||||
@@ -248,7 +248,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
|
||||
* static int skge_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
|
||||
* u8 *data)
|
||||
* {
|
||||
* struct skge_port *skge = netdev_priv(dev);
|
||||
* struct skge_port *skge = dev->priv;
|
||||
* struct pci_dev *pdev = skge->hw->pdev;
|
||||
* int cap = pci_find_capability(pdev, PCI_CAP_ID_VPD);
|
||||
* int length = eeprom->len;
|
||||
@@ -274,7 +274,7 @@ static void skge_led(struct skge_port *skge, enum led_mode mode)
|
||||
* static int skge_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
|
||||
* u8 *data)
|
||||
* {
|
||||
* struct skge_port *skge = netdev_priv(dev);
|
||||
* struct skge_port *skge = dev->priv;
|
||||
* struct pci_dev *pdev = skge->hw->pdev;
|
||||
* int cap = pci_find_capability(pdev, PCI_CAP_ID_VPD);
|
||||
* int length = eeprom->len;
|
||||
@@ -415,7 +415,7 @@ static void skge_link_down(struct skge_port *skge)
|
||||
static void xm_link_down(struct skge_hw *hw, int port)
|
||||
{
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
|
||||
xm_write16(hw, port, XM_IMSK, XM_IMSK_DISABLE);
|
||||
|
||||
@@ -553,7 +553,7 @@ static const u16 fiber_pause_map[] = {
|
||||
static void bcom_check_link(struct skge_hw *hw, int port)
|
||||
{
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
u16 status;
|
||||
|
||||
/* read twice because of latch */
|
||||
@@ -751,7 +751,7 @@ static void xm_phy_init(struct skge_port *skge)
|
||||
|
||||
static int xm_check_link(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
int port = skge->port;
|
||||
u16 status;
|
||||
@@ -852,7 +852,7 @@ static void xm_link_timer(struct skge_port *skge)
|
||||
static void genesis_mac_init(struct skge_hw *hw, int port)
|
||||
{
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
int i;
|
||||
u32 r;
|
||||
const u8 zero[6] = { 0 };
|
||||
@@ -1209,7 +1209,7 @@ static u16 gm_phy_read(struct skge_hw *hw, int port, u16 reg)
|
||||
/* Marvell Phy Initialization */
|
||||
static void yukon_init(struct skge_hw *hw, int port)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(hw->dev[port]);
|
||||
struct skge_port *skge = hw->dev[port]->priv;
|
||||
u16 ctrl, ct1000, adv;
|
||||
|
||||
if (skge->autoneg == AUTONEG_ENABLE) {
|
||||
@@ -1325,7 +1325,7 @@ static int is_yukon_lite_a0(struct skge_hw *hw)
|
||||
|
||||
static void yukon_mac_init(struct skge_hw *hw, int port)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(hw->dev[port]);
|
||||
struct skge_port *skge = hw->dev[port]->priv;
|
||||
int i;
|
||||
u32 reg;
|
||||
const u8 *addr = hw->dev[port]->ll_addr;
|
||||
@@ -1691,7 +1691,7 @@ static void skge_qset(struct skge_port *skge, u16 q,
|
||||
|
||||
void skge_free(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
|
||||
free(skge->rx_ring.start);
|
||||
skge->rx_ring.start = NULL;
|
||||
@@ -1706,7 +1706,7 @@ void skge_free(struct net_device *dev)
|
||||
|
||||
static int skge_up(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
int port = skge->port;
|
||||
u32 chunk, ram_addr;
|
||||
@@ -1789,7 +1789,7 @@ static void skge_rx_stop(struct skge_hw *hw, int port)
|
||||
|
||||
static void skge_down(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
int port = skge->port;
|
||||
|
||||
@@ -1862,7 +1862,7 @@ static inline int skge_tx_avail(const struct skge_ring *ring)
|
||||
|
||||
static int skge_xmit_frame(struct net_device *dev, struct io_buffer *iob)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
struct skge_element *e;
|
||||
struct skge_tx_desc *td;
|
||||
@@ -1908,7 +1908,7 @@ static int skge_xmit_frame(struct net_device *dev, struct io_buffer *iob)
|
||||
/* Free all buffers in transmit ring */
|
||||
static void skge_tx_clean(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_element *e;
|
||||
|
||||
for (e = skge->tx_ring.to_clean; e != skge->tx_ring.to_use; e = e->next) {
|
||||
@@ -1939,7 +1939,7 @@ static inline int bad_phy_status(const struct skge_hw *hw, u32 status)
|
||||
/* Free all buffers in Tx ring which are no longer owned by device */
|
||||
static void skge_tx_done(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_ring *ring = &skge->tx_ring;
|
||||
struct skge_element *e;
|
||||
|
||||
@@ -1961,7 +1961,7 @@ static void skge_tx_done(struct net_device *dev)
|
||||
|
||||
static void skge_rx_refill(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_ring *ring = &skge->rx_ring;
|
||||
struct skge_element *e;
|
||||
struct io_buffer *iob;
|
||||
@@ -2003,7 +2003,7 @@ static void skge_rx_refill(struct net_device *dev)
|
||||
|
||||
static void skge_rx_done(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_ring *ring = &skge->rx_ring;
|
||||
struct skge_rx_desc *rd;
|
||||
struct skge_element *e;
|
||||
@@ -2050,7 +2050,7 @@ static void skge_rx_done(struct net_device *dev)
|
||||
|
||||
static void skge_poll(struct net_device *dev)
|
||||
{
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
u32 status;
|
||||
|
||||
@@ -2085,7 +2085,7 @@ static void skge_phyirq(struct skge_hw *hw)
|
||||
|
||||
for (port = 0; port < hw->ports; port++) {
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
|
||||
if (hw->chip_id != CHIP_ID_GENESIS)
|
||||
yukon_phy_intr(skge);
|
||||
@@ -2302,7 +2302,7 @@ static struct net_device *skge_devinit(struct skge_hw *hw, int port,
|
||||
|
||||
dev->dev = &hw->pdev->dev;
|
||||
|
||||
skge = netdev_priv(dev);
|
||||
skge = dev->priv;
|
||||
skge->netdev = dev;
|
||||
skge->hw = hw;
|
||||
|
||||
@@ -2446,7 +2446,7 @@ static void skge_remove(struct pci_device *pdev)
|
||||
* This is a iPXE Network Driver API function.
|
||||
*/
|
||||
static void skge_net_irq ( struct net_device *dev, int enable ) {
|
||||
struct skge_port *skge = netdev_priv(dev);
|
||||
struct skge_port *skge = dev->priv;
|
||||
struct skge_hw *hw = skge->hw;
|
||||
|
||||
if (enable)
|
||||
|
||||
+15
-15
@@ -296,7 +296,7 @@ static const u16 gm_fc_disable[] = {
|
||||
|
||||
static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(hw->dev[port]);
|
||||
struct sky2_port *sky2 = hw->dev[port]->priv;
|
||||
u16 ctrl, ct1000, adv, pg, ledctrl, ledover, reg;
|
||||
|
||||
if (sky2->autoneg == AUTONEG_ENABLE &&
|
||||
@@ -1128,7 +1128,7 @@ static void sky2_free_rings(struct sky2_port *sky2)
|
||||
/* Bring up network interface. */
|
||||
static int sky2_up(struct net_device *dev)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
unsigned port = sky2->port;
|
||||
u32 imask, ramsize;
|
||||
@@ -1237,7 +1237,7 @@ static inline int tx_avail(const struct sky2_port *sky2)
|
||||
*/
|
||||
static int sky2_xmit_frame(struct net_device *dev, struct io_buffer *iob)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
struct sky2_tx_le *le = NULL;
|
||||
struct tx_ring_info *re;
|
||||
@@ -1303,7 +1303,7 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
|
||||
/* Cleanup all untransmitted buffers, assume transmitter not running */
|
||||
static void sky2_tx_clean(struct net_device *dev)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
|
||||
sky2_tx_complete(sky2, sky2->tx_prod);
|
||||
}
|
||||
@@ -1311,7 +1311,7 @@ static void sky2_tx_clean(struct net_device *dev)
|
||||
/* Network shutdown */
|
||||
static void sky2_down(struct net_device *dev)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
unsigned port = sky2->port;
|
||||
u16 ctrl;
|
||||
@@ -1511,7 +1511,7 @@ static int sky2_autoneg_done(struct sky2_port *sky2, u16 aux)
|
||||
static void sky2_phy_intr(struct sky2_hw *hw, unsigned port)
|
||||
{
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
u16 istatus, phystat;
|
||||
|
||||
istatus = gm_phy_read(hw, port, PHY_MARV_INT_STAT);
|
||||
@@ -1570,7 +1570,7 @@ static struct io_buffer *receive_new(struct sky2_port *sky2,
|
||||
static struct io_buffer *sky2_receive(struct net_device *dev,
|
||||
u16 length, u32 status)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct rx_ring_info *re = sky2->rx_ring + sky2->rx_next;
|
||||
struct io_buffer *iob = NULL;
|
||||
u16 count = (status & GMR_FS_LEN) >> 16;
|
||||
@@ -1634,7 +1634,7 @@ error:
|
||||
/* Transmit complete */
|
||||
static inline void sky2_tx_done(struct net_device *dev, u16 last)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
|
||||
sky2_tx_complete(sky2, last);
|
||||
}
|
||||
@@ -1700,10 +1700,10 @@ static void sky2_status_intr(struct sky2_hw *hw, u16 idx)
|
||||
sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
|
||||
|
||||
if (rx[0])
|
||||
sky2_rx_update(netdev_priv(hw->dev[0]), Q_R1);
|
||||
sky2_rx_update(hw->dev[0]->priv, Q_R1);
|
||||
|
||||
if (rx[1])
|
||||
sky2_rx_update(netdev_priv(hw->dev[1]), Q_R2);
|
||||
sky2_rx_update(hw->dev[1]->priv, Q_R2);
|
||||
}
|
||||
|
||||
static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
|
||||
@@ -1809,7 +1809,7 @@ static void sky2_le_error(struct sky2_hw *hw, unsigned port,
|
||||
u16 q, unsigned ring_size __unused)
|
||||
{
|
||||
struct net_device *dev = hw->dev[port];
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
int idx;
|
||||
const u64 *le = (q == Q_R1 || q == Q_R2)
|
||||
? (u64 *) sky2->rx_le : (u64 *) sky2->tx_le;
|
||||
@@ -1853,7 +1853,7 @@ static void sky2_err_intr(struct sky2_hw *hw, u32 status)
|
||||
|
||||
static void sky2_poll(struct net_device *dev)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
|
||||
u16 idx;
|
||||
@@ -2152,7 +2152,7 @@ static u32 sky2_supported_modes(const struct sky2_hw *hw)
|
||||
|
||||
static void sky2_set_multicast(struct net_device *dev)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
unsigned port = sky2->port;
|
||||
u16 reg;
|
||||
@@ -2189,7 +2189,7 @@ static struct net_device *sky2_init_netdev(struct sky2_hw *hw,
|
||||
|
||||
dev->dev = &hw->pdev->dev;
|
||||
|
||||
sky2 = netdev_priv(dev);
|
||||
sky2 = dev->priv;
|
||||
sky2->netdev = dev;
|
||||
sky2->hw = hw;
|
||||
|
||||
@@ -2241,7 +2241,7 @@ static const char *sky2_name(u8 chipid, char *buf, int sz)
|
||||
|
||||
static void sky2_net_irq(struct net_device *dev, int enable)
|
||||
{
|
||||
struct sky2_port *sky2 = netdev_priv(dev);
|
||||
struct sky2_port *sky2 = dev->priv;
|
||||
struct sky2_hw *hw = sky2->hw;
|
||||
|
||||
u32 imask = sky2_read32(hw, B0_IMSK);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user