Repository navigation
Expand file tree
/
Copy pathspb.c
More file actions
898 lines (732 loc) · 17.3 KB
/
Copy pathspb.c
File metadata and controls
898 lines (732 loc) · 17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
/*++
Copyright (c) Microsoft Corporation. All Rights Reserved.
Sample code. Dealpoint ID #843729.
Module Name:
spb.c
Abstract:
Contains all I2C-specific functionality
Environment:
Kernel mode
Revision History:
--*/
#include "cs35l45.h"
#include "spb.h"
#include <reshub.h>
#include <spb.h>
#if defined(CS35L45_DEBUG)
static ULONG Cs35l45DebugLevel = DEBUG_LEVEL_VERBOSE;
static ULONG Cs35l45DebugCatagories = DBG_INIT | DBG_PNP | DBG_IOCTL;
#endif
NTSTATUS
SpbDoWriteDataSynchronously(
IN SPB_CONTEXT* SpbContext,
IN PVOID Data,
IN ULONG Length
)
/*++
Routine Description:
This helper routine abstracts creating and sending an I/O
request (I2C Write) to the Spb I/O target.
Arguments:
SpbContext - Pointer to the current device context
Address - The I2C register address to write to
Data - A buffer to receive the data at at the above address
Length - The amount of data to be read from the above address
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
PUCHAR buffer;
ULONG length;
WDFMEMORY memory;
WDF_MEMORY_DESCRIPTOR memoryDescriptor;
NTSTATUS status;
length = Length;
memory = NULL;
if (length > DEFAULT_SPB_BUFFER_SIZE)
{
status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPool,
CS35L45_POOL_TAG,
length,
&memory,
(PVOID*)&buffer);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error allocating memory for Spb write - 0x%X\n",
status);
goto exit;
}
WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(
&memoryDescriptor,
memory,
NULL);
}
else
{
buffer = (PUCHAR)WdfMemoryGetBuffer(SpbContext->WriteMemory, NULL);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(
&memoryDescriptor,
(PVOID)buffer,
length);
}
RtlCopyMemory(buffer, Data, length);
status = WdfIoTargetSendWriteSynchronously(
SpbContext->SpbIoTarget,
NULL,
&memoryDescriptor,
NULL,
NULL,
NULL);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error writing to Spb - 0x%X\n",
status);
goto exit;
}
exit:
if (NULL != memory)
{
WdfObjectDelete(memory);
}
return status;
}
NTSTATUS
SpbWriteDataSynchronously(
IN SPB_CONTEXT* SpbContext,
IN PVOID Data,
IN ULONG Length
)
/*++
Routine Description:
This routine abstracts creating and sending an I/O
request (I2C Write) to the Spb I/O target and utilizes
a helper routine to do work inside of locked code.
Arguments:
SpbContext - Pointer to the current device context
Address - The I2C register address to write to
Data - A buffer to receive the data at at the above address
Length - The amount of data to be read from the above address
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
NTSTATUS status;
WdfWaitLockAcquire(SpbContext->SpbLock, NULL);
status = SpbDoWriteDataSynchronously(
SpbContext,
Data,
Length);
WdfWaitLockRelease(SpbContext->SpbLock);
return status;
}
NTSTATUS
SpbDoWriteDataSynchronouslyEx(
IN SPB_CONTEXT* SpbContext,
IN PVOID Data,
IN ULONG Length,
IN PVOID Data2,
IN ULONG Length2
)
/*++
Routine Description:
This helper routine abstracts creating and sending an I/O
request (I2C Write) to the Spb I/O target.
Arguments:
SpbContext - Pointer to the current device context
Address - The I2C register address to write to
Data - A buffer to receive the data at at the above address
Length - The amount of data to be read from the above address
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
PUCHAR buffer;
ULONG length;
WDFMEMORY memory;
WDF_MEMORY_DESCRIPTOR memoryDescriptor;
NTSTATUS status;
length = Length + Length2;
memory = NULL;
if (length > DEFAULT_SPB_BUFFER_SIZE)
{
status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPool,
CS35L45_POOL_TAG,
length,
&memory,
(PVOID*)&buffer);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error allocating memory for Spb write - 0x%X\n",
status);
goto exit;
}
WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(
&memoryDescriptor,
memory,
NULL);
}
else
{
buffer = (PUCHAR)WdfMemoryGetBuffer(SpbContext->WriteMemory, NULL);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(
&memoryDescriptor,
(PVOID)buffer,
length);
}
RtlCopyMemory(buffer, Data, Length);
RtlCopyMemory(buffer+Length, Data2, Length2);
status = WdfIoTargetSendWriteSynchronously(
SpbContext->SpbIoTarget,
NULL,
&memoryDescriptor,
NULL,
NULL,
NULL);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error writing to Spb - 0x%X\n",
status);
goto exit;
}
exit:
if (NULL != memory)
{
WdfObjectDelete(memory);
}
return status;
}
NTSTATUS
SpbWriteDataSynchronouslyEx(
IN SPB_CONTEXT* SpbContext,
IN PVOID Data,
IN ULONG Length,
IN PVOID Data2,
IN ULONG Length2
)
/*++
Routine Description:
This routine abstracts creating and sending an I/O
request (I2C Write) to the Spb I/O target and utilizes
a helper routine to do work inside of locked code.
Arguments:
SpbContext - Pointer to the current device context
Address - The I2C register address to write to
Data - A buffer to receive the data at at the above address
Length - The amount of data to be read from the above address
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
NTSTATUS status;
WdfWaitLockAcquire(SpbContext->SpbLock, NULL);
status = SpbDoWriteDataSynchronouslyEx(
SpbContext,
Data,
Length,
Data2,
Length2);
WdfWaitLockRelease(SpbContext->SpbLock);
return status;
}
NTSTATUS
_SpbSequence(
_In_ SPB_CONTEXT* SpbContext,
_In_reads_(SequenceLength) PVOID Sequence,
_In_ SIZE_T SequenceLength,
_Out_ PULONG BytesReturned,
_In_ ULONG Timeout
)
/*++
Routine Description:
This routine forwards a sequence request to the SPB I/O target
Arguments:
FxIoTarget - The SPB IoTarget to which to send the IOCTL/Read/Write
Sequence - Pointer to a list of sequence transfers
SequenceLength - Length of sequence transfers
BytesReturned - The number of bytes transferred in the actual transaction
Timeout - The timeout associated with this transfer
Default is HIDI2C_REQUEST_DEFAULT_TIMEOUT second
0 means no timeout
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
NTSTATUS status;
WdfWaitLockAcquire(SpbContext->SpbLock, NULL);
//
// Create preallocated WDFMEMORY.
//
WDFMEMORY memorySequence = NULL;
WDF_OBJECT_ATTRIBUTES attributes;
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
status = WdfMemoryCreatePreallocated(
&attributes,
Sequence,
SequenceLength,
&memorySequence);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"WdfMemoryCreatePreallocated failed creating memory for sequence"
"status:0x%X\n",
status);
goto exit;
}
WDF_MEMORY_DESCRIPTOR memoryDescriptor;
WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(
&memoryDescriptor,
memorySequence,
NULL);
ULONG_PTR bytes = 0;
if (Timeout == 0)
{
//
// Send the SPB sequence IOCTL without a timeout set
//
status = WdfIoTargetSendIoctlSynchronously(
SpbContext->SpbIoTarget,
NULL,
IOCTL_SPB_EXECUTE_SEQUENCE,
&memoryDescriptor,
NULL,
NULL,
&bytes);
}
else
{
//
// Set a request timeout
//
WDF_REQUEST_SEND_OPTIONS sendOptions;
WDF_REQUEST_SEND_OPTIONS_INIT(&sendOptions, WDF_REQUEST_SEND_OPTION_TIMEOUT);
sendOptions.Timeout = WDF_REL_TIMEOUT_IN_SEC(Timeout);
//
// Send the SPB sequence IOCTL.
//
status = WdfIoTargetSendIoctlSynchronously(
SpbContext->SpbIoTarget,
NULL,
IOCTL_SPB_EXECUTE_SEQUENCE,
&memoryDescriptor,
NULL,
&sendOptions,
&bytes);
}
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Failed sending SPB Sequence IOCTL bytes:%lu status:0x%X\n",
(ULONG)bytes,
status);
goto exit;
}
//
// Copy the number of bytes transmitted over the bus
// The controller needs to support querying for actual bytes
// for each transaction
//
*BytesReturned = (ULONG)bytes;
exit:
WdfWaitLockRelease(SpbContext->SpbLock);
WdfObjectDelete(memorySequence);
return status;
}
const USHORT REG_SIZE = 2;
NTSTATUS
SpbWriteRead(
_In_ SPB_CONTEXT* SpbContext,
_In_reads_(SendLength) PVOID SendData,
_In_ USHORT SendLength,
_Out_writes_(Length) PVOID Data,
_In_ USHORT Length,
_In_ ULONG DelayUs
)
/*++
Routine Description:
This routine forwards a write-read sequence to the SPB I/O target
Arguments:
SpbContext - Pointer to the current device context
SendData The first byte buffer containing the data
SendLength The length of the first byte buffer data
Data The second byte buffer containing the data
Length The length of the second byte buffer data
DelayUs The delay between calls
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
NTSTATUS status;
NT_ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
if (SendData == NULL || SendLength <= 0 ||
Data == NULL || Length <= 0)
{
status = STATUS_INVALID_PARAMETER;
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"SpbWriteRead failed parameters DataFirst:%p DataLengthFirst:%lu "
"DataSecond:%p DataLengthSecond:%lu status:0x%X\n",
SendData,
SendLength,
Data,
Length,
status);
goto exit;
}
//
// Compact the adjacent writes of the two register accesses into a
// single write transfer list entry without restarts between them.
//
//SPB_TRANSFER_BUFFER_LIST_ENTRY BufferListFirst[1];
//BufferListFirst[0].Buffer = SendData;
//BufferListFirst[0].BufferCb = SendLength;
//
// Build the SPB sequence
//
SPB_TRANSFER_LIST_AND_ENTRIES(2) sequence;
SPB_TRANSFER_LIST_INIT(&(sequence.List), 2);
{
//
// PreFAST cannot figure out the SPB_TRANSFER_LIST_ENTRY
// "struct hack" size but using an index variable quiets
// the warning. This is a false positive from OACR.
//
ULONG index = 0;
sequence.List.Transfers[index] = SPB_TRANSFER_LIST_ENTRY_INIT_SIMPLE(
SpbTransferDirectionToDevice,
0,
SendData,
SendLength);
sequence.List.Transfers[index + 1] = SPB_TRANSFER_LIST_ENTRY_INIT_SIMPLE(
SpbTransferDirectionFromDevice,
DelayUs,
Data,
Length);
}
//
// Send the read as a Sequence request to the SPB target
//
ULONG bytesReturned = 0;
status = _SpbSequence(SpbContext, &sequence, sizeof(sequence), &bytesReturned, 100);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"SpbSequence failed sending a sequence "
"status:0x%X\n",
status);
goto exit;
}
//
// Check if this is a "short transaction" i.e. the sequence
// resulted in lesser bytes transmitted/received than expected
//
ULONG expectedLength = REG_SIZE + SendLength + REG_SIZE;
if (bytesReturned < expectedLength)
{
status = STATUS_DEVICE_PROTOCOL_ERROR;
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"SpbSequence returned with 0x%lu bytes expected:0x%lu bytes "
"status:0x%X\n",
bytesReturned,
expectedLength,
status);
goto exit;
}
exit:
return status;
}
NTSTATUS
SpbXferDataSynchronously(
_In_ SPB_CONTEXT* SpbContext,
_In_ PVOID SendData,
_In_ ULONG SendLength,
_In_reads_bytes_(Length) PVOID Data,
_In_ ULONG Length
)
/*++
Routine Description:
This helper routine abstracts creating and sending an I/O
request (I2C Read) to the Spb I/O target.
Arguments:
SpbContext - Pointer to the current device context
Address - The I2C register address to read from
Data - A buffer to receive the data at at the above address
Length - The amount of data to be read from the above address
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
PUCHAR buffer;
WDFMEMORY memory;
WDF_MEMORY_DESCRIPTOR memoryDescriptor;
NTSTATUS status;
ULONG_PTR bytesRead;
WdfWaitLockAcquire(SpbContext->SpbLock, NULL);
memory = NULL;
status = STATUS_INVALID_PARAMETER;
bytesRead = 0;
//
// Xfer transactions start by writing an address pointer
//
status = SpbDoWriteDataSynchronously(
SpbContext,
SendData,
SendLength);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error setting address pointer for Spb read - 0x%X\n",
status);
goto exit;
}
if (Length > DEFAULT_SPB_BUFFER_SIZE)
{
status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPool,
CS35L45_POOL_TAG,
Length,
&memory,
(PVOID*)&buffer);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error allocating memory for Spb read - 0x%X\n",
status);
goto exit;
}
WDF_MEMORY_DESCRIPTOR_INIT_HANDLE(
&memoryDescriptor,
memory,
NULL);
}
else
{
buffer = (PUCHAR)WdfMemoryGetBuffer(SpbContext->ReadMemory, NULL);
WDF_MEMORY_DESCRIPTOR_INIT_BUFFER(
&memoryDescriptor,
(PVOID)buffer,
Length);
}
status = WdfIoTargetSendReadSynchronously(
SpbContext->SpbIoTarget,
NULL,
&memoryDescriptor,
NULL,
NULL,
&bytesRead);
if (!NT_SUCCESS(status) ||
bytesRead != Length)
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error reading from Spb - 0x%X\n",
status);
goto exit;
}
//
// Copy back to the caller's buffer
//
RtlCopyMemory(Data, buffer, Length);
exit:
if (NULL != memory)
{
WdfObjectDelete(memory);
}
WdfWaitLockRelease(SpbContext->SpbLock);
return status;
}
VOID
SpbTargetDeinitialize(
IN WDFDEVICE FxDevice,
IN SPB_CONTEXT* SpbContext
)
/*++
Routine Description:
This helper routine is used to free any members added to the SPB_CONTEXT,
note the SPB I/O target is parented to the device and will be
closed and free'd when the device is removed.
Arguments:
FxDevice - Handle to the framework device object
SpbContext - Pointer to the current device context
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
UNREFERENCED_PARAMETER(FxDevice);
UNREFERENCED_PARAMETER(SpbContext);
//
// Free any SPB_CONTEXT allocations here
//
if (SpbContext->SpbLock != NULL)
{
WdfObjectDelete(SpbContext->SpbLock);
}
if (SpbContext->ReadMemory != NULL)
{
WdfObjectDelete(SpbContext->ReadMemory);
}
if (SpbContext->WriteMemory != NULL)
{
WdfObjectDelete(SpbContext->WriteMemory);
}
}
NTSTATUS
SpbTargetInitialize(
IN WDFDEVICE FxDevice,
IN SPB_CONTEXT* SpbContext
)
/*++
Routine Description:
This helper routine opens the Spb I/O target and
initializes a request object used for the lifetime
of communication between this driver and Spb.
Arguments:
FxDevice - Handle to the framework device object
SpbContext - Pointer to the current device context
Return Value:
NTSTATUS Status indicating success or failure
--*/
{
WDF_OBJECT_ATTRIBUTES objectAttributes;
WDF_IO_TARGET_OPEN_PARAMS openParams;
UNICODE_STRING spbDeviceName;
WCHAR spbDeviceNameBuffer[RESOURCE_HUB_PATH_SIZE];
NTSTATUS status;
WDF_OBJECT_ATTRIBUTES_INIT(&objectAttributes);
objectAttributes.ParentObject = FxDevice;
status = WdfIoTargetCreate(
FxDevice,
&objectAttributes,
&SpbContext->SpbIoTarget);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error creating IoTarget object - 0x%X\n",
status);
WdfObjectDelete(SpbContext->SpbIoTarget);
goto exit;
}
RtlInitEmptyUnicodeString(
&spbDeviceName,
spbDeviceNameBuffer,
sizeof(spbDeviceNameBuffer));
status = RESOURCE_HUB_CREATE_PATH_FROM_ID(
&spbDeviceName,
SpbContext->I2cResHubId.LowPart,
SpbContext->I2cResHubId.HighPart);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error creating Spb resource hub path string - 0x%X\n",
status);
goto exit;
}
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
&openParams,
&spbDeviceName,
(GENERIC_READ | GENERIC_WRITE));
openParams.ShareAccess = 0;
openParams.CreateDisposition = FILE_OPEN;
openParams.FileAttributes = FILE_ATTRIBUTE_NORMAL;
status = WdfIoTargetOpen(SpbContext->SpbIoTarget, &openParams);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error opening Spb target for communication - 0x%X\n",
status);
goto exit;
}
//
// Allocate some fixed-size buffers from NonPagedPool for typical
// Spb transaction sizes to avoid pool fragmentation in most cases
//
status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPool,
CS35L45_POOL_TAG,
DEFAULT_SPB_BUFFER_SIZE,
&SpbContext->WriteMemory,
NULL);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error allocating default memory for Spb write - 0x%X\n",
status);
goto exit;
}
status = WdfMemoryCreate(
WDF_NO_OBJECT_ATTRIBUTES,
NonPagedPool,
CS35L45_POOL_TAG,
DEFAULT_SPB_BUFFER_SIZE,
&SpbContext->ReadMemory,
NULL);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error allocating default memory for Spb read - 0x%X\n",
status);
goto exit;
}
//
// Allocate a waitlock to guard access to the default buffers
//
status = WdfWaitLockCreate(
WDF_NO_OBJECT_ATTRIBUTES,
&SpbContext->SpbLock);
if (!NT_SUCCESS(status))
{
Cs35l45Print(
DEBUG_LEVEL_ERROR,
DBG_IOCTL,
"Error creating Spb Waitlock - 0x%X\n",
status);
goto exit;
}
exit:
if (!NT_SUCCESS(status))
{
SpbTargetDeinitialize(FxDevice, SpbContext);
}
return status;
}