Adam Hoka avatar Adam Hoka committed 0512773

rework os_netbsd.h

Comments (0)

Files changed (2)

kernel/OS/NetBSD/os_netbsd.h

 #include <machine/pio.h>
 #include <machine/vmparam.h>
 
+#ifdef _KERNEL
+#include <sys/bus.h>
+#include <dev/pci/pcivar.h>
+#endif
+// XXX avoid conflict: I hope it wont break anything!
+#undef PCI_INTERRUPT_LINE
+#endif
+
 #include <oss_errno.h>
 
 // XXX PORT
 				 unsigned long long ticks);
 extern void oss_untimeout (timeout_id_t id);
 
-#include "kernel/OS/NetBSD/wrapper/bsddefs.h"
-
 #define uiomove oss_uiomove
 typedef struct uio uio_t;
 extern int oss_uiomove (void *address, size_t nbytes, enum uio_rw rwflag,
 #undef HZ
 #define OSS_HZ hz
 
+typedef struct device dev_info_t;
+typedef int64_t oss_int64_t;		/* Signed 64 bit integer */
+typedef uint64_t oss_uint64_t;		/* Unsigned 64 bit integer */
+typedef off_t offset_t;
+
+/*
+ * Some integer types
+ */
+#if defined(__amd64__)
+typedef unsigned long long oss_native_word;	/* Same as the address and status register size */
+#else
+typedef unsigned long oss_native_word;	/* Same as the address and status register size */
+#endif
+
 /* The soundcard.h could be in a nonstandard place so include it here. */
 #include "soundcard.h"
 
 #define ACTIVATE_TIMER(name, proc, time) \
   name = oss_timeout((timeout_func_t)proc, (void*)&name, time)
 
-#endif
-
 struct fileinfo
 {
   int mode;			/* Open mode */
 
 #define GET_PROCESS_PID(f)	f->pid
 #define GET_PROCESS_UID(x)	oss_get_uid()
-#define GET_PROCESS_NAME(f)	f->cmd
+#define GET_PROCESS_NAME(f)	l->l_name
 
 #define abs(x)                  ((x) >= 0 ? (x) : -(x))
 
+extern int oss_get_uid (void);
+
+extern void cmn_err (int level, char *format, ...);
+#define CE_CONT		0
+#define CE_NOTE		1
+#define CE_WARN		2
+#define CE_PANIC	3
+
 /*
  * PCI config space access (in os.c)
  */
 extern char *oss_pci_read_devpath (dev_info_t * dip);
+
+#ifdef _KERNEL
+struct _oss_device_t
+{
+  dev_info_t *dip;
+  void *osid;
+  void *devc;
+  char *name;
+  char *hw_info;
+  int cardnum;
+  int dev_type;
+  int instance;
+  int available;
+  int major;
+  char nick[16];
+  char modname[16];
+  char handle[32];
+  int num_audio_engines;
+  int num_audioplay, num_audiorec, num_audioduplex;
+  int num_mididevs;
+  int num_mixerdevs;
+  int num_loopdevs;
+  int first_mixer;	/* This must be set to -1 by osdev_create() */
+
+  int intrcount;
+  int ackcount;
+  volatile int refcount; /* Nonzero means that the device is needed by some other (virtual) driver. */
+  bus_space_handle_t bus_space_handles[6]; /* I hope that will be enough */
+  struct pci_attach_args pa;
+};
+
+typedef struct _netbsd_dma_handle {
+  void *kva;
+  bus_dma_segment_t seg;
+  bus_dmamap_t map;
+  size_t size;
+  int nseg;
+} *oss_dma_handle_t;
+
+typedef int ddi_iblock_cookie_t;
+
+extern void oss_udelay (unsigned long t);
+
+extern oss_device_t *osdev_create (dev_info_t * dip, int dev_type,
+				   int instance, const char *nick,
+				   const char *handle);
+extern void osdev_delete (oss_device_t * osdev);
+
+extern char *oss_pci_read_devpath (dev_info_t * dip);
+extern int pci_read_config_byte (oss_device_t * osdev, offset_t where,
+				 unsigned char *val);
+extern int pci_read_config_irq (oss_device_t * osdev, offset_t where,
+				unsigned char *val);
+extern int pci_read_config_word (oss_device_t * osdev, offset_t where,
+				 unsigned short *val);
+extern int pci_read_config_dword (oss_device_t * osdev, offset_t where,
+				  unsigned int *val);
+extern int pci_write_config_byte (oss_device_t * osdev, offset_t where,
+				  unsigned char val);
+extern int pci_write_config_word (oss_device_t * osdev, offset_t where,
+				  unsigned short val);
+extern int pci_write_config_dword (oss_device_t * osdev, offset_t where,
+				   unsigned int val);
+#ifndef OSS_CONFIG_H
+/* These definitions must match with oss_config.h */
+typedef int (*oss_tophalf_handler_t) (struct _oss_device_t * osdev);
+typedef void (*oss_bottomhalf_handler_t) (struct _oss_device_t * osdev);
+#endif
+
+extern int oss_register_interrupts (oss_device_t * osdev, int intrnum,
+				    oss_tophalf_handler_t top,
+				    oss_bottomhalf_handler_t bottom);
+extern void oss_unregister_interrupts (oss_device_t * osdev);
+
+void *oss_contig_malloc (oss_device_t * osdev, int size, oss_uint64_t memlimit,
+			 oss_native_word * phaddr, oss_dma_handle_t * handlep);
+void oss_contig_free (oss_device_t * osdev, oss_dma_handle_t handle);
+
+extern void oss_register_module (char *name);
+extern void oss_unregister_module (char *name);
+extern void *oss_find_minor_info (int dev_class, int instance);
+extern int oss_find_minor (int dev_class, int instance);
+extern void oss_inc_intrcount (oss_device_t * osdev, int claimed);
+#else
+/* define as incomplete type for audio_core.h */
+struct _netbsd_dma_handle;
+typedef struct _netbsd_dma_handle *oss_dma_handle_t;
+#endif	/* _KERNEL */
+
+#define FP_SUPPORT
+
+#ifdef FP_SUPPORT
+typedef short fp_env_t[512];
+typedef unsigned int fp_flags_t[4];
+extern int oss_fp_check (void);
+extern void oss_fp_save (short *envbuf, fp_flags_t flags);
+extern void oss_fp_restore (short *envbuf, fp_flags_t flags);
+#   define FP_SAVE(envbuf, flags)		oss_fp_save(envbuf, flags)
+#   define FP_RESTORE(envbuf, flags)		oss_fp_restore(envbuf, flags)
+#endif

kernel/OS/NetBSD/wrapper/bsddefs.h

  */
 #define COPYING13 Copyright (C) Hannu Savolainen and Dev Mazumdar 2000-2006. All rights reserved.
 
-#include <sys/types.h>
+#ifdef _KERNEL
+#include <sys/param.h>
 #include <sys/bus.h>
 #include <dev/pci/pcivar.h>
+#endif
 
 // XXX avoid conflict: I hope it wont break anything!
 #undef PCI_INTERRUPT_LINE
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.