]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/MAI/bios_emulator/scitech/src/pm/stub/pm.c
* Patch by Thomas Frieden, 13 Nov 2002:
[karo-tx-uboot.git] / board / MAI / bios_emulator / scitech / src / pm / stub / pm.c
1 /****************************************************************************
2 *
3 *                   SciTech OS Portability Manager Library
4 *
5 *  ========================================================================
6 *
7 *    The contents of this file are subject to the SciTech MGL Public
8 *    License Version 1.0 (the "License"); you may not use this file
9 *    except in compliance with the License. You may obtain a copy of
10 *    the License at http://www.scitechsoft.com/mgl-license.txt
11 *
12 *    Software distributed under the License is distributed on an
13 *    "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
14 *    implied. See the License for the specific language governing
15 *    rights and limitations under the License.
16 *
17 *    The Original Code is Copyright (C) 1991-1998 SciTech Software, Inc.
18 *
19 *    The Initial Developer of the Original Code is SciTech Software, Inc.
20 *    All Rights Reserved.
21 *
22 *  ========================================================================
23 *
24 * Language:     ANSI C
25 * Environment:  *** TODO: ADD YOUR OS ENVIRONMENT NAME HERE ***
26 *
27 * Description:  Implementation for the OS Portability Manager Library, which
28 *               contains functions to implement OS specific services in a
29 *               generic, cross platform API. Porting the OS Portability
30 *               Manager library is the first step to porting any SciTech
31 *               products to a new platform.
32 *
33 ****************************************************************************/
34
35 #include "pmapi.h"
36 #include "drvlib/os/os.h"
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include <string.h>
40
41 // TODO: Include any OS specific headers here!
42
43 /*--------------------------- Global variables ----------------------------*/
44
45 // TODO: If you support access to the BIOS, the following VESABuf globals
46 //       keep track of a single VESA transfer buffer. If you don't support
47 //       access to the BIOS, remove these variables.
48
49 static uint VESABuf_len = 1024;     /* Length of the VESABuf buffer     */
50 static void *VESABuf_ptr = NULL;    /* Near pointer to VESABuf          */
51 static uint VESABuf_rseg;           /* Real mode segment of VESABuf     */
52 static uint VESABuf_roff;           /* Real mode offset of VESABuf      */
53
54 static void (PMAPIP fatalErrorCleanup)(void) = NULL;
55
56 /*----------------------------- Implementation ----------------------------*/
57
58 /****************************************************************************
59 REMARKS:
60 Initialise the PM library.
61 ****************************************************************************/
62 void PMAPI PM_init(void)
63 {
64     // TODO: Do any initialisation in here. This includes getting IOPL
65     //       access for the process calling PM_init. This will get called
66     //       more than once.
67
68     // TODO: If you support the supplied MTRR register stuff (you need to
69     //       be at ring 0 for this!), you should initialise it in here.
70
71 /* MTRR_init(); */
72 }
73
74 /****************************************************************************
75 REMARKS:
76 Return the operating system type identifier.
77 ****************************************************************************/
78 long PMAPI PM_getOSType(void)
79 {
80     // TODO: Change this to return the define for your OS from drvlib/os.h
81     return _OS_MYOS;
82 }
83
84 /****************************************************************************
85 REMARKS:
86 Return the runtime type identifier (always PM_386 for protected mode)
87 ****************************************************************************/
88 int PMAPI PM_getModeType(void)
89 { return PM_386; }
90
91 /****************************************************************************
92 REMARKS:
93 Add a file directory separator to the end of the filename.
94 ****************************************************************************/
95 void PMAPI PM_backslash(
96     char *s)
97 {
98     uint pos = strlen(s);
99     if (s[pos-1] != '/') {
100         s[pos] = '/';
101         s[pos+1] = '\0';
102         }
103 }
104
105 /****************************************************************************
106 REMARKS:
107 Add a user defined PM_fatalError cleanup function.
108 ****************************************************************************/
109 void PMAPI PM_setFatalErrorCleanup(
110     void (PMAPIP cleanup)(void))
111 {
112     fatalErrorCleanup = cleanup;
113 }
114
115 /****************************************************************************
116 REMARKS:
117 Report a fatal error condition and halt the program.
118 ****************************************************************************/
119 void PMAPI PM_fatalError(
120     const char *msg)
121 {
122     // TODO: If you are running in a GUI environment without a console,
123     //       this needs to be changed to bring up a fatal error message
124     //       box and terminate the program.
125     if (fatalErrorCleanup)
126         fatalErrorCleanup();
127     fprintf(stderr,"%s\n", msg);
128     exit(1);
129 }
130
131 /****************************************************************************
132 REMARKS:
133 Exit handler to kill the VESA transfer buffer.
134 ****************************************************************************/
135 static void ExitVBEBuf(void)
136 {
137     // TODO: If you do not have BIOS access, remove this function.
138     if (VESABuf_ptr)
139         PM_freeRealSeg(VESABuf_ptr);
140     VESABuf_ptr = 0;
141 }
142
143 /****************************************************************************
144 REMARKS:
145 Allocate the real mode VESA transfer buffer for communicating with the BIOS.
146 ****************************************************************************/
147 void * PMAPI PM_getVESABuf(
148     uint *len,
149     uint *rseg,
150     uint *roff)
151 {
152     // TODO: If you do not have BIOS access, simply delete the guts of
153     //       this function and return NULL.
154     if (!VESABuf_ptr) {
155         /* Allocate a global buffer for communicating with the VESA VBE */
156         if ((VESABuf_ptr = PM_allocRealSeg(VESABuf_len, &VESABuf_rseg, &VESABuf_roff)) == NULL)
157             return NULL;
158         atexit(ExitVBEBuf);
159         }
160     *len = VESABuf_len;
161     *rseg = VESABuf_rseg;
162     *roff = VESABuf_roff;
163     return VESABuf_ptr;
164 }
165
166 /****************************************************************************
167 REMARKS:
168 Check if a key has been pressed.
169 ****************************************************************************/
170 int PMAPI PM_kbhit(void)
171 {
172     // TODO: This function checks if a key is available to be read. This
173     //       should be implemented, but is mostly used by the test programs
174     //       these days.
175     return true;
176 }
177
178 /****************************************************************************
179 REMARKS:
180 Wait for and return the next keypress.
181 ****************************************************************************/
182 int PMAPI PM_getch(void)
183 {
184     // TODO: This returns the ASCII code of the key pressed. This
185     //       should be implemented, but is mostly used by the test programs
186     //       these days.
187     return 0xD;
188 }
189
190 /****************************************************************************
191 REMARKS:
192 Open a fullscreen console mode for output.
193 ****************************************************************************/
194 int PMAPI PM_openConsole(void)
195 {
196     // TODO: Opens up a fullscreen console for graphics output. If your
197     //       console does not have graphics/text modes, this can be left
198     //       empty. The main purpose of this is to disable console switching
199     //       when in graphics modes if you can switch away from fullscreen
200     //       consoles (if you want to allow switching, this can be done
201     //       elsewhere with a full save/restore state of the graphics mode).
202     return 0;
203 }
204
205 /****************************************************************************
206 REMARKS:
207 Return the size of the state buffer used to save the console state.
208 ****************************************************************************/
209 int PMAPI PM_getConsoleStateSize(void)
210 {
211     // TODO: Returns the size of the console state buffer used to save the
212     //       state of the console before going into graphics mode. This is
213     //       used to restore the console back to normal when we are done.
214     return 1;
215 }
216
217 /****************************************************************************
218 REMARKS:
219 Save the state of the console into the state buffer.
220 ****************************************************************************/
221 void PMAPI PM_saveConsoleState(
222     void *stateBuf,
223     int console_id)
224 {
225     // TODO: Saves the state of the console into the state buffer. This is
226     //       used to restore the console back to normal when we are done.
227     //       We will always restore 80x25 text mode after being in graphics
228     //       mode, so if restoring text mode is all you need to do this can
229     //       be left empty.
230 }
231
232 /****************************************************************************
233 REMARKS:
234 Restore the state of the console from the state buffer.
235 ****************************************************************************/
236 void PMAPI PM_restoreConsoleState(
237     const void *stateBuf,
238     int console_id)
239 {
240     // TODO: Restore the state of the console from the state buffer. This is
241     //       used to restore the console back to normal when we are done.
242     //       We will always restore 80x25 text mode after being in graphics
243     //       mode, so if restoring text mode is all you need to do this can
244     //       be left empty.
245 }
246
247 /****************************************************************************
248 REMARKS:
249 Close the console and return to non-fullscreen console mode.
250 ****************************************************************************/
251 void PMAPI PM_closeConsole(
252     int console_id)
253 {
254     // TODO: Close the console when we are done, going back to text mode.
255 }
256
257 /****************************************************************************
258 REMARKS:
259 Set the location of the OS console cursor.
260 ****************************************************************************/
261 void PM_setOSCursorLocation(
262     int x,
263     int y)
264 {
265     // TODO: Set the OS console cursor location to the new value. This is
266     //       generally used for new OS ports (used mostly for DOS).
267 }
268
269 /****************************************************************************
270 REMARKS:
271 Set the width of the OS console.
272 ****************************************************************************/
273 void PM_setOSScreenWidth(
274     int width,
275     int height)
276 {
277     // TODO: Set the OS console screen width. This is generally unused for
278     //       new OS ports.
279 }
280
281 /****************************************************************************
282 REMARKS:
283 Set the real time clock handler (used for software stereo modes).
284 ****************************************************************************/
285 ibool PMAPI PM_setRealTimeClockHandler(
286     PM_intHandler ih,
287     int frequency)
288 {
289     // TODO: Install a real time clock interrupt handler. Normally this
290     //       will not be supported from most OS'es in user land, so an
291     //       alternative mechanism is needed to enable software stereo.
292     //       Hence leave this unimplemented unless you have a high priority
293     //       mechanism to call the 32-bit callback when the real time clock
294     //       interrupt fires.
295     return false;
296 }
297
298 /****************************************************************************
299 REMARKS:
300 Set the real time clock frequency (for stereo modes).
301 ****************************************************************************/
302 void PMAPI PM_setRealTimeClockFrequency(
303     int frequency)
304 {
305     // TODO: Set the real time clock interrupt frequency. Used for stereo
306     //       LC shutter glasses when doing software stereo. Usually sets
307     //       the frequency to around 2048 Hz.
308 }
309
310 /****************************************************************************
311 REMARKS:
312 Restore the original real time clock handler.
313 ****************************************************************************/
314 void PMAPI PM_restoreRealTimeClockHandler(void)
315 {
316     // TODO: Restores the real time clock handler.
317 }
318
319 /****************************************************************************
320 REMARKS:
321 Return the current operating system path or working directory.
322 ****************************************************************************/
323 char * PMAPI PM_getCurrentPath(
324     char *path,
325     int maxLen)
326 {
327     return getcwd(path,maxLen);
328 }
329
330 /****************************************************************************
331 REMARKS:
332 Return the drive letter for the boot drive.
333 ****************************************************************************/
334 char PMAPI PM_getBootDrive(void)
335 {
336     // TODO: Return the boot drive letter for the OS. Normally this is 'c'
337     //       for DOS based OS'es and '/' for Unices.
338     return '/';
339 }
340
341 /****************************************************************************
342 REMARKS:
343 Return the path to the VBE/AF driver files (legacy and not used).
344 ****************************************************************************/
345 const char * PMAPI PM_getVBEAFPath(void)
346 {
347     return PM_getNucleusConfigPath();
348 }
349
350 /****************************************************************************
351 REMARKS:
352 Return the path to the Nucleus driver files.
353 ****************************************************************************/
354 const char * PMAPI PM_getNucleusPath(void)
355 {
356     // TODO: Change this to the default path to Nucleus driver files. The
357     //       following is the default for Unices.
358     char *env = getenv("NUCLEUS_PATH");
359     return env ? env : "/usr/lib/nucleus";
360 }
361
362 /****************************************************************************
363 REMARKS:
364 Return the path to the Nucleus configuration files.
365 ****************************************************************************/
366 const char * PMAPI PM_getNucleusConfigPath(void)
367 {
368     static char path[256];
369     strcpy(path,PM_getNucleusPath());
370     PM_backslash(path);
371     strcat(path,"config");
372     return path;
373 }
374
375 /****************************************************************************
376 REMARKS:
377 Return a unique identifier for the machine if possible.
378 ****************************************************************************/
379 const char * PMAPI PM_getUniqueID(void)
380 {
381     // TODO: Return a unique ID for the machine. If a unique ID is not
382     //       available, return the machine name.
383     static char buf[128];
384     gethostname(buf, 128);
385     return buf;
386 }
387
388 /****************************************************************************
389 REMARKS:
390 Get the name of the machine on the network.
391 ****************************************************************************/
392 const char * PMAPI PM_getMachineName(void)
393 {
394     // TODO: Return the network machine name for the machine.
395     static char buf[128];
396     gethostname(buf, 128);
397     return buf;
398 }
399
400 /****************************************************************************
401 REMARKS:
402 Return a pointer to the real mode BIOS data area.
403 ****************************************************************************/
404 void * PMAPI PM_getBIOSPointer(void)
405 {
406     // TODO: This returns a pointer to the real mode BIOS data area. If you
407     //       do not support BIOS access, you can simply return NULL here.
408     if (!zeroPtr)
409         zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF,true);
410     return (void*)(zeroPtr + 0x400);
411 }
412
413 /****************************************************************************
414 REMARKS:
415 Return a pointer to 0xA0000 physical VGA graphics framebuffer.
416 ****************************************************************************/
417 void * PMAPI PM_getA0000Pointer(void)
418 {
419     static void *bankPtr;
420     if (!bankPtr)
421         bankPtr = PM_mapPhysicalAddr(0xA0000,0xFFFF,true);
422     return bankPtr;
423 }
424
425 /****************************************************************************
426 REMARKS:
427 Map a physical address to a linear address in the callers process.
428 ****************************************************************************/
429 void * PMAPI PM_mapPhysicalAddr(
430     ulong base,
431     ulong limit,
432     ibool isCached)
433 {
434     // TODO: This function maps a physical memory address to a linear
435     //       address in the address space of the calling process.
436
437     // NOTE: This function *must* be able to handle any phsyical base
438     //       address, and hence you will have to handle rounding of
439     //       the physical base address to a page boundary (ie: 4Kb on
440     //       x86 CPU's) to be able to properly map in the memory
441     //       region.
442
443     // NOTE: If possible the isCached bit should be used to ensure that
444     //       the PCD (Page Cache Disable) and PWT (Page Write Through)
445     //       bits are set to disable caching for a memory mapping used
446     //       for MMIO register access. We also disable caching using
447     //       the MTRR registers for Pentium Pro and later chipsets so if
448     //       MTRR support is enabled for your OS then you can safely ignore
449     //       the isCached flag and always enable caching in the page
450     //       tables.
451     return NULL;
452 }
453
454 /****************************************************************************
455 REMARKS:
456 Free a physical address mapping allocated by PM_mapPhysicalAddr.
457 ****************************************************************************/
458 void PMAPI PM_freePhysicalAddr(
459     void *ptr,
460     ulong limit)
461 {
462     // TODO: This function will free a physical memory mapping previously
463     //       allocated with PM_mapPhysicalAddr() if at all possible. If
464     //       you can't free physical memory mappings, simply do nothing.
465 }
466
467 /****************************************************************************
468 REMARKS:
469 Find the physical address of a linear memory address in current process.
470 ****************************************************************************/
471 ulong PMAPI PM_getPhysicalAddr(void *p)
472 {
473     // TODO: This function should find the physical address of a linear
474     //       address.
475     return 0xFFFFFFFFUL;
476 }
477
478 void PMAPI PM_sleep(ulong milliseconds)
479 {
480     // TODO: Put the process to sleep for milliseconds
481 }
482
483 int PMAPI PM_getCOMPort(int port)
484 {
485     // TODO: Re-code this to determine real values using the Plug and Play
486     //       manager for the OS.
487     switch (port) {
488         case 0: return 0x3F8;
489         case 1: return 0x2F8;
490         }
491     return 0;
492 }
493
494 int PMAPI PM_getLPTPort(int port)
495 {
496     // TODO: Re-code this to determine real values using the Plug and Play
497     //       manager for the OS.
498     switch (port) {
499         case 0: return 0x3BC;
500         case 1: return 0x378;
501         case 2: return 0x278;
502         }
503     return 0;
504 }
505
506 /****************************************************************************
507 REMARKS:
508 Allocate a block of (unnamed) shared memory.
509 ****************************************************************************/
510 void * PMAPI PM_mallocShared(
511     long size)
512 {
513     // TODO: This is used to allocate memory that is shared between process
514     //       that all access the common Nucleus drivers via a common display
515     //       driver DLL. If your OS does not support shared memory (or if
516     //       the display driver does not need to allocate shared memory
517     //       for each process address space), this should just call PM_malloc.
518     return PM_malloc(size);
519 }
520
521 /****************************************************************************
522 REMARKS:
523 Free a block of shared memory.
524 ****************************************************************************/
525 void PMAPI PM_freeShared(
526     void *ptr)
527 {
528     // TODO: Free the shared memory block. This will be called in the context
529     //       of the original calling process that allocated the shared
530     //       memory with PM_mallocShared. Simply call PM_free if you do not
531     //       need this.
532     PM_free(ptr);
533 }
534
535 /****************************************************************************
536 REMARKS:
537 Map a linear memory address to the calling process address space. The
538 address will have been allocated in another process using the
539 PM_mapPhysicalAddr function.
540 ****************************************************************************/
541 void * PMAPI PM_mapToProcess(
542     void *base,
543     ulong limit)
544 {
545     // TODO: This function is used to map a physical memory mapping
546     //       previously allocated with PM_mapPhysicalAddr into the
547     //       address space of the calling process. If the memory mapping
548     //       allocated by PM_mapPhysicalAddr is global to all processes,
549     //       simply return the pointer.
550
551     // NOTE: This function must also handle rounding to page boundaries,
552     //       since this function is used to map in shared memory buffers
553     //       allocated with PM_mapPhysicalAddr(). Hence if you aligned
554     //       the physical address above, then you also need to do it here.
555     return base;
556 }
557
558 /****************************************************************************
559 REMARKS:
560 Map a real mode pointer to a protected mode pointer.
561 ****************************************************************************/
562 void * PMAPI PM_mapRealPointer(
563     uint r_seg,
564     uint r_off)
565 {
566     // TODO: This function maps a real mode memory pointer into the
567     //       calling processes address space as a 32-bit near pointer. If
568     //       you do not support BIOS access, simply return NULL here.
569     if (!zeroPtr)
570         zeroPtr = PM_mapPhysicalAddr(0,0xFFFFF);
571     return (void*)(zeroPtr + MK_PHYS(r_seg,r_off));
572 }
573
574 /****************************************************************************
575 REMARKS:
576 Allocate a block of real mode memory
577 ****************************************************************************/
578 void * PMAPI PM_allocRealSeg(
579     uint size,
580     uint *r_seg,
581     uint *r_off)
582 {
583     // TODO: This function allocates a block of real mode memory for the
584     //       calling process used to communicate with real mode BIOS
585     //       functions. If you do not support BIOS access, simply return
586     //       NULL here.
587     return NULL;
588 }
589
590 /****************************************************************************
591 REMARKS:
592 Free a block of real mode memory.
593 ****************************************************************************/
594 void PMAPI PM_freeRealSeg(
595     void *mem)
596 {
597     // TODO: Frees a previously allocated real mode memory block. If you
598     //       do not support BIOS access, this function should be empty.
599 }
600
601 /****************************************************************************
602 REMARKS:
603 Issue a real mode interrupt (parameters in DPMI compatible structure)
604 ****************************************************************************/
605 void PMAPI DPMI_int86(
606     int intno,
607     DPMI_regs *regs)
608 {
609     // TODO: This function calls the real mode BIOS using the passed in
610     //       register structure. If you do not support real mode BIOS
611     //       access, this function should be empty.
612 }
613
614 /****************************************************************************
615 REMARKS:
616 Issue a real mode interrupt.
617 ****************************************************************************/
618 int PMAPI PM_int86(
619     int intno,
620     RMREGS *in,
621     RMREGS *out)
622 {
623     // TODO: This function calls the real mode BIOS using the passed in
624     //       register structure. If you do not support real mode BIOS
625     //       access, this function should return 0.
626     return 0;
627 }
628
629 /****************************************************************************
630 REMARKS:
631 Issue a real mode interrupt.
632 ****************************************************************************/
633 int PMAPI PM_int86x(
634     int intno,
635     RMREGS *in,
636     RMREGS *out,
637     RMSREGS *sregs)
638 {
639     // TODO: This function calls the real mode BIOS using the passed in
640     //       register structure. If you do not support real mode BIOS
641     //       access, this function should return 0.
642     return 0;
643 }
644
645 /****************************************************************************
646 REMARKS:
647 Call a real mode far function.
648 ****************************************************************************/
649 void PMAPI PM_callRealMode(
650     uint seg,
651     uint off,
652     RMREGS *in,
653     RMSREGS *sregs)
654 {
655     // TODO: This function calls a real mode far function with a far call.
656     //       If you do not support BIOS access, this function should be
657     //       empty.
658 }
659
660 /****************************************************************************
661 REMARKS:
662 Return the amount of available memory.
663 ****************************************************************************/
664 void PMAPI PM_availableMemory(
665     ulong *physical,
666     ulong *total)
667 {
668     // TODO: Report the amount of available memory, both the amount of
669     //       physical memory left and the amount of virtual memory left.
670     //       If the OS does not provide these services, report 0's.
671     *physical = *total = 0;
672 }
673
674 /****************************************************************************
675 REMARKS:
676 Allocate a block of locked, physical memory for DMA operations.
677 ****************************************************************************/
678 void * PMAPI PM_allocLockedMem(
679     uint size,
680     ulong *physAddr,
681     ibool contiguous,
682     ibool below16M)
683 {
684     // TODO: Allocate a block of locked, physical memory of the specified
685     //       size. This is used for bus master operations. If this is not
686     //       supported by the OS, return NULL and bus mastering will not
687     //       be used.
688     return NULL;
689 }
690
691 /****************************************************************************
692 REMARKS:
693 Free a block of locked physical memory.
694 ****************************************************************************/
695 void PMAPI PM_freeLockedMem(
696     void *p,
697     uint size,
698     ibool contiguous)
699 {
700     // TODO: Free a memory block allocated with PM_allocLockedMem.
701 }
702
703 /****************************************************************************
704 REMARKS:
705 Call the VBE/Core software interrupt to change display banks.
706 ****************************************************************************/
707 void PMAPI PM_setBankA(
708     int bank)
709 {
710     RMREGS  regs;
711
712     // TODO: This does a bank switch function by calling the real mode
713     //       VESA BIOS. If you do not support BIOS access, this function should
714     //       be empty.
715     regs.x.ax = 0x4F05;
716     regs.x.bx = 0x0000;
717     regs.x.dx = bank;
718     PM_int86(0x10,&regs,&regs);
719 }
720
721 /****************************************************************************
722 REMARKS:
723 Call the VBE/Core software interrupt to change display banks.
724 ****************************************************************************/
725 void PMAPI PM_setBankAB(
726     int bank)
727 {
728     RMREGS  regs;
729
730     // TODO: This does a bank switch function by calling the real mode
731     //       VESA BIOS. If you do not support BIOS access, this function should
732     //       be empty.
733     regs.x.ax = 0x4F05;
734     regs.x.bx = 0x0000;
735     regs.x.dx = bank;
736     PM_int86(0x10,&regs,&regs);
737     regs.x.ax = 0x4F05;
738     regs.x.bx = 0x0001;
739     regs.x.dx = bank;
740     PM_int86(0x10,&regs,&regs);
741 }
742
743 /****************************************************************************
744 REMARKS:
745 Call the VBE/Core software interrupt to change display start address.
746 ****************************************************************************/
747 void PMAPI PM_setCRTStart(
748     int x,
749     int y,
750     int waitVRT)
751 {
752     RMREGS  regs;
753
754     // TODO: This changes the display start address by calling the real mode
755     //       VESA BIOS. If you do not support BIOS access, this function
756     //       should be empty.
757     regs.x.ax = 0x4F07;
758     regs.x.bx = waitVRT;
759     regs.x.cx = x;
760     regs.x.dx = y;
761     PM_int86(0x10,&regs,&regs);
762 }
763
764 /****************************************************************************
765 REMARKS:
766 Enable write combining for the memory region.
767 ****************************************************************************/
768 ibool PMAPI PM_enableWriteCombine(
769     ulong base,
770     ulong length,
771     uint type)
772 {
773     // TODO: This function should enable Pentium Pro and Pentium II MTRR
774     //       write combining for the passed in physical memory base address
775     //       and length. Normally this is done via calls to an OS specific
776     //       device driver as this can only be done at ring 0.
777     //
778     // NOTE: This is a *very* important function to implement! If you do
779     //       not implement, graphics performance on the latest Intel chips
780     //       will be severly impaired. For sample code that can be used
781     //       directly in a ring 0 device driver, see the MSDOS implementation
782     //       which includes assembler code to do this directly (if the
783     //       program is running at ring 0).
784     return false;
785 }
786
787 /****************************************************************************
788 REMARKS:
789 Execute the POST on the secondary BIOS for a controller.
790 ****************************************************************************/
791 ibool PMAPI PM_doBIOSPOST(
792     ushort axVal,
793     ulong BIOSPhysAddr,
794     void *mappedBIOS)
795 {
796     // TODO: This function is used to run the BIOS POST code on a secondary
797     //       controller to initialise it for use. This is not necessary
798     //       for multi-controller operation, but it will make it a lot
799     //       more convenicent for end users (otherwise they have to boot
800     //       the system once with the secondary controller as primary, and
801     //       then boot with both controllers installed).
802     //
803     //       Even if you don't support full BIOS access, it would be
804     //       adviseable to be able to POST the secondary controllers in the
805     //       system using this function as a minimum requirement. Some
806     //       graphics hardware has registers that contain values that only
807     //       the BIOS knows about, which makes bring up a card from cold
808     //       reset difficult if the BIOS has not POST'ed it.
809     return false;
810 }
811
812 /****************************************************************************
813 REMARKS:
814 Load an OS specific shared library or DLL. If the OS does not support
815 shared libraries, simply return NULL.
816 ****************************************************************************/
817 PM_MODULE PMAPI PM_loadLibrary(
818     const char *szDLLName)
819 {
820     // TODO: This function should load a native shared library from disk
821     //       given the path to the library.
822     (void)szDLLName;
823     return NULL;
824 }
825
826 /****************************************************************************
827 REMARKS:
828 Get the address of a named procedure from a shared library.
829 ****************************************************************************/
830 void * PMAPI PM_getProcAddress(
831     PM_MODULE hModule,
832     const char *szProcName)
833 {
834     // TODO: This function should return the address of a named procedure
835     //       from a native shared library.
836     (void)hModule;
837     (void)szProcName;
838     return NULL;
839 }
840
841 /****************************************************************************
842 REMARKS:
843 Unload a shared library.
844 ****************************************************************************/
845 void PMAPI PM_freeLibrary(
846     PM_MODULE hModule)
847 {
848     // TODO: This function free a previously loaded native shared library.
849     (void)hModule;
850 }
851
852 /****************************************************************************
853 REMARKS:
854 Enable requested I/O privledge level (usually only to set to a value of
855 3, and then restore it back again). If the OS is protected this function
856 must be implemented in order to enable I/O port access for ring 3
857 applications. The function should return the IOPL level active before
858 the switch occurred so it can be properly restored.
859 ****************************************************************************/
860 int PMAPI PM_setIOPL(
861     int level)
862 {
863     // TODO: This function should enable IOPL for the task (if IOPL is
864     //       not always enabled for the app through some other means).
865     return level;
866 }
867
868 /****************************************************************************
869 REMARKS:
870 Function to find the first file matching a search criteria in a directory.
871 ****************************************************************************/
872 void *PMAPI PM_findFirstFile(
873     const char *filename,
874     PM_findData *findData)
875 {
876     // TODO: This function should start a directory enumeration search
877     //       given the filename (with wildcards). The data should be
878     //       converted and returned in the findData standard form.
879     (void)filename;
880     (void)findData;
881     return PM_FILE_INVALID;
882 }
883
884 /****************************************************************************
885 REMARKS:
886 Function to find the next file matching a search criteria in a directory.
887 ****************************************************************************/
888 ibool PMAPI PM_findNextFile(
889     void *handle,
890     PM_findData *findData)
891 {
892     // TODO: This function should find the next file in directory enumeration
893     //       search given the search criteria defined in the call to
894     //       PM_findFirstFile. The data should be converted and returned
895     //       in the findData standard form.
896     (void)handle;
897     (void)findData;
898     return false;
899 }
900
901 /****************************************************************************
902 REMARKS:
903 Function to close the find process
904 ****************************************************************************/
905 void PMAPI PM_findClose(
906     void *handle)
907 {
908     // TODO: This function should close the find process. This may do
909     //       nothing for some OS'es.
910     (void)handle;
911 }
912
913 /****************************************************************************
914 REMARKS:
915 Function to determine if a drive is a valid drive or not. Under Unix this
916 function will return false for anything except a value of 3 (considered
917 the root drive, and equivalent to C: for non-Unix systems). The drive
918 numbering is:
919
920     1   - Drive A:
921     2   - Drive B:
922     3   - Drive C:
923     etc
924
925 ****************************************************************************/
926 ibool PMAPI PM_driveValid(
927     char drive)
928 {
929     if (drive == 3)
930         return true;
931     return false;
932 }
933
934 /****************************************************************************
935 REMARKS:
936 Function to get the current working directory for the specififed drive.
937 Under Unix this will always return the current working directory regardless
938 of what the value of 'drive' is.
939 ****************************************************************************/
940 void PMAPI PM_getdcwd(
941     int drive,
942     char *dir,
943     int len)
944 {
945     (void)drive;
946     getcwd(dir,len);
947 }
948
949 /****************************************************************************
950 REMARKS:
951 Function to change the file attributes for a specific file.
952 ****************************************************************************/
953 void PMAPI PM_setFileAttr(
954     const char *filename,
955     uint attrib)
956 {
957     // TODO: Set the file attributes for a file
958     (void)filename;
959     (void)attrib;
960 }
961
962 /****************************************************************************
963 REMARKS:
964 Function to create a directory.
965 ****************************************************************************/
966 ibool PMAPI PM_mkdir(
967     const char *filename)
968 {
969     return mkdir(filename) == 0;
970 }
971
972 /****************************************************************************
973 REMARKS:
974 Function to remove a directory.
975 ****************************************************************************/
976 ibool PMAPI PM_rmdir(
977     const char *filename)
978 {
979     return rmdir(filename) == 0;
980 }