Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** ----------------------------------------------------------------------------- |
| 3 | ** |
| 4 | ** Perle Specialix driver for Linux |
| 5 | ** Ported from existing RIO Driver for SCO sources. |
| 6 | * |
| 7 | * (C) 1990 - 2000 Specialix International Ltd., Byfleet, Surrey, UK. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License as published by |
| 11 | * the Free Software Foundation; either version 2 of the License, or |
| 12 | * (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 22 | ** |
| 23 | ** Module : rioboot.c |
| 24 | ** SID : 1.3 |
| 25 | ** Last Modified : 11/6/98 10:33:36 |
| 26 | ** Retrieved : 11/6/98 10:33:48 |
| 27 | ** |
| 28 | ** ident @(#)rioboot.c 1.3 |
| 29 | ** |
| 30 | ** ----------------------------------------------------------------------------- |
| 31 | */ |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #include <linux/module.h> |
| 34 | #include <linux/slab.h> |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 35 | #include <linux/termios.h> |
| 36 | #include <linux/serial.h> |
| 37 | #include <asm/semaphore.h> |
| 38 | #include <linux/generic_serial.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | #include <linux/errno.h> |
| 40 | #include <linux/interrupt.h> |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 41 | #include <linux/delay.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 42 | #include <asm/io.h> |
| 43 | #include <asm/system.h> |
| 44 | #include <asm/string.h> |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 45 | #include <asm/uaccess.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | |
| 47 | |
| 48 | #include "linux_compat.h" |
| 49 | #include "rio_linux.h" |
| 50 | #include "typdef.h" |
| 51 | #include "pkt.h" |
| 52 | #include "daemon.h" |
| 53 | #include "rio.h" |
| 54 | #include "riospace.h" |
| 55 | #include "top.h" |
| 56 | #include "cmdpkt.h" |
| 57 | #include "map.h" |
| 58 | #include "riotypes.h" |
| 59 | #include "rup.h" |
| 60 | #include "port.h" |
| 61 | #include "riodrvr.h" |
| 62 | #include "rioinfo.h" |
| 63 | #include "func.h" |
| 64 | #include "errors.h" |
| 65 | #include "pci.h" |
| 66 | |
| 67 | #include "parmmap.h" |
| 68 | #include "unixrup.h" |
| 69 | #include "board.h" |
| 70 | #include "host.h" |
| 71 | #include "error.h" |
| 72 | #include "phb.h" |
| 73 | #include "link.h" |
| 74 | #include "cmdblk.h" |
| 75 | #include "route.h" |
| 76 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 77 | static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 79 | static const unsigned char RIOAtVec2Ctrl[] = { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 80 | /* 0 */ INTERRUPT_DISABLE, |
| 81 | /* 1 */ INTERRUPT_DISABLE, |
| 82 | /* 2 */ INTERRUPT_DISABLE, |
| 83 | /* 3 */ INTERRUPT_DISABLE, |
| 84 | /* 4 */ INTERRUPT_DISABLE, |
| 85 | /* 5 */ INTERRUPT_DISABLE, |
| 86 | /* 6 */ INTERRUPT_DISABLE, |
| 87 | /* 7 */ INTERRUPT_DISABLE, |
| 88 | /* 8 */ INTERRUPT_DISABLE, |
| 89 | /* 9 */ IRQ_9 | INTERRUPT_ENABLE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | /* 10 */ INTERRUPT_DISABLE, |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 91 | /* 11 */ IRQ_11 | INTERRUPT_ENABLE, |
| 92 | /* 12 */ IRQ_12 | INTERRUPT_ENABLE, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | /* 13 */ INTERRUPT_DISABLE, |
| 94 | /* 14 */ INTERRUPT_DISABLE, |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 95 | /* 15 */ IRQ_15 | INTERRUPT_ENABLE |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | }; |
| 97 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 98 | /** |
| 99 | * RIOBootCodeRTA - Load RTA boot code |
| 100 | * @p: RIO to load |
| 101 | * @rbp: Download descriptor |
| 102 | * |
| 103 | * Called when the user process initiates booting of the card firmware. |
| 104 | * Lads the firmware |
| 105 | */ |
| 106 | |
| 107 | int RIOBootCodeRTA(struct rio_info *p, struct DownLoad * rbp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | { |
| 109 | int offset; |
| 110 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 111 | func_enter(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 113 | rio_dprintk(RIO_DEBUG_BOOT, "Data at user address %p\n", rbp->DataP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
| 115 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 116 | ** Check that we have set asside enough memory for this |
| 117 | */ |
| 118 | if (rbp->Count > SIXTY_FOUR_K) { |
| 119 | rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code Too Large!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | p->RIOError.Error = HOST_FILE_TOO_LARGE; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 121 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | return -ENOMEM; |
| 123 | } |
| 124 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 125 | if (p->RIOBooting) { |
| 126 | rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot Code : BUSY BUSY BUSY!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | p->RIOError.Error = BOOT_IN_PROGRESS; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 128 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | return -EBUSY; |
| 130 | } |
| 131 | |
| 132 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 133 | ** The data we load in must end on a (RTA_BOOT_DATA_SIZE) byte boundary, |
| 134 | ** so calculate how far we have to move the data up the buffer |
| 135 | ** to achieve this. |
| 136 | */ |
| 137 | offset = (RTA_BOOT_DATA_SIZE - (rbp->Count % RTA_BOOT_DATA_SIZE)) % RTA_BOOT_DATA_SIZE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 140 | ** Be clean, and clear the 'unused' portion of the boot buffer, |
| 141 | ** because it will (eventually) be part of the Rta run time environment |
| 142 | ** and so should be zeroed. |
| 143 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 144 | memset(p->RIOBootPackets, 0, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | /* |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 147 | ** Copy the data from user space into the array |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 148 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 150 | if (copy_from_user(((u8 *)p->RIOBootPackets) + offset, rbp->DataP, rbp->Count)) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 151 | rio_dprintk(RIO_DEBUG_BOOT, "Bad data copy from user space\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | p->RIOError.Error = COPYIN_FAILED; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 153 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | return -EFAULT; |
| 155 | } |
| 156 | |
| 157 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 158 | ** Make sure that our copy of the size includes that offset we discussed |
| 159 | ** earlier. |
| 160 | */ |
| 161 | p->RIONumBootPkts = (rbp->Count + offset) / RTA_BOOT_DATA_SIZE; |
| 162 | p->RIOBootCount = rbp->Count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | func_exit(); |
| 165 | return 0; |
| 166 | } |
| 167 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 168 | /** |
| 169 | * rio_start_card_running - host card start |
| 170 | * @HostP: The RIO to kick off |
| 171 | * |
| 172 | * Start a RIO processor unit running. Encapsulates the knowledge |
| 173 | * of the card type. |
| 174 | */ |
| 175 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 176 | void rio_start_card_running(struct Host *HostP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 178 | switch (HostP->Type) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | case RIO_AT: |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 180 | rio_dprintk(RIO_DEBUG_BOOT, "Start ISA card running\n"); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 181 | writeb(BOOT_FROM_RAM | EXTERNAL_BUS_ON | HostP->Mode | RIOAtVec2Ctrl[HostP->Ivec & 0xF], &HostP->Control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | case RIO_PCI: |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 184 | /* |
| 185 | ** PCI is much the same as MCA. Everything is once again memory |
| 186 | ** mapped, so we are writing to memory registers instead of io |
| 187 | ** ports. |
| 188 | */ |
| 189 | rio_dprintk(RIO_DEBUG_BOOT, "Start PCI card running\n"); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 190 | writeb(PCITpBootFromRam | PCITpBusEnable | HostP->Mode, &HostP->Control); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | break; |
| 192 | default: |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 193 | rio_dprintk(RIO_DEBUG_BOOT, "Unknown host type %d\n", HostP->Type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | break; |
| 195 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | return; |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | ** Load in the host boot code - load it directly onto all halted hosts |
| 201 | ** of the correct type. |
| 202 | ** |
| 203 | ** Put your rubber pants on before messing with this code - even the magic |
| 204 | ** numbers have trouble understanding what they are doing here. |
| 205 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 206 | |
| 207 | int RIOBootCodeHOST(struct rio_info *p, struct DownLoad *rbp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | { |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 209 | struct Host *HostP; |
| 210 | u8 *Cad; |
| 211 | PARM_MAP *ParmMapP; |
| 212 | int RupN; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | int PortN; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 214 | unsigned int host; |
| 215 | u8 *StartP; |
| 216 | u8 *DestP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | int wait_count; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 218 | u16 OldParmMap; |
| 219 | u16 offset; /* It is very important that this is a u16 */ |
| 220 | u8 *DownCode = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | unsigned long flags; |
| 222 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 223 | HostP = NULL; /* Assure the compiler we've initialized it */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 224 | |
| 225 | |
| 226 | /* Walk the hosts */ |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 227 | for (host = 0; host < p->RIONumHosts; host++) { |
| 228 | rio_dprintk(RIO_DEBUG_BOOT, "Attempt to boot host %d\n", host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | HostP = &p->RIOHosts[host]; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 230 | |
| 231 | rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 233 | /* Don't boot hosts already running */ |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 234 | if ((HostP->Flags & RUN_STATE) != RC_WAITING) { |
| 235 | rio_dprintk(RIO_DEBUG_BOOT, "%s %d already running\n", "Host", host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | continue; |
| 237 | } |
| 238 | |
| 239 | /* |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 240 | ** Grab a pointer to the card (ioremapped) |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 241 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | Cad = HostP->Caddr; |
| 243 | |
| 244 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 245 | ** We are going to (try) and load in rbp->Count bytes. |
| 246 | ** The last byte will reside at p->RIOConf.HostLoadBase-1; |
| 247 | ** Therefore, we need to start copying at address |
| 248 | ** (caddr+p->RIOConf.HostLoadBase-rbp->Count) |
| 249 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 250 | StartP = &Cad[p->RIOConf.HostLoadBase - rbp->Count]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 252 | rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for host is %p\n", Cad); |
| 253 | rio_dprintk(RIO_DEBUG_BOOT, "kernel virtual address for download is %p\n", StartP); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 254 | rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase); |
| 255 | rio_dprintk(RIO_DEBUG_BOOT, "size of download is 0x%x\n", rbp->Count); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 257 | /* Make sure it fits */ |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 258 | if (p->RIOConf.HostLoadBase < rbp->Count) { |
| 259 | rio_dprintk(RIO_DEBUG_BOOT, "Bin too large\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | p->RIOError.Error = HOST_FILE_TOO_LARGE; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 261 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | return -EFBIG; |
| 263 | } |
| 264 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 265 | ** Ensure that the host really is stopped. |
| 266 | ** Disable it's external bus & twang its reset line. |
| 267 | */ |
| 268 | RIOHostReset(HostP->Type, (struct DpRam *) HostP->CardP, HostP->Slot); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | |
| 270 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 271 | ** Copy the data directly from user space to the SRAM. |
| 272 | ** This ain't going to be none too clever if the download |
| 273 | ** code is bigger than this segment. |
| 274 | */ |
| 275 | rio_dprintk(RIO_DEBUG_BOOT, "Copy in code\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 277 | /* Buffer to local memory as we want to use I/O space and |
| 278 | some cards only do 8 or 16 bit I/O */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 280 | DownCode = vmalloc(rbp->Count); |
| 281 | if (!DownCode) { |
| 282 | p->RIOError.Error = NOT_ENOUGH_CORE_FOR_PCI_COPY; |
| 283 | func_exit(); |
| 284 | return -ENOMEM; |
| 285 | } |
| 286 | if (copy_from_user(rbp->DataP, DownCode, rbp->Count)) { |
| 287 | kfree(DownCode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | p->RIOError.Error = COPYIN_FAILED; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 289 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | return -EFAULT; |
| 291 | } |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 292 | HostP->Copy(DownCode, StartP, rbp->Count); |
| 293 | vfree(DownCode); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 295 | rio_dprintk(RIO_DEBUG_BOOT, "Copy completed\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | |
| 297 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 298 | ** S T O P ! |
| 299 | ** |
| 300 | ** Upto this point the code has been fairly rational, and possibly |
| 301 | ** even straight forward. What follows is a pile of crud that will |
| 302 | ** magically turn into six bytes of transputer assembler. Normally |
| 303 | ** you would expect an array or something, but, being me, I have |
| 304 | ** chosen [been told] to use a technique whereby the startup code |
| 305 | ** will be correct if we change the loadbase for the code. Which |
| 306 | ** brings us onto another issue - the loadbase is the *end* of the |
| 307 | ** code, not the start. |
| 308 | ** |
| 309 | ** If I were you I wouldn't start from here. |
| 310 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | |
| 312 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 313 | ** We now need to insert a short boot section into |
| 314 | ** the memory at the end of Sram2. This is normally (de)composed |
| 315 | ** of the last eight bytes of the download code. The |
| 316 | ** download has been assembled/compiled to expect to be |
| 317 | ** loaded from 0x7FFF downwards. We have loaded it |
| 318 | ** at some other address. The startup code goes into the small |
| 319 | ** ram window at Sram2, in the last 8 bytes, which are really |
| 320 | ** at addresses 0x7FF8-0x7FFF. |
| 321 | ** |
| 322 | ** If the loadbase is, say, 0x7C00, then we need to branch to |
| 323 | ** address 0x7BFE to run the host.bin startup code. We assemble |
| 324 | ** this jump manually. |
| 325 | ** |
| 326 | ** The two byte sequence 60 08 is loaded into memory at address |
| 327 | ** 0x7FFE,F. This is a local branch to location 0x7FF8 (60 is nfix 0, |
| 328 | ** which adds '0' to the .O register, complements .O, and then shifts |
| 329 | ** it left by 4 bit positions, 08 is a jump .O+8 instruction. This will |
| 330 | ** add 8 to .O (which was 0xFFF0), and will branch RELATIVE to the new |
| 331 | ** location. Now, the branch starts from the value of .PC (or .IP or |
| 332 | ** whatever the bloody register is called on this chip), and the .PC |
| 333 | ** will be pointing to the location AFTER the branch, in this case |
| 334 | ** .PC == 0x8000, so the branch will be to 0x8000+0xFFF8 = 0x7FF8. |
| 335 | ** |
| 336 | ** A long branch is coded at 0x7FF8. This consists of loading a four |
| 337 | ** byte offset into .O using nfix (as above) and pfix operators. The |
| 338 | ** pfix operates in exactly the same way as the nfix operator, but |
| 339 | ** without the complement operation. The offset, of course, must be |
| 340 | ** relative to the address of the byte AFTER the branch instruction, |
| 341 | ** which will be (urm) 0x7FFC, so, our final destination of the branch |
| 342 | ** (loadbase-2), has to be reached from here. Imagine that the loadbase |
| 343 | ** is 0x7C00 (which it is), then we will need to branch to 0x7BFE (which |
| 344 | ** is the first byte of the initial two byte short local branch of the |
| 345 | ** download code). |
| 346 | ** |
| 347 | ** To code a jump from 0x7FFC (which is where the branch will start |
| 348 | ** from) to 0x7BFE, we will need to branch 0xFC02 bytes (0x7FFC+0xFC02)= |
| 349 | ** 0x7BFE. |
| 350 | ** This will be coded as four bytes: |
| 351 | ** 60 2C 20 02 |
| 352 | ** being nfix .O+0 |
| 353 | ** pfix .O+C |
| 354 | ** pfix .O+0 |
| 355 | ** jump .O+2 |
| 356 | ** |
| 357 | ** The nfix operator is used, so that the startup code will be |
| 358 | ** compatible with the whole Tp family. (lies, damn lies, it'll never |
| 359 | ** work in a month of Sundays). |
| 360 | ** |
| 361 | ** The nfix nyble is the 1s complement of the nyble value you |
| 362 | ** want to load - in this case we wanted 'F' so we nfix loaded '0'. |
| 363 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 364 | |
| 365 | |
| 366 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 367 | ** Dest points to the top 8 bytes of Sram2. The Tp jumps |
| 368 | ** to 0x7FFE at reset time, and starts executing. This is |
| 369 | ** a short branch to 0x7FF8, where a long branch is coded. |
| 370 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 372 | DestP = (u8 *) &Cad[0x7FF8]; /* <<<---- READ THE ABOVE COMMENTS */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | |
| 374 | #define NFIX(N) (0x60 | (N)) /* .O = (~(.O + N))<<4 */ |
| 375 | #define PFIX(N) (0x20 | (N)) /* .O = (.O + N)<<4 */ |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 376 | #define JUMP(N) (0x00 | (N)) /* .PC = .PC + .O */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 377 | |
| 378 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 379 | ** 0x7FFC is the address of the location following the last byte of |
| 380 | ** the four byte jump instruction. |
| 381 | ** READ THE ABOVE COMMENTS |
| 382 | ** |
| 383 | ** offset is (TO-FROM) % MEMSIZE, but with compound buggering about. |
| 384 | ** Memsize is 64K for this range of Tp, so offset is a short (unsigned, |
| 385 | ** cos I don't understand 2's complement). |
| 386 | */ |
| 387 | offset = (p->RIOConf.HostLoadBase - 2) - 0x7FFC; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 389 | writeb(NFIX(((ushort) (~offset) >> (ushort) 12) & 0xF), DestP); |
| 390 | writeb(PFIX((offset >> 8) & 0xF), DestP + 1); |
| 391 | writeb(PFIX((offset >> 4) & 0xF), DestP + 2); |
| 392 | writeb(JUMP(offset & 0xF), DestP + 3); |
| 393 | |
| 394 | writeb(NFIX(0), DestP + 6); |
| 395 | writeb(JUMP(8), DestP + 7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 397 | rio_dprintk(RIO_DEBUG_BOOT, "host loadbase is 0x%x\n", p->RIOConf.HostLoadBase); |
| 398 | rio_dprintk(RIO_DEBUG_BOOT, "startup offset is 0x%x\n", offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | |
| 400 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 401 | ** Flag what is going on |
| 402 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | HostP->Flags &= ~RUN_STATE; |
| 404 | HostP->Flags |= RC_STARTUP; |
| 405 | |
| 406 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 407 | ** Grab a copy of the current ParmMap pointer, so we |
| 408 | ** can tell when it has changed. |
| 409 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 410 | OldParmMap = readw(&HostP->__ParmMapR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 412 | rio_dprintk(RIO_DEBUG_BOOT, "Original parmmap is 0x%x\n", OldParmMap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 413 | |
| 414 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 415 | ** And start it running (I hope). |
| 416 | ** As there is nothing dodgy or obscure about the |
| 417 | ** above code, this is guaranteed to work every time. |
| 418 | */ |
| 419 | rio_dprintk(RIO_DEBUG_BOOT, "Host Type = 0x%x, Mode = 0x%x, IVec = 0x%x\n", HostP->Type, HostP->Mode, HostP->Ivec); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 420 | |
| 421 | rio_start_card_running(HostP); |
| 422 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 423 | rio_dprintk(RIO_DEBUG_BOOT, "Set control port\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
| 425 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 426 | ** Now, wait for upto five seconds for the Tp to setup the parmmap |
| 427 | ** pointer: |
| 428 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 429 | for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && (readw(&HostP->__ParmMapR) == OldParmMap); wait_count++) { |
| 430 | rio_dprintk(RIO_DEBUG_BOOT, "Checkout %d, 0x%x\n", wait_count, readw(&HostP->__ParmMapR)); |
| 431 | mdelay(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 432 | |
| 433 | } |
| 434 | |
| 435 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 436 | ** If the parmmap pointer is unchanged, then the host code |
| 437 | ** has crashed & burned in a really spectacular way |
| 438 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 439 | if (readw(&HostP->__ParmMapR) == OldParmMap) { |
| 440 | rio_dprintk(RIO_DEBUG_BOOT, "parmmap 0x%x\n", readw(&HostP->__ParmMapR)); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 441 | rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail\n"); |
| 442 | HostP->Flags &= ~RUN_STATE; |
| 443 | HostP->Flags |= RC_STUFFED; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 444 | RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); |
| 445 | continue; |
| 446 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 448 | rio_dprintk(RIO_DEBUG_BOOT, "Running 0x%x\n", readw(&HostP->__ParmMapR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 | |
| 450 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 451 | ** Well, the board thought it was OK, and setup its parmmap |
| 452 | ** pointer. For the time being, we will pretend that this |
| 453 | ** board is running, and check out what the error flag says. |
| 454 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | |
| 456 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 457 | ** Grab a 32 bit pointer to the parmmap structure |
| 458 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 459 | ParmMapP = (PARM_MAP *) RIO_PTR(Cad, readw(&HostP->__ParmMapR)); |
| 460 | rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); |
| 461 | ParmMapP = (PARM_MAP *) ((unsigned long) Cad + readw(&HostP->__ParmMapR)); |
| 462 | rio_dprintk(RIO_DEBUG_BOOT, "ParmMapP : %p\n", ParmMapP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
| 464 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 465 | ** The links entry should be 0xFFFF; we set it up |
| 466 | ** with a mask to say how many PHBs to use, and |
| 467 | ** which links to use. |
| 468 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 469 | if (readw(&ParmMapP->links) != 0xFFFF) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 470 | rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 471 | rio_dprintk(RIO_DEBUG_BOOT, "Links = 0x%x\n", readw(&ParmMapP->links)); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 472 | HostP->Flags &= ~RUN_STATE; |
| 473 | HostP->Flags |= RC_STUFFED; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 474 | RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); |
| 475 | continue; |
| 476 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 477 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 478 | writew(RIO_LINK_ENABLE, &ParmMapP->links); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | |
| 480 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 481 | ** now wait for the card to set all the parmmap->XXX stuff |
| 482 | ** this is a wait of upto two seconds.... |
| 483 | */ |
| 484 | rio_dprintk(RIO_DEBUG_BOOT, "Looking for init_done - %d ticks\n", p->RIOConf.StartupTime); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 485 | HostP->timeout_id = 0; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 486 | for (wait_count = 0; (wait_count < p->RIOConf.StartupTime) && !readw(&ParmMapP->init_done); wait_count++) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 487 | rio_dprintk(RIO_DEBUG_BOOT, "Waiting for init_done\n"); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 488 | mdelay(100); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 489 | } |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 490 | rio_dprintk(RIO_DEBUG_BOOT, "OK! init_done!\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 491 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 492 | if (readw(&ParmMapP->error) != E_NO_ERROR || !readw(&ParmMapP->init_done)) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 493 | rio_dprintk(RIO_DEBUG_BOOT, "RIO Mesg Run Fail %s\n", HostP->Name); |
| 494 | rio_dprintk(RIO_DEBUG_BOOT, "Timedout waiting for init_done\n"); |
| 495 | HostP->Flags &= ~RUN_STATE; |
| 496 | HostP->Flags |= RC_STUFFED; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 497 | RIOHostReset( HostP->Type, (struct DpRam *)HostP->CardP, HostP->Slot ); |
| 498 | continue; |
| 499 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 501 | rio_dprintk(RIO_DEBUG_BOOT, "Got init_done\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 502 | |
| 503 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 504 | ** It runs! It runs! |
| 505 | */ |
| 506 | rio_dprintk(RIO_DEBUG_BOOT, "Host ID %x Running\n", HostP->UniqueNum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 507 | |
| 508 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 509 | ** set the time period between interrupts. |
| 510 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 511 | writew(p->RIOConf.Timer, &ParmMapP->timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 512 | |
| 513 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 514 | ** Translate all the 16 bit pointers in the __ParmMapR into |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 515 | ** 32 bit pointers for the driver in ioremap space. |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 516 | */ |
| 517 | HostP->ParmMapP = ParmMapP; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 518 | HostP->PhbP = (PHB *) RIO_PTR(Cad, readw(&ParmMapP->phb_ptr)); |
| 519 | HostP->RupP = (RUP *) RIO_PTR(Cad, readw(&ParmMapP->rups)); |
| 520 | HostP->PhbNumP = (ushort *) RIO_PTR(Cad, readw(&ParmMapP->phb_num_ptr)); |
| 521 | HostP->LinkStrP = (LPB *) RIO_PTR(Cad, readw(&ParmMapP->link_str_ptr)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | |
| 523 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 524 | ** point the UnixRups at the real Rups |
| 525 | */ |
| 526 | for (RupN = 0; RupN < MAX_RUP; RupN++) { |
| 527 | HostP->UnixRups[RupN].RupP = &HostP->RupP[RupN]; |
| 528 | HostP->UnixRups[RupN].Id = RupN + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 529 | HostP->UnixRups[RupN].BaseSysPort = NO_PORT; |
| 530 | spin_lock_init(&HostP->UnixRups[RupN].RupLock); |
| 531 | } |
| 532 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 533 | for (RupN = 0; RupN < LINKS_PER_UNIT; RupN++) { |
| 534 | HostP->UnixRups[RupN + MAX_RUP].RupP = &HostP->LinkStrP[RupN].rup; |
| 535 | HostP->UnixRups[RupN + MAX_RUP].Id = 0; |
| 536 | HostP->UnixRups[RupN + MAX_RUP].BaseSysPort = NO_PORT; |
| 537 | spin_lock_init(&HostP->UnixRups[RupN + MAX_RUP].RupLock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 541 | ** point the PortP->Phbs at the real Phbs |
| 542 | */ |
| 543 | for (PortN = p->RIOFirstPortsMapped; PortN < p->RIOLastPortsMapped + PORTS_PER_RTA; PortN++) { |
| 544 | if (p->RIOPortp[PortN]->HostP == HostP) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | struct Port *PortP = p->RIOPortp[PortN]; |
| 546 | struct PHB *PhbP; |
| 547 | /* int oldspl; */ |
| 548 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 549 | if (!PortP->Mapped) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | continue; |
| 551 | |
| 552 | PhbP = &HostP->PhbP[PortP->HostPort]; |
| 553 | rio_spin_lock_irqsave(&PortP->portSem, flags); |
| 554 | |
| 555 | PortP->PhbP = PhbP; |
| 556 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 557 | PortP->TxAdd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_add)); |
| 558 | PortP->TxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_start)); |
| 559 | PortP->TxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->tx_end)); |
| 560 | PortP->RxRemove = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_remove)); |
| 561 | PortP->RxStart = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_start)); |
| 562 | PortP->RxEnd = (u16 *) RIO_PTR(Cad, readw(&PhbP->rx_end)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 563 | |
| 564 | rio_spin_unlock_irqrestore(&PortP->portSem, flags); |
| 565 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 566 | ** point the UnixRup at the base SysPort |
| 567 | */ |
| 568 | if (!(PortN % PORTS_PER_RTA)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | HostP->UnixRups[PortP->RupNum].BaseSysPort = PortN; |
| 570 | } |
| 571 | } |
| 572 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 573 | rio_dprintk(RIO_DEBUG_BOOT, "Set the card running... \n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 574 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 575 | ** last thing - show the world that everything is in place |
| 576 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | HostP->Flags &= ~RUN_STATE; |
| 578 | HostP->Flags |= RC_RUNNING; |
| 579 | } |
| 580 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 581 | ** MPX always uses a poller. This is actually patched into the system |
| 582 | ** configuration and called directly from each clock tick. |
| 583 | ** |
| 584 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 585 | p->RIOPolling = 1; |
| 586 | |
| 587 | p->RIOSystemUp++; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 588 | |
| 589 | rio_dprintk(RIO_DEBUG_BOOT, "Done everything %x\n", HostP->Ivec); |
| 590 | func_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | return 0; |
| 592 | } |
| 593 | |
| 594 | |
| 595 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 596 | /** |
| 597 | * RIOBootRup - Boot an RTA |
| 598 | * @p: rio we are working with |
| 599 | * @Rup: Rup number |
| 600 | * @HostP: host object |
| 601 | * @PacketP: packet to use |
| 602 | * |
| 603 | * If we have successfully processed this boot, then |
| 604 | * return 1. If we havent, then return 0. |
| 605 | */ |
| 606 | |
| 607 | int RIOBootRup(struct rio_info *p, unsigned int Rup, struct Host *HostP, struct PKT *PacketP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 609 | struct PktCmd *PktCmdP = (struct PktCmd *) PacketP->data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | struct PktCmd_M *PktReplyP; |
| 611 | struct CmdBlk *CmdBlkP; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 612 | unsigned int sequence; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 613 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 614 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 615 | ** If we haven't been told what to boot, we can't boot it. |
| 616 | */ |
| 617 | if (p->RIONumBootPkts == 0) { |
| 618 | rio_dprintk(RIO_DEBUG_BOOT, "No RTA code to download yet\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | return 0; |
| 620 | } |
| 621 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 622 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 623 | ** Special case of boot completed - if we get one of these then we |
| 624 | ** don't need a command block. For all other cases we do, so handle |
| 625 | ** this first and then get a command block, then handle every other |
| 626 | ** case, relinquishing the command block if disaster strikes! |
| 627 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 628 | if ((readb(&PacketP->len) & PKT_CMD_BIT) && (readb(&PktCmdP->Command) == BOOT_COMPLETED)) |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 629 | return RIOBootComplete(p, HostP, Rup, PktCmdP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | |
| 631 | /* |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 632 | ** Try to allocate a command block. This is in kernel space |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 633 | */ |
| 634 | if (!(CmdBlkP = RIOGetCmdBlk())) { |
| 635 | rio_dprintk(RIO_DEBUG_BOOT, "No command blocks to boot RTA! come back later.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | return 0; |
| 637 | } |
| 638 | |
| 639 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 640 | ** Fill in the default info on the command block |
| 641 | */ |
| 642 | CmdBlkP->Packet.dest_unit = Rup < (ushort) MAX_RUP ? Rup : 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 643 | CmdBlkP->Packet.dest_port = BOOT_RUP; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 644 | CmdBlkP->Packet.src_unit = 0; |
| 645 | CmdBlkP->Packet.src_port = BOOT_RUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | |
| 647 | CmdBlkP->PreFuncP = CmdBlkP->PostFuncP = NULL; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 648 | PktReplyP = (struct PktCmd_M *) CmdBlkP->Packet.data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | |
| 650 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 651 | ** process COMMANDS on the boot rup! |
| 652 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 653 | if (readb(&PacketP->len) & PKT_CMD_BIT) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 654 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 655 | ** We only expect one type of command - a BOOT_REQUEST! |
| 656 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 657 | if (readb(&PktCmdP->Command) != BOOT_REQUEST) { |
| 658 | rio_dprintk(RIO_DEBUG_BOOT, "Unexpected command %d on BOOT RUP %d of host %Zd\n", readb(&PktCmdP->Command), Rup, HostP - p->RIOHosts); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 659 | RIOFreeCmdBlk(CmdBlkP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | return 1; |
| 661 | } |
| 662 | |
| 663 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 664 | ** Build a Boot Sequence command block |
| 665 | ** |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 666 | ** We no longer need to use "Boot Mode", we'll always allow |
| 667 | ** boot requests - the boot will not complete if the device |
| 668 | ** appears in the bindings table. |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 669 | ** |
| 670 | ** We'll just (always) set the command field in packet reply |
| 671 | ** to allow an attempted boot sequence : |
| 672 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 673 | PktReplyP->Command = BOOT_SEQUENCE; |
| 674 | |
| 675 | PktReplyP->BootSequence.NumPackets = p->RIONumBootPkts; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 676 | PktReplyP->BootSequence.LoadBase = p->RIOConf.RtaLoadBase; |
| 677 | PktReplyP->BootSequence.CodeSize = p->RIOBootCount; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 678 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 679 | CmdBlkP->Packet.len = BOOT_SEQUENCE_LEN | PKT_CMD_BIT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 680 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 681 | memcpy((void *) &CmdBlkP->Packet.data[BOOT_SEQUENCE_LEN], "BOOT", 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 682 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 683 | rio_dprintk(RIO_DEBUG_BOOT, "Boot RTA on Host %Zd Rup %d - %d (0x%x) packets to 0x%x\n", HostP - p->RIOHosts, Rup, p->RIONumBootPkts, p->RIONumBootPkts, p->RIOConf.RtaLoadBase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 684 | |
| 685 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 686 | ** If this host is in slave mode, send the RTA an invalid boot |
| 687 | ** sequence command block to force it to kill the boot. We wait |
| 688 | ** for half a second before sending this packet to prevent the RTA |
| 689 | ** attempting to boot too often. The master host should then grab |
| 690 | ** the RTA and make it its own. |
| 691 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 692 | p->RIOBooting++; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 693 | RIOQueueCmdBlk(HostP, Rup, CmdBlkP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 694 | return 1; |
| 695 | } |
| 696 | |
| 697 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 698 | ** It is a request for boot data. |
| 699 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 700 | sequence = readw(&PktCmdP->Sequence); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 701 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 702 | rio_dprintk(RIO_DEBUG_BOOT, "Boot block %d on Host %Zd Rup%d\n", sequence, HostP - p->RIOHosts, Rup); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 704 | if (sequence >= p->RIONumBootPkts) { |
| 705 | rio_dprintk(RIO_DEBUG_BOOT, "Got a request for packet %d, max is %d\n", sequence, p->RIONumBootPkts); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | } |
| 707 | |
| 708 | PktReplyP->Sequence = sequence; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 709 | memcpy(PktReplyP->BootData, p->RIOBootPackets[p->RIONumBootPkts - sequence - 1], RTA_BOOT_DATA_SIZE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 710 | CmdBlkP->Packet.len = PKT_MAX_DATA_LEN; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 711 | RIOQueueCmdBlk(HostP, Rup, CmdBlkP); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 712 | return 1; |
| 713 | } |
| 714 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 715 | /** |
| 716 | * RIOBootComplete - RTA boot is done |
| 717 | * @p: RIO we are working with |
| 718 | * @HostP: Host structure |
| 719 | * @Rup: RUP being used |
| 720 | * @PktCmdP: Packet command that was used |
| 721 | * |
| 722 | * This function is called when an RTA been booted. |
| 723 | * If booted by a host, HostP->HostUniqueNum is the booting host. |
| 724 | * If booted by an RTA, HostP->Mapping[Rup].RtaUniqueNum is the booting RTA. |
| 725 | * RtaUniq is the booted RTA. |
| 726 | */ |
| 727 | |
| 728 | static int RIOBootComplete(struct rio_info *p, struct Host *HostP, unsigned int Rup, struct PktCmd *PktCmdP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 729 | { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 730 | struct Map *MapP = NULL; |
| 731 | struct Map *MapP2 = NULL; |
| 732 | int Flag; |
| 733 | int found; |
| 734 | int host, rta; |
| 735 | int EmptySlot = -1; |
| 736 | int entry, entry2; |
| 737 | char *MyType, *MyName; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 738 | unsigned int MyLink; |
| 739 | unsigned short RtaType; |
| 740 | u32 RtaUniq = (readb(&PktCmdP->UniqNum[0])) + (readb(&PktCmdP->UniqNum[1]) << 8) + (readb(&PktCmdP->UniqNum[2]) << 16) + (readb(&PktCmdP->UniqNum[3]) << 24); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 741 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 742 | p->RIOBooting = 0; |
| 743 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 744 | rio_dprintk(RIO_DEBUG_BOOT, "RTA Boot completed - BootInProgress now %d\n", p->RIOBooting); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 745 | |
| 746 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 747 | ** Determine type of unit (16/8 port RTA). |
| 748 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 749 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | RtaType = GetUnitType(RtaUniq); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 751 | if (Rup >= (ushort) MAX_RUP) |
| 752 | rio_dprintk(RIO_DEBUG_BOOT, "RIO: Host %s has booted an RTA(%d) on link %c\n", HostP->Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A'); |
| 753 | else |
| 754 | rio_dprintk(RIO_DEBUG_BOOT, "RIO: RTA %s has booted an RTA(%d) on link %c\n", HostP->Mapping[Rup].Name, 8 * RtaType, readb(&PktCmdP->LinkNum) + 'A'); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 755 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 756 | rio_dprintk(RIO_DEBUG_BOOT, "UniqNum is 0x%x\n", RtaUniq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 757 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 758 | if (RtaUniq == 0x00000000 || RtaUniq == 0xffffffff) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 759 | rio_dprintk(RIO_DEBUG_BOOT, "Illegal RTA Uniq Number\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | return TRUE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | } |
| 762 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 763 | /* |
| 764 | ** If this RTA has just booted an RTA which doesn't belong to this |
| 765 | ** system, or the system is in slave mode, do not attempt to create |
| 766 | ** a new table entry for it. |
| 767 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 768 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 769 | if (!RIOBootOk(p, HostP, RtaUniq)) { |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 770 | MyLink = readb(&PktCmdP->LinkNum); |
| 771 | if (Rup < (unsigned short) MAX_RUP) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 772 | /* |
| 773 | ** RtaUniq was clone booted (by this RTA). Instruct this RTA |
| 774 | ** to hold off further attempts to boot on this link for 30 |
| 775 | ** seconds. |
| 776 | */ |
| 777 | if (RIOSuspendBootRta(HostP, HostP->Mapping[Rup].ID, MyLink)) { |
| 778 | rio_dprintk(RIO_DEBUG_BOOT, "RTA failed to suspend booting on link %c\n", 'A' + MyLink); |
| 779 | } |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 780 | } else |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 781 | /* |
| 782 | ** RtaUniq was booted by this host. Set the booting link |
| 783 | ** to hold off for 30 seconds to give another unit a |
| 784 | ** chance to boot it. |
| 785 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 786 | writew(30, &HostP->LinkStrP[MyLink].WaitNoBoot); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 787 | rio_dprintk(RIO_DEBUG_BOOT, "RTA %x not owned - suspend booting down link %c on unit %x\n", RtaUniq, 'A' + MyLink, HostP->Mapping[Rup].RtaUniqueNum); |
| 788 | return TRUE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | } |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 790 | |
| 791 | /* |
| 792 | ** Check for a SLOT_IN_USE entry for this RTA attached to the |
| 793 | ** current host card in the driver table. |
| 794 | ** |
| 795 | ** If it exists, make a note that we have booted it. Other parts of |
| 796 | ** the driver are interested in this information at a later date, |
| 797 | ** in particular when the booting RTA asks for an ID for this unit, |
| 798 | ** we must have set the BOOTED flag, and the NEWBOOT flag is used |
| 799 | ** to force an open on any ports that where previously open on this |
| 800 | ** unit. |
| 801 | */ |
| 802 | for (entry = 0; entry < MAX_RUP; entry++) { |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 803 | unsigned int sysport; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 804 | |
| 805 | if ((HostP->Mapping[entry].Flags & SLOT_IN_USE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { |
| 806 | HostP->Mapping[entry].Flags |= RTA_BOOTED | RTA_NEWBOOT; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 807 | if ((sysport = HostP->Mapping[entry].SysPort) != NO_PORT) { |
| 808 | if (sysport < p->RIOFirstPortsBooted) |
| 809 | p->RIOFirstPortsBooted = sysport; |
| 810 | if (sysport > p->RIOLastPortsBooted) |
| 811 | p->RIOLastPortsBooted = sysport; |
| 812 | /* |
| 813 | ** For a 16 port RTA, check the second bank of 8 ports |
| 814 | */ |
| 815 | if (RtaType == TYPE_RTA16) { |
| 816 | entry2 = HostP->Mapping[entry].ID2 - 1; |
| 817 | HostP->Mapping[entry2].Flags |= RTA_BOOTED | RTA_NEWBOOT; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 818 | sysport = HostP->Mapping[entry2].SysPort; |
| 819 | if (sysport < p->RIOFirstPortsBooted) |
| 820 | p->RIOFirstPortsBooted = sysport; |
| 821 | if (sysport > p->RIOLastPortsBooted) |
| 822 | p->RIOLastPortsBooted = sysport; |
| 823 | } |
| 824 | } |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 825 | if (RtaType == TYPE_RTA16) |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 826 | rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given IDs %d+%d\n", entry + 1, entry2 + 1); |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 827 | else |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 828 | rio_dprintk(RIO_DEBUG_BOOT, "RTA will be given ID %d\n", entry + 1); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 829 | return TRUE; |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | rio_dprintk(RIO_DEBUG_BOOT, "RTA not configured for this host\n"); |
| 834 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 835 | if (Rup >= (unsigned short) MAX_RUP) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 836 | /* |
| 837 | ** It was a host that did the booting |
| 838 | */ |
| 839 | MyType = "Host"; |
| 840 | MyName = HostP->Name; |
| 841 | } else { |
| 842 | /* |
| 843 | ** It was an RTA that did the booting |
| 844 | */ |
| 845 | MyType = "RTA"; |
| 846 | MyName = HostP->Mapping[Rup].Name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 847 | } |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 848 | MyLink = readb(&PktCmdP->LinkNum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 849 | |
| 850 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 851 | ** There is no SLOT_IN_USE entry for this RTA attached to the current |
| 852 | ** host card in the driver table. |
| 853 | ** |
| 854 | ** Check for a SLOT_TENTATIVE entry for this RTA attached to the |
| 855 | ** current host card in the driver table. |
| 856 | ** |
| 857 | ** If we find one, then we re-use that slot. |
| 858 | */ |
| 859 | for (entry = 0; entry < MAX_RUP; entry++) { |
| 860 | if ((HostP->Mapping[entry].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry].RtaUniqueNum == RtaUniq)) { |
| 861 | if (RtaType == TYPE_RTA16) { |
| 862 | entry2 = HostP->Mapping[entry].ID2 - 1; |
| 863 | if ((HostP->Mapping[entry2].Flags & SLOT_TENTATIVE) && (HostP->Mapping[entry2].RtaUniqueNum == RtaUniq)) |
| 864 | rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slots (%d+%d)\n", entry, entry2); |
| 865 | else |
| 866 | continue; |
| 867 | } else |
| 868 | rio_dprintk(RIO_DEBUG_BOOT, "Found previous tentative slot (%d)\n", entry); |
| 869 | if (!p->RIONoMessage) |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 870 | printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 871 | return TRUE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 872 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 873 | } |
| 874 | |
| 875 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 876 | ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA |
| 877 | ** attached to the current host card in the driver table. |
| 878 | ** |
| 879 | ** Check if there is a SLOT_IN_USE or SLOT_TENTATIVE entry on another |
| 880 | ** host for this RTA in the driver table. |
| 881 | ** |
| 882 | ** For a SLOT_IN_USE entry on another host, we need to delete the RTA |
| 883 | ** entry from the other host and add it to this host (using some of |
| 884 | ** the functions from table.c which do this). |
| 885 | ** For a SLOT_TENTATIVE entry on another host, we must cope with the |
| 886 | ** following scenario: |
| 887 | ** |
| 888 | ** + Plug 8 port RTA into host A. (This creates SLOT_TENTATIVE entry |
| 889 | ** in table) |
| 890 | ** + Unplug RTA and plug into host B. (We now have 2 SLOT_TENTATIVE |
| 891 | ** entries) |
| 892 | ** + Configure RTA on host B. (This slot now becomes SLOT_IN_USE) |
| 893 | ** + Unplug RTA and plug back into host A. |
| 894 | ** + Configure RTA on host A. We now have the same RTA configured |
| 895 | ** with different ports on two different hosts. |
| 896 | */ |
| 897 | rio_dprintk(RIO_DEBUG_BOOT, "Have we seen RTA %x before?\n", RtaUniq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 898 | found = 0; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 899 | Flag = 0; /* Convince the compiler this variable is initialized */ |
| 900 | for (host = 0; !found && (host < p->RIONumHosts); host++) { |
| 901 | for (rta = 0; rta < MAX_RUP; rta++) { |
| 902 | if ((p->RIOHosts[host].Mapping[rta].Flags & (SLOT_IN_USE | SLOT_TENTATIVE)) && (p->RIOHosts[host].Mapping[rta].RtaUniqueNum == RtaUniq)) { |
| 903 | Flag = p->RIOHosts[host].Mapping[rta].Flags; |
| 904 | MapP = &p->RIOHosts[host].Mapping[rta]; |
| 905 | if (RtaType == TYPE_RTA16) { |
| 906 | MapP2 = &p->RIOHosts[host].Mapping[MapP->ID2 - 1]; |
| 907 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA is units %d+%d from host %s\n", rta + 1, MapP->ID2, p->RIOHosts[host].Name); |
| 908 | } else |
| 909 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA is unit %d from host %s\n", rta + 1, p->RIOHosts[host].Name); |
| 910 | found = 1; |
| 911 | break; |
| 912 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 913 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 914 | } |
| 915 | |
| 916 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 917 | ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA |
| 918 | ** attached to the current host card in the driver table. |
| 919 | ** |
| 920 | ** If we have not found a SLOT_IN_USE or SLOT_TENTATIVE entry on |
| 921 | ** another host for this RTA in the driver table... |
| 922 | ** |
| 923 | ** Check for a SLOT_IN_USE entry for this RTA in the config table. |
| 924 | */ |
| 925 | if (!MapP) { |
| 926 | rio_dprintk(RIO_DEBUG_BOOT, "Look for RTA %x in RIOSavedTable\n", RtaUniq); |
| 927 | for (rta = 0; rta < TOTAL_MAP_ENTRIES; rta++) { |
| 928 | rio_dprintk(RIO_DEBUG_BOOT, "Check table entry %d (%x)", rta, p->RIOSavedTable[rta].RtaUniqueNum); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 930 | if ((p->RIOSavedTable[rta].Flags & SLOT_IN_USE) && (p->RIOSavedTable[rta].RtaUniqueNum == RtaUniq)) { |
| 931 | MapP = &p->RIOSavedTable[rta]; |
| 932 | Flag = p->RIOSavedTable[rta].Flags; |
| 933 | if (RtaType == TYPE_RTA16) { |
| 934 | for (entry2 = rta + 1; entry2 < TOTAL_MAP_ENTRIES; entry2++) { |
| 935 | if (p->RIOSavedTable[entry2].RtaUniqueNum == RtaUniq) |
| 936 | break; |
| 937 | } |
| 938 | MapP2 = &p->RIOSavedTable[entry2]; |
| 939 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entries %d+%d\n", rta, entry2); |
| 940 | } else |
| 941 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA is from table entry %d\n", rta); |
| 942 | break; |
| 943 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | } |
| 946 | |
| 947 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 948 | ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA |
| 949 | ** attached to the current host card in the driver table. |
| 950 | ** |
| 951 | ** We may have found a SLOT_IN_USE entry on another host for this |
| 952 | ** RTA in the config table, or a SLOT_IN_USE or SLOT_TENTATIVE entry |
| 953 | ** on another host for this RTA in the driver table. |
| 954 | ** |
| 955 | ** Check the driver table for room to fit this newly discovered RTA. |
| 956 | ** RIOFindFreeID() first looks for free slots and if it does not |
| 957 | ** find any free slots it will then attempt to oust any |
| 958 | ** tentative entry in the table. |
| 959 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | EmptySlot = 1; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 961 | if (RtaType == TYPE_RTA16) { |
| 962 | if (RIOFindFreeID(p, HostP, &entry, &entry2) == 0) { |
| 963 | RIODefaultName(p, HostP, entry); |
| 964 | FillSlot(entry, entry2, RtaUniq, HostP); |
| 965 | EmptySlot = 0; |
| 966 | } |
| 967 | } else { |
| 968 | if (RIOFindFreeID(p, HostP, &entry, NULL) == 0) { |
| 969 | RIODefaultName(p, HostP, entry); |
| 970 | FillSlot(entry, 0, RtaUniq, HostP); |
| 971 | EmptySlot = 0; |
| 972 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 973 | } |
| 974 | |
| 975 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 976 | ** There is no SLOT_IN_USE or SLOT_TENTATIVE entry for this RTA |
| 977 | ** attached to the current host card in the driver table. |
| 978 | ** |
| 979 | ** If we found a SLOT_IN_USE entry on another host for this |
| 980 | ** RTA in the config or driver table, and there are enough free |
| 981 | ** slots in the driver table, then we need to move it over and |
| 982 | ** delete it from the other host. |
| 983 | ** If we found a SLOT_TENTATIVE entry on another host for this |
| 984 | ** RTA in the driver table, just delete the other host entry. |
| 985 | */ |
| 986 | if (EmptySlot == 0) { |
| 987 | if (MapP) { |
| 988 | if (Flag & SLOT_IN_USE) { |
| 989 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA configured on another host - move entry to current host (1)\n"); |
| 990 | HostP->Mapping[entry].SysPort = MapP->SysPort; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 991 | memcpy(HostP->Mapping[entry].Name, MapP->Name, MAX_NAME_LEN); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 992 | HostP->Mapping[entry].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 993 | RIOReMapPorts(p, HostP, &HostP->Mapping[entry]); |
| 994 | if (HostP->Mapping[entry].SysPort < p->RIOFirstPortsBooted) |
| 995 | p->RIOFirstPortsBooted = HostP->Mapping[entry].SysPort; |
| 996 | if (HostP->Mapping[entry].SysPort > p->RIOLastPortsBooted) |
| 997 | p->RIOLastPortsBooted = HostP->Mapping[entry].SysPort; |
| 998 | rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) MapP->SysPort, MapP->Name); |
| 999 | } else { |
| 1000 | rio_dprintk(RIO_DEBUG_BOOT, "This RTA has a tentative entry on another host - delete that entry (1)\n"); |
| 1001 | HostP->Mapping[entry].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1002 | } |
| 1003 | if (RtaType == TYPE_RTA16) { |
| 1004 | if (Flag & SLOT_IN_USE) { |
| 1005 | HostP->Mapping[entry2].Flags = SLOT_IN_USE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1006 | HostP->Mapping[entry2].SysPort = MapP2->SysPort; |
| 1007 | /* |
| 1008 | ** Map second block of ttys for 16 port RTA |
| 1009 | */ |
| 1010 | RIOReMapPorts(p, HostP, &HostP->Mapping[entry2]); |
| 1011 | if (HostP->Mapping[entry2].SysPort < p->RIOFirstPortsBooted) |
| 1012 | p->RIOFirstPortsBooted = HostP->Mapping[entry2].SysPort; |
| 1013 | if (HostP->Mapping[entry2].SysPort > p->RIOLastPortsBooted) |
| 1014 | p->RIOLastPortsBooted = HostP->Mapping[entry2].SysPort; |
| 1015 | rio_dprintk(RIO_DEBUG_BOOT, "SysPort %d, Name %s\n", (int) HostP->Mapping[entry2].SysPort, HostP->Mapping[entry].Name); |
| 1016 | } else |
| 1017 | HostP->Mapping[entry2].Flags = SLOT_TENTATIVE | RTA_BOOTED | RTA_NEWBOOT | RTA16_SECOND_SLOT; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1018 | memset(MapP2, 0, sizeof(struct Map)); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1019 | } |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1020 | memset(MapP, 0, sizeof(struct Map)); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1021 | if (!p->RIONoMessage) |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1022 | printk("An orphaned RTA has been adopted by %s '%s' (%c).\n", MyType, MyName, MyLink + 'A'); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1023 | } else if (!p->RIONoMessage) |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1024 | printk("RTA connected to %s '%s' (%c) not configured.\n", MyType, MyName, MyLink + 'A'); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1025 | RIOSetChange(p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | return TRUE; |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1027 | } |
| 1028 | |
| 1029 | /* |
| 1030 | ** There is no room in the driver table to make an entry for the |
| 1031 | ** booted RTA. Keep a note of its Uniq Num in the overflow table, |
| 1032 | ** so we can ignore it's ID requests. |
| 1033 | */ |
| 1034 | if (!p->RIONoMessage) |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1035 | printk("The RTA connected to %s '%s' (%c) cannot be configured. You cannot configure more than 128 ports to one host card.\n", MyType, MyName, MyLink + 'A'); |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1036 | for (entry = 0; entry < HostP->NumExtraBooted; entry++) { |
| 1037 | if (HostP->ExtraUnits[entry] == RtaUniq) { |
| 1038 | /* |
| 1039 | ** already got it! |
| 1040 | */ |
| 1041 | return TRUE; |
| 1042 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | } |
| 1044 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1045 | ** If there is room, add the unit to the list of extras |
| 1046 | */ |
| 1047 | if (HostP->NumExtraBooted < MAX_EXTRA_UNITS) |
| 1048 | HostP->ExtraUnits[HostP->NumExtraBooted++] = RtaUniq; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | return TRUE; |
| 1050 | } |
| 1051 | |
| 1052 | |
| 1053 | /* |
| 1054 | ** If the RTA or its host appears in the RIOBindTab[] structure then |
| 1055 | ** we mustn't boot the RTA and should return FALSE. |
| 1056 | ** This operation is slightly different from the other drivers for RIO |
| 1057 | ** in that this is designed to work with the new utilities |
| 1058 | ** not config.rio and is FAR SIMPLER. |
| 1059 | ** We no longer support the RIOBootMode variable. It is all done from the |
| 1060 | ** "boot/noboot" field in the rio.cf file. |
| 1061 | */ |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1062 | int RIOBootOk(struct rio_info *p, struct Host *HostP, unsigned long RtaUniq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1063 | { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1064 | int Entry; |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1065 | unsigned int HostUniq = HostP->UniqueNum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
| 1067 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1068 | ** Search bindings table for RTA or its parent. |
| 1069 | ** If it exists, return 0, else 1. |
| 1070 | */ |
| 1071 | for (Entry = 0; (Entry < MAX_RTA_BINDINGS) && (p->RIOBindTab[Entry] != 0); Entry++) { |
| 1072 | if ((p->RIOBindTab[Entry] == HostUniq) || (p->RIOBindTab[Entry] == RtaUniq)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1073 | return 0; |
| 1074 | } |
| 1075 | return 1; |
| 1076 | } |
| 1077 | |
| 1078 | /* |
| 1079 | ** Make an empty slot tentative. If this is a 16 port RTA, make both |
| 1080 | ** slots tentative, and the second one RTA_SECOND_SLOT as well. |
| 1081 | */ |
| 1082 | |
Alan Cox | b6c6b60 | 2006-03-24 03:18:26 -0800 | [diff] [blame^] | 1083 | void FillSlot(int entry, int entry2, unsigned int RtaUniq, struct Host *HostP) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1084 | { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1085 | int link; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1086 | |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1087 | rio_dprintk(RIO_DEBUG_BOOT, "FillSlot(%d, %d, 0x%x...)\n", entry, entry2, RtaUniq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | |
| 1089 | HostP->Mapping[entry].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE); |
| 1090 | HostP->Mapping[entry].SysPort = NO_PORT; |
| 1091 | HostP->Mapping[entry].RtaUniqueNum = RtaUniq; |
| 1092 | HostP->Mapping[entry].HostUniqueNum = HostP->UniqueNum; |
| 1093 | HostP->Mapping[entry].ID = entry + 1; |
| 1094 | HostP->Mapping[entry].ID2 = 0; |
| 1095 | if (entry2) { |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1096 | HostP->Mapping[entry2].Flags = (RTA_BOOTED | RTA_NEWBOOT | SLOT_TENTATIVE | RTA16_SECOND_SLOT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1097 | HostP->Mapping[entry2].SysPort = NO_PORT; |
| 1098 | HostP->Mapping[entry2].RtaUniqueNum = RtaUniq; |
| 1099 | HostP->Mapping[entry2].HostUniqueNum = HostP->UniqueNum; |
| 1100 | HostP->Mapping[entry2].Name[0] = '\0'; |
| 1101 | HostP->Mapping[entry2].ID = entry2 + 1; |
| 1102 | HostP->Mapping[entry2].ID2 = entry + 1; |
| 1103 | HostP->Mapping[entry].ID2 = entry2 + 1; |
| 1104 | } |
| 1105 | /* |
Alan Cox | 3b8e3f1 | 2006-03-24 03:18:24 -0800 | [diff] [blame] | 1106 | ** Must set these up, so that utilities show |
| 1107 | ** topology of 16 port RTAs correctly |
| 1108 | */ |
| 1109 | for (link = 0; link < LINKS_PER_UNIT; link++) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | HostP->Mapping[entry].Topology[link].Unit = ROUTE_DISCONNECT; |
| 1111 | HostP->Mapping[entry].Topology[link].Link = NO_LINK; |
| 1112 | if (entry2) { |
| 1113 | HostP->Mapping[entry2].Topology[link].Unit = ROUTE_DISCONNECT; |
| 1114 | HostP->Mapping[entry2].Topology[link].Link = NO_LINK; |
| 1115 | } |
| 1116 | } |
| 1117 | } |