hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
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
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
/******************************************************************************
 *
 * Copyright(c) 2019 - 2020 Realtek Corporation.
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * 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.
 *
 *****************************************************************************/
#ifndef _PLTFM_OPS_LINUX_H_
#define _PLTFM_OPS_LINUX_H_
#include "drv_types.h"
#ifdef CONFIG_RTW_DEDICATED_CMA_POOL
#include <linux/platform_device.h>
extern struct platform_device *g_pldev;
#endif
 
#ifdef CONFIG_PLATFORM_AML_S905_V1
extern struct device * g_pcie_reserved_mem_dev;
#endif
 
static inline char *_os_strpbrk(const char *s, const char *ct)
{
   return strpbrk(s, ct);
}
 
static inline char *_os_strsep(char **s, const char *ct)
{
   return strsep(s, ct);
}
 
#if 1
#define _os_sscanf(buf, fmt, ...) sscanf(buf, fmt, ##__VA_ARGS__)
#else
static inline int _os_sscanf(const char *buf, const char *fmt, ...)
{
   va_list args;
   int i;
 
   va_start(args, fmt);
   i = vsscanf(buf, fmt, args);
   va_end(args);
   return i;
}
#endif
static inline int _os_strcmp(const char *s1, const char *s2)
{
   return strcmp(s1, s2);
}
static inline int _os_strncmp(const char *s1, const char *s2, size_t n)
{
   return strncmp(s1, s2, n);
}
static inline char *_os_strcpy(char *dest, const char *src)
{
   return strcpy(dest, src);
}
static inline char *_os_strncpy(char *dest, const char *src, size_t n)
{
   return strncpy(dest, src, n);
}
#if 1
#define _os_strchr(s, c) strchr(s, c)
#else
static inline char*_os_strchr(const char *s, int c)
{
   return strchr(s, c);
}
#endif
 
#if 1
#define _os_snprintf(s, sz, fmt, ...) snprintf(s, sz, fmt, ##__VA_ARGS__)
#define _os_vsnprintf(str, size, fmt, args) vsnprintf(str, size, fmt, args)
#define _os_va_start(args, fmt) va_start(args, fmt)
#define _os_va_end(args) va_end(args)
#else
static int _os_snprintf(char *str, size_t size, const char *fmt, ...)
{
   va_list args;
   int ret;
 
   va_start(args, fmt);
   ret = vsnprintf(str, size, fmt, args);
   va_end(args);
   if (size > 0)
       str[size - 1] = '\0';
   return ret;
}
#endif
 
static inline u32 _os_strlen(u8 *buf)
{
   return strlen(buf);
}
static inline void _os_delay_ms(void *d, u32 ms)
{
   rtw_mdelay_os(ms);
}
static inline void _os_delay_us(void *d, u32 us)
{
   rtw_udelay_os(us);
}
static inline void _os_sleep_ms(void *d, u32 ms)
{
   rtw_msleep_os(ms);
}
static inline void _os_sleep_us(void *d, u32 us)
{
   rtw_usleep_os(us);
}
static inline u32 _os_get_cur_time_us(void)
{
   return rtw_systime_to_us(rtw_get_current_time());
}
static inline u32 _os_get_cur_time_ms(void)
{
   return rtw_systime_to_ms(rtw_get_current_time());
}
 
static inline u64 _os_modular64(u64 x, u64 y)
{
   /*return do_div(x, y);*/
   return rtw_modular64(x, y);
}
static inline u64 _os_division64(u64 x, u64 y)
{
   /*return do_div(x, y);*/
   return rtw_division64(x, y);
}
 
static inline u32 _os_div_round_up(u32 x, u32 y)
{
   return RTW_DIV_ROUND_UP(x, y);
}
 
static inline u64 _os_minus64(u64 x, u64 y)
 
{
   return x - y;
}
 
static inline u64 _os_add64(u64 x, u64 y)
 
{
   return x + y;
}
 
#ifdef CONFIG_PCI_HCI
static inline void _os_cache_inv(void *d, u32 *bus_addr_l, u32 *bus_addr_h,
                                 u32 buf_sz, u8 direction)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t bus_addr = *bus_addr_l;
 
   #ifdef PHL_DMA_ADDR_64
   bus_addr |= ((dma_addr_t)*bus_addr_h) << 32;
   #endif
 
   pci_cache_inv(pdev, &bus_addr, buf_sz, direction);
}
 
static inline void _os_cache_wback(void *d, u32 *bus_addr_l, u32 *bus_addr_h,
                                   u32 buf_sz, u8 direction)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t bus_addr = *bus_addr_l;
 
   #ifdef PHL_DMA_ADDR_64
   bus_addr |= (((dma_addr_t)*bus_addr_h) << 32);
   #endif
 
   pci_cache_wback(pdev, &bus_addr, buf_sz, direction);
}
 
static inline void *_os_dma_pool_create(void *d, char *name, u32 wd_page_sz)
{
   struct dvobj_priv *dvobj = (struct dvobj_priv *)d;
   struct device *dev = NULL;
#ifdef CONFIG_RTW_DEDICATED_CMA_POOL
   dev = &g_pldev->dev;
#else
   dev = &dvobj->pci_data.ppcidev->dev;
#endif
   return dma_pool_create(name, dev, wd_page_sz, 2, 0);
}
 
