/[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 4 by dpavlin, Mon Oct 8 16:18:00 2007 UTC revision 34 by dpavlin, Mon Oct 8 16:21:17 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2003-2005  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.40 2005/02/18 06:19:19 debug Exp $   *  $Id: dev_turbochannel.c,v 1.48 2006/12/30 13:30:59 debug Exp $
29   *     *  
30   *  Generic framework for TURBOchannel devices, used in DECstation machines.   *  Generic framework for TURBOchannel devices, used in DECstation machines.
31   */   */
# Line 41  Line 41 
41  #include "sfbreg.h"  #include "sfbreg.h"
42    
43    
44    #define DEVICE_NAME_BUFLEN              9
45    #define CARD_NAME_BUFLEN                9
46    #define CARD_FIRMWARE_BUFLEN            5
47    
48  struct turbochannel_data {  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[9];         /*  NUL-terminated  */          char            device_name[DEVICE_NAME_BUFLEN];  /*  NUL-terminated  */
56    
57          /*  These should be terminated with spaces  */          /*  These should be terminated with spaces  */
58          char            card_firmware_version[8];          char            card_firmware_version[CARD_NAME_BUFLEN];
59          char            card_vendor_name[8];          char            card_vendor_name[CARD_NAME_BUFLEN];
60          char            card_module_name[8];          char            card_module_name[CARD_NAME_BUFLEN];
61          char            card_firmware_type[4];          char            card_firmware_type[CARD_FIRMWARE_BUFLEN];
62  };  };
63    
64    
65  /*  /*
66   *  dev_turbochannel_access():   *  dev_turbochannel_access():
67   */   */
68  int dev_turbochannel_access(struct cpu *cpu, struct memory *mem,  DEVICE_ACCESS(turbochannel)
         uint64_t relative_addr, unsigned char *data, size_t len,  
         int writeflag, void *extra)  
