win-pvdrivers

annotate liblfds.6/src/single_dir_for_windows_kernel/slist_new.c @ 766:6300617040e0

Big changes - not ready for production use.
Removed all the custom DMA handling code as it was completely incompatible with the Windows verifier.
Added liblfds (using the lock free stack) from liblfds.org so that grant's can be obtained at DIRQL.
Fixed xennet and xenvbd to support the changes.
xenusb and xenscsi almost certainly will not yet work after the changes.
author James Harper <james.harper@bendigoit.com.au>
date Sun Jan 31 21:28:42 2010 +1100 (2010-01-31)
parents
children
rev   line source
james@766 1 #include "slist_internal.h"
james@766 2
james@766 3
james@766 4
james@766 5
james@766 6
james@766 7 /****************************************************************************/
james@766 8 int slist_new( struct slist_state **ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state )
james@766 9 {
james@766 10 int
james@766 11 rv = 0;
james@766 12
james@766 13 assert( ss != NULL );
james@766 14 // TRD : user_data_delete_function can be NULL
james@766 15 // TRD : user_state can be NULL
james@766 16
james@766 17 *ss = (struct slist_state *) abstraction_aligned_malloc( sizeof(struct slist_state), ALIGN_SINGLE_POINTER );
james@766 18
james@766 19 if( *ss != NULL )
james@766 20 {
james@766 21 slist_internal_init_slist( *ss, user_data_delete_function, user_state );
james@766 22 rv = 1;
james@766 23 }
james@766 24
james@766 25 return( rv );
james@766 26 }
james@766 27
james@766 28
james@766 29
james@766 30
james@766 31
james@766 32 /****************************************************************************/
james@766 33 void slist_internal_init_slist( struct slist_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state )
james@766 34 {
james@766 35 assert( ss != NULL );
james@766 36 // TRD : user_data_delete_function can be NULL
james@766 37 // TRD : user_state can be NULL
james@766 38
james@766 39 ss->head = NULL;
james@766 40 ss->user_data_delete_function = user_data_delete_function;
james@766 41 ss->user_state = user_state;
james@766 42
james@766 43 return;
james@766 44 }
james@766 45
james@766 46
james@766 47
james@766 48
james@766 49
james@766 50 /****************************************************************************/
james@766 51 struct slist_element *slist_new_head( struct slist_state *ss, void *user_data )
james@766 52 {
james@766 53 ALIGN(ALIGN_SINGLE_POINTER) struct slist_element
james@766 54 *volatile se;
james@766 55
james@766 56 assert( ss != NULL );
james@766 57 // TRD : user_data can be NULL
james@766 58
james@766 59 se = (struct slist_element *) abstraction_aligned_malloc( sizeof(struct slist_element), ALIGN_DOUBLE_POINTER );
james@766 60
james@766 61 if( se != NULL )
james@766 62 {
james@766 63 se->user_data_and_flags[SLIST_USER_DATA] = user_data;
james@766 64 se->user_data_and_flags[SLIST_FLAGS] = SLIST_NO_FLAGS;
james@766 65
james@766 66 slist_internal_link_element_to_head( ss, se );
james@766 67 }
james@766 68
james@766 69 return( (struct slist_element *) se );
james@766 70 }
james@766 71
james@766 72
james@766 73
james@766 74
james@766 75
james@766 76 /****************************************************************************/
james@766 77 struct slist_element *slist_new_next( struct slist_element *se, void *user_data )
james@766 78 {
james@766 79 ALIGN(ALIGN_SINGLE_POINTER) struct slist_element
james@766 80 *volatile se_next;
james@766 81
james@766 82 assert( se != NULL );
james@766 83 // TRD : user_data can be NULL
james@766 84
james@766 85 se_next = (struct slist_element *) abstraction_aligned_malloc( sizeof(struct slist_element), ALIGN_DOUBLE_POINTER );
james@766 86
james@766 87 if( se_next != NULL )
james@766 88 {
james@766 89 se_next->user_data_and_flags[SLIST_USER_DATA] = user_data;
james@766 90 se_next->user_data_and_flags[SLIST_FLAGS] = SLIST_NO_FLAGS;
james@766 91
james@766 92 slist_internal_link_element_after_element( se, se_next );
james@766 93 }
james@766 94
james@766 95 return( (struct slist_element *) se_next );
james@766 96 }
james@766 97