📄 rocket.c
字号:
max_num_aiops = 1; break; case PCI_DEVICE_ID_RP8J: str = "8J"; max_num_aiops = 1; break; case PCI_DEVICE_ID_RP16INTF: str = "16"; max_num_aiops = 2; break; case PCI_DEVICE_ID_RP32INTF: str = "32"; max_num_aiops = 4; break; case PCI_DEVICE_ID_RPP4: str = "Plus Quadcable"; max_num_aiops = 1; break; case PCI_DEVICE_ID_RPP8: str = "Plus Octacable"; max_num_aiops = 1; break; case PCI_DEVICE_ID_RP8M: str = "8-port Modem"; max_num_aiops = 1; break; default: str = "(unknown/unsupported)"; max_num_aiops = 0; break; } for(aiop=0;aiop < max_num_aiops;aiop++) aiopio[aiop] = rcktpt_io_addr[i] + (aiop * 0x40); ctlp = sCtlNumToCtlPtr(i); num_aiops = sPCIInitController(ctlp, i, aiopio, max_num_aiops, 0, FREQ_DIS, 0); printk("Rocketport controller #%d found at %02x:%02x, " "%d AIOP(s) (PCI Rocketport %s)\n", i, bus, device_fn, num_aiops, str); if(num_aiops <= 0) { rcktpt_io_addr[i] = 0; return(0); } for(aiop = 0;aiop < num_aiops; aiop++) { sResetAiopByNum(ctlp, aiop); sEnAiop(ctlp, aiop); num_chan = sGetAiopNumChan(ctlp, aiop); for(chan=0;chan < num_chan; chan++) init_r_port(i, aiop, chan); } return(1);}__initfunc(static int init_PCI(int boards_found)){ unsigned char bus, device_fn; int i, count = 0; for(i=0; i < (NUM_BOARDS - boards_found); i++) { if (!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP4QUAD, i, &bus, &device_fn)) if (register_PCI(count+boards_found, bus, device_fn)) count++; if (!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8J, i, &bus, &device_fn)) if (register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8OCTA, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8INTF, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP16INTF, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP32INTF, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP4QUAD, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8J, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RPP4, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RPP8, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; if(!pcibios_find_device(PCI_VENDOR_ID_RP, PCI_DEVICE_ID_RP8M, i, &bus, &device_fn)) if(register_PCI(count+boards_found, bus, device_fn)) count++; } return(count);}#endif__initfunc(static int init_ISA(int i, int *reserved_controller)){ int num_aiops, num_chan; int aiop, chan; unsigned int aiopio[MAX_AIOPS_PER_BOARD]; CONTROLLER_t *ctlp; if (rcktpt_io_addr[i] == 0) return(0); if (check_region(rcktpt_io_addr[i],64)) { printk("RocketPort board address 0x%lx in use...\n", rcktpt_io_addr[i]); rcktpt_io_addr[i] = 0; return(0); } for (aiop=0; aiop<MAX_AIOPS_PER_BOARD; aiop++) aiopio[aiop]= rcktpt_io_addr[i] + (aiop * 0x400); ctlp= sCtlNumToCtlPtr(i); num_aiops = sInitController(ctlp, i, controller + (i*0x400), aiopio, MAX_AIOPS_PER_BOARD, 0, FREQ_DIS, 0); if (num_aiops <= 0) { rcktpt_io_addr[i] = 0; return(0); } for (aiop = 0; aiop < num_aiops; aiop++) { sResetAiopByNum(ctlp, aiop); sEnAiop(ctlp, aiop); num_chan = sGetAiopNumChan(ctlp,aiop); for (chan=0; chan < num_chan; chan++) init_r_port(i, aiop, chan); } printk("Rocketport controller #%d found at 0x%lx, " "%d AIOPs\n", i, rcktpt_io_addr[i], num_aiops); if (rcktpt_io_addr[i] + 0x40 == controller) { *reserved_controller = 1; request_region(rcktpt_io_addr[i], 68, "Comtrol Rocketport"); } else { request_region(rcktpt_io_addr[i], 64, "Comtrol Rocketport"); } return(1);}/* * The module "startup" routine; it's run when the module is loaded. */__initfunc(int rp_init(void)){ int i, retval, pci_boards_found, isa_boards_found; int reserved_controller = 0; printk("Rocketport device driver module, version %s, %s\n", ROCKET_VERSION, ROCKET_DATE); /* * Set up the timer channel. If it is already in use by * some other driver, give up. */ if (timer_table[COMTROL_TIMER].fn) { printk("rocket.o: Timer channel %d already in use!\n", COMTROL_TIMER); return -EBUSY; } timer_table[COMTROL_TIMER].fn = rp_do_poll; timer_table[COMTROL_TIMER].expires = 0; /* * Initialize the array of pointers to our own internal state * structures. */ memset(rp_table, 0, sizeof(rp_table)); memset(xmit_flags, 0, sizeof(xmit_flags)); if (board1 == 0) board1 = 0x180; if (controller == 0) controller = board1 + 0x40; if (check_region(controller, 4)) { printk("Controller IO addresses in use, unloading driver.\n"); return -EBUSY; } rcktpt_io_addr[0] = board1; rcktpt_io_addr[1] = board2; rcktpt_io_addr[2] = board3; rcktpt_io_addr[3] = board4; /* * If support_low_speed is set, use the slow clock prescale, * which supports 50 bps */ if (support_low_speed) { sClockPrescale = 0x19; /* mod 9 (divide by 10) prescale */ rp_baud_base = 230400; } else { sClockPrescale = 0x14; /* mod 4 (devide by 5) prescale */ rp_baud_base = 460800; } /* * OK, let's probe each of the controllers looking for boards. */ isa_boards_found = 0; pci_boards_found = 0; for (i=0; i < NUM_BOARDS; i++) { if(init_ISA(i, &reserved_controller)) isa_boards_found++; }#ifdef ENABLE_PCI if (pcibios_present()) { if(isa_boards_found < NUM_BOARDS) pci_boards_found = init_PCI(isa_boards_found); } else { printk("No PCI BIOS found\n"); }#endif max_board = pci_boards_found + isa_boards_found; if (max_board == 0) { printk("No rocketport ports found; unloading driver.\n"); timer_table[COMTROL_TIMER].fn = 0; return -ENODEV; } if (reserved_controller == 0) request_region(controller, 4, "Comtrol Rocketport"); /* * Set up the tty driver structure and then register this * driver with the tty layer. */ memset(&rocket_driver, 0, sizeof(struct tty_driver)); rocket_driver.magic = TTY_DRIVER_MAGIC; rocket_driver.name = "ttyR"; rocket_driver.major = TTY_ROCKET_MAJOR; rocket_driver.minor_start = 0; rocket_driver.num = MAX_RP_PORTS; rocket_driver.type = TTY_DRIVER_TYPE_SERIAL; rocket_driver.subtype = SERIAL_TYPE_NORMAL; rocket_driver.init_termios = tty_std_termios; rocket_driver.init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL; rocket_driver.flags = TTY_DRIVER_REAL_RAW; rocket_driver.refcount = &rocket_refcount; rocket_driver.table = rocket_table; rocket_driver.termios = rocket_termios; rocket_driver.termios_locked = rocket_termios_locked; rocket_driver.open = rp_open; rocket_driver.close = rp_close; rocket_driver.write = rp_write; rocket_driver.put_char = rp_put_char; rocket_driver.write_room = rp_write_room; rocket_driver.chars_in_buffer = rp_chars_in_buffer; rocket_driver.flush_buffer = rp_flush_buffer; rocket_driver.ioctl = rp_ioctl; rocket_driver.throttle = rp_throttle; rocket_driver.unthrottle = rp_unthrottle; rocket_driver.set_termios = rp_set_termios; rocket_driver.stop = rp_stop; rocket_driver.start = rp_start; rocket_driver.hangup = rp_hangup;#if (LINUX_VERSION_CODE >= 131394) /* Linux 2.1.66 */ rocket_driver.break_ctl = rp_break;#endif#if (LINUX_VERSION_CODE >= 131343) rocket_driver.send_xchar = rp_send_xchar; rocket_driver.wait_until_sent = rp_wait_until_sent;#endif /* * The callout device is just like normal device except for * the minor number and the subtype code. */ callout_driver = rocket_driver; callout_driver.name = "cur"; callout_driver.major = CUA_ROCKET_MAJOR; callout_driver.minor_start = 0; callout_driver.subtype = SERIAL_TYPE_CALLOUT; retval = tty_register_driver(&callout_driver); if (retval < 0) { printk("Couldn't install Rocketport callout driver " "(error %d)\n", -retval); return -1; } retval = tty_register_driver(&rocket_driver); if (retval < 0) { printk("Couldn't install tty Rocketport driver " "(error %d)\n", -retval); return -1; }#ifdef ROCKET_DEBUG_OPEN printk("Rocketport driver is major %d, callout is %d\n", rocket_driver.major, callout_driver.major);#endif return 0;}#ifdef MODULEint init_module(void){ return rp_init();}voidcleanup_module( void) { int retval; int i; int released_controller = 0; retval = tty_unregister_driver(&callout_driver); if (retval) { printk("Error %d while trying to unregister " "rocketport callout driver\n", -retval); } retval = tty_unregister_driver(&rocket_driver); if (retval) { printk("Error %d while trying to unregister " "rocketport driver\n", -retval); } for (i = 0; i < MAX_RP_PORTS; i++) { if (rp_table[i]) kfree(rp_table[i]); } for (i=0; i < NUM_BOARDS; i++) { if (rcktpt_io_addr[i] <= 0) continue; if (rcktpt_io_addr[i] + 0x40 == controller) { released_controller++; release_region(rcktpt_io_addr[i], 68); } else release_region(rcktpt_io_addr[i], 64); if (released_controller == 0) release_region(controller, 4); } if (tmp_buf) free_page((unsigned long) tmp_buf); timer_table[COMTROL_TIMER].fn = 0;}#endif/*********************************************************************** Copyright 1994 Comtrol Corporation. All Rights Reserved.The following source code is subject to Comtrol Corporation'sDeveloper's License Agreement.This source code is protected by United States copyright law and international copyright treaties.This source code may only be used to develop software products thatwill operate with Comtrol brand hardware.You may not reproduce nor distribute this source code in its originalform but must produce a derivative work which includes portions ofthis source code only.The portions of this source code which you use in your derivativework must bear Comtrol's copyright notice: Copyright 1994 Comtrol Corporation.***********************************************************************/#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endifstatic Byte_t RData[RDATASIZE] ={ 0x00, 0x09, 0xf6, 0x82, 0x02, 0x09, 0x86, 0xfb, 0x04, 0x09, 0x00, 0x0a, 0x06, 0x09, 0x01, 0x0a, 0x08, 0x09, 0x8a, 0x13, 0x0a, 0x09, 0xc5, 0x11, 0x0c, 0x09, 0x86, 0x85, 0x0e, 0x09, 0x20, 0x0a, 0x10, 0x09, 0x21, 0x0a, 0x12, 0x09, 0x41, 0xff, 0x14, 0x09, 0x82, 0x00, 0x16, 0x09, 0x82, 0x7b, 0x18, 0x09, 0x8a, 0x7d, 0x1a, 0x09, 0x88, 0x81, 0x1c, 0x09, 0x86, 0x7a, 0x1e, 0x09, 0x84, 0x81, 0x20, 0x09, 0x82, 0x7c, 0x22, 0x09, 0x0a, 0x0a };static Byte_t RRegData[RREGDATASIZE]={ 0x00, 0x09, 0xf6, 0x82, /* 00: Stop Rx processor */ 0x08, 0x09, 0x8a, 0x13, /* 04: Tx software flow control */ 0x0a, 0x09, 0xc5, 0x11, /* 08: XON char */ 0x0c, 0x09, 0x86, 0x85, /* 0c: XANY */ 0x12, 0x09, 0x41, 0xff, /* 10: Rx mask char */ 0x14, 0x09, 0x82, 0x00, /* 14: Compare/Ignore #0 */ 0x16, 0x09, 0x82, 0x7b, /* 18: Compare #1 */ 0x18, 0x09, 0x8a, 0x7d, /* 1c: Compare #2 */ 0x1a, 0x09, 0x88, 0x81, /* 20: Interrupt #1 */ 0x1c, 0x09, 0x86, 0x7a, /* 24: Ignore/Replace #1 */ 0x1e, 0x09, 0x84, 0x81, /* 28: Interrupt #2 */ 0x20, 0x09, 0x82, 0x7c, /* 2c: Ignore/Replace #2 */ 0x22, 0x09, 0x0a, 0x0a /* 30: Rx FIFO Enable */};CONTROLLER_T sController[CTL_SIZE] ={ {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}}, {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}}, {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}}, {-1,-1,0,0,0,0,0,0,0,0,0,{0,0,0,0},{0,0,0,0},{-1,-1,-1,-1},{0,0,0,0}}};#if 0/* IRQ number to MUDBAC register 2 mapping */Byte_t sIRQMap[16] ={ 0,0,0,0x10,0x20,0x30,0,0,0,0x40,0x50,0x60,0x70,0,0,0x80};#endifByte_t sBitMapClrTbl[8] ={ 0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};Byte_t sBitMapSetTbl[8] ={ 0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};int sClockPrescale = 0x14;/***************************************************************************Function: sInitControllerPurpose: Initialization of controller global registers and controller structure.Call: sInitController(CtlP,CtlNum,MudbacIO,AiopIOList,AiopIOListSize, IRQNum,Frequency,PeriodicOnly) CONTROLLER_T *CtlP; Ptr to controller structure int CtlNum; Controller number ByteIO_t MudbacIO; Mudbac base I/O address. ByteIO_t *AiopIOList; List of I/O addresses for each AIOP. This list must be in the order the AIOPs will be found on the controller. Once an AIOP in the list is not found, it is assumed that there are no more AIOPs on the controller. int AiopIOListSize; Number of addresses in AiopIOList int IRQNum; Interrupt Request number. Can be any of the following: 0: Disable global interrupts 3: IRQ 3 4: IRQ 4 5: IRQ 5 9: IRQ 9 10: IRQ 10 11: IRQ 11 12: IRQ 12 15: IRQ 15 Byte_t Frequency: A flag identifying the frequency of the periodic interrupt, can be any one of the following: FREQ_DIS - periodic interrupt disabled FREQ_137HZ - 137 Hertz FREQ_69HZ - 69 Hertz FREQ_34HZ - 34 Hertz FREQ_17HZ - 17 Hertz FREQ_9HZ - 9 Hertz FREQ_4HZ - 4 Hertz If IRQNum is set to 0 the Frequency parameter is overidden, it is forced to a value of FREQ_DIS. int PeriodicOn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -