--- tme/generic/bus-device.c 2018/04/24 16:41:10 1.1.1.4 +++ tme/generic/bus-device.c 2018/04/24 16:42:57 1.1.1.5 @@ -1,4 +1,4 @@ -/* $Id: bus-device.c,v 1.1.1.4 2018/04/24 16:41:10 root Exp $ */ +/* $Id: bus-device.c,v 1.1.1.5 2018/04/24 16:42:57 root Exp $ */ /* generic/bus-device.c - implementation of a generic bus device support: */ @@ -34,7 +34,7 @@ */ #include -_TME_RCSID("$Id: bus-device.c,v 1.1.1.4 2018/04/24 16:41:10 root Exp $"); +_TME_RCSID("$Id: bus-device.c,v 1.1.1.5 2018/04/24 16:42:57 root Exp $"); /* includes: */ #include @@ -42,6 +42,49 @@ _TME_RCSID("$Id: bus-device.c,v 1.1.1.4 /* include the automatically-generated bus-device functions: */ #include "bus-device-auto.c" +/* this adds a generic bus TLB set: */ +int +tme_bus_device_tlb_set_add(struct tme_bus_device *bus_device, + unsigned long tlb_count, + struct tme_bus_tlb *tlb) +{ + struct tme_bus_tlb_set_info tlb_set_info; + struct tme_token *token; + struct tme_bus_connection *conn_bus; + int rc; + + /* make the TLB set information, and allocate a token for each TLB + entry: */ + assert (tlb_count > 0); + memset(&tlb_set_info, 0, sizeof(tlb_set_info)); + tlb_set_info.tme_bus_tlb_set_info_token0 = tme_new(struct tme_token, tlb_count); + tlb_set_info.tme_bus_tlb_set_info_token_stride = sizeof(struct tme_token); + tlb_set_info.tme_bus_tlb_set_info_token_count = tlb_count; + tlb_set_info.tme_bus_tlb_set_info_bus_context = NULL; + + /* connect each TLB entry with its token: */ + token = tlb_set_info.tme_bus_tlb_set_info_token0; + do { + tme_token_init(token); + tlb->tme_bus_tlb_token = token; + tlb++; + token++; + } while (--tlb_count); + + /* get our bus connection: */ + conn_bus + = tme_memory_atomic_pointer_read(struct tme_bus_connection *, + bus_device->tme_bus_device_connection, + &bus_device->tme_bus_device_connection_rwlock); + + /* add the TLB set: */ + rc + = ((*conn_bus->tme_bus_tlb_set_add) + (conn_bus, + &tlb_set_info)); + return (rc); +} + /* this scores a connection: */ int tme_bus_device_connection_score(struct tme_connection *conn, unsigned int *_score)