2 * Copyright (c) 2010 Broadcom Corporation
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
11 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
13 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #include <linux/delay.h>
20 #include <asm/paccess.h>
22 #include <linux/module.h>
23 #include <linux/pci.h>
24 #include <linux/netdevice.h>
25 #include <linux/sched.h>
32 #define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */
33 #define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */
35 /* Global ASSERT type flag */
38 struct osl_info *osl_attach(void *pdev, uint bustype)
42 osh = kmalloc(sizeof(struct osl_info), GFP_ATOMIC);
45 memset(osh, 0, sizeof(struct osl_info));
46 osh->magic = OS_HANDLE_MAGIC;
50 void osl_detach(struct osl_info *osh)
55 ASSERT(osh->magic == OS_HANDLE_MAGIC);
59 #if defined(BCMDBG_ASSERT)
60 void osl_assert(char *exp, char *file, int line)
65 basename = strrchr(file, '/');
74 snprintf(tempbuf, 256,
75 "assertion \"%s\" failed: file \"%s\", line %d\n", exp,
78 /* Print assert message and give it time to be written to /var/log/messages */
79 if (!in_interrupt()) {
81 printk(KERN_ERR "%s", tempbuf);
82 printk(KERN_ERR "panic in %d seconds\n", delay);
83 set_current_state(TASK_INTERRUPTIBLE);
84 schedule_timeout(delay * HZ);
87 switch (g_assert_type) {
89 panic(KERN_ERR "%s", tempbuf);
92 printk(KERN_ERR "%s", tempbuf);
96 printk(KERN_ERR "%s", tempbuf);
101 #endif /* BCMDBG_ASSERT */
104 #endif /* defined(BCMDBG_ASSERT) */