69  {  {
70          struct turbochannel_data *d = extra;          struct turbochannel_data *d = extra;
71          uint64_t idata = 0, odata = 0;          uint64_t idata = 0, odata = 0;
72    
73          idata = memory_readmax64(cpu, data, len);          if (writeflag == MEM_WRITE)
74                    idata = memory_readmax64(cpu, data, len);
75    
76          relative_addr += d->rom_skip;          relative_addr += d->rom_skip;
77    
# Line 175  int dev_turbochannel_access(struct cpu * Line 177  int dev_turbochannel_access(struct cpu *
177   */   */
178  void dev_turbochannel_init(struct machine *machine, struct memory *mem,  void dev_turbochannel_init(struct machine *machine, struct memory *mem,
179          int slot_nr, uint64_t baseaddr, uint64_t endaddr,          int slot_nr, uint64_t baseaddr, uint64_t endaddr,
180          char *device_name, int irq)          char *device_name, char *irq_path)
181  {  {
182          struct vfb_data *fb;          struct vfb_data *fb;
183          struct turbochannel_data *d;          struct turbochannel_data *d;
184          int rom_offset = 0x3c0000;          int rom_offset=0x3c0000, rom_length=DEV_TURBOCHANNEL_LEN, rom_skip=0;
         int rom_length = DEV_TURBOCHANNEL_LEN;  
         int rom_skip = 0;  
185          char *name2;          char *name2;
186            size_t nlen;
187    
188          if (device_name == NULL)          if (device_name == NULL)
189                  return;                  return;
# Line 201  void dev_turbochannel_init(struct machin Line 202  void dev_turbochannel_init(struct machin
202          d->slot_nr  = slot_nr;          d->slot_nr  = slot_nr;
203          d->baseaddr = baseaddr;          d->baseaddr = baseaddr;
204          d->endaddr  = endaddr;          d->endaddr  = endaddr;
         d->irq      = irq;  
205    
206          strcpy(d->device_name, device_name);          strlcpy(d->device_name, device_name, DEVICE_NAME_BUFLEN);
207    
208          strncpy(d->card_firmware_version, "V5.3a   ", 8);          strncpy(d->card_firmware_version, "V5.3a   ", CARD_NAME_BUFLEN);
209          strncpy(d->card_vendor_name,      "DEC     ", 8);          strncpy(d->card_vendor_name,      "DEC     ", CARD_NAME_BUFLEN);
210          strncpy(d->card_firmware_type,    "TCF0", 4);          strncpy(d->card_firmware_type,    "TCF0", CARD_FIRMWARE_BUFLEN);
211    
212          memset(d->card_module_name, ' ', 8);          memset(d->card_module_name, ' ', 8);
213          strncpy(d->card_module_name, device_name, strlen(device_name));          memcpy(d->card_module_name, device_name, strlen(device_name));
214    
215          /*          /*
216           *  According to NetBSD/pmax:           *  According to NetBSD/pmax:
# Line 231  void dev_turbochannel_init(struct machin Line 231  void dev_turbochannel_init(struct machin
231    
232          if (strcmp(device_name, "PMAD-AA")==0) {          if (strcmp(device_name, "PMAD-AA")==0) {
233                  /*  le in NetBSD, Lance ethernet  */                  /*  le in NetBSD, Lance ethernet  */
234                  dev_le_init(machine, mem, baseaddr, 0, 0, irq, DEV_LE_LENGTH);                  dev_le_init(machine, mem, baseaddr, 0, 0,
235                        irq_path, DEV_LE_LENGTH);
236                  /*  One ROM at 0x1c03e0, and one at 0x3c0000.  */                  /*  One ROM at 0x1c03e0, and one at 0x3c0000.  */
237                  rom_skip = 0x300;                  rom_skip = 0x300;
238                  rom_offset = 0x1c0000;                  rom_offset = 0x1c0000;
239                  rom_length = 0x201000;                  rom_length = 0x201000;
240          } else if (strcmp(device_name, "PMAZ-AA")==0) {          } else if (strcmp(device_name, "PMAZ-AA")==0) {
241                  /*  asc in NetBSD, SCSI  */                  /*  asc in NetBSD, SCSI  */
242                  dev_asc_init(machine, mem, baseaddr, irq, d,                  dev_asc_init(machine, mem, baseaddr, irq_path, d,
243                      DEV_ASC_DEC, NULL, NULL);                      DEV_ASC_DEC, NULL, NULL);
244                  rom_offset = 0xc0000;                  rom_offset = 0xc0000;
245                  /*  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 246  void dev_turbochannel_init(struct machin Line 247  void dev_turbochannel_init(struct machin
247          } else if (strcmp(device_name, "PMAG-AA")==0) {          } else if (strcmp(device_name, "PMAG-AA")==0) {
248                  /*  mfb in NetBSD  */                  /*  mfb in NetBSD  */
249                  fb = dev_fb_init(machine, mem, baseaddr + VFB_MFB_VRAM,                  fb = dev_fb_init(machine, mem, baseaddr + VFB_MFB_VRAM,
250                      VFB_GENERIC, 1280, 1024, 2048, 1024, 8, device_name, 1);                      VFB_GENERIC, 1280, 1024, 2048, 1024, 8, device_name);
251                  /*  bt455 = palette, bt431 = cursor  */                  /*  bt455 = palette, bt431 = cursor  */
252                  dev_bt455_init(mem, baseaddr + VFB_MFB_BT455, fb);                  dev_bt455_init(mem, baseaddr + VFB_MFB_BT455, fb);
253                  dev_bt431_init(mem, baseaddr + VFB_MFB_BT431, fb, 8);                  dev_bt431_init(mem, baseaddr + VFB_MFB_BT431, fb, 8);
# Line 254  void dev_turbochannel_init(struct machin Line 255  void dev_turbochannel_init(struct machin
255          } else if (strcmp(device_name, "PMAG-BA")==0) {          } else if (strcmp(device_name, "PMAG-BA")==0) {
256                  /*  cfb in NetBSD  */                  /*  cfb in NetBSD  */
257                  fb = dev_fb_init(machine, mem, baseaddr, VFB_GENERIC,                  fb = dev_fb_init(machine, mem, baseaddr, VFB_GENERIC,
258                      1024,864, 1024,1024,8, device_name, 1);                      1024,864, 1024,1024,8, device_name);
259                  dev_bt459_init(machine, mem, baseaddr + VFB_CFB_BT459,                  dev_bt459_init(machine, mem, baseaddr + VFB_CFB_BT459,
260                      baseaddr + 0x300000, fb, 8, irq, BT459_BA);                      baseaddr + 0x300000, fb, 8, irq_path, BT459_BA);
261                  /*  ROM at both 0x380000 and 0x3c0000?  */                  /*  ROM at both 0x380000 and 0x3c0000?  */
262                  rom_offset = 0x380000;                  rom_offset = 0x380000;
263                  rom_length = 0x080000;                  rom_length = 0x080000;
# Line 264  void dev_turbochannel_init(struct machin Line 265  void dev_turbochannel_init(struct machin
265                  /*  sfb in NetBSD  */                  /*  sfb in NetBSD  */
266                  /*  TODO: This is not working with Ultrix yet.  */                  /*  TODO: This is not working with Ultrix yet.  */
267                  fb = dev_fb_init(machine, mem, baseaddr + SFB_OFFSET_VRAM,                  fb = dev_fb_init(machine, mem, baseaddr + SFB_OFFSET_VRAM,
268                      VFB_GENERIC, 1280,1024, 1280,1024,8, device_name, 1);                      VFB_GENERIC, 1280,1024, 1280,1024,8, device_name);
269                  dev_sfb_init(machine, mem, baseaddr + SFB_ASIC_OFFSET, fb);                  dev_sfb_init(machine, mem, baseaddr + SFB_ASIC_OFFSET, fb);
270                  /*  TODO: the CLEAR doesn't get through, as the address                  /*  TODO: the CLEAR doesn't get through, as the address
271                          range is already in use by the asic  */                          range is already in use by the asic  */
272                  dev_bt459_init(machine, mem, baseaddr + SFB_OFFSET_BT459,                  dev_bt459_init(machine, mem, baseaddr + SFB_OFFSET_BT459,
273                      baseaddr + SFB_CLEAR, fb, 8, irq, BT459_BBA);                      baseaddr + SFB_CLEAR, fb, 8, irq_path, BT459_BBA);
274                  rom_offset = 0x0;       /*  ? TODO  */                  rom_offset = 0x0;       /*  ? TODO  */
275          } else if (strcmp(device_name, "PMAG-CA")==0) {          } else if (strcmp(device_name, "PMAG-CA")==0) {
276                  /*  px in NetBSD  */                  /*  px in NetBSD  */
277                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PX, irq);                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PX, irq_path);
278                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
279          } else if (strcmp(device_name, "PMAG-DA")==0) {          } else if (strcmp(device_name, "PMAG-DA")==0) {
280                  /*  pxg in NetBSD  */                  /*  pxg in NetBSD  */
281                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PXG, irq);                  dev_px_init(machine, mem, baseaddr, DEV_PX_TYPE_PXG, irq_path);
282                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
283          } else if (strcmp(device_name, "PMAG-EA")==0) {          } else if (strcmp(device_name, "PMAG-EA")==0) {
284                  /*  pxg+ in NetBSD: TODO  (not supported by the kernel                  /*  pxg+ in NetBSD: TODO  (not supported by the kernel
# Line 287  void dev_turbochannel_init(struct machin Line 288  void dev_turbochannel_init(struct machin
288          } else if (strcmp(device_name, "PMAG-FA")==0) {          } else if (strcmp(device_name, "PMAG-FA")==0) {
289                  /*  "pxg+ Turbo" in NetBSD  */                  /*  "pxg+ Turbo" in NetBSD  */
290                  dev_px_init(machine, mem, baseaddr,                  dev_px_init(machine, mem, baseaddr,
291                      DEV_PX_TYPE_PXGPLUSTURBO, irq);                      DEV_PX_TYPE_PXGPLUSTURBO, irq_path);
292                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
293          } else if (strcmp(device_name, "PMAG-DV")==0) {          } else if (strcmp(device_name, "PMAG-DV")==0) {
294                  /*  xcfb in NetBSD: TODO  */                  /*  xcfb in NetBSD: TODO  */
295                  fb = dev_fb_init(machine, mem, baseaddr + 0x2000000,                  fb = dev_fb_init(machine, mem, baseaddr + 0x2000000,
296                      VFB_DEC_MAXINE, 0, 0, 0, 0, 0, "PMAG-DV", 1);                      VFB_DEC_MAXINE, 0, 0, 0, 0, 0, "PMAG-DV");
297                  /*  TODO:  not yet usable, needs a IMS332 vdac  */                  /*  TODO:  not yet usable, needs a IMS332 vdac  */
298                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
299          } else if (strcmp(device_name, "PMAG-JA")==0) {          } else if (strcmp(device_name, "PMAG-JA")==0) {
300                  /*  "Truecolor", mixed 8- and 24-bit  */                  /*  "Truecolor", mixed 8- and 24-bit  */
301                  dev_pmagja_init(machine, mem, baseaddr, irq);                  dev_pmagja_init(machine, mem, baseaddr, irq_path);
302                  rom_offset = 0;         /*  NOTE: 0, not 0x3c0000  */                  rom_offset = 0;         /*  NOTE: 0, not 0x3c0000  */
303          } else if (strcmp(device_name, "PMAG-RO")==0) {          } else if (strcmp(device_name, "PMAG-RO")==0) {
304                  /*  This works at least B/W in Ultrix, so far.  */                  /*  This works at least B/W in Ultrix, so far.  */
305                  fb = dev_fb_init(machine, mem, baseaddr + 0x200000,                  fb = dev_fb_init(machine, mem, baseaddr + 0x200000,
306                      VFB_GENERIC, 1280,1024, 1280,1024, 8, "PMAG-RO", 1);                      VFB_GENERIC, 1280,1024, 1280,1024, 8, "PMAG-RO");
307                  /*  TODO: bt463 at offset 0x040000, not bt459  */                  /*  TODO: bt463 at offset 0x040000, not bt459  */
308                  dev_bt459_init(machine, mem, baseaddr + 0x40000, 0,                  dev_bt459_init(machine, mem, baseaddr + 0x40000, 0,
309                      fb, 8, irq, 0);             /*  TODO: type  */                      fb, 8, irq_path, 0);                /*  TODO: type  */
310                  dev_bt431_init(mem, baseaddr + 0x40010, fb, 8);  /*  cursor  */                  dev_bt431_init(mem, baseaddr + 0x40010, fb, 8);  /*  cursor  */
311                  rom_offset = 0x3c0000;                  rom_offset = 0x3c0000;
312          } else if (device_name[0] == '\0') {          } else if (device_name[0] == '\0') {
# Line 320  void dev_turbochannel_init(struct machin Line 321  void dev_turbochannel_init(struct machin
321    
322          d->rom_skip = rom_skip;          d->rom_skip = rom_skip;
323    
324          name2 = malloc(strlen(device_name) + 30);          nlen = strlen(device_name) + 30;
325            name2 = malloc(nlen);
326          if (name2 == NULL) {          if (name2 == NULL) {
327                  fprintf(stderr, "out of memory in dev_turbochannel_init()\n");                  fprintf(stderr, "out of memory in dev_turbochannel_init()\n");
328                  exit(1);                  exit(1);
329          }          }
330          if (*device_name)          if (*device_name)
331                  sprintf(name2, "turbochannel [%s]", device_name);                  snprintf(name2, nlen, "turbochannel [%s]", device_name);
332          else          else
333                  sprintf(name2, "turbochannel");                  snprintf(name2, nlen, "turbochannel");
334    
335          memory_device_register(mem, name2, baseaddr + rom_offset + rom_skip,          memory_device_register(mem, name2, baseaddr + rom_offset + rom_skip,
336              rom_length-rom_skip, dev_turbochannel_access, d, MEM_DEFAULT, NULL);              rom_length-rom_skip, dev_turbochannel_access, d, DM_DEFAULT, NULL);
337  }  }
338    

Legend:
Removed from v.4  
changed lines
  Added in v.34

  ViewVC Help
Powered by ViewVC 1.1.26