main.c

00001 /*
00002  * Copyright (c) 2006 Ondrej Palkovsky
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  * - Redistributions of source code must retain the above copyright
00010  *   notice, this list of conditions and the following disclaimer.
00011  * - Redistributions in binary form must reproduce the above copyright
00012  *   notice, this list of conditions and the following disclaimer in the
00013  *   documentation and/or other materials provided with the distribution.
00014  * - The name of the author may not be used to endorse or promote products
00015  *   derived from this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00019  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
00022  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00023  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00024  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00025  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00026  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  */
00028 
00029 #include <ipc/services.h>
00030 #include <ipc/ns.h>
00031 #include <sysinfo.h>
00032 #include <async.h>
00033 #include <as.h>
00034 #include <align.h>
00035 #include <errno.h>
00036 #include <stdio.h>
00037 
00038 #include "fb.h"
00039 #include "ega.h"
00040 #include "msim.h"
00041 #include "ski.h"
00042 #include "sgcn.h"
00043 #include "niagara.h"
00044 #include "main.h"
00045 
00046 #define NAME "fb"
00047 
00048 void receive_comm_area(ipc_callid_t callid, ipc_call_t *call, void **area)
00049 {
00050         void *dest;
00051         
00052         dest = as_get_mappable_page(IPC_GET_ARG2(*call));
00053         if (async_answer_1(callid, EOK, (sysarg_t) dest) == 0) {
00054                 if (*area)
00055                         as_area_destroy(*area);
00056                 *area = dest;
00057         }
00058 }
00059 
00060 int main(int argc, char *argv[])
00061 {
00062         printf("%s: HelenOS Framebuffer service\n", NAME);
00063         
00064         bool initialized = false;
00065         sysarg_t fb_present;
00066         sysarg_t fb_kind;
00067         
00068         if (sysinfo_get_value("fb", &fb_present) != EOK)
00069                 fb_present = false;
00070         
00071         if (sysinfo_get_value("fb.kind", &fb_kind) != EOK) {
00072                 printf("%s: Unable to detect framebuffer configuration\n", NAME);
00073                 return -1;
00074         }
00075         
00076 #ifdef FB_ENABLED
00077         if ((!initialized) && (fb_kind == 1)) {
00078                 if (fb_init() == 0)
00079                         initialized = true;
00080         }
00081 #endif
00082 #ifdef EGA_ENABLED
00083         if ((!initialized) && (fb_kind == 2)) {
00084                 if (ega_init() == 0)
00085                         initialized = true;
00086         }
00087 #endif
00088 #ifdef MSIM_ENABLED
00089         if ((!initialized) && (fb_kind == 3)) {
00090                 if (msim_init() == 0)
00091                         initialized = true;
00092         }
00093 #endif
00094 #ifdef SGCN_ENABLED
00095         if ((!initialized) && (fb_kind == 4)) {
00096                 if (sgcn_init() == 0)
00097                         initialized = true;
00098         }
00099 #endif
00100 #ifdef NIAGARA_ENABLED
00101         if ((!initialized) && (fb_kind == 5)) {
00102                 if (niagara_init() == 0)
00103                         initialized = true;
00104         }
00105 #endif
00106 #ifdef SKI_ENABLED
00107         if ((!initialized) && (fb_kind == 6)) {
00108                 if (ski_init() == 0)
00109                         initialized = true;
00110         }
00111 #endif
00112 
00113         if (!initialized)
00114                 return -1;
00115         
00116         if (service_register(SERVICE_VIDEO) != EOK)
00117                 return -1;
00118         
00119         printf("%s: Accepting connections\n", NAME);
00120         async_manager();
00121         
00122         /* Never reached */
00123         return 0;
00124 }

Generated on Thu Jun 2 07:45:41 2011 for HelenOS/USB by  doxygen 1.4.7