-
Notifications
You must be signed in to change notification settings - Fork 1
/
playwav.lst
3136 lines (3136 loc) · 201 KB
/
playwav.lst
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
1 ; ****************************************************************************
2 ; PLAYWAV.ASM - ICH AC97 .wav player for DOS. PLAYWAV.COM
3 ; ----------------------------------------------------------------------------
4 ; Last Update: 13/05/2024
5 ; ----------------------------------------------------------------------------
6 ; Beginning: 17/02/2017
7 ; ----------------------------------------------------------------------------
8 ; Assembler: NASM version 2.15
9 ; nasm playwav.asm -l playwav.lst -o PLAYWAV.COM
10 ; ----------------------------------------------------------------------------
11 ; Derived from '.wav file player for DOS' Jeff Leyda, Sep 02, 2002
12 ; ****************************************************************************
13 ; Modidified from 'PLAYER.COM' for VIA VT8233 wav player source code by
14 ; (PLAYER.ASM) by Erdogan Tan (07/11/2016 - 08/12/2016)
15
16 [BITS 16]
17
18 [ORG 100h]
19
20 %include 'ac97.inc' ; 17/02/2017
1 <1> ; 11/11/2023
2 <1> ; 05/11/2023
3 <1> ; 03/11/2023
4 <1> ; 17/02/2017 (Erdogan Tan, PLAYWAV.ASM)
5 <1> ; constant.inc & codec.inc (for ICH AC97 wav player, 'PLAYWAV.COM')
6 <1>
7 <1> ; ----------------------------------------------------------------------------
8 <1> ; CONSTANT.INC
9 <1> ; ----------------------------------------------------------------------------
10 <1>
11 <1> ;constants of stuff that seem hard to remember at times.
12 <1>
13 <1> TRUE EQU 1
14 <1> FALSE EQU 0
15 <1>
16 <1> ENABLED EQU 1
17 <1> DISABLED EQU 0
18 <1>
19 <1> BIT0 EQU 1
20 <1> BIT1 EQU 2
21 <1> BIT2 EQU 4
22 <1> BIT3 EQU 8
23 <1> BIT4 EQU 10h
24 <1> BIT5 EQU 20h
25 <1> BIT6 EQU 40h
26 <1> BIT7 EQU 80h
27 <1> BIT8 EQU 100h
28 <1> BIT9 EQU 200h
29 <1> BIT10 EQU 400h
30 <1> BIT11 EQU 800h
31 <1> BIT12 EQU 1000h
32 <1> BIT13 EQU 2000h
33 <1> BIT14 EQU 4000h
34 <1> BIT15 EQU 8000h
35 <1> BIT16 EQU 10000h
36 <1> BIT17 EQU 20000h
37 <1> BIT18 EQU 40000h
38 <1> BIT19 EQU 80000h
39 <1> BIT20 EQU 100000h
40 <1> BIT21 EQU 200000h
41 <1> BIT22 EQU 400000h
42 <1> BIT23 EQU 800000h
43 <1> BIT24 EQU 1000000h
44 <1> BIT25 EQU 2000000h
45 <1> BIT26 EQU 4000000h
46 <1> BIT27 EQU 8000000h
47 <1> BIT28 EQU 10000000h
48 <1> BIT29 EQU 20000000h
49 <1> BIT30 EQU 40000000h
50 <1> BIT31 EQU 80000000h
51 <1>
52 <1> ;special characters
53 <1> NUL EQU 0
54 <1> NULL EQU 0
55 <1> BELL EQU 07
56 <1> BS EQU 08
57 <1> TAB EQU 09
58 <1> LF EQU 10
59 <1> CR EQU 13
60 <1> ESCAPE EQU 27 ;ESC is a reserved word....
61 <1>
62 <1>
63 <1> ;file stuff
64 <1> READONLY EQU BIT0
65 <1> HIDDEN EQU BIT1
66 <1> SYSTEM EQU BIT2
67 <1> VOLUME EQU BIT3 ;ignored for file access
68 <1> DIRECTORY EQU BIT4 ;must be 0 for file access
69 <1> ARCHIVE EQU BIT5
70 <1> SHAREABLE EQU BIT7 ;for novell networks
71 <1> OPEN EQU 2 ; open existing file
72 <1> CREATE EQU 1 ; create new file
73 <1>
74 <1>
75 <1> ; PCI equates
76 <1> ; PCI function address (PFA)
77 <1> ; bit 31 = 1
78 <1> ; bit 23:16 = bus number (0-255)
79 <1> ; bit 15:11 = device number (0-31)
80 <1> ; bit 10:8 = function number (0-7)
81 <1> ; bit 7:0 = register number (0-255)
82 <1>
83 <1> IO_ADDR_MASK EQU 0FFFEh ; mask off bit 0 for reading BARs
84 <1> PCI_INDEX_PORT EQU 0CF8h
85 <1> PCI_DATA_PORT EQU 0CFCh
86 <1> PCI32 EQU BIT31 ; bitflag to signal 32bit access
87 <1> PCI16 EQU BIT30 ; bitflag for 16bit access
88 <1>
89 <1> PCI_FN0 EQU 0 << 8
90 <1> PCI_FN1 EQU 1 << 8
91 <1> PCI_FN2 EQU 2 << 8
92 <1> PCI_FN3 EQU 3 << 8
93 <1> PCI_FN4 EQU 4 << 8
94 <1> PCI_FN5 EQU 5 << 8
95 <1> PCI_FN6 EQU 6 << 8
96 <1> PCI_FN7 EQU 7 << 8
97 <1>
98 <1> PCI_CMD_REG EQU 04h ; reg 04, command reg
99 <1> IO_ENA EQU BIT0 ; i/o decode enable
100 <1> MEM_ENA EQU BIT1 ; memory decode enable
101 <1> BM_ENA EQU BIT2 ; bus master enable
102 <1>
103 <1> ; ----------------------------------------------------------------------------
104 <1> ; CODEC.INC
105 <1> ; ----------------------------------------------------------------------------
106 <1>
107 <1> ;Codec registers.
108 <1> ;
109 <1> ;Not all codecs are created equal. Refer to the spec for your specific codec.
110 <1> ;
111 <1> ;All registers are 16bits wide. Access to codec registers over the AC97 link
112 <1> ;is defined by the OEM.
113 <1> ;
114 <1> ;Secondary codec's are accessed by ORing in BIT7 of all register accesses.
115 <1> ;
116 <1>
117 <1> ; each codec/mixer register is 16bits
118 <1>
119 <1> CODEC_RESET_REG equ 00 ; reset codec
120 <1> CODEC_MASTER_VOL_REG equ 02 ; master volume
121 <1> CODEC_HP_VOL_REG equ 04 ; headphone volume
122 <1> CODEC_MASTER_MONO_VOL_REG equ 06 ; master mono volume
123 <1> CODEC_MASTER_TONE_REG equ 08 ; master tone (R+L)
124 <1> CODEC_PCBEEP_VOL_REG equ 0ah ; PC beep volume
125 <1> CODEC_PHONE_VOL_REG equ 0bh ; phone volume
126 <1> CODEC_MIC_VOL_REG equ 0eh ; MIC volume
127 <1> CODEC_LINE_IN_VOL_REG equ 10h ; line input volume
128 <1> CODEC_CD_VOL_REG equ 12h ; CD volume
129 <1> CODEC_VID_VOL_REG equ 14h ; video volume
130 <1> CODEC_AUX_VOL_REG equ 16h ; aux volume
131 <1> CODEC_PCM_OUT_REG equ 18h ; PCM output volume
132 <1> CODEC_RECORD_SELECT_REG equ 1ah ; record select input
133 <1> CODEC_RECORD_VOL_REG equ 1ch ; record volume
134 <1> CODEC_RECORD_MIC_VOL_REG equ 1eh ; record mic volume
135 <1> CODEC_GP_REG equ 20h ; general purpose
136 <1> CODEC_3D_CONTROL_REG equ 22h ; 3D control
137 <1> ; 24h is reserved
138 <1> CODEC_POWER_CTRL_REG equ 26h ; powerdown control
139 <1> CODEC_EXT_AUDIO_REG equ 28h ; extended audio
140 <1> CODEC_EXT_AUDIO_CTRL_REG equ 2ah ; extended audio control
141 <1> CODEC_PCM_FRONT_DACRATE_REG equ 2ch ; PCM out sample rate
142 <1> CODEC_PCM_SURND_DACRATE_REG equ 2eh ; surround sound sample rate
143 <1> CODEC_PCM_LFE_DACRATE_REG equ 30h ; LFE sample rate
144 <1> CODEC_LR_ADCRATE_REG equ 32h ; PCM in sample rate
145 <1> CODEC_MIC_ADCRATE_REG equ 34h ; mic in sample rate
146 <1>
147 <1> ; registers 36-7a are reserved on the ICH
148 <1>
149 <1> CODEC_VENDORID1_REG equ 7ch ; codec vendor ID 1
150 <1> CODEC_VENDORID2_REG equ 7eh ; codec vendor ID 2
151 <1>
152 <1> ; Mixer registers 0 through 51h reside in the ICH and are not forwarded over
153 <1> ; the AC97 link to the codec, which I think is a little weird. Looks like
154 <1> ; the ICH makes it so you don't need a fully functional codec to play audio?
155 <1> ;
156 <1> ; whenever 2 codecs are present in the system, use BIT7 to access the 2nd
157 <1> ; set of registers, ie 80h-feh
158 <1>
159 <1> PRIMARY_CODEC equ 0 ; 0-7F for primary codec
160 <1> SECONDARY_CODEC equ BIT7 ; 80-8f registers for 2ndary
161 <1>
162 <1> SAMPLE_RATE_441khz equ 44100 ; 44.1Khz (cd quality) rate
163 <1>
164 <1> ; ----------------------------------------------------------------------------
165 <1> ; 17/02/2017
166 <1> PCI_IO_BASE equ 10h ; = NAMBAR register offset
167 <1> AC97_INT_LINE equ 3Ch ; AC97 Interrupt Line register offset
168 <1>
169 <1> ; ----------------------------------------------------------------------------
170 <1> ; ICH2AC97.INC
171 <1> ; ----------------------------------------------------------------------------
172 <1>
173 <1> ; PCI stuff
174 <1>
175 <1> ; Intel ICH2 equates. It is assumed that ICH0 and plain ole ICH are compatible.
176 <1>
177 <1> INTEL_VID equ 8086h ; Intel's PCI vendor ID
178 <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
179 <1> SIS_VID equ 1039h
180 <1> NVIDIA_VID equ 10DEh ; Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source c.
181 <1> AMD_VID equ 1022h
182 <1>
183 <1> ICH_DID equ 2415h ; ICH device ID
184 <1> ICH0_DID equ 2425h ; ICH0
185 <1> ICH2_DID equ 2445h ; ICH2 I think there are more ICHes.
186 <1> ; they all should be compatible.
187 <1>
188 <1> ; 17/02/2017 (Erdogan Tan, ref: ALSA Device IDs, ALSA project)
189 <1> ICH3_DID equ 2485h ; ICH3
190 <1> ICH4_DID equ 24C5h ; ICH4
191 <1> ICH5_DID equ 24D5h ; ICH5
192 <1> ICH6_DID equ 266Eh ; ICH6
193 <1> ESB6300_DID equ 25A6h ; 6300ESB
194 <1> ESB631X_DID equ 2698h ; 631XESB
195 <1> ICH7_DID equ 27DEh ; ICH7
196 <1> ; 03/11/2023 - Erdogan Tan (Ref: MenuetOS AC97 WAV Player source code, 2004)
197 <1> MX82440_DID equ 7195h
198 <1> SI7012_DID equ 7012h
199 <1> NFORCE_DID equ 01B1h
200 <1> NFORCE2_DID equ 006Ah
201 <1> AMD8111_DID equ 746Dh
202 <1> AMD768_DID equ 7445h
203 <1> ; 03/11/2023 - Erdogan Tan - Ref: MPXPLAY/SBEMU/KOLIBRIOS AC97 source code
204 <1> CK804_DID equ 0059h
205 <1> MCP04_DID equ 003Ah
206 <1> CK8_DID equ 008Ah
207 <1> NFORCE3_DID equ 00DAh
208 <1> CK8S_DID equ 00EAh
209 <1>
210 <1> NAMBAR_REG equ 10h ; native audio mixer BAR
211 <1> NAM_SIZE equ 256 ; 256 bytes required.
212 <1>
213 <1> NABMBAR_REG equ 14h ; native audio bus mastering BAR
214 <1> NABM_SIZE equ 64 ; 64 bytes
215 <1>
216 <1> ; BUS master registers, accessed via NABMBAR+offset
217 <1>
218 <1> ; ICH supports 3 different types of register sets for three types of things
219 <1> ; it can do, thus:
220 <1> ;
221 <1> ; PCM in (for recording) aka PI
222 <1> ; PCM out (for playback) aka PO
223 <1> ; MIC in (for recording) aka MC
224 <1>
225 <1> PI_BDBAR_REG equ 0 ; PCM in buffer descriptor BAR
226 <1> PO_BDBAR_REG equ 10h ; PCM out buffer descriptor BAR
227 <1> MC_BDBAR_REG equ 20h ; MIC in buffer descriptor BAR
228 <1>
229 <1> ; each buffer descriptor BAR holds a pointer which has entries to the buffer
230 <1> ; contents of the .WAV file we're going to play. Each entry is 8 bytes long
231 <1> ; (more on that later) and can contain 32 entries total, so each BAR is
232 <1> ; 256 bytes in length, thus:
233 <1>
234 <1> BDL_SIZE equ 32*8 ; Buffer Descriptor List size
235 <1> INDEX_MASK equ 31 ; indexes must be 0-31
236 <1>
237 <1>
238 <1>
239 <1> PI_CIV_REG equ 4 ; PCM in current Index value (RO)
240 <1> PO_CIV_REG equ 14h ; PCM out current Index value (RO)
241 <1> MC_CIV_REG equ 24h ; MIC in current Index value (RO)
242 <1> ;8bit read only
243 <1> ; each current index value is simply a pointer showing us which buffer
244 <1> ; (0-31) the codec is currently processing. Once this counter hits 31, it
245 <1> ; wraps back to 0.
246 <1> ; this can be handy to know, as once it hits 31, we're almost out of data to
247 <1> ; play back or room to record!
248 <1>
249 <1>
250 <1> PI_LVI_REG equ 5 ; PCM in Last Valid Index
251 <1> PO_LVI_REG equ 15h ; PCM out Last Valid Index
252 <1> MC_LVI_REG equ 25h ; MIC in Last Valid Index
253 <1> ;8bit read/write
254 <1> ; The Last Valid Index is a number (0-31) to let the codec know what buffer
255 <1> ; number to stop on after processing. It could be very nasty to play audio
256 <1> ; from buffers that aren't filled with the audio we want to play.
257 <1>
258 <1>
259 <1> PI_SR_REG equ 6 ; PCM in Status register
260 <1> PO_SR_REG equ 16h ; PCM out Status register
261 <1> MC_SR_REG equ 26h ; MIC in Status register
262 <1> ;16bit read/write
263 <1> ; status registers. Bitfields follow:
264 <1>
265 <1> FIFO_ERR equ BIT4 ; FIFO Over/Underrun W1TC.
266 <1>
267 <1> BCIS equ BIT3 ; buffer completion interrupt status.
268 <1> ; Set whenever the last sample in ANY
269 <1> ; buffer is finished. Bit is only
270 <1> ; set when the Interrupt on Complete
271 <1> ; (BIT4 of control reg) is set.
272 <1>
273 <1> LVBCI equ BIT2 ; Set whenever the codec has processed
274 <1> ; the last buffer in the buffer list.
275 <1> ; Will fire an interrupt if IOC bit is
276 <1> ; set. Probably set after the last
277 <1> ; sample in the last buffer is
278 <1> ; processed. W1TC
279 <1>
280 <1> ;
281 <1> CELV equ BIT1 ; Current buffer == last valid.
282 <1> ; Bit is RO and remains set until LVI is
283 <1> ; cleared. Probably set up the start
284 <1> ; of processing for the last buffer.
285 <1>
286 <1>
287 <1> DCH equ BIT0 ; DMA controller halted.
288 <1> ; set whenever audio stream is stopped
289 <1> ; or something else goes wrong.
290 <1>
291 <1>
292 <1> PI_PICB_REG equ 8 ; PCM in position in current buffer(RO)
293 <1> PO_PICB_REG equ 18h ; PCM out position in current buffer(RO)
294 <1> MC_PICB_REG equ 28h ; MIC in position in current buffer (RO)
295 <1> ;16bit read only
296 <1> ; position in current buffer regs show the number of dwords left to be
297 <1> ; processed in the current buffer.
298 <1> ;
299 <1>
300 <1> PI_PIV_REG equ 0ah ; PCM in Prefected index value
301 <1> PO_PIV_REG equ 1ah ; PCM out Prefected index value
302 <1> MC_PIV_REG equ 2ah ; MIC in Prefected index value
303 <1> ;8bit, read only
304 <1> ; Prefetched index value register.
305 <1> ; tells which buffer number (0-31) has be prefetched. I'd imagine this
306 <1> ; value follows the current index value fairly closely. (CIV+1)
307 <1> ;
308 <1>
309 <1>
310 <1> PI_CR_REG equ 0bh ; PCM in Control Register
311 <1> PO_CR_REG equ 1bh ; PCM out Control Register
312 <1> MC_CR_REG equ 2bh ; MIC in Control Register
313 <1> ; 8bit
314 <1> ; Control register *MUST* only be accessed as an 8bit value.
315 <1> ; Control register. See bitfields below.
316 <1> ;
317 <1>
318 <1>
319 <1> IOCE equ BIT4 ; interrupt on complete enable.
320 <1> ; set this bit if you want an intrtpt
321 <1> ; to fire whenever LVBCI is set.
322 <1> FEIFE equ BIT3 ; set if you want an interrupt to fire
323 <1> ; whenever there is a FIFO (over or
324 <1> ; under) error.
325 <1> LVBIE equ BIT2 ; last valid buffer interrupt enable.
326 <1> ; set if you want an interrupt to fire
327 <1> ; whenever the completion of the last
328 <1> ; valid buffer.
329 <1> RR equ BIT1 ; reset registers. Nukes all regs
330 <1> ; except bits 4:2 of this register.
331 <1> ; Only set this bit if BIT 0 is 0
332 <1> RPBM equ BIT0 ; Run/Pause
333 <1> ; set this bit to start the codec!
334 <1>
335 <1>
336 <1> GLOB_CNT_REG equ 2ch ; Global control register
337 <1> SEC_RES_EN equ BIT5 ; secondary codec resume event
338 <1> ; interrupt enable. Not used here.
339 <1> PRI_RES_EN equ BIT4 ; ditto for primary. Not used here.
340 <1> ACLINK_OFF equ BIT3 ; Turn off the AC97 link
341 <1> ACWARM_RESET equ BIT2 ; Awaken the AC97 link from sleep.
342 <1> ; registers preserved, bit self clears
343 <1> ACCOLD_RESET equ BIT1 ; Reset everything in the AC97 and
344 <1> ; reset all registers. Not self clearing
345 <1>
346 <1> GPIIE equ BIT0 ; GPI Interrupt enable.
347 <1> ; set if you want an interrupt to
348 <1> ; fire upon ANY of the bits in the
349 <1> ; GPI (general pursose inputs?) not used.
350 <1>
351 <1> GLOB_STS_REG equ 30h ; Global Status register (RO)
352 <1>
353 <1> MD3 equ BIT17 ; modem powerdown status (yawn)
354 <1> AD3 equ BIT16 ; Audio powerdown status (yawn)
355 <1> RD_COMPLETE_STS equ BIT15 ; Codec read timed out. 0=normal
356 <1> BIT3SLOT12 equ BIT14 ; shadowed status of bit 3 in slot 12
357 <1> BIT2SLOT12 equ BIT13 ; shadowed status of bit 2 in slot 12
358 <1> BIT1SLOT12 equ BIT12 ; shadowed status of bit 1 in slot 12
359 <1> SEC_RESUME_STS equ BIT11 ; secondary codec has resumed (and irqed)
360 <1> PRI_RESUME_STS equ BIT10 ; primary codec has resumed (and irqed)
361 <1> SEC_CODEC_RDY equ BIT9 ; secondary codec is ready for action
362 <1> PRI_CODEC_RDY equ BIT8 ; Primary codec is ready for action
363 <1> ; software must check these bits before
364 <1> ; starting the codec!
365 <1> MIC_IN_IRQ equ BIT7 ; MIC in caused an interrupt
366 <1> PCM_OUT_IRQ equ BIT6 ; One of the PCM out channels IRQed
367 <1> PCM_IN_IRQ equ BIT5 ; One of the PCM in channels IRQed
368 <1> MODEM_OUT_IRQ equ BIT2 ; modem out channel IRQed
369 <1> MODEM_IN_IRQ equ BIT1 ; modem in channel IRQed
370 <1> GPI_STS_CHANGE equ BIT0 ; set whenever GPI's have changed.
371 <1> ; BIT0 of slot 12 also reflects this.
372 <1>
373 <1> ACC_SEMA_REG equ 34h ; Codec write semiphore register
374 <1> CODEC_BUSY equ BIT0 ; codec register I/O is happening
375 <1> ; self clearing
376 <1> ;
377 <1> ; Buffer Descriptors List
378 <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32
379 <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
380 <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
381 <1> ; entry describe various control things detailed below.
382 <1> ;
383 <1> ; Buffer pointers must always be aligned on a Dword boundry.
384 <1> ;
385 <1>
386 <1> IOC equ BIT31 ; Fire an interrupt whenever this
387 <1> ; buffer is complete.
388 <1>
389 <1> BUP equ BIT30 ; Buffer Underrun Policy.
390 <1> ; if this buffer is the last buffer
391 <1> ; in a playback, fill the remaining
392 <1> ; samples with 0 (silence) or not.
393 <1> ; It's a good idea to set this to 1
394 <1> ; for the last buffer in playback,
395 <1> ; otherwise you're likely to get a lot
396 <1> ; of noise at the end of the sound.
397 <1>
398 <1> ;
399 <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
400 <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
401 <1> ; Luckily for us, that's the same format as .wav files.
402 <1> ;
403 <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
404 <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
405 <1> ;
406 <1> ; A value of 0 in these bits means play no samples.
407 <1> ;
408 <1>
409 <1> ; 11/11/2023
410 <1> CTRL_ST_CREADY equ BIT8+BIT9+BIT28 ; Primary Codec Ready
411 <1> CODEC_REG_POWERDOWN equ 26h
21
22 _STARTUP:
23
24 ; memory allocation
25
26 00000000 E88001 call setFree ; deallocate unused DOS mem
27
28 ; 17/02/2017
29 ; Clear BSS (uninitialized data) area
30 00000003 31C0 xor ax, ax ; 0
31 00000005 B92740 mov cx, (EOF - bss_start)/2
32 00000008 BF[620A] mov di, bss_start
33 0000000B F3AB rep stosw
34
35 ; allocate 256 bytes of data for DCM_OUT Buffer Descriptor List. (BDL)
36
37 0000000D B81000 mov ax, BDL_SIZE / 16
38 00000010 E87801 call memAlloc
39 00000013 A3[880A] mov [BDL_BUFFER], ax ; segment
40
41 ; allocate 2 buffers, 64k each for now.
42
43 00000016 B80010 mov ax, BUFFERSIZE / 16 ; 64k for .WAV file
44 00000019 E86F01 call memAlloc
45 0000001C A3[8A0A] mov [WAV_BUFFER1], ax ; segment
46
47 0000001F B80010 mov ax, BUFFERSIZE / 16
48 00000022 E86601 call memAlloc
49 00000025 A3[8C0A] mov [WAV_BUFFER2], ax
50
51 ; Detect/reset AC97
52 ;
53 00000028 E8D302 call pciFindDevice
54 0000002B 7342 jnc short _1
55
56 ; couldn't find the audio device!
57
58 0000002D 0E push cs
59 0000002E 1F pop ds
60 0000002F BA[3900] mov dx, noDevMsg
61 00000032 B409 mov ah, 9
62 00000034 CD21 int 21h
63 00000036 E93A01 jmp exit
64
65 ; 17/02/2017
66 00000039 4572726F723A20556E- noDevMsg db "Error: Unable to find intel ICH based audio device!",CR,LF,"$"
66 00000042 61626C6520746F2066-
66 0000004B 696E6420696E74656C-
66 00000054 204943482062617365-
66 0000005D 6420617564696F2064-
66 00000066 6576696365210D0A24
67
68 _1:
69 ; eax = BUS/DEV/FN
70 ; 00000000BBBBBBBBDDDDDFFF00000000
71 ; edx = DEV/VENDOR
72 ; DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
73
74 0000006F 66A3[900A] mov [bus_dev_fn], eax
75 00000073 668916[940A] mov [dev_vendor], edx
76
77 ; get ICH base address regs for mixer and bus master
78
79 00000078 B010 mov al, NAMBAR_REG
80 0000007A E8F301 call pciRegRead16 ; read PCI registers 10-11
81 0000007D 83E2FE and dx, IO_ADDR_MASK ; mask off BIT0
82
83 00000080 8916[840A] mov [NAMBAR], dx ; save audio mixer base addy
84
85 00000084 B014 mov al, NABMBAR_REG
86 00000086 E8E701 call pciRegRead16
87 00000089 83E2FE and dx, IO_ADDR_MASK
88
89 0000008C 8916[860A] mov [NABMBAR], dx ; save bus master base addy
90
91 ; init controller
92 ; 17/02/2017
93 00000090 B004 mov al, PCI_CMD_REG ; command register (04h)
94 00000092 E8DB01 call pciRegRead16 ; pciRegRead8
95
96 ; eax = BUS/DEV/FN/REG
97 ; dx = PCI Command Register Content ; 17/02/2017
98 ; 00000000CCCCCCCC
99 00000095 8916[980A] mov [stats_cmd], dx
100
101 00000099 B010 mov al, PCI_IO_BASE ; IO base address register (10h)
102 0000009B E8E001 call pciRegRead32
103
104 0000009E 83E2C0 and dx, 0FFC0h ; IO_ADDR_MASK (0FFFE) ?
105 000000A1 8916[9A0A] mov [ac97_io_base], dx
106
107 000000A5 B03C mov al, AC97_INT_LINE ; Interrupt line register (3Ch)
108 000000A7 E8BE01 call pciRegRead8 ; 17/02/2017
109
110 000000AA 8816[8F0A] mov [ac97_int_ln_reg], dl
111
112 ; 28/11/2016
113 000000AE BB0100 mov bx, 1
114 000000B1 30F6 xor dh, dh ; 17/02/2017
115 000000B3 89D1 mov cx, dx
116 000000B5 D3E3 shl bx, cl
117
118 ;not bx
119 000000B7 E4A1 in al, 0A1h ; irq 8-15
120 000000B9 88C4 mov ah, al
121 000000BB E421 in al, 21h ; irq 0-7
122 ;and ax, bx ; unmask
123 000000BD 0FB3D0 btr ax, dx ; unmask
124 000000C0 E621 out 21h, al ; enable interrupt (if irq <= 7)
125 000000C2 88E0 mov al, ah
126 000000C4 E6A1 out 0A1h, al ; enable interrupt (if irq > 7)
127 ;not bx
128
129 000000C6 BAD104 mov dx, 4D1h ;8259 ELCR1
130 000000C9 EC in al, dx
131 000000CA 88C4 mov ah, al
132 000000CC BAD004 mov dx, 4D0h
133 000000CF EC in al, dx
134 ;or ax, bx
135 000000D0 0FABC8 bts ax, cx
136 000000D3 BAD004 mov dx, 4D0h
137 000000D6 EE out dx, al ;set level-triggered mode
138 000000D7 88E0 mov al, ah
139 000000D9 BAD104 mov dx, 4D1h
140 000000DC EE out dx, al ;set level-triggered mode
141
142 ; 24/11/2016 - Erdogan Tan
143 000000DD 89CB mov bx, cx
144 ;mov bx, dx
145 000000DF 8A9F[B208] mov bl, [bx+irq_int]
146 000000E3 C1E302 shl bx, 2 ; * 4
147
148 ; set up interrupt vector
149 ; 30/11/2016
150 000000E6 06 push es
151 000000E7 31C0 xor ax, ax
152 000000E9 8EC0 mov es, ax
153 000000EB 26C707[0A08] mov word [es:bx], ac97_int_handler
154 000000F0 8CC8 mov ax, cs
155 000000F2 26894702 mov [es:bx+2], ax
156 000000F6 07 pop es
157
158 000000F7 E8A005 call write_ac97_dev_info
159
160 ; check the command line for a file to play
161
162 ;push ds
163 000000FA E89700 call processCmdline ; get the filename
164
165 ; open the file
166 000000FD B002 mov al, OPEN ; open existing file
167 000000FF E8B200 call openFile ; no error? ok.
168 ;pop ds
169 00000102 7322 jnc short _gsr
170
171 ; file not found!
172
173 ;push cs
174 ;pop ds
175 00000104 BA[0D01] mov dx, noFileErrMsg
176 00000107 B409 mov ah, 9
177 00000109 CD21 int 21h
178 0000010B EB66 jmp exit
179
180 0000010D 4572726F723A206669- noFileErrMsg db "Error: file not found.",CR,LF,"$"
180 00000116 6C65206E6F7420666F-
180 0000011F 756E642E0D0A24
181
182 _gsr:
183 00000126 E8B200 call getSampleRate ; read the sample rate
184 ; pass it onto codec.
185 00000129 7248 jc short exit ; 19/11/2016 - nothing to do
186
187 0000012B A3[9C0A] mov [sample_rate], ax
188 ; 19/11/2016
189 0000012E 880E[9E0A] mov [stmo], cl
190 00000132 8816[A00A] mov [bps], dl
191
192 ; 17/02/2017
193 00000136 C606[A20A]00 mov byte [fbs_shift], 0 ; 0 = stereo and 16 bit
194 0000013B FEC9 dec cl
195 0000013D 7504 jnz short _gsr_1 ; stereo
196 0000013F FE06[A20A] inc byte [fbs_shift] ; 1 = mono or 8 bit
197 _gsr_1:
198 00000143 80FA08 cmp dl, 8
199 00000146 7704 ja short _gsr_2 ; 16 bit samples
200 00000148 FE06[A20A] inc byte [fbs_shift] ; 2 = mono and 8 bit
201 _gsr_2:
202 0000014C E86A06 call write_sample_rate
203
204 ; 17/02/2017
205 0000014F 8B16[980A] mov dx, [stats_cmd]
206 00000153 80CA05 or dl, IO_ENA+BM_ENA ; enable IO and bus master
207 00000156 E88901 call pciRegWrite16 ; pciRegWrite8
208
209 ; setup the Codec (actually mixer registers)
210 00000159 E8E501 call codecConfig ; unmute codec, set rates.
211
212 ; 13/05/2024
213 ; 11/11/2023
214 0000015C 721C jc short init_err
215
216 ;
217 ; position file pointer to start in actual wav data
218 ; MUCH improvement should really be done here to check if sample size is
219 ; supported, make sure there are 2 channels, etc.
220 ;
221 0000015E B442 mov ah, 42h
222 00000160 B000 mov al, 0 ; from start of file
223 00000162 8B1E[7E0A] mov bx, [filehandle]
224 00000166 31C9 xor cx, cx
225 00000168 BA2C00 mov dx, 44 ; jump past .wav/riff header
226 0000016B CD21 int 21h
227
228 ; play the .wav file. Most of the good stuff is in here.
229
230 0000016D E83703 call playWav
231
232 ; close the .wav file and exit.
233
234 close_exit: ; 13/05/2024
235 00000170 E85300 call closeFile
236
237 exit:
238 00000173 B8004C mov ax, 4c00h
239 00000176 CD21 int 21h
240
241 here:
242 00000178 EBFE jmp short here
243
244 ; 13/05/2024
245 init_err:
246 0000017A BA[F809] mov dx, msg_init_err
247
248 ; 13/05/2024
249 vra_err: ; 12/11/2023
250 ;mov dx, msg_no_vra
251 0000017D B409 mov ah, 9
252 0000017F CD21 int 21h
253 00000181 EBED jmp short close_exit
254
255 ; MEMALLOC.ASM
256 ;-- SETFREE: Release memory not used ----------------
257 ;-- Input : ES = address of PSP
258 ;-- Output : none
259 ;-- Register : AX, BX, CL and FLAGS are changed
260 ;-- Info : Since the stack-segment is always the last segment in an
261 ; EXE-file, ES:0000 points to the beginning and SS:SP
262 ; to the end of the program in memory. Through this the
263 ; length of the program can be calculated
264 ; call this routine once at the beginning of the program to free up memory
265 ; assigned to it by DOS.
266
267 setFree:
268 00000183 BB0010 mov bx, 65536/16 ; 4K paragraphs ; 17/02/2017 (Erdogan Tan)
269
270 00000186 B44A mov ah, 4ah ;pass new length to DOS
271 00000188 CD21 int 21h
272
273 0000018A C3 retn ; back to caller
274 ; new size (allocated memory) = 64KB
275
276 memAlloc:
277 ; input: AX = # of paragraphs required
278 ; output: AX = segment of block to use
279
280 0000018B 53 push bx
281 0000018C 89C3 mov bx, ax
282 0000018E B448 mov ah, 48h
283 00000190 CD21 int 21h
284 00000192 5B pop bx
285 00000193 C3 retn
286
287 ; CMDLINE.ASM
288 ; parse the command line
289 ; entry: none
290 ; exit: DS:DX to the 1st supplied item on the command line
291
292 processCmdline:
293 00000194 53 push bx
294 00000195 56 push si
295
296 ;mov ah, 51h
297 ;int 21h
298 ;mov ds, bx
299
300 00000196 BE8000 mov si, 80h
301 00000199 0FB61C movzx bx, byte [si]
302 0000019C 01DE add si, bx
303 0000019E 46 inc si
304
305 0000019F C60400 mov byte [si], NULL ; zero terminate
306
307 000001A2 BE8100 mov si, 81h
308
309 cmdlineloop:
310 000001A5 AC lodsb
311
312 000001A6 3C00 cmp al, NULL ; found end of line?
313 000001A8 7404 je short exitpc
314 000001AA 3C20 cmp al, ' ' ; found a space?
315 000001AC 74F7 je short cmdlineloop
316
317 ; must be the filename here.
318 exitpc:
319 000001AE 4E dec si ; point to start of filename
320 000001AF 89F2 mov dx, si
321 000001B1 5E pop si
322 000001B2 5B pop bx
323 000001B3 C3 retn
324
325 ; FILE.ASM
326 ;open or create file
327 ;
328 ;input: ds:dx-->filename (asciiz)
329 ; al=file Mode (create or open)
330 ;output: none cs:[filehandle] filled
331 ;
332 openFile:
333 000001B4 50 push ax
334 000001B5 51 push cx
335 000001B6 B43B mov ah, 3bh ; start with a mode
336 000001B8 00C4 add ah, al ; add in create or open mode
337 000001BA 31C9 xor cx, cx
338 000001BC CD21 int 21h
339 000001BE 7203 jc short _of1
340 ;mov [cs:filehandle], ax
341 000001C0 A3[7E0A] mov [filehandle], ax
342 _of1:
343 000001C3 59 pop cx
344 000001C4 58 pop ax
345 000001C5 C3 retn
346
347 ; close the currently open file
348 ; input: none, uses cs:[filehandle]
349 closeFile:
350 000001C6 50 push ax
351 000001C7 53 push bx
352 000001C8 833E[7E0A]FF cmp word [filehandle], -1
353 000001CD 7409 jz short _cf1
354 000001CF 8B1E[7E0A] mov bx, [filehandle]
355 000001D3 B8003E mov ax,3e00h
356 000001D6 CD21 int 21h ;close file
357 _cf1:
358 000001D8 5B pop bx
359 000001D9 58 pop ax
360 000001DA C3 retn
361
362 getSampleRate:
363 ; 08/12/2016
364 ; reads the sample rate from the .wav file.
365 ; entry: none - assumes file is already open
366 ; 19/11/2016 - Erdogan Tan
367 ; exit: ax = sample rate (11025, 22050, 44100, 48000)
368 ; cx = number of channels (mono=1, stereo=2)
369 ; dx = bits per sample (8, 16)
370
371 000001DB 53 push bx
372
373 000001DC B442 mov ah, 42h
374 000001DE B000 mov al, 0 ; from start of file
375 000001E0 8B1E[7E0A] mov bx, [filehandle]
376 000001E4 31C9 xor cx, cx
377 000001E6 BA0800 mov dx, 08h ; "WAVE"
378 000001E9 CD21 int 21h
379
380 000001EB BA[620A] mov dx, smpRBuff
381 000001EE B91C00 mov cx, 28 ; 28 bytes
382 000001F1 B43F mov ah, 3fh
383 000001F3 CD21 int 21h
384
385 000001F5 813E[620A]5741 cmp word [smpRBuff], 'WA'
386 000001FB 751C jne short gsr_stc
387
388 000001FD 813E[640A]5645 cmp word [smpRBuff+2], 'VE'
389 00000203 7514 jne short gsr_stc
390
391 00000205 833E[6E0A]01 cmp word [smpRBuff+12], 1 ; Offset 20, must be 1 (= PCM)
392 0000020A 750D jne short gsr_stc
393
394
395 0000020C 8B0E[700A] mov cx, [smpRBuff+14] ; return num of channels in CX
396 00000210 A1[720A] mov ax, [smpRBuff+16] ; return sample rate in AX
397 00000213 8B16[7C0A] mov dx, [smpRBuff+26] ; return bits per sample value in DX
398 gsr_retn:
399 00000217 5B pop bx
400 00000218 C3 retn
401
402 gsr_stc:
403 00000219 F9 stc
404 0000021A EBFB jmp short gsr_retn
405
406 %include 'ac97.asm' ; 29/11/2016 (AC97 codec configuration)
1 <1> ; 12/11/2023
2 <1> ; 11/11/2023
3 <1> ; 06/11/2023
4 <1> ; 05/11/2023
5 <1> ; 04/11/2023
6 <1> ; 03/11/2023
7 <1> ; PCI and AC97 codec functions for wav player
8 <1> ; Erdogan Tan (17/02/2017)
9 <1>
10 <1> ; ----------------------------------------------------------------------------
11 <1> ; PCI.ASM
12 <1> ; ----------------------------------------------------------------------------
13 <1>
14 <1> ; PCI device register reader/writers.
15 <1> ; NASM version: Erdogan Tan (29/11/2016)
16 <1> ; Last Update: 17/02/2017
17 <1>
18 <1> ;===============================================================
19 <1> ; 8/16/32bit PCI reader
20 <1> ;
21 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
22 <1> ; BIT30 set if 32 bit access requested
23 <1> ; BIT29 set if 16 bit access requested
24 <1> ; otherwise defaults to 8 bit read
25 <1> ;
26 <1> ; Exit: DL,DX,EDX register data depending on requested read size
27 <1> ;
28 <1> ; Note: this routine is meant to be called via pciRegRead8, pciRegread16,
29 <1> ; or pciRegRead32, listed below.
30 <1> ;
31 <1> ; Note2: don't attempt to read 32bits of data from a non dword aligned reg
32 <1> ; number. Likewise, don't do 16bit reads from non word aligned reg #
33 <1> ;
34 <1> pciRegRead:
35 0000021C 6653 <1> push ebx
36 0000021E 51 <1> push cx
37 0000021F 6689C3 <1> mov ebx, eax ; save eax, dh
38 00000222 88F1 <1> mov cl, dh
39 00000224 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
40 0000022A 660D00000080 <1> or eax, BIT31 ; make a PCI access request
41 00000230 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
42 <1>
43 00000232 BAF80C <1> mov dx, PCI_INDEX_PORT
44 00000235 66EF <1> out dx, eax ; write PCI selector
45 <1>
46 00000237 BAFC0C <1> mov dx, PCI_DATA_PORT
47 0000023A 88D8 <1> mov al, bl
48 0000023C 2403 <1> and al, 3 ; figure out which port to
49 0000023E 00C2 <1> add dl, al ; read to
50 <1>
51 00000240 66ED <1> in eax, dx ; do 32bit read
52 00000242 66F7C300000080 <1> test ebx, PCI32
53 00000249 7403 <1> jz short _pregr1
54 <1>
55 0000024B 6689C2 <1> mov edx, eax ; return 32bits of data
56 <1> _pregr1:
57 0000024E 89C2 <1> mov dx, ax ; return 16bits of data
58 00000250 66F7C3000000C0 <1> test ebx, PCI32+PCI16
59 00000257 7502 <1> jnz short _pregr2
60 00000259 88CE <1> mov dh, cl ; restore dh for 8 bit read
61 <1> _pregr2:
62 0000025B 6689D8 <1> mov eax, ebx ; restore eax
63 0000025E 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
64 00000264 59 <1> pop cx
65 00000265 665B <1> pop ebx
66 00000267 C3 <1> retn
67 <1>
68 <1> pciRegRead8:
69 00000268 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 8 bit read size
70 0000026E EBAC <1> jmp short pciRegRead ; call generic PCI access
71 <1>
72 <1> pciRegRead16:
73 00000270 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 16 bit read size
74 00000276 660D00000040 <1> or eax, PCI16 ; call generic PCI access
75 0000027C EB9E <1> jmp short pciRegRead
76 <1>
77 <1> pciRegRead32:
78 0000027E 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 32 bit read size
79 00000284 660D00000080 <1> or eax, PCI32 ; call generic PCI access
80 0000028A EB90 <1> jmp short pciRegRead
81 <1>
82 <1> ;===============================================================
83 <1> ; 8/16/32bit PCI writer
84 <1> ;
85 <1> ; Entry: EAX=PCI Bus/Device/fn/register number
86 <1> ; BIT31 set if 32 bit access requested
87 <1> ; BIT30 set if 16 bit access requested
88 <1> ; otherwise defaults to 8bit read
89 <1> ; DL/DX/EDX data to write depending on size
90 <1> ;
91 <1> ;
92 <1> ; note: this routine is meant to be called via pciRegWrite8, pciRegWrite16,
93 <1> ; or pciRegWrite32 as detailed below.
94 <1> ;
95 <1> ; Note2: don't attempt to write 32bits of data from a non dword aligned reg
96 <1> ; number. Likewise, don't do 16bit writes from non word aligned reg #
97 <1> ;
98 <1> pciRegWrite:
99 0000028C 6653 <1> push ebx
100 0000028E 51 <1> push cx
101 0000028F 6689C3 <1> mov ebx, eax ; save eax, dx
102 00000292 89D1 <1> mov cx, dx
103 00000294 660D00000080 <1> or eax, BIT31 ; make a PCI access request
104 0000029A 6625FFFFFFBF <1> and eax, ~PCI16 ; NOT PCI16 ; clear out data size request
105 000002A0 24FC <1> and al, ~3 ; NOT 3 ; force index to be dword
106 <1>
107 000002A2 BAF80C <1> mov dx, PCI_INDEX_PORT
108 000002A5 66EF <1> out dx, eax ; write PCI selector
109 <1>
110 000002A7 BAFC0C <1> mov dx, PCI_DATA_PORT
111 000002AA 88D8 <1> mov al, bl
112 000002AC 2403 <1> and al, 3 ; figure out which port to
113 000002AE 00C2 <1> add dl, al ; write to
114 <1>
115 000002B0 6689D0 <1> mov eax, edx ; put data into eax
116 000002B3 89C8 <1> mov ax, cx
117 <1>
118 000002B5 EE <1> out dx, al
119 000002B6 66F7C3000000C0 <1> test ebx, PCI16+PCI32 ; only 8bit access? bail
120 000002BD 740C <1> jz short _pregw1
121 <1>
122 000002BF EF <1> out dx, ax ; write 16 bit value
123 000002C0 66F7C300000040 <1> test ebx, PCI16 ; 16bit requested? bail
124 000002C7 7502 <1> jnz short _pregw1
125 <1>
126 000002C9 66EF <1> out dx, eax ; write full 32bit
127 <1> _pregw1:
128 000002CB 6689D8 <1> mov eax, ebx ; restore eax
129 000002CE 6625FFFFFFBF <1> and eax, (~PCI32)+PCI16 ; clear out data size request
130 000002D4 89CA <1> mov dx, cx ; restore dx
131 000002D6 59 <1> pop cx
132 000002D7 665B <1> pop ebx
133 000002D9 C3 <1> ret
134 <1>
135 <1> pciRegWrite8:
136 000002DA 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 8 bit write size
137 000002E0 EBAA <1> jmp short pciRegWrite ; call generic PCI access
138 <1>
139 <1> pciRegWrite16:
140 000002E2 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 16 bit write size
141 000002E8 660D00000040 <1> or eax, PCI16 ; call generic PCI access
142 000002EE EB9C <1> jmp short pciRegWrite
143 <1>
144 <1> pciRegWrite32:
145 000002F0 6625FFFFFF3F <1> and eax, (~PCI16)+PCI32 ; set up 32 bit write size
146 000002F6 660D00000080 <1> or eax, PCI32 ; call generic PCI access
147 000002FC EB8E <1> jmp short pciRegWrite
148 <1>
149 <1> ; 17/02/2017 (Modifed by Erdogan Tan for various ICH device IDs)
150 <1> ;===============================================================
151 <1> ; PCIFindDevice: scan through PCI space looking for a device+vendor ID
152 <1> ;
153 <1> ; ENTRY: none
154 <1> ;; Entry: EAX=Device+Vendor ID
155 <1> ;
156 <1> ; Exit: EAX=PCI address if device found
157 <1> ; EDX=Device+Vendor ID
158 <1> ; CY clear if found, set if not found. EAX invalid if CY set.
159 <1> ;
160 <1> ; [old stackless] Destroys: ebx, esi, edi, cl
161 <1> ;
162 <1> pciFindDevice:
163 <1> ;push cx
164 <1> ;push eax ; *
165 <1> ;push esi
166 <1> ;push edi
167 <1>
168 <1> ;mov esi, eax ; save off vend+device ID
169 <1>
170 <1> ; 17/02/2017
171 000002FE BE[C208] <1> mov si, valid_ids ; address of Valid ICH (AC97) Device IDs
172 00000301 B91500 <1> mov cx, valid_id_count
173 <1> pfd_0:
174 00000304 66BF00FFFF7F <1> mov edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
175 <1> nextPCIdevice:
176 0000030A 6681C700010000 <1> add edi, 100h