static inline void _os_dma_pool_destory(void *d, void *pool)
{
   struct dvobj_priv *dvobj = (struct dvobj_priv *)d;
 
   dma_pool_destroy((struct dma_pool *)pool);
}
 
/* txbd, rxbd, wd */
static inline void *_os_shmem_alloc(void *d, void *pool, u32 *bus_addr_l, u32 *bus_addr_h,
                                    u32 buf_sz, u8 cache, u8 direction,
                                    void **os_rsvd)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t bus_addr;
   void *vir_addr = NULL;
 
   if ((cache == NONCACHE_ADDR) && (pool == NULL))
       vir_addr = pci_alloc_noncache_mem(pdev, &bus_addr, buf_sz);
   else if ((cache == NONCACHE_ADDR) && pool)
       vir_addr = dma_pool_zalloc((struct dma_pool *)pool, (in_atomic() ? GFP_ATOMIC : GFP_KERNEL), &bus_addr);
   else /* CACHE_ADDR */
       vir_addr = pci_alloc_cache_mem(pdev, &bus_addr, buf_sz, direction);
 
   if (vir_addr) {
       #ifdef PHL_DMA_ADDR_64
       *bus_addr_h = (u32)(bus_addr >> 32);
       #else
       *bus_addr_h = 0;
       #endif /* PHL_DMA_ADDR_64 */
       *bus_addr_l = (u32)bus_addr;
   }
 
   return vir_addr;
}
 
static inline void _os_shmem_free(void *d, void *pool, u8 *vir_addr, u32 *bus_addr_l,
                 u32 *bus_addr_h, u32 buf_sz,
                 u8 cache, u8 direction, void *os_rsvd)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t bus_addr = *bus_addr_l;
 
   #ifdef PHL_DMA_ADDR_64
   bus_addr |= ((dma_addr_t)*bus_addr_h) << 32;
   #endif
 
   if ((cache == NONCACHE_ADDR) && (pool == NULL))
       return pci_free_noncache_mem(pdev, vir_addr, &bus_addr, buf_sz);
   else if ((cache == NONCACHE_ADDR) && pool)
       return dma_pool_free((struct dma_pool *)pool, vir_addr, bus_addr);
   else /* CACHE_ADDR */
       return pci_free_cache_mem(pdev, vir_addr, &bus_addr, buf_sz, direction);
   return;
}
#endif /*CONFIG_PCI_HCI*/
 
#ifdef CONFIG_PCI_HCI
static inline void _os_pkt_buf_unmap_rx_pci(struct dvobj_priv *pobj, u32 bus_addr_l,
                                            u32 bus_addr_h, u32 buf_sz)
{
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t dma_addr = bus_addr_l;
 
   #ifdef PHL_DMA_ADDR_64
   dma_addr |= ((dma_addr_t)bus_addr_h) << 32;
   #endif
 
#ifdef CONFIG_PLATFORM_AML_S905_V1
   if (g_pcie_reserved_mem_dev)
       pdev->dev.dma_mask = NULL;
#endif
   dma_unmap_single(&pdev->dev, dma_addr, buf_sz, DMA_FROM_DEVICE);
 
#ifdef RTW_CORE_RECORD
   phl_add_record(d, REC_RX_UNMAP, bus_addr_l, buf_sz);
#endif
}
#endif /*CONFIG_PCI_HCI*/
 
static inline void *_os_pkt_buf_unmap_rx(void *d, u32 bus_addr_l,
                                         u32 bus_addr_h, u32 buf_sz)
{
#ifdef CONFIG_PCI_HCI
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
 
   if (pobj->interface_type == RTW_HCI_PCIE) {
       _os_pkt_buf_unmap_rx_pci(pobj, bus_addr_l, bus_addr_h,
                                buf_sz);
   }
#endif /* CONFIG_PCI_HCI */
 
   return NULL;
}
 
#ifdef CONFIG_PCI_HCI
static inline void _os_pkt_buf_map_rx_pci(struct dvobj_priv *pobj,
                                          u32 *bus_addr_l, u32 *bus_addr_h,
                                          u32 buf_sz, void *os_priv)
{
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   struct sk_buff *skb = os_priv;
   dma_addr_t dma_addr;
 
#ifdef CONFIG_PLATFORM_AML_S905_V1
   if (g_pcie_reserved_mem_dev)
       pdev->dev.dma_mask = NULL;
#endif
   dma_addr = dma_map_single(&pdev->dev, skb->data, buf_sz, DMA_FROM_DEVICE);
   *bus_addr_l = (u32)dma_addr;
 
   #ifdef PHL_DMA_ADDR_64
   *bus_addr_h = (u32)(dma_addr >> 32);
   #else
   *bus_addr_h = 0;
   #endif /* PHL_DMA_ADDR_64 */
}
#endif /*CONFIG_PCI_HCI*/
 
static inline void *_os_pkt_buf_map_rx(void *d, u32 *bus_addr_l,
                                       u32 *bus_addr_h, u32 buf_sz,
                     void *os_priv)
{
#ifdef CONFIG_PCI_HCI
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
 
   if (pobj->interface_type == RTW_HCI_PCIE) {
       _os_pkt_buf_map_rx_pci(pobj, bus_addr_l, bus_addr_h,
                              buf_sz, os_priv);
   }
#endif /* CONFIG_PCI_HCI */
 
   return NULL;
}
 
