Freer requires outct CT_END negociation in both ways before closing down.

This commit is contained in:
Russell
2012-01-09 16:11:32 +00:00
parent 541ee1af81
commit dd5e086088
3 changed files with 178 additions and 147 deletions

View File

@@ -1,7 +1,7 @@
######################################################### #########################################################
# XMOS Compiled Assembly File # # XMOS Compiled Assembly File #
######################################################### #########################################################
# generated: Mon Jan 09 2012, 13:44 # # generated: Mon Jan 09 2012, 15:48 #
# product: XS1-040 # # product: XS1-040 #
# compiler: XMOS 32-bit XC Compiler 11.11.0beta1 (build 2136)# # compiler: XMOS 32-bit XC Compiler 11.11.0beta1 (build 2136)#
# input: reboot.xi # # input: reboot.xi #
@@ -194,6 +194,7 @@
.align 4 .align 4
.LDBG5: .LDBG5:
.call device_reboot, __builtin_outct .call device_reboot, __builtin_outct
.call device_reboot, __builtin_inct
.call device_reboot, get_core_id .call device_reboot, get_core_id
.call device_reboot, read_sswitch_reg .call device_reboot, read_sswitch_reg
.call device_reboot, write_sswitch_reg_blind .call device_reboot, write_sswitch_reg_blind
@@ -201,6 +202,9 @@
.set __builtin_outct, 0 .set __builtin_outct, 0
.linkset __builtin_outct.locnoside, 0 .linkset __builtin_outct.locnoside, 0
.linkset __builtin_outct.locnochandec, 1 .linkset __builtin_outct.locnochandec, 1
.set __builtin_inct, 0
.linkset __builtin_inct.locnoside, 0
.linkset __builtin_inct.locnochandec, 1
.globl device_reboot, "f{0}(chd)" .globl device_reboot, "f{0}(chd)"
.globl device_reboot.nstackwords .globl device_reboot.nstackwords
.globl device_reboot.maxthreads .globl device_reboot.maxthreads
@@ -228,10 +232,10 @@
# -----1-| _t0 # -----1-| _t0
# -----0-| rsvd # -----0-| rsvd
# ------------------------ # ------------------------
# r0 = [f:spare, t:8, l:core_id, t:10, t:11, t:12, t:14, t:15, t:16, t:17, t:19, t:21, t:24] # r0 = [f:spare, t:8, l:core_id, t:11, t:12, t:13, t:15, t:16, t:17, t:18, t:20, t:22, t:25]
# r1 = [t:23, t:25, t:26] # r1 = [t:9, t:24, t:26, t:27]
# r2 = [t:13, t:18, t:22] # r2 = [t:14, t:19, t:23]
# r4 = [t:9, t:20] # r4 = [t:10, t:21]
# r5 = [t:1] # r5 = [t:1]
# r6 = [t:2] # r6 = [t:2]
# r7 = [t:3] # r7 = [t:3]
@@ -254,60 +258,69 @@ device_reboot:
.loc 1 10 0 .loc 1 10 0
.L17_EndPoint: .L20_EndPoint:
outct res[r0], 0x1 # output ctrl token on `_t0_r0' outct res[r0], 0x1 # output ctrl token on `_t0_r0'
.L4_bb_begin: .loc 1 11 0
.L5_bb_begin:
.loc 1 11 0
.loc 1 11 0
.L21_EndPoint:
inct r1, res[r0] # input control token on `_t0_r0'
.L7_bb_begin:
freer res[r0] freer res[r0]
.LDBG6: .LDBG6:
.loc 1 17 0 .loc 1 18 0
.L18_Call: .L22_Call:
bl get_core_id bl get_core_id
mov r4, r0 # move r4 <-- r0 mov r4, r0 # move r4 <-- r0
.L7_bb_begin:
.loc 1 18 0
.L10_bb_begin: .L10_bb_begin:
.loc 1 18 0
ldaw r2, sp[0x2]
ldc r1, 0x6
.loc 1 18 0
.L19_Call:
bl read_sswitch_reg
.loc 1 19 0 .loc 1 19 0
.L13_bb_begin: .L13_bb_begin:
.loc 1 19 0 .loc 1 19 0
ldaw r2, sp[0x2]
ldc r1, 0x6
.loc 1 19 0
.L23_Call:
bl read_sswitch_reg
.loc 1 20 0
.L16_bb_begin:
.loc 1 20 0
ldc r0, 0x8000 ldc r0, 0x8000
xor r0, r4, r0 xor r0, r4, r0
ldw r2, sp[0x2] ldw r2, sp[0x2]
ldc r1, 0x6 ldc r1, 0x6
.loc 1 19 0 .loc 1 20 0
.L20_Call: .L24_Call:
bl write_sswitch_reg_blind bl write_sswitch_reg_blind
.loc 1 20 0 .loc 1 21 0
.L15_bb_begin: .L18_bb_begin:
.loc 1 20 0 .loc 1 21 0
ldw r2, sp[0x2] ldw r2, sp[0x2]
mov r0, r4 # move r0 <-- r4 mov r0, r4 # move r0 <-- r4
ldc r1, 0x6 ldc r1, 0x6
.loc 1 20 0 .loc 1 21 0
.L21_Call: .L25_Call:
bl write_sswitch_reg_blind bl write_sswitch_reg_blind
.LDBG7: .LDBG7:
.loc 1 22 0 .loc 1 23 0
.LDBG13: .LDBG13:
ldw r4, sp[0x1] ldw r4, sp[0x1]
.LDBG14: .LDBG14:
.L16_bb_begin: .L19_bb_begin:
retsp 0x3 # return: dealloc and link (pc=r15=mem[sp]) retsp 0x3 # return: dealloc and link (pc=r15=mem[sp])
.LDBG10: .LDBG10:
.LDBG15: .LDBG15:
@@ -510,7 +523,7 @@ device_reboot:
.uleb128 0x6 .uleb128 0x6
.asciiz "pllVal" .asciiz "pllVal"
.byte 0x01 .byte 0x01
.short 0x0010 .short 0x0011
.short .LDBG47-.LDBG46 .short .LDBG47-.LDBG46
.int .LDBG28-.LDBG22 .int .LDBG28-.LDBG22
.int .LDBG48 .int .LDBG48
@@ -532,7 +545,7 @@ device_reboot:
.uleb128 0x6 .uleb128 0x6
.asciiz "core_id" .asciiz "core_id"
.byte 0x01 .byte 0x01
.short 0x0011 .short 0x0012
.short 0x0000 .short 0x0000
.int .LDBG28-.LDBG22 .int .LDBG28-.LDBG22
.int .LDBG51 .int .LDBG51
@@ -655,58 +668,68 @@ device_reboot:
.byte 0x00 .byte 0x00
.section .xtaendpointtable, "", @progbits .section .xtaendpointtable, "", @progbits
.L22_xta_begin:
.int .L23_xta_end-.L22_xta_begin
.int 0x00000000
.asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build"
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x0000000a
.long .L17_EndPoint
.cc_bottom device_reboot.function
.L23_xta_end:
.section .xtacalltable, "", @progbits
.L24_xta_begin:
.int .L25_xta_end-.L24_xta_begin
.int 0x00000000
.asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build"
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000014
.long .L21_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000013
.long .L20_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000012
.long .L19_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000011
.long .L18_Call
.cc_bottom device_reboot.function
.L25_xta_end:
.section .xtalabeltable, "", @progbits
.L26_xta_begin: .L26_xta_begin:
.int .L27_xta_end-.L26_xta_begin .int .L27_xta_end-.L26_xta_begin
.int 0x00000000 .int 0x00000000
.asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build" .asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build"
.cc_top device_reboot.function, device_reboot .cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000016 .int 0x0000000b
.int 0x00000016 .long .L21_EndPoint
# line info for line 22 .cc_bottom device_reboot.function
.long .L16_bb_begin .cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x0000000a
.long .L20_EndPoint
.cc_bottom device_reboot.function
.L27_xta_end:
.section .xtacalltable, "", @progbits
.L28_xta_begin:
.int .L29_xta_end-.L28_xta_begin
.int 0x00000000
.asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build"
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000015
.long .L25_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000014
.long .L24_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000013
.long .L23_Call
.cc_bottom device_reboot.function
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000012
.long .L22_Call
.cc_bottom device_reboot.function
.L29_xta_end:
.section .xtalabeltable, "", @progbits
.L30_xta_begin:
.int .L31_xta_end-.L30_xta_begin
.int 0x00000000
.asciiz "/local/USBAudio/sw_usb_aud_l1_ios/app_usb_aud_l1/.build"
.cc_top device_reboot.function, device_reboot
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000017
.int 0x00000017
# line info for line 23
.long .L19_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000015
.int 0x00000015
# line info for line 21
.long .L18_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000014 .int 0x00000014
.int 0x00000014 .int 0x00000014
# line info for line 20 # line info for line 20
.long .L15_bb_begin .long .L16_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000013 .int 0x00000013
.int 0x00000013 .int 0x00000013
@@ -718,22 +741,22 @@ device_reboot:
# line info for line 18 # line info for line 18
.long .L10_bb_begin .long .L10_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x00000011 .int 0x0000000d
.int 0x00000011 .int 0x0000000d
# line info for line 17 # line info for line 13
.long .L7_bb_begin .long .L7_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x0000000c .int 0x0000000b
.int 0x0000000c .int 0x0000000b
# line info for line 12 # line info for line 11
.long .L4_bb_begin .long .L5_bb_begin
.asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc" .asciiz "../../../sc_usb_audio/module_usb_aud_shared/reboot.xc"
.int 0x0000000a .int 0x0000000a
.int 0x0000000a .int 0x0000000a
# line info for line 10 # line info for line 10
.long .L2_bb_begin .long .L2_bb_begin
.cc_bottom device_reboot.function .cc_bottom device_reboot.function
.L27_xta_end: .L31_xta_end:
.section .dp.data, "adw", @progbits .section .dp.data, "adw", @progbits
.align 4 .align 4
.align 4 .align 4
@@ -744,5 +767,5 @@ device_reboot:
.corerev "REVB" .corerev "REVB"
# memory access instructions: 6 # memory access instructions: 6
# total instructions: 19 # total instructions: 20
######################################## ########################################

