~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Linux/drivers/ieee1394/hosts.h

Version: ~ [ 2.4.0 ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 
  2 #ifndef _IEEE1394_HOSTS_H
  3 #define _IEEE1394_HOSTS_H
  4 
  5 #include <linux/wait.h>
  6 #include <linux/tqueue.h>
  7 #include <asm/semaphore.h>
  8 
  9 #include "ieee1394_types.h"
 10 #include "csr.h"
 11 
 12 
 13 struct hpsb_packet;
 14 
 15 struct hpsb_host {
 16 /* private fields (hosts, do not use them) */
 17         struct hpsb_host *next;
 18 
 19         struct list_head pending_packets;
 20         spinlock_t pending_pkt_lock;
 21         struct tq_struct timeout_tq;
 22 
 23         /* A bitmask where a set bit means that this tlabel is in use.
 24          * FIXME - should be handled per node instead of per bus. */
 25         u32 tlabel_pool[2];
 26         struct semaphore tlabel_count;
 27         spinlock_t tlabel_lock;
 28 
 29         int reset_retries;
 30         quadlet_t *topology_map;
 31         u8 *speed_map;
 32         struct csr_control csr;
 33 
 34         unsigned char iso_listen_count[64];
 35 
 36 /* readonly fields for hosts */
 37         struct hpsb_host_template *template;
 38 
 39         int node_count; /* number of identified nodes on this bus */
 40         int selfid_count; /* total number of SelfIDs received */
 41 
 42         nodeid_t node_id; /* node ID of this host */
 43         nodeid_t irm_id; /* ID of this bus' isochronous resource manager */
 44         nodeid_t busmgr_id; /* ID of this bus' bus manager */
 45 
 46         unsigned initialized:1; /* initialized and usable */
 47         unsigned in_bus_reset:1; /* in bus reset / SelfID stage */
 48         unsigned attempt_root:1; /* attempt to become root during next reset */
 49 
 50         /* this nodes' duties on the bus */
 51         unsigned is_root:1;
 52         unsigned is_cycmst:1;
 53         unsigned is_irm:1;
 54         unsigned is_busmgr:1;
 55 
 56 /* fields readable and writeable by the hosts */
 57 
 58         void *hostdata;
 59         int embedded_hostdata[0];
 60 };
 61 
 62 
 63 
 64 enum devctl_cmd {
 65         /* Host is requested to reset its bus and cancel all outstanding async
 66          * requests.  If arg == 1, it shall also attempt to become root on the
 67          * bus.  Return void. */
 68         RESET_BUS,
 69 
 70         /* Arg is void, return value is the hardware cycle counter value. */
 71         GET_CYCLE_COUNTER,
 72 
 73         /* Set the hardware cycle counter to the value in arg, return void.
 74          * FIXME - setting is probably not required. */
 75         SET_CYCLE_COUNTER,
 76 
 77         /* Configure hardware for new bus ID in arg, return void. */
 78         SET_BUS_ID,
 79 
 80         /* If arg true, start sending cycle start packets, stop if arg == 0.
 81          * Return void. */
 82         ACT_CYCLE_MASTER,
 83 
 84         /* Cancel all outstanding async requests without resetting the bus.
 85          * Return void. */
 86         CANCEL_REQUESTS,
 87 
 88         /* Decrease module usage count if arg == 0, increase otherwise.  Return
 89          * void. */
 90         MODIFY_USAGE,
 91 
 92         /* Start or stop receiving isochronous channel in arg.  Return void.
 93          * This acts as an optimization hint, hosts are not required not to
 94          * listen on unrequested channels. */
 95         ISO_LISTEN_CHANNEL,
 96         ISO_UNLISTEN_CHANNEL
 97 };
 98 
 99 struct hpsb_host_template {
100         struct hpsb_host_template *next;
101 
102         struct hpsb_host *hosts;
103         int number_of_hosts;
104 
105         /* fields above will be ignored and overwritten after registering */
106 
107         /* This should be the name of the driver (single word) and must not be
108          * NULL. */
109         const char *name;
110 
111         /* This function shall detect all available adapters of this type and
112          * call hpsb_get_host for each one.  The initialize_host function will
113          * be called to actually set up these adapters.  The number of detected
114          * adapters or zero if there are none must be returned.
115          */
116         int (*detect_hosts) (struct hpsb_host_template *template);
117 
118         /* After detecting and registering hosts, this function will be called
119          * for every registered host.  It shall set up the host to be fully
120          * functional for bus operations and return 0 for failure.
121          */
122         int (*initialize_host) (struct hpsb_host *host);
123 
124         /* To unload modules, this function is provided.  It shall free all
125          * resources this host is using (if host is not NULL) or free all
126          * resources globally allocated by the driver (if host is NULL).
127          */
128         void (*release_host) (struct hpsb_host *host); 
129 
130         /* This function must store a pointer to the configuration ROM into the
131          * location referenced to by pointer and return the size of the ROM. It
132          * may not fail.  If any allocation is required, it must be done
133          * earlier.
134          */
135         size_t (*get_rom) (struct hpsb_host *host, const quadlet_t **pointer);
136 
137         /* This function shall implement packet transmission based on
138          * packet->type.  It shall CRC both parts of the packet (unless
139          * packet->type == raw) and do byte-swapping as necessary or instruct
140          * the hardware to do so.  It can return immediately after the packet
141          * was queued for sending.  After sending, hpsb_sent_packet() has to be
142          * called.  Return 0 for failure.
143          * NOTE: The function must be callable in interrupt context.
144          */
145         int (*transmit_packet) (struct hpsb_host *host, 
146                                 struct hpsb_packet *packet);
147 
148         /* This function requests miscellanous services from the driver, see
149          * above for command codes and expected actions.  Return -1 for unknown
150          * command, though that should never happen.
151          */
152         int (*devctl) (struct hpsb_host *host, enum devctl_cmd command, int arg);
153 
154         /* This function is mainly to redirect local CSR reads/locks to the iso
155          * management registers (bus manager id, bandwidth available, channels
156          * available) to the hardware registers in OHCI.  reg is 0,1,2,3 for bus
157          * mgr, bwdth avail, ch avail hi, ch avail lo respectively (the same ids
158          * as OHCI uses).  data and compare are the new data and expected data
159          * respectively, return value is the old value.
160          */
161         quadlet_t (*hw_csr_reg) (struct hpsb_host *host, int reg,
162                                  quadlet_t data, quadlet_t compare);
163 };
164 
165 
166 
167 /* mid level internal use */
168 void register_builtin_lowlevels(void);
169 
170 /* high level internal use */
171 struct hpsb_highlevel;
172 void hl_all_hosts(struct hpsb_highlevel *hl, int init);
173 
174 /* 
175  * These functions are for lowlevel (host) driver use.
176  */
177 int hpsb_register_lowlevel(struct hpsb_host_template *tmpl);
178 void hpsb_unregister_lowlevel(struct hpsb_host_template *tmpl);
179 
180 /*
181  * Get a initialized host structure with hostdata_size bytes allocated in
182  * embedded_hostdata for free usage.  Returns NULL for failure.  
183  */
184 struct hpsb_host *hpsb_get_host(struct hpsb_host_template *tmpl, 
185                                 size_t hostdata_size);
186 
187 /*
188  * Increase / decrease host usage counter.  Increase function will return true
189  * only if successful (host still existed).  Decrease function expects host to
190  * exist.
191  */
192 int hpsb_inc_host_usage(struct hpsb_host *host);
193 void hpsb_dec_host_usage(struct hpsb_host *host);
194 
195 #endif /* _IEEE1394_HOSTS_H */
196 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.