#ifdef CONFIG_PCI_HCI
static inline struct sk_buff *_os_alloc_fake_skb(struct pci_dev *pdev, u32 buf_sz,
                        enum cache_addr_type cache)
{
   struct sk_buff *skb = NULL;
   unsigned char *data = NULL;
 
   skb = rtw_zmalloc(sizeof(struct sk_buff));
   if (!skb)
       goto out;
 
   if (cache == NONCACHE_ADDR)
       data = pci_alloc_noncache_mem(pdev, (dma_addr_t *)&skb->cb, buf_sz);
   else if (cache == CACHE_ADDR)
       data = pci_alloc_cache_mem(pdev, (dma_addr_t *)&skb->cb, buf_sz, DMA_FROM_DEVICE);
   else
       RTW_ERR("%s-%d: unsupported cache type: %d\n", __func__, __LINE__, cache);
 
   if (!data)
       goto nodata;
 
   skb->head = data;
   skb->data = data;
   skb_reset_tail_pointer(skb);
   skb->end = skb->tail + buf_sz;
   skb->len = buf_sz;
out:
   return skb;
nodata:
   _rtw_mfree(skb, sizeof(struct sk_buff));
   skb = NULL;
   goto out;
}
 
static inline void _os_free_fake_skb(struct pci_dev *pdev,
   struct sk_buff *skb, u32 buf_sz, enum cache_addr_type cache)
{
   /* skb buffer */
   if (cache == NONCACHE_ADDR)
       pci_free_noncache_mem(pdev, skb->data, (dma_addr_t *)skb->cb, buf_sz);
   else if (cache == CACHE_ADDR)
       pci_free_cache_mem(pdev, skb->data, (dma_addr_t *)skb->cb, buf_sz, DMA_FROM_DEVICE);
   else
       RTW_ERR("%s-%d: unsupported cache type: %d\n", __func__, __LINE__, cache);
 
   /* skb */
   rtw_mfree(skb, sizeof(struct sk_buff));
}
#endif /*CONFIG_PCI_HCI*/
 
/* rxbuf */
#define PHL_RX_HEADROOM 0/* 50 */
 
static inline void *_os_pkt_buf_alloc_rx(void *d, u32 *bus_addr_l,
                                         u32 *bus_addr_h, u32 buf_sz,
                                         enum cache_addr_type cache,
                    void **os_priv)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
   struct sk_buff *skb = NULL;
   u32 rxbuf_size = buf_sz + PHL_RX_HEADROOM;
#ifdef CONFIG_PCI_HCI
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t dma_addr;
 
#ifdef CONFIG_RTW_RXSKB_KMALOC
   skb = _os_alloc_fake_skb(pdev, buf_sz, cache);
#else
   if (cache == NONCACHE_ADDR)
       skb = _os_alloc_fake_skb(pdev, buf_sz, cache);
   else
       skb = rtw_skb_alloc(rxbuf_size);
#endif
#else
       skb = rtw_skb_alloc(rxbuf_size);
#endif
 
   if (!skb)
       return NULL;
 
#if PHL_RX_HEADROOM > 0
   skb_pull(skb, PHL_RX_HEADROOM);
#endif
 
#ifdef CONFIG_PCI_HCI
#ifdef CONFIG_PLATFORM_AML_S905_V1
   if (g_pcie_reserved_mem_dev)
       pdev->dev.dma_mask = NULL;
#endif
#ifdef CONFIG_RTW_RXSKB_KMALOC
   *bus_addr_l = *(dma_addr_t *)skb->cb;
#else
   if (cache == NONCACHE_ADDR) {
       *bus_addr_l = *(dma_addr_t *)skb->cb;
   }
   else
   {
       dma_addr = dma_map_single(&pdev->dev, skb->data, rxbuf_size, DMA_FROM_DEVICE);
       *bus_addr_l = (u32)dma_addr;
   }
#endif
   #ifdef PHL_DMA_ADDR_64
   *bus_addr_h = (u32)(dma_addr >> 32);
   #else
   *bus_addr_h = 0;
   #endif /* PHL_DMA_ADDR_64 */
#endif /*CONFIG_PCI_HCI*/
   *os_priv = skb;
 
   return skb->data;
}
 
static inline void _os_pkt_buf_free_rx(void *d, u8 *vir_addr, u32 bus_addr_l,
                                       u32 bus_addr_h, u32 buf_sz, enum cache_addr_type cache, void *os_priv)
{
   struct dvobj_priv *pobj = (struct dvobj_priv *)d;
#ifdef CONFIG_PCI_HCI
   PPCI_DATA pci_data = dvobj_to_pci(pobj);
   struct pci_dev *pdev = pci_data->ppcidev;
   dma_addr_t bus_addr = bus_addr_l;
#endif /*CONFIG_PCI_HCI*/
   struct sk_buff *skb = (struct sk_buff *)os_priv;
 
#ifdef CONFIG_PCI_HCI
   #ifdef PHL_DMA_ADDR_64
   bus_addr |= ((dma_addr_t)bus_addr_h) << 32;
   #endif
 
#ifdef CONFIG_PLATFORM_AML_S905_V1
   if (g_pcie_reserved_mem_dev)
       pdev->dev.dma_mask = NULL;
#endif
#ifdef CONFIG_RTW_RXSKB_KMALOC
   _os_free_fake_skb(pdev, skb, buf_sz, cache);
   return;
#else
   if (cache == NONCACHE_ADDR) {
       _os_free_fake_skb(pdev, skb, buf_sz, cache);
       return;
   } else {
       dma_unmap_single(&pdev->dev, bus_addr, buf_sz, DMA_FROM_DEVICE);
   }
#endif
#endif /*CONFIG_PCI_HCI*/
   rtw_skb_free(skb);
}
 