View File

@@ -8,6 +8,7 @@ int write_sswitch_reg_blind(unsigned coreid, unsigned reg, unsigned data);
void device_reboot(chanend spare) void device_reboot(chanend spare)
{ {
outct(spare, XS1_CT_END); // have to do this before freeing the chanend outct(spare, XS1_CT_END); // have to do this before freeing the chanend
inct(spare); // Receive end ct from usb_buffer to close down in both directions
// Need a spare chanend so we can talk to the pll register // Need a spare chanend so we can talk to the pll register
asm("freer res[%0]"::"r"(spare)); asm("freer res[%0]"::"r"(spare));
// Need to tell the mapper we have freed one // Need to tell the mapper we have freed one

View File

@@ -261,7 +261,6 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
/* End XUD_SetData */ /* End XUD_SetData */
} }
#endif #endif
asm("stw %0, dp[g_intFlag]" :: "r" (0) ); asm("stw %0, dp[g_intFlag]" :: "r" (0) );
XUD_SetNotReady(ep_int); XUD_SetNotReady(ep_int);
break; break;
@@ -269,73 +268,81 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
#endif #endif
/* Sample Freq our chan count update from ep 0 */ /* Sample Freq our chan count update from ep 0 */
case inuint_byref(c_aud_ctl, tmp): case testct_byref(c_aud_ctl, tmp):
{ {
int min, mid, max; if (tmp) {
int usb_speed; // is a control token sent by reboot_device
int frameTime; inct(c_aud_ctl);
asm("ldw %0, dp[g_curUsbSpeed]" : "=r" (usb_speed) :); outct(c_aud_ctl, XS1_CT_END);
while(1) {};
if(tmp == SET_SAMPLE_FREQ) } else {
{ int min, mid, max;
sampleFreq = inuint(c_aud_ctl); int usb_speed;
int frameTime;
/* Tidy up double buffer, note we can do better than this for 44.1 etc but better tmp = inuint(c_aud_ctl);
* than sending two packets at old speed! */ GET_SHARED_GLOBAL(usb_speed, g_curUsbSpeed);
if (usb_speed == XUD_SPEED_HS)
frameTime = 8000; if(tmp == SET_SAMPLE_FREQ)
else {
frameTime = 1000; sampleFreq = inuint(c_aud_ctl);
min = sampleFreq / frameTime;
max = min + 1;
mid = min; /* Tidy up double buffer, note we can do better than this for 44.1 etc but better
* than sending two packets at old speed! */
/* Check for INT(SampFreq/8000) == SampFreq/8000 */ if (usb_speed == XUD_SPEED_HS)
if((sampleFreq % frameTime) == 0) frameTime = 8000;
{ else
min -= 1; frameTime = 1000;
}
#ifdef FB_TOLERANCE_TEST min = sampleFreq / frameTime;
expected_fb = ((sampleFreq * 0x2000) / frametime);
#endif max = min + 1;
asm("stw %0, dp[g_speed]"::"r"(mid << 16)); mid = min;
if (usb_speed == XUD_SPEED_HS) /* Check for INT(SampFreq/8000) == SampFreq/8000 */
mid *= NUM_USB_CHAN_IN*4; if((sampleFreq % frameTime) == 0)
else {
mid *= NUM_USB_CHAN_IN*3; min -= 1;
}
asm("stw %0, %1[0]"::"r"(mid),"r"(inZeroBuff)); #ifdef FB_TOLERANCE_TEST
expected_fb = ((sampleFreq * 0x2000) / frametime);
/* Reset FB */ #endif
/* Note, Endpoint 0 will hold off host for a sufficient period to allow out feedback
* to stabilise (i.e. sofCount == 128 to fire) */ asm("stw %0, dp[g_speed]"::"r"(mid << 16));
sofCount = 0;
clocks = 0; if (usb_speed == XUD_SPEED_HS)
remnant = 0; mid *= NUM_USB_CHAN_IN*4;
else
/* Ideally we want to wait for handshake (and pass back up) here. But we cannot keep this mid *= NUM_USB_CHAN_IN*3;
* thread locked, it must stay responsive to packets/SOFs. So, set a flag and check for
* handshake elsewhere */ asm("stw %0, %1[0]"::"r"(mid),"r"(inZeroBuff));
/* Pass on sample freq change to decouple */
SET_SHARED_GLOBAL(g_freqChange, SET_SAMPLE_FREQ); /* Reset FB */
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq); /* Note, Endpoint 0 will hold off host for a sufficient period to allow out feedback
SET_SHARED_GLOBAL(g_freqChange_flag, SET_SAMPLE_FREQ); * to stabilise (i.e. sofCount == 128 to fire) */
sofCount = 0;
clocks = 0;
remnant = 0;
/* Ideally we want to wait for handshake (and pass back up) here. But we cannot keep this
* thread locked, it must stay responsive to packets/SOFs. So, set a flag and check for
* handshake elsewhere */
/* Pass on sample freq change to decouple */
SET_SHARED_GLOBAL(g_freqChange, SET_SAMPLE_FREQ);
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq);
SET_SHARED_GLOBAL(g_freqChange_flag, SET_SAMPLE_FREQ);
}
else
{
sampleFreq = inuint(c_aud_ctl);
SET_SHARED_GLOBAL(g_freqChange, tmp); /* Set command */
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq); /* Set flag */
SET_SHARED_GLOBAL(g_freqChange_flag, tmp);
}
} }
else
{
sampleFreq = inuint(c_aud_ctl);
SET_SHARED_GLOBAL(g_freqChange, tmp); /* Set command */
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq); /* Set flag */
SET_SHARED_GLOBAL(g_freqChange_flag, tmp);
}
break; break;
} }