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
|
// ============================================================================================
//
// Copyright (C) 2002 Jeroen Janssen
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// ============================================================================================
//
// This VBE is part of the VGA Bios specific to the plex86/bochs Emulated VGA card.
// You can NOT drive any physical vga card with it.
//
// ============================================================================================
//
// This VBE Bios is based on information taken from :
// - VESA BIOS EXTENSION (VBE) Core Functions Standard Version 3.0 located at www.vesa.org
//
// ============================================================================================
// defines available
// enable LFB support (depends upon bochs-vbe-lfb patch)
#define VBE_HAVE_LFB
// disable VESA/VBE2 check in vbe info
//#define VBE2_NO_VESA_CHECK
// dynamicly generate a mode_info list
//#define DYN_LIST
#include "vbe.h"
#include "vbetables.h"
// The current OEM Software Revision of this VBE Bios
#define VBE_OEM_SOFTWARE_REV 0x0002;
#define VBEInfoData ((VbeInfoBlock *) 0)
extern char vbebios_copyright;
extern char vbebios_vendor_name;
extern char vbebios_product_name;
extern char vbebios_product_revision;
// FIXME: find out why we cannot use the dynamic list generation (due to a bug somewhere)
//#define DYN_LIST
#ifndef DYN_LIST
extern Bit16u vbebios_mode_list;
#endif
ASM_START
// FIXME: 'merge' these (c) etc strings with the vgabios.c strings?
_vbebios_copyright:
.ascii "Bochs/Plex86 VBE(C) 2003 Jeroen Janssen <japj@darius.demon.nl>"
.byte 0x00
_vbebios_vendor_name:
.ascii "Bochs/Plex86 Developers"
.byte 0x00
_vbebios_product_name:
.ascii "Bochs/Plex86 VBE Adapter"
.byte 0x00
_vbebios_product_revision:
.ascii "$Id: vbe.c,v 1.34 2003/08/07 15:54:11 vruppert Exp $"
.byte 0x00
_vbebios_info_string:
.ascii "Bochs VBE Display Adapter enabled"
.byte 0x0a,0x0d
.byte 0x0a,0x0d
.byte 0x00
_no_vbebios_info_string:
.ascii "NO Bochs VBE Support available!"
.byte 0x0a,0x0d
.byte 0x0a,0x0d
.byte 0x00
#ifndef DYN_LIST
// FIXME: for each new mode add a statement here
// at least until dynamic list creation is working
_vbebios_mode_list:
.word VBE_VESA_MODE_640X400X8
.word VBE_VESA_MODE_640X480X8
.word VBE_VESA_MODE_800X600X4
.word VBE_VESA_MODE_800X600X8
.word VBE_VESA_MODE_1024X768X8
.word VBE_VESA_MODE_640X480X1555
.word VBE_VESA_MODE_640X480X565
.word VBE_VESA_MODE_640X480X888
.word VBE_VESA_MODE_800X600X1555
.word VBE_VESA_MODE_800X600X565
.word VBE_VESA_MODE_800X600X888
.word VBE_VESA_MODE_1024X768X1555
.word VBE_VESA_MODE_1024X768X565
.word VBE_VESA_MODE_1024X768X888
.word VBE_OWN_MODE_640X480X8888
.word VBE_OWN_MODE_800X600X8888
.word VBE_OWN_MODE_1024X768X8888
.word VBE_OWN_MODE_320X200X8
.word VBE_VESA_MODE_END_OF_LIST
#endif
ASM_END
// from rombios.c
#define PANIC_PORT 0x501
ASM_START
MACRO HALT
;; the HALT macro is called with the line number of the HALT call.
;; The line number is then sent to the PANIC_PORT, causing Bochs to
;; print a BX_PANIC message. This will normally halt the simulation
;; with a message such as "BIOS panic at rombios.c, line 4091".
;; However, users can choose to make panics non-fatal and continue.
mov dx,#PANIC_PORT
mov ax,#?1
out dx,ax
MEND
ASM_END
// DISPI ioport functions
// FIXME: what if no VBE host side code?
static Bit16u dispi_get_id()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
return inw(VBE_DISPI_IOPORT_DATA);
}
static void dispi_set_id(id)
Bit16u id;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
outw(VBE_DISPI_IOPORT_DATA,id);
}
static void dispi_set_xres(xres)
Bit16u xres;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_XRES);
outw(VBE_DISPI_IOPORT_DATA,xres);
}
static void dispi_set_yres(yres)
Bit16u yres;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_YRES);
outw(VBE_DISPI_IOPORT_DATA,yres);
}
static void dispi_set_bpp(bpp)
Bit16u bpp;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
outw(VBE_DISPI_IOPORT_DATA,bpp);
}
static Bit16u dispi_get_bpp()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BPP);
return inw(VBE_DISPI_IOPORT_DATA);
}
static Bit16u dispi_get_enable()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
return inw(VBE_DISPI_IOPORT_DATA);
}
void dispi_set_enable(enable)
Bit16u enable;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
outw(VBE_DISPI_IOPORT_DATA,enable);
}
static void dispi_set_bank(bank)
Bit16u bank;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
outw(VBE_DISPI_IOPORT_DATA,bank);
}
static Bit16u dispi_get_bank()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_BANK);
return inw(VBE_DISPI_IOPORT_DATA);
}
static void dispi_set_bank_farcall()
{
ASM_START
cmp bx,#0x0100
je dispi_set_bank_farcall_get
or bx,bx
jnz dispi_set_bank_farcall_error
push dx
mov ax,# VBE_DISPI_INDEX_BANK
mov dx,# VBE_DISPI_IOPORT_INDEX
out dx,ax
pop ax
mov dx,# VBE_DISPI_IOPORT_DATA
out dx,ax
retf
dispi_set_bank_farcall_get:
mov ax,# VBE_DISPI_INDEX_BANK
mov dx,# VBE_DISPI_IOPORT_INDEX
out dx,ax
mov dx,# VBE_DISPI_IOPORT_DATA
in ax,dx
mov dx,ax
retf
dispi_set_bank_farcall_error:
mov ax,#0x014F
retf
ASM_END
}
static void dispi_set_x_offset(offset)
Bit16u offset;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
outw(VBE_DISPI_IOPORT_DATA,offset);
}
static Bit16u dispi_get_x_offset()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_X_OFFSET);
return inw(VBE_DISPI_IOPORT_DATA);
}
static void dispi_set_y_offset(offset)
Bit16u offset;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
outw(VBE_DISPI_IOPORT_DATA,offset);
}
static Bit16u dispi_get_y_offset()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_Y_OFFSET);
return inw(VBE_DISPI_IOPORT_DATA);
}
static void dispi_set_virt_width(width)
Bit16u width;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
outw(VBE_DISPI_IOPORT_DATA,width);
}
static Bit16u dispi_get_virt_width()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_WIDTH);
return inw(VBE_DISPI_IOPORT_DATA);
}
/*
static void dispi_set_virt_height(height)
Bit16u height;
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
outw(VBE_DISPI_IOPORT_DATA,height);
}
*/
static Bit16u dispi_get_virt_height()
{
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_VIRT_HEIGHT);
return inw(VBE_DISPI_IOPORT_DATA);
}
// ModeInfo helper function
static ModeInfoListItem* mode_info_find_mode(mode, using_lfb)
Bit16u mode; Boolean using_lfb;
{
ModeInfoListItem *cur_info=&mode_info_list;
while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST)
{
if (cur_info->mode == mode)
{
if (!using_lfb)
{
return cur_info;
}
else if (cur_info->info.ModeAttributes & VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE)
{
return cur_info;
}
else
{
cur_info++;
}
}
else
{
cur_info++;
}
}
return 0;
}
/** Has VBE display - Returns true if VBE display detected
*
*/
Boolean vbe_has_vbe_display()
{
dispi_set_id(VBE_DISPI_ID2);
return (dispi_get_id()==VBE_DISPI_ID2);
}
/** VBE Init - Initialise the Vesa Bios Extension Code
*
* This function does a sanity check on the host side display code interface.
*/
void vbe_init()
{
Bit16u dispi_id;
outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ID);
outw(VBE_DISPI_IOPORT_DATA,VBE_DISPI_ID0);
dispi_id=inw(VBE_DISPI_IOPORT_DATA);
if (dispi_id!=VBE_DISPI_ID0)
{
//FIXME this results in a 'rombios.c' line panic, but it's actually a 'vbe.c' panic
ASM_START
HALT(__LINE__)
ASM_END
}
//#ifdef DEBUG
printf("VBE Bios $Id: vbe.c,v 1.34 2003/08/07 15:54:11 vruppert Exp $\n");
//#endif
}
/** VBE Display Info - Display information on screen about the VBE
*/
void vbe_display_info()
{
// Check for VBE display extension in Bochs
if (vbe_has_vbe_display())
{
ASM_START
mov ax,#0xc000
mov ds,ax
mov si,#_vbebios_info_string
call _display_string
ASM_END
}
else
{
ASM_START
mov ax,#0xc000
mov ds,ax
mov si,#_no_vbebios_info_string
call _display_string
ASM_END
}
}
/** Function 00h - Return VBE Controller Information
*
* Input:
* AX = 4F00h
* ES:DI = Pointer to buffer in which to place VbeInfoBlock structure
* (VbeSignature should be VBE2 when VBE 2.0 information is desired and
* the info block is 512 bytes in size)
* Output:
* AX = VBE Return Status
*
*/
void vbe_biosfn_return_controller_information(AX, ES, DI)
Bit16u *AX;Bit16u ES;Bit16u DI;
{
Bit16u ss=get_SS();
VbeInfoBlock vbe_info_block;
Bit16u status;
Bit16u result;
Bit16u vbe2_info;
#ifdef DYN_LIST
Bit16u *video_mode_list;
#endif
Bit16u cur_mode=0;
ModeInfoListItem *cur_info=&mode_info_list;
status = read_word(ss, AX);
#ifdef DEBUG
printf("VBE vbe_biosfn_return_vbe_info ES%x DI%x AX%x\n",ES,DI,status);
#endif
vbe2_info = 0;
#ifdef VBE2_NO_VESA_CHECK
#else
// get vbe_info_block into local variable
memcpyb(ss, &vbe_info_block, ES, DI, sizeof(vbe_info_block));
// check for VBE2 signature
if (((vbe_info_block.VbeSignature[0] == 'V') &&
(vbe_info_block.VbeSignature[1] == 'B') &&
(vbe_info_block.VbeSignature[2] == 'E') &&
(vbe_info_block.VbeSignature[3] == '2')) ||
((vbe_info_block.VbeSignature[0] == 'V') &&
(vbe_info_block.VbeSignature[1] == 'E') &&
(vbe_info_block.VbeSignature[2] == 'S') &&
(vbe_info_block.VbeSignature[3] == 'A')) )
{
vbe2_info = 1;
#ifdef DEBUG
printf("VBE correct VESA/VBE2 signature found\n");
#endif
}
#endif
// VBE Signature
vbe_info_block.VbeSignature[0] = 'V';
vbe_info_block.VbeSignature[1] = 'E';
vbe_info_block.VbeSignature[2] = 'S';
vbe_info_block.VbeSignature[3] = 'A';
// VBE Version supported
vbe_info_block.VbeVersion = 0x0200;
// OEM String
vbe_info_block.OemStringPtr_Seg = 0xc000;
vbe_info_block.OemStringPtr_Off = &vbebios_copyright;
// Capabilities
vbe_info_block.Capabilities[0] = 0;
vbe_info_block.Capabilities[1] = 0;
vbe_info_block.Capabilities[2] = 0;
vbe_info_block.Capabilities[3] = 0;
#ifdef DYN_LIST
// FIXME: This doesn't work correctly somehow?
// VBE Video Mode Pointer (dynamicly generated from the mode_info_list)
vbe_info_block.VideoModePtr_Seg= ES ;//0xc000;
vbe_info_block.VideoModePtr_Off= DI + 34;//&(VBEInfoData->Reserved);//&vbebios_mode_list;
#else
// VBE Video Mode Pointer (staticly in rom)
vbe_info_block.VideoModePtr_Seg = 0xc000;
vbe_info_block.VideoModePtr_Off = &vbebios_mode_list;
#endif
#ifdef DYN_LIST
// video_mode_list=(Bit16u*)&(vbe_info_block.Reserved);
do
{
#ifdef DEBUG
printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode);
#endif
// *video_mode_list=cur_info->mode;
vbe_info_block.Reserved[cur_mode] = cur_info->mode;
cur_info++;
//video_mode_list++;
cur_mode++;
} while (cur_info->mode != VBE_VESA_MODE_END_OF_LIST);
// Add vesa mode list terminator
vbe_info_block.Reserved[cur_mode] = VBE_VESA_MODE_END_OF_LIST;
#endif
// VBE Total Memory (in 64b blocks)
vbe_info_block.TotalMemory = VBE_TOTAL_VIDEO_MEMORY_DIV_64K;
if (vbe2_info)
{
// OEM Stuff
vbe_info_block.OemSoftwareRev = VBE_OEM_SOFTWARE_REV;
vbe_info_block.OemVendorNamePtr_Seg = 0xc000;
vbe_info_block.OemVendorNamePtr_Off = &vbebios_vendor_name;
vbe_info_block.OemProductNamePtr_Seg = 0xc000;
vbe_info_block.OemProductNamePtr_Off = &vbebios_product_name;
vbe_info_block.OemProductRevPtr_Seg = 0xc000;
vbe_info_block.OemProductRevPtr_Off = &vbebios_product_revision;
// copy updates in vbe_info_block back
memcpyb(ES, DI, ss, &vbe_info_block, sizeof(vbe_info_block));
}
else
{
// copy updates in vbe_info_block back (VBE 1.x compatibility)
memcpyb(ES, DI, ss, &vbe_info_block, 256);
}
result = 0x4f;
write_word(ss, AX, result);
}
/** Function 01h - Return VBE Mode Information
*
* Input:
* AX = 4F01h
* CX = Mode Number
* ES:DI = Pointer to buffer in which to place ModeInfoBlock structure
* Output:
* AX = VBE Return Status
*
*/
void vbe_biosfn_return_mode_information(AX, CX, ES, DI)
Bit16u *AX;Bit16u CX; Bit16u ES;Bit16u DI;
{
Bit16u result=0x0100;
Bit16u ss=get_SS();
ModeInfoBlock info;
ModeInfoListItem *cur_info;
Boolean using_lfb;
#ifdef DEBUG
printf("VBE vbe_biosfn_return_mode_information ES%x DI%x CX%x\n",ES,DI,CX);
#endif
using_lfb=((CX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
CX = (CX & 0x1ff);
cur_info = mode_info_find_mode(CX, using_lfb, &cur_info);
if (cur_info != 0)
{
#ifdef DEBUG
printf("VBE found mode %x\n",CX);
#endif
memsetb(ss, &info, 0, sizeof(ModeInfoBlock));
memcpyb(ss, &info, 0xc000, &(cur_info->info), sizeof(ModeInfoBlockCompact));
if (info.WinAAttributes & VBE_WINDOW_ATTRIBUTE_RELOCATABLE) {
info.WinFuncPtr = 0xC0000000UL;
*(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall);
}
result = 0x4f;
}
else
{
#ifdef DEBUG
printf("VBE *NOT* found mode %x\n",CX);
#endif
result = 0x100;
}
if (result == 0x4f)
{
// copy updates in mode_info_block back
memcpyb(ES, DI, ss, &info, sizeof(info));
}
write_word(ss, AX, result);
}
/** Function 02h - Set VBE Mode
*
* Input:
* AX = 4F02h
* BX = Desired Mode to set
* ES:DI = Pointer to CRTCInfoBlock structure
* Output:
* AX = VBE Return Status
*
*/
void vbe_biosfn_set_mode(AX, BX, ES, DI)
Bit16u *AX;Bit16u BX; Bit16u ES;Bit16u DI;
{
Bit16u ss = get_SS();
Bit16u result;
ModeInfoListItem *cur_info;
Boolean using_lfb;
Bit8u no_clear;
Bit8u lfb_flag;
using_lfb=((BX & VBE_MODE_LINEAR_FRAME_BUFFER) == VBE_MODE_LINEAR_FRAME_BUFFER);
lfb_flag=using_lfb?VBE_DISPI_LFB_ENABLED:0;
no_clear=((BX & VBE_MODE_PRESERVE_DISPLAY_MEMORY) == VBE_MODE_PRESERVE_DISPLAY_MEMORY)?VBE_DISPI_NOCLEARMEM:0;
BX = (BX & 0x1ff);
//result=read_word(ss,AX);
// check for non vesa mode
if (BX<VBE_MODE_VESA_DEFINED)
{
Bit8u mode;
dispi_set_enable(VBE_DISPI_DISABLED);
// call the vgabios in order to set the video mode
// this allows for going back to textmode with a VBE call (some applications expect that to work)
mode=(BX & 0xff);
biosfn_set_video_mode(mode);
result = 0x4f;
}
cur_info = mode_info_find_mode(BX, using_lfb, &cur_info);
if (cur_info != 0)
{
#ifdef DEBUG
printf("VBE found mode %x, setting:\n", BX);
printf("\txres%x yres%x bpp%x\n",
cur_info->info.XResolution,
cur_info->info.YResolution,
cur_info->info.BitsPerPixel);
#endif
// first disable current mode (when switching between vesa modi)
dispi_set_enable(VBE_DISPI_DISABLED);
if (cur_info->mode == VBE_VESA_MODE_800X600X4)
{
biosfn_set_video_mode(0x6a);
}
dispi_set_xres(cur_info->info.XResolution);
dispi_set_yres(cur_info->info.YResolution);
dispi_set_bpp(cur_info->info.BitsPerPixel);
dispi_set_bank(0);
dispi_set_enable(VBE_DISPI_ENABLED | no_clear | lfb_flag);
write_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE,BX);
result = 0x4f;
}
else
{
#ifdef DEBUG
printf("VBE *NOT* found mode %x\n" , BX);
#endif
result = 0x100;
// FIXME: redirect non VBE modi to normal VGA bios operation
// (switch back to VGA mode
if (BX == 3)
result = 0x4f;
}
write_word(ss, AX, result);
}
/** Function 03h - Return Current VBE Mode
*
* Input:
* AX = 4F03h
* Output:
* AX = VBE Return Status
* BX = Current VBE Mode
*
*/
void vbe_biosfn_return_current_mode(AX, BX)
Bit16u *AX;Bit16u *BX;
{
Bit16u ss=get_SS();
Bit16u mode;
#ifdef DEBUG
printf("VBE vbe_biosfn_return_current_mode\n");
#endif
if(dispi_get_enable())
{
mode=read_word(BIOSMEM_SEG,BIOSMEM_VBE_MODE);
}
else
{
mode=read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE);
}
write_word(ss, AX, 0x4f);
write_word(ss, BX, mode);
}
/** Function 04h - Save/Restore State
*
* Input:
* AX = 4F04h
* DL = 00h Return Save/Restore State buffer size
* 01h Save State
* 02h Restore State
* CX = Requested states
* ES:BX = Pointer to buffer (if DL <> 00h)
* Output:
* AX = VBE Return Status
* BX = Number of 64-byte blocks to hold the state buffer (if DL=00h)
*
*/
void vbe_biosfn_save_restore_state(AX, DL, CX, ES, BX)
{
}
/** Function 05h - Display Window Control
*
* Input:
* AX = 4F05h
* (16-bit) BH = 00h Set memory window
* = 01h Get memory window
* BL = Window number
* = 00h Window A
* = 01h Window B
* DX = Window number in video memory in window
* granularity units (Set Memory Window only)
* Note:
* If this function is called while in a linear frame buffer mode,
* this function must fail with completion code AH=03h
*
* Output:
* AX = VBE Return Status
* DX = Window number in window granularity units
* (Get Memory Window only)
*/
void vbe_biosfn_display_window_control(AX,BX,DX)
Bit16u *AX;Bit16u BX;Bit16u *DX;
{
Bit16u ss = get_SS();
Bit16u window = read_word(ss, DX);
Bit16u result = 0x014f;
if (BX==0x0000)
{
dispi_set_bank(window);
result = 0x4f;
}
else if (BX==0x0100)
{
window = dispi_get_bank();
write_word(ss, DX, result);
result = 0x4f;
}
write_word(ss, AX, result);
}
/** Function 06h - Set/Get Logical Scan Line Length
*
* Input:
* AX = 4F06h
* BL = 00h Set Scan Line Length in Pixels
* = 01h Get Scan Line Length
* = 02h Set Scan Line Length in Bytes
* = 03h Get Maximum Scan Line Length
* CX = If BL=00h Desired Width in Pixels
* If BL=02h Desired Width in Bytes
* (Ignored for Get Functions)
*
* Output:
* AX = VBE Return Status
* BX = Bytes Per Scan Line
* CX = Actual Pixels Per Scan Line
* (truncated to nearest complete pixel)
* DX = Maximum Number of Scan Lines
*/
void vbe_biosfn_set_get_logical_scan_line_length(AX,BX,CX,DX)
Bit16u *AX;Bit16u *BX;Bit16u *DX;Bit16u *DX;
{
Bit16u ss=get_SS();
Bit16u result=0x100;
Bit16u width = read_word(ss, CX);
Bit16u cmd = read_word(ss, BX);
Bit8u bytespp = dispi_get_bpp()/8;
// check bl
if ( ((cmd & 0xff) == 0x00) || ((cmd & 0xff) == 0x02) )
{
// set scan line lenght in pixels(0x00) or bytes (0x02)
Bit16u new_width;
Bit16u new_height;
if ( ((cmd & 0xff) == 0x02) && (bytespp > 1) )
{
width/=bytespp;
}
dispi_set_virt_width(width);
new_width=dispi_get_virt_width();
new_height=dispi_get_virt_height();
if (new_width!=width)
{
#ifdef DEBUG
printf("* VBE width adjusted\n");
#endif
// notify width adjusted
result=0x024f;
}
else
{
result=0x4f;
}
write_word(ss,BX,new_width*bytespp);
write_word(ss,CX,new_width);
write_word(ss,DX,new_height);
}
write_word(ss, AX, result);
}
/** Function 07h - Set/Get Display Start
*
* Input(16-bit):
* AX = 4F07h
* BH = 00h Reserved and must be 00h
* BL = 00h Set Display Start
* = 01h Get Display Start
* = 02h Schedule Display Start (Alternate)
* = 03h Schedule Stereoscopic Display Start
* = 04h Get Scheduled Display Start Status
* = 05h Enable Stereoscopic Mode
* = 06h Disable Stereoscopic Mode
* = 80h Set Display Start during Vertical Retrace
* = 82h Set Display Start during Vertical Retrace (Alternate)
* = 83h Set Stereoscopic Display Start during Vertical Retrace
* ECX = If BL=02h/82h Display Start Address in bytes
* If BL=03h/83h Left Image Start Address in bytes
* EDX = If BL=03h/83h Right Image Start Address in bytes
* CX = If BL=00h/80h First Displayed Pixel In Scan Line
* DX = If BL=00h/80h First Displayed Scan Line
*
* Output:
* AX = VBE Return Status
* BH = If BL=01h Reserved and will be 0
* CX = If BL=01h First Displayed Pixel In Scan Line
* If BL=04h 0 if flip has not occurred, not 0 if it has
* DX = If BL=01h First Displayed Scan Line
*
* Input(32-bit):
* BH = 00h Reserved and must be 00h
* BL = 00h Set Display Start
* = 80h Set Display Start during Vertical Retrace
* CX = Bits 0-15 of display start address
* DX = Bits 16-31 of display start address
* ES = Selector for memory mapped registers
*/
void vbe_biosfn_set_get_display_start(AX,BX,CX,DX)
Bit16u *AX;Bit16u BX;Bit16u CX;Bit16u DX;
{
Bit16u ss=get_SS();
Bit16u result=0x100;
#ifdef DEBUG
// printf("VBE vbe_biosfn_set_get_display_start\n");
#endif
// check for set display start
if ((GET_BL()==0x00) || (GET_BL()==0x80))
{
// 0x80 is during vertical retrace - is also used by sdd vbetest during multibuffering
#ifdef DEBUG
// printf("VBE vbe_biosfn_set_get_display_start CX%x DX%x\n",CX,DX);
#endif
dispi_set_x_offset(CX);
dispi_set_y_offset(DX);
result = 0x4f;
}
write_word(ss, AX, result);
}
/** Function 08h - Set/Get Dac Palette Format
*
* Input:
* AX = 4F08h
* Output:
* AX = VBE Return Status
*
* FIXME: incomplete API description, Input & Output
*/
void vbe_biosfn_set_get_dac_palette_format(AX)
{
}
/** Function 09h - Set/Get Palette Data
*
* Input:
* AX = 4F09h
* Output:
* AX = VBE Return Status
*
* FIXME: incomplete API description, Input & Output
*/
void vbe_biosfn_set_get_palette_data(AX)
{
}
/** Function 0Ah - Return VBE Protected Mode Interface
*
* Input:
* AX = 4F0Ah
* Output:
* AX = VBE Return Status
*
* FIXME: incomplete API description, Input & Output
*/
void vbe_biosfn_return_protected_mode_interface(AX)
{
}
|