/* phl pre-alloc network layer buffer */
static inline void * _os_alloc_netbuf(void *d, u32 buf_sz, void **os_priv)
{
   return _os_pkt_buf_alloc_rx(d, NULL, NULL, buf_sz, CACHE_ADDR, os_priv);
}
 
/* Free netbuf for error case. (ex. drop rx-reorder packet) */
static inline void _os_free_netbuf(void *d, u8 *vir_addr, u32 buf_sz, void *os_priv)
{
   _os_pkt_buf_free_rx(d, vir_addr, 0,0, buf_sz, CACHE_ADDR, os_priv);
}
 
/* Generate an unsigned 32-bit random number */
static inline u32 _os_random32(void *d)
{
   return rtw_random32();
}
 
/*virtually contiguous memory*/
static inline void *_os_mem_alloc(void *d, u32 buf_sz)
{
   #ifdef DBG_PHL_MEM_ALLOC
   struct dvobj_priv *obj = (struct dvobj_priv *)d;
 
   ATOMIC_ADD_RETURN(&obj->phl_mem, buf_sz);
   #endif
 
   #ifdef CONFIG_PHL_USE_KMEM_ALLOC_BY_PAGE_SIZE
   /* if buf < 4K, use kmalloc */
   if (buf_sz < 4096)
       return rtw_zmalloc(buf_sz);
   #endif
   if (in_atomic()) {
       RTW_ERR("Call rtw_zvmalloc in atomic @%s:%u\n",
           __FUNCTION__, __LINE__);
       dump_stack();
   }
   return rtw_zvmalloc(buf_sz);
}
 
/*virtually contiguous memory*/
static inline void _os_mem_free(void *d, void *buf, u32 buf_sz)
{
   #ifdef DBG_PHL_MEM_ALLOC
   struct dvobj_priv *obj = (struct dvobj_priv *)d;
 
   ATOMIC_SUB(&obj->phl_mem, buf_sz);
   #endif
 
   #ifdef CONFIG_PHL_USE_KMEM_ALLOC_BY_PAGE_SIZE
   /* if buf < 4K, use kmalloc */
   if (buf_sz < 4096)
       return rtw_mfree(buf, buf_sz);
   #endif
   if (in_atomic()) {
       RTW_ERR("Call rtw_vmfree in atomic @%s:%u\n",
           __FUNCTION__, __LINE__);
       dump_stack();
   }
   rtw_vmfree(buf, buf_sz);
}
 
/*physically contiguous memory if the buffer will be accessed by a DMA device*/
static inline void *_os_kmem_alloc(void *d, u32 buf_sz)
{
   #ifdef DBG_PHL_MEM_ALLOC
   struct dvobj_priv *obj = (struct dvobj_priv *)d;
   ATOMIC_ADD_RETURN(&obj->phl_mem, buf_sz);
   #endif
   return rtw_zmalloc(buf_sz);
}
 
/*physically contiguous memory if the buffer will be accessed by a DMA device*/
static inline void _os_kmem_free(void *d, void *buf, u32 buf_sz)
{
   #ifdef DBG_PHL_MEM_ALLOC
   struct dvobj_priv *obj = (struct dvobj_priv *)d;
   ATOMIC_SUB(&obj->phl_mem, buf_sz);
   #endif
 
   rtw_mfree(buf, buf_sz);
}
 
static inline void _os_mem_set(void *d, void *buf, s8 value, u32 size)
{
   _rtw_memset(buf, value, size);
}
static inline void _os_mem_cpy(void *d, void *dest, const void *src, u32 size)
{
   _rtw_memcpy(dest, src, size);
}
/*Return Value
 * <0 :the first byte that does not match in both memory blocks has a lower value in ptr1 than in ptr2 (if evaluated as unsigned char values)
 * 0   :the contents of both memory blocks are equal
 * >0 :the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2 (if evaluated as unsigned char values)
*/
static inline int _os_mem_cmp(void *d, const void *dest, const void *src, size_t size)
{
 
   return memcmp(dest, src, size);
}
static inline void _os_init_timer(void *d, _os_timer *timer,
       void (*call_back_func)(void *context), void *context,
       const char *sz_id)
{
   _init_timer(timer, call_back_func, context);
}
 
static inline void _os_set_timer(void *d, _os_timer *timer, u32 ms_delay)
{
   _set_timer(timer, ms_delay);
}
 
static inline void _os_cancel_timer(void *d, _os_timer *timer)
{
   _cancel_timer_ex(timer);
}
 
static inline void _os_cancel_timer_async(void *d, _os_timer *timer)
{
   _cancel_timer_async(timer);
}
 
