/[gxemul]/trunk/src/devices/dev_turbochannel.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/devices/dev_turbochannel.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 22 by dpavlin, Mon Oct 8 16:19:37 2007 UTC revision 42 by dpavlin, Mon Oct 8 16:22:32 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2006  Anders Gavare.  All rights reserved.   *  Copyright (C) 2003-2007  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *     *  
27   *   *
28   *  $Id: dev_turbochannel.c,v 1.46 2006/01/01 13:17:17 debug Exp $   *  $Id: dev_turbochannel.c,v 1.50 2007/06/15 19:57:34 debug Exp $
29   *     *  
30   *  Generic framework for TURBOchannel devices, used in DECstation machines.   *  COMMENT: TURBOchannel bus framework, used in DECstation machines
31   */   */
32    
33  #include <stdio.h>  #include <stdio.h>
# Line 41  Line 41 
41  #include "sfbreg.h"  #include "sfbreg.h"
42    
43    
44  #define DEVICE_NAME_BUFLEN              9  #define DEVICE_MAX_NAMELEN              9
45  #define CARD_NAME_BUFLEN                9  #define CARD_NAME_BUFLEN                9
46  #define CARD_FIRMWARE_BUFLEN            5  #define CARD_FIRMWARE_BUFLEN            5
47    
# Line 49  struct turbochannel_data { Line 49  struct turbochannel_data {
49          int             slot_nr;          int             slot_nr;
50          uint64_t        baseaddr;          uint64_t        baseaddr;
51          uint64_t        endaddr;          uint64_t        endaddr;
         int             irq;  
52    
53          int             rom_skip;          int             rom_skip;
54    
55          char            device_name[DEVICE_NAME_BUFLEN];  /*  NUL-terminated  */          char            device_name[DEVICE_MAX_NAMELEN];  /*  NUL-terminated  */
56    
57          /*  These should be terminated with spaces  */          /*  These should be terminated with spaces  */
58          char            card_firmware_version[CARD_NAME_BUFLEN];          char            card_firmware_version[CARD_NAME_BUFLEN];
# Line 63  struct turbochannel_data { Line 62  struct turbochannel_data {
62  };  };
63    
64    
 /*  
  *  dev_turbochannel_access():  
  */  
