Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/serial/mcs9922.c need to be fixed.

0001 /*                    The Quest Operating System
0002  *  Copyright (C) 2005-2010  Richard West, Boston University
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008  *
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013  *
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 /* MosChip 9922 PCIE - To - Serial Card Driver */
0019 
0020 #include "drivers/pci/pci.h"
0021 #include "arch/i386.h"
0022 #include "arch/i386-percpu.h"
0023 #include "util/printf.h"
0024 #include "mem/physical.h"
0025 #include "mem/virtual.h"
0026 #include "kernel.h"
0027 
0028 #define MCS9922_VID    0x9710
0029 #define MCS9922_DID    0x9922
0030 
0031 #define DEBUG_MCS9922
0032 
0033 #ifdef DEBUG_MCS9922
0034 #define DLOG(fmt,...) DLOG_PREFIX("MCS9922",fmt,##__VA_ARGS__)
0035 #else
0036 #define DLOG(fmt,...) ;
0037 #endif
0038 
0039 uint16 serial_port1 = 0x03F8;    /* Default COM1 */
0040 //uint16 serial_port1 = 0xDE00;    /* Default COM1 */
0041 
0042 extern void initialize_serial_port (void);
0043 
0044 bool
0045 mcs9922_init (void)
0046 {
0047   uint device_index, port_num;
0048 
0049   if (!pci_find_device (MCS9922_VID, MCS9922_DID, 0xFF, 0xFF, 0, &device_index)) {
0050     return FALSE;
0051   }
0052 
0053   if (device_index == (uint)(~0)) {
0054     DLOG ("Unable to detect compatible device.");
0055     return FALSE;
0056   }
0057 
0058   if (pci_decode_bar (device_index, 0, NULL, &port_num, NULL)) {
0059     serial_port1 = port_num;
0060     DLOG ("Found Port Number: 0x%X", serial_port1);
0061     initialize_serial_port ();
0062     return TRUE;
0063   } else {
0064     DLOG ("Bar decoding failed!");
0065     return FALSE;
0066   }
0067 }
0068 
0069 #include "module/header.h"
0070 
0071 static const struct module_ops mod_ops = {
0072   .init = mcs9922_init
0073 };
0074 
0075 DEF_MODULE (serial___mcs9922, "MosChip 9922 PCI-E serial card driver", &mod_ops, {"pci"});
0076 
0077 /*
0078  * Local Variables:
0079  * indent-tabs-mode: nil
0080  * mode: C
0081  * c-file-style: "gnu"
0082  * c-basic-offset: 2
0083  * End:
0084  */
0085 
0086 /* vi: set et sw=2 sts=2: */