static inline void _os_release_timer(void *d, _os_timer *timer)
{
 
}
static inline void _os_mutex_init(void *d, _os_mutex *mutex)
{
   _rtw_mutex_init(mutex);
}
 
static inline void _os_mutex_deinit(void *d, _os_mutex *mutex)
{
   _rtw_mutex_free(mutex);
}
 
static inline void _os_mutex_lock(void *d, _os_mutex *mutex)
{
   _rtw_mutex_lock_interruptible(mutex);
}
 
static inline void _os_mutex_unlock(void *d, _os_mutex *mutex)
{
   _rtw_mutex_unlock(mutex);
}
 
static inline void _os_sema_init(void *d, _os_sema *sema, int int_cnt)
{
   _rtw_init_sema(sema, int_cnt);
}
 
static inline void _os_sema_free(void *d, _os_sema *sema)
{
   _rtw_free_sema(sema);
}
 
static inline void _os_sema_up(void *d, _os_sema *sema)
{
   _rtw_up_sema(sema);
}
 
static inline u8 _os_sema_down(void *d, _os_sema *sema)
{
   _rtw_down_sema(sema);
   return 0; //success
}
 
/* event */
static __inline void _os_event_init(void *h, _os_event *event)
{
   init_completion(event);
}
 
static __inline void _os_event_free(void *h, _os_event *event)
{
}
 
static __inline void _os_event_reset(void *h, _os_event *event)
{
   /* TODO */
}
 
static __inline void _os_event_set(void *h, _os_event *event)
{
   complete(event);
}
 
/*
 * m_sec
 *     == 0 : wait for completion
 *     >  0 : wait for timeout or completion
 * return value
 *     0:timeout
 *     otherwise:success
 */
static __inline int _os_event_wait(void *h, _os_event *event, u32 m_sec)
{
   unsigned long expire;
 
   if (m_sec) {
       expire = msecs_to_jiffies(m_sec);
 
       if (expire > MAX_SCHEDULE_TIMEOUT)
           expire = MAX_SCHEDULE_TIMEOUT;
   }
   else {
       #ifdef RTW_MAX_SCHEDULE_TIMEOUT
       expire = msecs_to_jiffies(RTW_MAX_SCHEDULE_TIMEOUT);
       #else
       expire = MAX_SCHEDULE_TIMEOUT;
       #endif /*RTW_MAX_SCHEDULE_TIMEOUT*/
   }
 
   expire = wait_for_completion_timeout(event, expire);
 
   if (expire == 0)
       return 0; /* timeout */
 
   return jiffies_to_msecs(expire); /* success */
}
 
/* spinlock */
 
static inline void _os_spinlock_init(void *d, _os_lock *plock)
{
   _rtw_spinlock_init(plock);
}
static inline void _os_spinlock_free(void *d, _os_lock *plock)
{
   _rtw_spinlock_free(plock);
}
 
static inline void _os_spinlock(void *d, _os_lock *plock,
                   enum lock_type type, _os_spinlockfg *flags
)
{
   if(type == _irq)
   {
       if(flags==NULL)
           RTW_ERR("_os_spinlock_irq: flags=NULL @%s:%u\n",
               __FUNCTION__, __LINE__);
       _rtw_spinlock_irq(plock, flags);
   }
   else if(type == _bh)
       _rtw_spinlock_bh(plock);
   else if(type == _ps)
       _rtw_spinlock(plock);
}
static inline void _os_spinunlock(void *d, _os_lock *plock,
                   enum lock_type type, _os_spinlockfg *flags
)
{
   if(type == _irq)
   {
       if(flags==NULL)
           RTW_ERR("_os_spinunlock_irq: flags=NULL @%s:%u\n",
               __FUNCTION__, __LINE__);
       _rtw_spinunlock_irq(plock, flags);
   }
   else if(type == _bh)
       _rtw_spinunlock_bh(plock);
   else if(type == _ps)
       _rtw_spinunlock(plock);
}
static inline int _os_test_and_clear_bit(int nr, unsigned long *addr)
{
   return rtw_test_and_clear_bit(nr, addr);
}
static inline int _os_test_and_set_bit(int nr, unsigned long *addr)
{
   return rtw_test_and_set_bit(nr, addr);
}
/* Atomic integer operations */
static inline void _os_atomic_set(void *d, _os_atomic *v, int i)
{
   ATOMIC_SET(v, i);
}
 
static inline int _os_atomic_read(void *d, _os_atomic *v)
{
   return ATOMIC_READ(v);
}
 
static inline void _os_atomic_add(void *d, _os_atomic *v, int i)
{
   ATOMIC_ADD(v, i);
}
static inline void _os_atomic_sub(void *d, _os_atomic *v, int i)
{
   ATOMIC_SUB(v, i);
}
 
static inline void _os_atomic_inc(void *d, _os_atomic *v)
{
   ATOMIC_INC(v);
}
 
static inline void _os_atomic_dec(void *d, _os_atomic *v)
{
   ATOMIC_DEC(v);
}
 
static inline int _os_atomic_add_return(void *d, _os_atomic *v, int i)
{
   return ATOMIC_ADD_RETURN(v, i);
}
 
