win-pvdrivers

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/liblfds.6/src/single_dir_for_windows_kernel/slist_new.c	Sun Jan 31 21:28:42 2010 +1100
     1.3 @@ -0,0 +1,97 @@
     1.4 +#include "slist_internal.h"
     1.5 +
     1.6 +
     1.7 +
     1.8 +
     1.9 +
    1.10 +/****************************************************************************/
    1.11 +int slist_new( struct slist_state **ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state )
    1.12 +{
    1.13 +  int
    1.14 +    rv = 0;
    1.15 +
    1.16 +  assert( ss != NULL );
    1.17 +  // TRD : user_data_delete_function can be NULL
    1.18 +  // TRD : user_state can be NULL
    1.19 +
    1.20 +  *ss = (struct slist_state *) abstraction_aligned_malloc( sizeof(struct slist_state), ALIGN_SINGLE_POINTER );
    1.21 +
    1.22 +  if( *ss != NULL )
    1.23 +  {
    1.24 +    slist_internal_init_slist( *ss, user_data_delete_function, user_state );
    1.25 +    rv = 1;
    1.26 +  }
    1.27 +
    1.28 +  return( rv );
    1.29 +}
    1.30 +
    1.31 +
    1.32 +
    1.33 +
    1.34 +
    1.35 +/****************************************************************************/
    1.36 +void slist_internal_init_slist( struct slist_state *ss, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state )
    1.37 +{
    1.38 +  assert( ss != NULL );
    1.39 +  // TRD : user_data_delete_function can be NULL
    1.40 +  // TRD : user_state can be NULL
    1.41 +
    1.42 +  ss->head = NULL;
    1.43 +  ss->user_data_delete_function = user_data_delete_function;
    1.44 +  ss->user_state = user_state;
    1.45 +
    1.46 +  return;
    1.47 +}
    1.48 +
    1.49 +
    1.50 +
    1.51 +
    1.52 +
    1.53 +/****************************************************************************/
    1.54 +struct slist_element *slist_new_head( struct slist_state *ss, void *user_data )
    1.55 +{
    1.56 +  ALIGN(ALIGN_SINGLE_POINTER) struct slist_element
    1.57 +    *volatile se;
    1.58 +
    1.59 +  assert( ss != NULL );
    1.60 +  // TRD : user_data can be NULL
    1.61 +
    1.62 +  se = (struct slist_element *) abstraction_aligned_malloc( sizeof(struct slist_element), ALIGN_DOUBLE_POINTER );
    1.63 +
    1.64 +  if( se != NULL )
    1.65 +  {
    1.66 +    se->user_data_and_flags[SLIST_USER_DATA] = user_data;
    1.67 +    se->user_data_and_flags[SLIST_FLAGS] = SLIST_NO_FLAGS;
    1.68 +
    1.69 +    slist_internal_link_element_to_head( ss, se );
    1.70 +  }
    1.71 +
    1.72 +  return( (struct slist_element *) se );
    1.73 +}
    1.74 +
    1.75 +
    1.76 +
    1.77 +
    1.78 +
    1.79 +/****************************************************************************/
    1.80 +struct slist_element *slist_new_next( struct slist_element *se, void *user_data )
    1.81 +{
    1.82 +  ALIGN(ALIGN_SINGLE_POINTER) struct slist_element
    1.83 +    *volatile se_next;
    1.84 +
    1.85 +  assert( se != NULL );
    1.86 +  // TRD : user_data can be NULL
    1.87 +
    1.88 +  se_next = (struct slist_element *) abstraction_aligned_malloc( sizeof(struct slist_element), ALIGN_DOUBLE_POINTER );
    1.89 +
    1.90 +  if( se_next != NULL )
    1.91 +  {
    1.92 +    se_next->user_data_and_flags[SLIST_USER_DATA] = user_data;
    1.93 +    se_next->user_data_and_flags[SLIST_FLAGS] = SLIST_NO_FLAGS;
    1.94 +
    1.95 +    slist_internal_link_element_after_element( se, se_next );
    1.96 +  }
    1.97 +
    1.98 +  return( (struct slist_element *) se_next );
    1.99 +}
   1.100 +