reorg core
This commit is contained in:
parent
ba1b3e0678
commit
59cacbb1e5
|
@ -18,7 +18,7 @@ SEDLFAXOBJ += isac.o arcofi.o fsm.o isar.o
|
|||
FRITZOBJ := fritz_pci.o debug.o helper.o
|
||||
FRITZOBJ += isac.o arcofi.o fsm.o
|
||||
|
||||
OBJ_core := hisax_core.o hisax_dev.o
|
||||
OBJ_core := hisax_core.o hisax_stack.o hisax_dev.o
|
||||
OBJ_l1 := hisax_l1.o helper.o debug.o fsm.o
|
||||
OBJ_l2 := hisax_l2.o tei.o helper.o debug.o fsm.o
|
||||
OBJ_l3udss1 := hisax_l3.o helper.o debug.o fsm.o l3_udss1.o
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
/* $Id$
|
||||
*
|
||||
* Author Karsten Keil (keil@isdn4linux.de)
|
||||
* based on the teles driver from Jan den Ouden
|
||||
*
|
||||
* This file is (c) under GNU PUBLIC LICENSE
|
||||
*
|
||||
|
@ -17,7 +16,8 @@
|
|||
#endif
|
||||
|
||||
hisaxobject_t *hisax_objects = NULL;
|
||||
hisaxstack_t *hisax_stacklist = NULL;
|
||||
int core_debug;
|
||||
|
||||
static int debug = 0;
|
||||
|
||||
#ifdef MODULE
|
||||
|
@ -35,109 +35,6 @@ static moditem_t modlist[] = {
|
|||
{NULL, -1, ISDN_PID_NONE}
|
||||
};
|
||||
|
||||
int
|
||||
get_stack_cnt(void) {
|
||||
int cnt = 0;
|
||||
hisaxstack_t *st = hisax_stacklist;
|
||||
|
||||
while(st) {
|
||||
cnt++;
|
||||
st = st->next;
|
||||
}
|
||||
return(cnt);
|
||||
}
|
||||
|
||||
void
|
||||
get_stack_profile(iframe_t *frm) {
|
||||
hisaxstack_t *cst, *st = hisax_stacklist;
|
||||
int i,cnt = 0;
|
||||
int *dp,*ccnt;
|
||||
|
||||
while(st) {
|
||||
cnt++;
|
||||
if (cnt == frm->addr) {
|
||||
dp = frm->data.p;
|
||||
*dp++ = st->id;
|
||||
for (i=0; i<=MAX_LAYER; i++) {
|
||||
*dp++ = st->protocols[i];
|
||||
}
|
||||
ccnt=dp++;
|
||||
*ccnt=0;
|
||||
cst = st->child;
|
||||
while(cst) {
|
||||
(*ccnt)++;
|
||||
*dp++ = cst->id;
|
||||
for (i=0; i<=MAX_LAYER; i++) {
|
||||
*dp++ = cst->protocols[i];
|
||||
}
|
||||
cst = cst->next;
|
||||
}
|
||||
frm->len = (u_char *)dp - (u_char *)frm->data.p;
|
||||
return;
|
||||
}
|
||||
st = st->next;
|
||||
}
|
||||
frm->len = 0;
|
||||
}
|
||||
|
||||
static int
|
||||
get_free_stackid(hisaxstack_t *mst) {
|
||||
int id=1;
|
||||
hisaxstack_t *st;
|
||||
|
||||
if (!mst) {
|
||||
while(id<127) {
|
||||
st = hisax_stacklist;
|
||||
while (st) {
|
||||
if (st->id == id)
|
||||
break;
|
||||
st = st->next;
|
||||
}
|
||||
if (st)
|
||||
id++;
|
||||
else
|
||||
return(id);
|
||||
}
|
||||
return(0); /* 127 used controllers ??? */
|
||||
} else { /* new child_id */
|
||||
id = mst->id;
|
||||
while(id<0x7fffffff) {
|
||||
id += 0x00010000;
|
||||
st = mst->child;
|
||||
while (st) {
|
||||
if (st->id == id)
|
||||
break;
|
||||
st = st->next;
|
||||
}
|
||||
if (!st)
|
||||
return(id);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
hisaxstack_t *
|
||||
get_stack4id(int id)
|
||||
{
|
||||
hisaxstack_t *cst, *st = hisax_stacklist;
|
||||
|
||||
|
||||
if (debug & DEBUG_CORE_FUNC)
|
||||
printk(KERN_DEBUG "get_stack4id(%x)\n", id);
|
||||
while(st) {
|
||||
if (id == st->id)
|
||||
return(st);
|
||||
cst = st->child;
|
||||
while (cst) {
|
||||
if (cst->id == id)
|
||||
return(cst);
|
||||
cst = cst->next;
|
||||
}
|
||||
st = st->next;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
static hisaxobject_t *
|
||||
find_object(int layer, int protocol) {
|
||||
hisaxobject_t *obj = hisax_objects;
|
||||
|
@ -203,38 +100,6 @@ register_instance(hisaxstack_t *st, hisaxinstance_t *inst) {
|
|||
return(0);
|
||||
}
|
||||
|
||||
static hisaxstack_t *
|
||||
create_stack(hisaxinstance_t *inst, hisaxstack_t *master) {
|
||||
hisaxstack_t *newst;
|
||||
int err;
|
||||
|
||||
if (!inst)
|
||||
return(NULL);
|
||||
if (debug & DEBUG_CORE_FUNC)
|
||||
printk(KERN_DEBUG "create %s stack for %s\n",
|
||||
master ? "child" : "master", inst->obj->name);
|
||||
if (!(newst = kmalloc(sizeof(hisaxstack_t), GFP_ATOMIC))) {
|
||||
printk(KERN_ERR "kmalloc hisax_stack failed\n");
|
||||
return(NULL);
|
||||
}
|
||||
memset(newst, 0, sizeof(hisaxstack_t));
|
||||
register_instance(newst, inst);
|
||||
newst->id = get_free_stackid(master);
|
||||
if ((err = inst->obj->own_ctrl(newst, MGR_ADDLAYER | CONFIRM, NULL))) {
|
||||
printk(KERN_ERR "hisax_stack register failed err %d\n", err);
|
||||
kfree(newst);
|
||||
inst->obj->refcnt--;
|
||||
return(NULL);
|
||||
}
|
||||
if (master) {
|
||||
APPEND_TO_LIST(newst, master->child);
|
||||
} else {
|
||||
APPEND_TO_LIST(newst, hisax_stacklist);
|
||||
}
|
||||
printk(KERN_INFO "Stack for %s.%d added\n", inst->obj->name, newst->id);
|
||||
return(newst);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_object(hisaxobject_t *obj) {
|
||||
hisaxstack_t *st = hisax_stacklist;
|
||||
|
@ -258,77 +123,6 @@ remove_object(hisaxobject_t *obj) {
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
release_childstack(hisaxstack_t *st, hisaxstack_t *cst) {
|
||||
int l;
|
||||
hisaxinstance_t *inst, *tmp;
|
||||
|
||||
for(l=0;l<=MAX_LAYER;l++) {
|
||||
inst = cst->inst[l];
|
||||
while (inst) {
|
||||
tmp = inst->next;
|
||||
inst->obj->own_ctrl(cst, MGR_RELEASE | INDICATION,
|
||||
inst);
|
||||
inst = tmp;
|
||||
}
|
||||
}
|
||||
REMOVE_FROM_LISTBASE(cst, st->child);
|
||||
kfree(cst);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static int
|
||||
release_stack(hisaxstack_t *st) {
|
||||
int l;
|
||||
hisaxinstance_t *inst, *tmp;
|
||||
|
||||
while (st->child)
|
||||
release_childstack(st, st->child);
|
||||
for(l=0;l<=MAX_LAYER;l++) {
|
||||
inst = st->inst[l];
|
||||
while (inst) {
|
||||
tmp = inst->next;
|
||||
inst->obj->own_ctrl(st, MGR_RELEASE | INDICATION,
|
||||
inst);
|
||||
inst = tmp;
|
||||
}
|
||||
}
|
||||
REMOVE_FROM_LISTBASE(st, hisax_stacklist);
|
||||
kfree(st);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void
|
||||
release_stacks(hisaxobject_t *obj) {
|
||||
hisaxstack_t *st, *tmp;
|
||||
hisaxinstance_t *inst;
|
||||
int l, rel;
|
||||
|
||||
if (!obj->refcnt)
|
||||
return;
|
||||
st = hisax_stacklist;
|
||||
while (st) {
|
||||
rel = 0;
|
||||
for (l=0;l<=MAX_LAYER;l++) {
|
||||
inst = st->inst[l];
|
||||
while (inst) {
|
||||
if (inst->obj == obj)
|
||||
rel++;
|
||||
inst = inst->next;
|
||||
}
|
||||
}
|
||||
if (rel) {
|
||||
tmp = st->next;
|
||||
release_stack(st);
|
||||
st = tmp;
|
||||
} else
|
||||
st = st->next;
|
||||
}
|
||||
if (obj->refcnt)
|
||||
printk(KERN_WARNING "release_stacks obj %s refcnt is %d\n",
|
||||
obj->name, obj->refcnt);
|
||||
}
|
||||
|
||||
static int
|
||||
dummy_if(hisaxif_t *hif, u_int prim, uint nr, int dtyp, void *arg) {
|
||||
if (debug & DEBUG_DUMMY_FUNC)
|
||||
|
@ -496,6 +290,7 @@ HiSaxInit(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
core_debug = debug;
|
||||
err = init_hisaxdev(debug);
|
||||
return(err);
|
||||
}
|
||||
|
|
|
@ -9,10 +9,6 @@
|
|||
#include <linux/hisaxif.h>
|
||||
#include "helper.h"
|
||||
|
||||
/* intern exported lists */
|
||||
extern hisaxobject_t *hisax_objects;
|
||||
extern hisaxstack_t *hisax_stacklist;
|
||||
|
||||
#define HISAX_MAJOR 46
|
||||
#define HISAX_DEVBUF_SIZE 8192
|
||||
|
||||
|
@ -25,13 +21,24 @@ extern hisaxstack_t *hisax_stacklist;
|
|||
#define DEBUG_WDATA 0x2000
|
||||
|
||||
/* from hisax_dev.c */
|
||||
|
||||
extern int init_hisaxdev(int);
|
||||
extern int free_hisaxdev(void);
|
||||
|
||||
/* from hisax_core.c */
|
||||
/* from hisax_stack.c */
|
||||
|
||||
extern hisaxstack_t *hisax_stacklist;
|
||||
|
||||
extern void get_stack_profile(iframe_t *);
|
||||
extern int get_stack_cnt(void);
|
||||
extern hisaxstack_t *get_stack4id(int);
|
||||
extern hisaxstack_t *create_stack(hisaxinstance_t *, hisaxstack_t *);
|
||||
extern void release_stacks(hisaxobject_t *);
|
||||
|
||||
/* from hisax_core.c */
|
||||
|
||||
extern hisaxobject_t *hisax_objects;
|
||||
extern int core_debug;
|
||||
|
||||
extern void hisaxlock_core(void);
|
||||
extern void hisaxunlock_core(void);
|
||||
|
|
Loading…
Reference in New Issue