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