Skip to content

Commit e68c665

Browse files
committed
move gtd extra out of control struct to save sram
also rename gtd_data to gtd_extra
1 parent 3349e40 commit e68c665

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

src/portable/ohci/ohci.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,12 +612,11 @@ static inline ohci_ed_t* gtd_get_ed(ohci_gtd_t const * const p_qtd)
612612
}
613613

614614
static gtd_extra_data_t *gtd_get_extra_data(ohci_gtd_t const * const gtd) {
615-
if ( gtd_is_control(gtd) )
616-
{
617-
return &ohci_data.control[((intptr_t)gtd - (intptr_t)&ohci_data.control->gtd) / sizeof(ohci_data.control[0])].gtd_data;
618-
}else
619-
{
620-
return &ohci_data.gtd_data[gtd - ohci_data.gtd_pool];
615+
if ( gtd_is_control(gtd) ) {
616+
uint8_t idx = ((uintptr_t)gtd - (uintptr_t)&ohci_data.control->gtd) / sizeof(ohci_data.control[0]);
617+
return &ohci_data.gtd_extra_control[idx];
618+
}else {
619+
return &ohci_data.gtd_extra[gtd - ohci_data.gtd_pool];
621620
}
622621
}
623622

@@ -661,7 +660,7 @@ static void done_queue_isr(uint8_t hostid)
661660
// --> HC will not process Control list (due to service ratio when Bulk list not empty)
662661
// To walk-around this, the halted ED will have TailP = HeadP (empty list condition), when clearing halt
663662
// the TailP must be set back to NULL for processing remaining TDs
664-
if ((event != XFER_RESULT_SUCCESS))
663+
if (event != XFER_RESULT_SUCCESS)
665664
{
666665
ed->td_tail &= 0x0Ful;
667666
ed->td_tail |= tu_align16(ed->td_head.address); // mark halted EP as empty queue

src/portable/ohci/ohci.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,15 +154,12 @@ typedef struct TU_ATTR_ALIGNED(32)
154154

155155
TU_VERIFY_STATIC( sizeof(ochi_itd_t) == 32, "size is not correct" );
156156

157-
typedef struct
158-
{
159-
uint16_t expected_bytes : 13; // can be up to 8192 bytes long so use 13 bits
160-
uint16_t : 3; // can be used
157+
typedef struct {
158+
uint16_t expected_bytes; // up to 8192 bytes so max is 13 bits
161159
} gtd_extra_data_t;
162160

163161
// structure with member alignment required from large to small
164-
typedef struct TU_ATTR_ALIGNED(256)
165-
{
162+
typedef struct TU_ATTR_ALIGNED(256) {
166163
ohci_hcca_t hcca;
167164

168165
ohci_ed_t bulk_head_ed; // static bulk head (dummy)
@@ -172,16 +169,17 @@ typedef struct TU_ATTR_ALIGNED(256)
172169
struct {
173170
ohci_ed_t ed;
174171
ohci_gtd_t gtd;
175-
gtd_extra_data_t gtd_data;
176-
}control[CFG_TUH_DEVICE_MAX+CFG_TUH_HUB+1];
172+
} control[CFG_TUH_DEVICE_MAX + CFG_TUH_HUB + 1];
177173

178174
// ochi_itd_t itd[OHCI_MAX_ITD]; // itd requires alignment of 32
179175
ohci_ed_t ed_pool[ED_MAX];
180176
ohci_gtd_t gtd_pool[GTD_MAX];
181-
gtd_extra_data_t gtd_data[GTD_MAX]; // extra data needed by TDs that can't fit in the TD struct
182177

183-
volatile uint16_t frame_number_hi;
178+
// extra data needed by TDs that can't fit in the TD struct
179+
gtd_extra_data_t gtd_extra_control[CFG_TUH_DEVICE_MAX + CFG_TUH_HUB + 1];
180+
gtd_extra_data_t gtd_extra[GTD_MAX];
184181

182+
volatile uint16_t frame_number_hi;
185183
} ohci_data_t;
186184

187185
//--------------------------------------------------------------------+

0 commit comments

Comments
 (0)