static inline int _os_atomic_sub_return(void *d, _os_atomic *v, int i)
{
   return ATOMIC_SUB_RETURN(v, i);
}
 
static inline int _os_atomic_inc_return(void *d, _os_atomic *v)
{
   return ATOMIC_INC_RETURN(v);
}
 
static inline int _os_atomic_dec_return(void *d, _os_atomic *v)
{
   return ATOMIC_DEC_RETURN(v);
}
/*
static inline bool _os_atomic_inc_unless(void *d, _os_atomic *v, int u)
{
   return ATOMIC_INC_UNLESS(v, 1, u);
}
*/
 
static inline void rtw_taskletw_hdl(unsigned long data)
{
   _taskletw *ptask = (_taskletw *) data;
 
   ptask->func(ptask->data);
}
 
static inline void rtw_taskletw_init(_taskletw *t,  void (*func)(void *), void *data)
{
   t->func = func;
   t->data = data;
   tasklet_init(&t->tasklet, rtw_taskletw_hdl, (unsigned long) t);
}
 
static inline void rtw_taskletw_kill(_taskletw *t)
{
   tasklet_kill(&t->tasklet);
}
 
static inline void rtw_taskletw_hi_schedule(_taskletw *t)
{
   tasklet_hi_schedule(&t->tasklet);
}
 
static inline u8 _os_tasklet_init(void *drv_priv, _os_tasklet *task,
   void (*call_back_func)(void* context), void *context)
{
   rtw_taskletw_init(task,
            call_back_func,
            task);
   return 0;
}
static inline u8 _os_tasklet_deinit(void *drv_priv, _os_tasklet *task)
{
   rtw_taskletw_kill(task);
   return 0;
}
static inline u8 _os_tasklet_schedule(void *drv_priv, _os_tasklet *task)
{
   #if 1
   rtw_taskletw_hi_schedule(task);
   #else
   rtw_tasklet_schedule(task);
   #endif
   return 0;
}
 
static __inline u8 _os_thread_init(    void *drv_priv, _os_thread *thread,
                   int (*call_back_func)(void * context),
                   void *context,
                   const char namefmt[])
{
   RST_THREAD_STATUS(thread);
   thread->thread_handler = rtw_thread_start(call_back_func, context, namefmt);
   if (thread->thread_handler) {
       SET_THREAD_STATUS(thread, THREAD_STATUS_STARTED);
       return RTW_PHL_STATUS_SUCCESS;
   }
 
   return RTW_PHL_STATUS_FAILURE;
}
static __inline u8 _os_thread_deinit(void *drv_priv, _os_thread *thread)
{
   if (CHK_THREAD_STATUS(thread, THREAD_STATUS_STARTED)) {
       CLR_THREAD_STATUS(thread, THREAD_STATUS_STARTED);
       rtw_thread_stop(thread->thread_handler);
   }
 
   return RTW_PHL_STATUS_SUCCESS;
}
static __inline enum rtw_phl_status _os_thread_schedule(void *drv_priv, _os_thread *thread)
{
   return RTW_PHL_STATUS_SUCCESS;
}
static inline void _os_thread_stop(void *drv_priv, _os_thread *thread)
{
   SET_THREAD_STATUS(thread, THREAD_STATUS_STOPPED);
}
static inline int _os_thread_check_stop(void *drv_priv, _os_thread *thread)
{
   return CHK_THREAD_STATUS(thread, THREAD_STATUS_STOPPED);
}
 
static inline int _os_thread_wait_stop(void *drv_priv, _os_thread *thread)
{
   rtw_thread_wait_stop();
   return RTW_PHL_STATUS_SUCCESS;
}
 
#if 0
static inline _os_thread _os_thread_start(int (*threadfn)(void *data),
   void *data, const char namefmt[])
{
   return rtw_thread_start(threadfn, data, namefmt);
}
static inline bool _os_thread_stop(_os_thread th)
{
 
   return rtw_thread_stop(th);
}
static inline void _os_thread_wait_stop(void)
{
   rtw_thread_wait_stop();
}
static inline int _os_thread_should_stop(void)
{
   return kthread_should_stop();
}
#endif
 
#ifdef CONFIG_CPU_BALANCE
static inline u8 _os_workitem_config_cpu(void *drv_priv, _os_workitem *workitem,
           char *work_name, int cpu_id)
{
   _config_workitem_cpu(workitem, work_name, cpu_id);
   return 0;
}
#endif
 
static inline u8 _os_workitem_init(void *drv_priv, _os_workitem *workitem,
           void (*call_back_func)(void* context), void *context)
{
#ifdef CONFIG_CPU_BALANCE
   _init_workitem_cpu(workitem, call_back_func, context);
#else
   _init_workitem(workitem, call_back_func, context);
#endif
   return 0;
}
static inline u8 _os_workitem_schedule(void *drv_priv, _os_workitem *workitem)
{
#ifdef CONFIG_CPU_BALANCE
   _set_workitem_cpu(workitem);
#elif defined(CONFIG_PHL_HANDLER_WQ_HIGHPRI)
   _set_workitem_highpri(workitem);
#else
   _set_workitem(workitem);
#endif
   return 0;
}
static inline u8 _os_workitem_deinit(void *drv_priv, _os_workitem *workitem)
{
#ifdef CONFIG_CPU_BALANCE
   _cancel_workitem_sync_cpu(workitem);
#else
   _cancel_workitem_sync(workitem);
#endif
   return 0;
}
 
