5171d409a5
This now provides slightly more functionality than the FreeBSD layer1-newbus interface. It was meant to be a simple change to one header and a few c files, but the change rippled all through various stuff. To prevent a change to the kernel<->userland interface right now the kernel is now lying about card types to userland (but who cares). This will be fixed when the userland interface changes, after layer 3 <-> layer 4 has been fixed. Functional changes: Provide a clean interface for hardware drivers to attach to the upper layers. This will need another small change in the B-channel handling when a similar change to the layer 3 <-> layer 4 interface happens. Avoid passing indices into global arrays of pointers around, instead pass the pointers itself. Don't code hardware driver types by predefined magic numbers (think LKM). Prepare for detachable drivers (think pcmcia). While there remove some sets of function pointers always pointing to the same function (meant to be the configurable set of D channel protocol handlers). It is unlikely another supported D-channel protocol will fit into that (maximal layer interface) abstraction. When we get support for another protocol, we will need to come up with a workable interface. Besides, the old implementation was, uhm, strange.
106 lines
3.8 KiB
C
106 lines
3.8 KiB
C
/* $NetBSD: i4b_l1l2.h,v 1.2 2001/03/24 12:40:31 martin Exp $ */
|
|
|
|
/*
|
|
* Copyright (c) 2001 Martin Husemann. All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions
|
|
* are met:
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer.
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
* SUCH DAMAGE.
|
|
*
|
|
*/
|
|
|
|
#ifndef _I4B_L1L2_H_
|
|
#define _I4B_L1L2_H_
|
|
|
|
/*
|
|
* This file defines the interface between layer 1 (physical card hardware)
|
|
* and layer 2 of a passive ISDN card (i.e. a card that does not run it's
|
|
* own ISDN stack in firmware).
|
|
*
|
|
* The layer 2 is represented in all functions by an opaque layer2token type,
|
|
* internally representing the layer 2 struct softc (which is unknown to
|
|
* layer 1).
|
|
* Similarily layer 1 is represented by a layer1token type, typically
|
|
* representing its struct device derived softc pointer. If someone ever
|
|
* creates a multi-bri passive isdn card, it would need to be something
|
|
* else (i.e. pointer to a struct containing the softc pointer and a
|
|
* interface index), so we do not define it as 'struct device *' here.
|
|
*/
|
|
|
|
typedef void * isdn_layer2token;
|
|
typedef void * isdn_layer1token;
|
|
|
|
/*
|
|
* Each driver attaching to layer 2 via this interface provides a pointer
|
|
* to a struct of function pointers used to communicate with layer 1, while
|
|
* layer 1 calls layer 2 functions directly (see below).
|
|
*
|
|
* Layer 1 functions called from layer 2:
|
|
*/
|
|
struct isdn_layer1_bri_driver {
|
|
/* Activate card and enable interrupts or disable it. */
|
|
int (*enable)(isdn_layer1token, int);
|
|
|
|
/* Request to transmit data. */
|
|
int (*ph_data_req)(isdn_layer1token, struct mbuf *, int);
|
|
|
|
/* Request to activate layer 1. */
|
|
int (*ph_activate_req)(isdn_layer1token);
|
|
|
|
/* Request to execute an internal command. */
|
|
int (*mph_command_req)(isdn_layer1token, int, void *);
|
|
|
|
/* switch on/off trace */
|
|
void (*n_mgmt_command)(isdn_layer1token, int cmd, void *);
|
|
};
|
|
|
|
/*
|
|
* Support functions called from upper layers
|
|
*/
|
|
isdn_layer2token isdn_find_l2_by_bri(int);
|
|
|
|
/*
|
|
* Layer 2 functions called by layer 1:
|
|
*/
|
|
|
|
/* Attach a new BRI and return it's layer 2 token. */
|
|
isdn_layer2token isdn_attach_layer1_bri(isdn_layer1token,
|
|
const char *, const char *,
|
|
const struct isdn_layer1_bri_driver *);
|
|
|
|
/* Detach a BRI. */
|
|
int isdn_detach_layer1_bri(isdn_layer2token);
|
|
|
|
/* Pass data up to layer 2. */
|
|
int isdn_layer2_data_ind(isdn_layer2token, struct mbuf *);
|
|
|
|
/* Pass a layer 1 activation/deactivation to layer 2. */
|
|
int isdn_layer2_activate_ind(isdn_layer2token, int);
|
|
|
|
/* Pass trace data to layer 2. */
|
|
struct i4b_trace_hdr; /* from i4b_trace.h */
|
|
int isdn_layer2_trace_ind(isdn_layer2token, struct i4b_trace_hdr *, size_t, unsigned char *);
|
|
|
|
/* Pass status informations to layer 2. */
|
|
int isdn_layer2_status_ind(isdn_layer2token, int, int);
|
|
|
|
#endif /* !_I4B_L1L2_H_ */
|
|
|