--- tme/generic/bus-device-auto.sh 2018/04/24 16:39:48 1.1.1.1 +++ tme/generic/bus-device-auto.sh 2018/04/24 16:41:13 1.1.1.2 @@ -1,6 +1,6 @@ #! /bin/sh -# $Id: bus-device-auto.sh,v 1.1.1.1 2018/04/24 16:39:48 root Exp $ +# $Id: bus-device-auto.sh,v 1.1.1.2 2018/04/24 16:41:13 root Exp $ # generic/bus-device-auto.sh - automatically generates C code for # generic bus device support: @@ -48,7 +48,7 @@ done PROG=`basename $0` cat <tme_bus_tlb_addr_last);" - echo " if (address_init < TME_ATOMIC_READ(tme_bus_addr_t, tlb->tme_bus_tlb_addr_first)" - echo " || address_init > tlb_addr_last" + echo " if (tme_bus_tlb_is_invalid(tlb)" + echo " || address_init < tlb->tme_bus_tlb_addr_first" + echo " || address_init > tlb->tme_bus_tlb_addr_last" echo " || (tlb->tme_bus_tlb_emulator_off_${name} == TME_EMULATOR_OFF_UNDEF" echo " && !(tlb->tme_bus_tlb_cycles_ok & TME_BUS_CYCLE_${capname}))) {" echo "" + echo " /* unbusy this TLB entry for filling: */" + echo " tme_bus_tlb_unbusy_fill(tlb);" + echo "" echo " /* reserve this TLB entry: */" - echo " tme_bus_tlb_reserve(tlb, &tlb_local);" + echo " tlb_local.tme_bus_tlb_global = tlb;" echo " tlb = &tlb_local;" echo "" echo " /* get our bus connection: */" - echo " conn_bus = TME_ATOMIC_READ(struct tme_bus_connection *," - echo " bus_device->tme_bus_device_connection);" + echo " conn_bus = tme_memory_atomic_pointer_read(struct tme_bus_connection *," + echo " bus_device->tme_bus_device_connection," + echo " &bus_device->tme_bus_device_connection_rwlock);" echo "" echo " /* unlock the device: */" echo " (*bus_device->tme_bus_device_unlock)(bus_device, locks);" @@ -317,15 +323,11 @@ while test ${i_width} != 32; do echo " return (err);" echo " }" echo "" - echo " /* the TLB entry must cover this address and allow ${naming}: */" - echo " tlb_addr_last = TME_ATOMIC_READ(tme_bus_addr_t, tlb->tme_bus_tlb_addr_last);" - echo " assert (address_init >= TME_ATOMIC_READ(tme_bus_addr_t, tlb->tme_bus_tlb_addr_first)" - echo " && address_init <= tlb_addr_last" - echo " && (tlb->tme_bus_tlb_emulator_off_${name} != TME_EMULATOR_OFF_UNDEF" - echo " || (tlb->tme_bus_tlb_cycles_ok & TME_BUS_CYCLE_${capname})));" - echo "" echo " /* store the TLB entry: */" echo " tme_bus_tlb_back(tlb);" + echo "" + echo " /* loop to check the newly filled TLB entry: */" + echo " continue;" echo " }" echo "" echo " /* if this TLB entry allows fast ${naming}: */" @@ -333,7 +335,7 @@ while test ${i_width} != 32; do echo "" echo " /* see how many bytes we can fast ${name} ${from} this TLB entry," echo " starting at this address: */" - echo " count_minus_one = (tlb_addr_last - address_init);" + echo " count_minus_one = (tlb->tme_bus_tlb_addr_last - address_init);" echo "" echo " /* ${name} that many bytes or size bytes, whichever is smaller: */" echo " count_minus_one = TME_MIN(count_minus_one," @@ -341,19 +343,11 @@ while test ${i_width} != 32; do echo " count = count_minus_one + 1;" echo " assert (count != 0);" echo "" - echo " /* do the fast ${name}: */" - if test ${name} = read; then - echo " tme_memory_sequence_rdlock(tlb->tme_bus_tlb_rwlock);" - echo " memcpy(buffer," - echo " (tlb->tme_bus_tlb_emulator_off_${name} + address_init), " - echo " count);" - else - echo " tme_memory_sequence_wrlock(tlb->tme_bus_tlb_rwlock);" - echo " memcpy((tlb->tme_bus_tlb_emulator_off_${name} + address_init), " - echo " buffer," - echo " count);" - fi - echo " tme_memory_sequence_unlock(tlb->tme_bus_tlb_rwlock);" + echo " /* do the bus ${name}: */" + echo " tme_memory_bus_${name}_buffer((tlb->tme_bus_tlb_emulator_off_${name} + address_init), buffer, count, tlb->tme_bus_tlb_rwlock, sizeof(tme_uint8_t), sizeof(tme_uint${i_width}_t));" + echo "" + echo " /* unbusy this TLB entry: */" + echo " tme_bus_tlb_unbusy(tlb);" echo " }" echo "" echo " /* otherwise, we have to do a slow ${name}: */" @@ -387,6 +381,9 @@ while test ${i_width} != 32; do echo " }" echo " cycle.tme_bus_cycle_address = address_resp;" echo "" + echo " /* unbusy this TLB entry: */" + echo " tme_bus_tlb_unbusy(tlb);" + echo "" echo " /* unlock the device: */" echo " (*bus_device->tme_bus_device_unlock)(bus_device, locks);" echo "" @@ -394,9 +391,10 @@ while test ${i_width} != 32; do echo " err = (*tlb->tme_bus_tlb_cycle)" echo " (tlb->tme_bus_tlb_cycle_private, &cycle);" echo "" - echo " /* we don't support deadlocking: */" - echo " if (err == TME_EDEADLK) {" - echo " abort();" + echo " /* if the TLB entry was invalidated before the ${name}: */" + echo " if (err == EBADF" + echo " && tme_bus_tlb_is_invalid(tlb)) {" + echo " count = 0;" echo " }" echo "" echo " /* otherwise, any other error might be a bus error: */"