#ifdef RTW_WKARD_SDIO_TX_USE_YIELD
/**
 * yield - yield the current processor to other threads.
 */
static inline void _os_yield(void *drv_priv)
{
   yield();
}
#endif /* RTW_WKARD_SDIO_TX_USE_YIELD */
 
/* OS handler extension */
#if defined(CONFIG_RTW_OS_HANDLER_EXT)
static inline u8 _os_init_handler_ext(void *drv_priv,
                                      struct rtw_phl_handler *phl_handler)
{
   return rtw_plfm_init_handler_ext(drv_priv, phl_handler);
}
 
static inline u8 _os_deinit_handler_ext(void *drv_priv,
                                        struct rtw_phl_handler *phl_handler)
{
   return rtw_plfm_deinit_handler_ext(drv_priv, phl_handler);
}
#endif /* CONFIG_RTW_OS_HANDLER_EXT */
 
/* File Operation */
static inline u32 _os_read_file(const char *path, u8 *buf, u32 sz)
{
   return (u32)rtw_retrieve_from_file(path, buf, sz);
}
 
/* Network Function */
#ifdef CONFIG_RTW_MIRROR_DUMP
static inline u32 _os_mirror_dump(u8 *hdr, u32 hdr_len, u8 *buf, u32 sz)
{
   return rtw_mirror_dump(hdr, hdr_len, buf, sz);
}
#endif
 
/*BUS*/
#ifdef CONFIG_PCI_HCI
#include <pci_ops_linux.h>
static inline u8 _os_read8_pcie(void *d, u32 addr)
{
   return os_pci_read8((struct dvobj_priv *)d, addr);
}
static inline u16 _os_read16_pcie(void *d, u32 addr)
{
   return os_pci_read16((struct dvobj_priv *)d, addr);
 
}
static inline u32 _os_read32_pcie(void *d, u32 addr)
{
   return os_pci_read32((struct dvobj_priv *)d, addr);
}
 
static inline int _os_write8_pcie(void *d, u32 addr, u8 val)
{
   return os_pci_write8((struct dvobj_priv *)d, addr, val);
}
static inline int _os_write16_pcie(void *d, u32 addr, u16 val)
{
   return os_pci_write16((struct dvobj_priv *)d, addr, val);
}
static inline int _os_write32_pcie(void *d, u32 addr, u32 val)
{
   return os_pci_write32((struct dvobj_priv *)d, addr, val);
}
#endif/*#ifdef CONFIG_PCI_HCI*/
 
#ifdef CONFIG_USB_HCI
#include <usb_ops_linux.h>
static inline int _os_usbctrl_vendorreq(void *d, u8 request, u16 value,
               u16 index, void *pdata, u16 len, u8 requesttype)
{
   return usbctrl_vendorreq((struct dvobj_priv *)d, request, value,
               index, pdata, len, requesttype);
}
static __inline u8 os_out_token_alloc(void *drv_priv)
{
   return 0; // RTW_PHL_STATUS_SUCCESS
}
 
static __inline void os_out_token_free(void *drv_priv)
{
}
 
static inline int os_usb_tx(void *d, u8 *tx_buf_ptr,
           u8 bulk_id, u32 len, u8 *pkt_data_buf)
{
   return rtw_usb_write_port((struct dvobj_priv *)d, tx_buf_ptr,
           bulk_id, len, pkt_data_buf);
}
 
static __inline void os_enable_usb_out_pipes(void *drv_priv)
{
}
 
static __inline void os_disable_usb_out_pipes(void *drv_priv)
{
   /* Free bulkout urb */
   rtw_usb_write_port_cancel(drv_priv);
}
 
static __inline u8 os_in_token_alloc(void *drv_priv)
{
   // Allocate in token (pUrb) list
   return 0;
}
 
static __inline void os_in_token_free(void *drv_priv)
{
   // free in token memory
   /*rtw_usb_read_port_free(drv_priv);*/
}
 
 
static __inline u8 os_send_usb_in_token(void *drv_priv, void *rxobj, u8 *inbuf, u32 inbuf_len, u8 pipe_idx, u8 minLen)
{
   return rtw_usb_read_port(drv_priv, rxobj, inbuf, inbuf_len, pipe_idx, minLen);
}
 
static __inline void os_enable_usb_in_pipes(void *drv_priv)
{
}
 
static __inline void os_disable_usb_in_pipes(void *drv_priv)
{
   // Cancel Pending IN IRPs.
   rtw_usb_read_port_cancel(drv_priv);
}
 
 
#endif /*CONFIG_USB_HCI*/
 
#ifdef CONFIG_SDIO_HCI
#include <rtw_sdio.h>
#include <sdio_ops_linux.h>
#include <rtw_debug.h>
 