65  DEVICE_ACCESS(turbochannel)  DEVICE_ACCESS(turbochannel)
66  {  {
67          struct turbochannel_data *d = extra;          struct turbochannel_data *d = extra;
# Line 178  DEVICE_ACCESS(turbochannel) Line 174  DEVICE_ACCESS(turbochannel)
174   */   */
175  void dev_turbochannel_init(struct machine *machine, struct memory *mem,  void dev_turbochannel_init(struct machine *machine, struct memory *mem,
176          int slot_nr, uint64_t baseaddr, uint64_t endaddr,          int slot_nr, uint64_t baseaddr, uint64_t endaddr,
177          char *device_name, int irq)          char *device_name, char *irq_path)
178  {  {
179          struct vfb_data *fb;          struct vfb_data *fb;
180          struct turbochannel_data *d;          struct turbochannel_data *d;
# Line 194  void dev_turbochannel_init(struct machin Line 190  void dev_turbochannel_init(struct machin
190                  exit(1);                  exit(1);
191          }          }
192    
193          d = malloc(sizeof(struct turbochannel_data));          CHECK_ALLOCATION(d = malloc(sizeof(struct turbochannel_data)));
         if (d == NULL) {  
                 fprintf(stderr, "out of memory\n");  
                 exit(1);  
         }  
194          memset(d, 0, sizeof(struct turbochannel_data));          memset(d, 0, sizeof(struct turbochannel_data));
195    
196          d->slot_nr  = slot_nr;          d->slot_nr  = slot_nr;
197          d->baseaddr = baseaddr;          d->baseaddr = baseaddr;
198          d->endaddr  = endaddr;          d->endaddr  = endaddr;
         d->irq      = irq;  
199    
200          strlcpy(d->device_name, device_name, DEVICE_NAME_BUFLEN);          strlcpy(d->device_name, device_name, DEVICE_MAX_NAMELEN);
201    
202          strncpy(d->card_firmware_version, "V5.3a   ", CARD_NAME_BUFLEN);          strncpy(d->card_firmware_version, "V5.3a   ", CARD_NAME_BUFLEN);
203          strncpy(d->card_vendor_name,      "DEC     ", CARD_NAME_BUFLEN);          strncpy(d->card_vendor_name,      "DEC     ", CARD_NAME_BUFLEN);
# Line 233  void dev_turbochannel_init(struct machin Line 225  void dev_turbochannel_init(struct machin
225    
226          if (strcmp(device_name, "PMAD-AA")==0) {          if (strcmp(device_name, "PMAD-AA")==0) {
227                  /*  le in NetBSD, Lance ethernet  */                  /*  le in NetBSD, Lance ethernet  */
228                  dev_le_init(machine, mem, baseaddr, 0, 0, irq, DEV_LE_LENGTH);                  dev_le_init(machine, mem, baseaddr, 0, 0,
229                        irq_path, DEV_LE_LENGTH);
230                  /*  One ROM at 0x1c03e0, and one at 0x3c0000.  */                  /*  One ROM at 0x1c03e0, and one at 0x3c0000.  */
231                  rom_skip = 0x300;                  rom_skip = 0x300;
232                  rom_offset = 0x1c0000;                  rom_offset = 0x1c0000;
233                  rom_length = 0x201000;                  rom_length = 0x201000;
234          } else if (strcmp(device_name, "PMAZ-AA")==0) {          } else if (strcmp(device_name, "PMAZ-AA")==0) {
235                  /*  asc in NetBSD, SCSI  */                  /*  asc in NetBSD, SCSI  */
236                  dev_asc_init(machine, mem, baseaddr, irq, d,                  dev_asc_init(machine, mem, baseaddr, irq_path, d,
237                      DEV_ASC_DEC, NULL, NULL);                      DEV_ASC_DEC, NULL, NULL);
238                  rom_offset = 0xc0000;                  rom_offset = 0xc0000;
239                  /*  There is a copy at 0x0, at least that's where Linux                  /*  There is a copy at 0x0, at least that's where Linux
# Line 258  void dev_turbochannel_init(struct machin Line 251  void dev_turbochannel_init(struct machin
251                  fb = dev_fb_init(machine, mem, baseaddr, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, baseaddr, VFB_GENERIC,
252                      1024,864, 1024,1024,8, device_name);                      1024,864, 1024,1024,8, device_name);
253                  dev_bt459_init(machine, mem, baseaddr + VFB_CFB_BT459,                  dev_bt459_init(machine, mem, baseaddr + VFB_CFB_BT459,
254                      baseaddr + 0x300000, fb, 8, irq, BT459_BA);                      baseaddr + 0x300000, fb, 8, irq_path, BT459_BA);
255                  /*  ROM at both 0x380000 and 0x3c0000?  */                  /*  ROM at both 0x380000 and 0x3c0000?  */
256                  rom_offset = 0x380000;                  rom_offset = 0x380000;
257                  rom_length = 0x080000;                  rom_length = 0x080000;
# Line 271  void dev_turbochannel_init(struct machin Line 264  void dev_turbochannel_init(struct machin
264                  /*  TODO: the CLEAR doesn't get through, as the address                  /*  TODO: the CLEAR doesn't get through, as the address
265                          range is already in use by the asic  */                          range is already in use by the asic  */
266                  dev_bt459_init(machine, mem, baseaddr + SFB_OFFSET_BT459,                  dev_bt459_init(machine, mem, baseaddr + SFB_OFFSET_BT459,
267                      baseaddr + SFB_CLEAR, fb, 8, irq, BT459_BBA);                      baseaddr + SFB_CLEAR, fb, 8, irq_path, BT459_BBA);
268                  rom_offset = 0x0;       /*  ? TODO  */                  rom_offset = 0x0;       /*  ? TODO  */
269          } else if (strcmp(device_name, "PMAG-CA")==0) {          } else if (strcmp(device_name, "PMAG-CA")==0) {
270                  /*  px in NetBSD  */                  /*  px in NetBSD  */
271                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PX, irq);                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PX, irq_path);
272                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
273          } else if (strcmp(device_name, "PMAG-DA")==0) {          } else if (strcmp(device_name, "PMAG-DA")==0) {
274                  /*  pxg in NetBSD  */                  /*  pxg in NetBSD  */
275                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PXG, irq);                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PXG, irq_path);
276                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
277          } else if (strcmp(device_name, "PMAG-EA")==0) {          } else if (strcmp(device_name, "PMAG-EA")==0) {
278                  /*  pxg+ in NetBSD: TODO  (not supported by the kernel                  /*  pxg+ in NetBSD: TODO  (not supported by the kernel
# Line 289  void dev_turbochannel_init(struct machin Line 282  void dev_turbochannel_init(struct machin
282          } else if (strcmp(device_name, "PMAG-FA")==0) {          } else if (strcmp(device_name, "PMAG-FA")==0) {
283                  /*  "pxg+ Turbo" in NetBSD  */                  /*  "pxg+ Turbo" in NetBSD  */
284                  dev_px_init(machine, mem, baseaddr,                  dev_px_init(machine, mem, baseaddr,
285                      DEV_PX_TYPE_PXGPLUSTURBO, irq);                      DEV_PX_TYPE_PXGPLUSTURBO, irq_path);
286                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
287          } else if (strcmp(device_name, "PMAG-DV")==0) {          } else if (strcmp(device_name, "PMAG-DV")==0) {
288                  /*  xcfb in NetBSD: TODO  */                  /*  xcfb in NetBSD: TODO  */
# Line 299  void dev_turbochannel_init(struct machin Line 292  void dev_turbochannel_init(struct machin
292                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
293          } else if (strcmp(device_name, "PMAG-JA")==0) {          } else if (strcmp(device_name, "PMAG-JA")==0) {
294                  /*  "Truecolor", mixed 8- and 24-bit  */                  /*  "Truecolor", mixed 8- and 24-bit  */
295                  dev_pmagja_init(machine, mem, baseaddr, irq);                  dev_pmagja_init(machine, mem, baseaddr, irq_path);
296                  rom_offset = 0;         /*  NOTE: 0, not 0x3c0000  */                  rom_offset = 0;         /*  NOTE: 0, not 0x3c0000  */
297          } else if (strcmp(device_name, "PMAG-RO")==0) {          } else if (strcmp(device_name, "PMAG-RO")==0) {
298                  /*  This works at least B/W in Ultrix, so far.  */                  /*  This works at least B/W in Ultrix, so far.  */
# Line 307  void dev_turbochannel_init(struct machin Line 300  void dev_turbochannel_init(struct machin
300                      VFB_GENERIC, 1280,1024, 1280,1024, 8, "PMAG-RO");                      VFB_GENERIC, 1280,1024, 1280,1024, 8, "PMAG-RO");
301                  /*  TODO: bt463 at offset 0x040000, not bt459  */                  /*  TODO: bt463 at offset 0x040000, not bt459  */
302                  dev_bt459_init(machine, mem, baseaddr + 0x40000, 0,                  dev_bt459_init(machine, mem, baseaddr + 0x40000, 0,
303                      fb, 8, irq, 0);             /*  TODO: type  */                      fb, 8, irq_path, 0);                /*  TODO: type  */
304                  dev_bt431_init(mem, baseaddr + 0x40010, fb, 8);  /*  cursor  */                  dev_bt431_init(mem, baseaddr + 0x40010, fb, 8);  /*  cursor  */
305                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
306          } else if (device_name[0] == '\0') {          } else if (device_name[0] == '\0') {
# Line 323  void dev_turbochannel_init(struct machin Line 316  void dev_turbochannel_init(struct machin
316          d->rom_skip = rom_skip;          d->rom_skip = rom_skip;
317    
318          nlen = strlen(device_name) + 30;          nlen = strlen(device_name) + 30;
319          name2 = malloc(nlen);          CHECK_ALLOCATION(name2 = malloc(nlen));
320          if (name2 == NULL) {  
                 fprintf(stderr, "out of memory in dev_turbochannel_init()\n");  
                 exit(1);  
         }  
321          if (*device_name)          if (*device_name)
322                  snprintf(name2, nlen, "turbochannel [%s]", device_name);                  snprintf(name2, nlen, "turbochannel [%s]", device_name);
323          else          else

Legend:
Removed from v.22  
changed lines
  Added in v.42

  ViewVC Help
Powered by ViewVC 1.1.26