win-pvdrivers

view liblfds.6/src/single_dir_for_windows_kernel/ringbuffer_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 source
1 #include "ringbuffer_internal.h"
7 /****************************************************************************/
8 int ringbuffer_new( struct ringbuffer_state **rs, atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state )
9 {
10 int
11 rv = 0;
13 assert( rs != NULL );
14 // TRD : number_elements can be any value in its range
15 // TRD : user_data_init_function can be NULL
16 // TRD : user_state can be NULL
18 *rs = (struct ringbuffer_state *) abstraction_aligned_malloc( sizeof(struct ringbuffer_state), ALIGN_DOUBLE_POINTER );
20 if( *rs != NULL )
21 {
22 freelist_new( &(*rs)->fs, number_elements, user_data_init_function, user_state );
24 if( (*rs)->fs != NULL )
25 {
26 queue_new( &(*rs)->qs, number_elements );
28 if( (*rs)->qs != NULL )
29 rv = 1;
31 if( (*rs)->qs == NULL )
32 {
33 abstraction_aligned_free( *rs );
34 *rs = NULL;
35 }
36 }
38 if( (*rs)->fs == NULL )
39 {
40 abstraction_aligned_free( *rs );
41 *rs = NULL;
42 }
43 }
45 return( rv );
46 }