static inline u8 _os_sdio_cmd52_r8(void *d, u32 offset)
{
   u8 val = SDIO_ERR_VAL8;
 
   if (rtw_sdio_read_cmd52((struct dvobj_priv *)d, offset, &val, 1) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
 
   return val;
}
 
static inline u8 _os_sdio_cmd53_r8(void *d, u32 offset)
{
   u8 val = SDIO_ERR_VAL8;
 
 
   if (rtw_sdio_read_cmd53((struct dvobj_priv *)d, offset, &val, 1) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
 
   return val;
}
 
static inline u16 _os_sdio_cmd53_r16(void *d, u32 offset)
{
   u16 val = SDIO_ERR_VAL16;
 
 
   if (rtw_sdio_read_cmd53((struct dvobj_priv *)d, offset, &val, 2) == _FAIL) {
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
       goto exit;
   }
   val = le16_to_cpu(val);
 
exit:
   return val;
}
 
static inline u32 _os_sdio_cmd53_r32(void *d, u32 offset)
{
   u32 val = SDIO_ERR_VAL32;
 
 
   if (rtw_sdio_read_cmd53((struct dvobj_priv *)d, offset, &val, 4) == _FAIL) {
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
       goto exit;
   }
   val = le32_to_cpu(val);
 
exit:
   return val;
}
 
static inline u8 _os_sdio_cmd53_rn(void *d, u32 offset, u32 size, u8 *data)
{
   struct dvobj_priv *dv = d;
   struct sdio_data *sdio = dvobj_to_sdio(dv);
   u8 *pbuf = data;
   u32 sdio_read_size;
 
   if (!data)
       return _FAIL;
 
   sdio_read_size = RND4(size);
   sdio_read_size = rtw_sdio_cmd53_align_size(dv, sdio_read_size);
 
   if (sdio_read_size > sdio->tmpbuf_sz) {
       pbuf = rtw_malloc(sdio_read_size);
       if (!pbuf)
           return _FAIL;
   }
 
   if (rtw_sdio_read_cmd53(dv, offset, pbuf, sdio_read_size) == _FAIL) {
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
       goto exit;
   }
 
   if (pbuf != data)
       _rtw_memcpy(data, pbuf, size);
 
exit:
   if (pbuf != data)
       rtw_mfree(pbuf, sdio_read_size);
 
   return _SUCCESS;
}
 
static inline u8 _os_sdio_cmd53_r(void *d, u32 offset, u32 size, u8 *data)
{
   u8 ret;
 
   ret = rtw_sdio_read_cmd53((struct dvobj_priv *)d, offset, data, size);
   if (ret == _FAIL) {
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
       return _FAIL;
   }
 
   return _SUCCESS;
}
 
static inline void _os_sdio_cmd52_w8(void *d, u32 offset, u8 val)
{
   if (rtw_sdio_write_cmd52((struct dvobj_priv *)d, offset, &val, 1) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
}
 
static inline void _os_sdio_cmd53_w8(void *d, u32 offset, u8 val)
{
   if (rtw_sdio_write_cmd53((struct dvobj_priv *)d, offset, &val, 1) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
}
 
static inline void _os_sdio_cmd53_w16(void *d, u32 offset, u16 val)
{
   val = cpu_to_le16(val);
   if (rtw_sdio_write_cmd53((struct dvobj_priv *)d, offset, &val, 2) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
}
 
static inline void _os_sdio_cmd53_w32(void *d, u32 offset, u32 val)
{
   val = cpu_to_le32(val);
   if (rtw_sdio_write_cmd53((struct dvobj_priv *)d, offset, &val, 4) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
}
 
static inline void _os_sdio_cmd53_wn(void *d, u32 offset, u32 size, u8 *data)
{
   struct dvobj_priv *dv = d;
   struct sdio_data *sdio = dvobj_to_sdio(dv);
   u8 *pbuf = data;
 
 
   if (size > sdio->tmpbuf_sz) {
       pbuf = rtw_malloc(size);
       if (!pbuf)
           return;
       _rtw_memcpy(pbuf, data, size);
   }
 
   if (rtw_sdio_write_cmd53(dv, offset, pbuf, size) == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
 
   if (pbuf != data)
       rtw_mfree(pbuf, size);
}
 
static inline void _os_sdio_cmd53_w(void *d, u32 offset, u32 size, u8 *data)
{
   u8 ret;
 
   ret = rtw_sdio_write_cmd53((struct dvobj_priv *)d, offset, data, size);
   if (ret == _FAIL)
       RTW_ERR("%s: I/O FAIL!\n", __FUNCTION__);
}
 
static inline u8 _os_sdio_f0_read(void *d, u32 addr, void *buf, size_t len)
{
   return rtw_sdio_f0_read((struct dvobj_priv *)d, addr, buf, len);
}
 
static inline u8 _os_sdio_read_cia_r8(void *d, u32 addr)
{
   u8 data = 0;
 
   if (rtw_sdio_f0_read((struct dvobj_priv *)d, addr, &data, 1) == _FAIL)
       RTW_ERR("%s: read sdio cia FAIL!\n", __FUNCTION__);
 
   return data;
}
 
#endif /*CONFIG_SDIO_HCI*/
 
#ifdef CONFIG_PHL_DRV_HAS_NVM
static inline u32 _os_nvm_get_info(void *d, u32 info_type,
                                   void *value, u8 size)
{
   return rtw_nvm_get_info(d, info_type, value, size);
}
 
#endif /* CONFIG_PHL_DRV_HAS_NVM */
 
#endif /*_PLTFM_OPS_LINUX_H_*/