Add the 'volatile' qualifier to all descriptor fields to prevent the
compiler optimising away or reordering accesses to them. Fixes ehci(4) on NetBSD/evbarm when using -Os optimisation. It's likely ohci(4) and uhci(4) are similarly afflicted, so the same changes have been made there. Quite how other platforms got away without this for so long is a mystery...
This commit is contained in:
parent
ce8b831234
commit
4f8db3981d
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ehcireg.h,v 1.23 2005/11/20 18:36:20 augustss Exp $ */
|
||||
/* $NetBSD: ehcireg.h,v 1.24 2006/10/08 11:52:48 scw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001, 2004 The NetBSD Foundation, Inc.
|
||||
|
@ -194,14 +194,14 @@ typedef u_int32_t ehci_physaddr_t;
|
|||
|
||||
/* Isochronous Transfer Descriptor */
|
||||
typedef struct {
|
||||
ehci_link_t itd_next;
|
||||
volatile ehci_link_t itd_next;
|
||||
/* XXX many more */
|
||||
} ehci_itd_t;
|
||||
#define EHCI_ITD_ALIGN 32
|
||||
|
||||
/* Split Transaction Isochronous Transfer Descriptor */
|
||||
typedef struct {
|
||||
ehci_link_t sitd_next;
|
||||
volatile ehci_link_t sitd_next;
|
||||
/* XXX many more */
|
||||
} ehci_sitd_t;
|
||||
#define EHCI_SITD_ALIGN 32
|
||||
|
@ -209,9 +209,9 @@ typedef struct {
|
|||
/* Queue Element Transfer Descriptor */
|
||||
#define EHCI_QTD_NBUFFERS 5
|
||||
typedef struct {
|
||||
ehci_link_t qtd_next;
|
||||
ehci_link_t qtd_altnext;
|
||||
u_int32_t qtd_status;
|
||||
volatile ehci_link_t qtd_next;
|
||||
volatile ehci_link_t qtd_altnext;
|
||||
volatile u_int32_t qtd_status;
|
||||
#define EHCI_QTD_GET_STATUS(x) (((x) >> 0) & 0xff)
|
||||
#define EHCI_QTD_SET_STATUS(x) ((x) << 0)
|
||||
#define EHCI_QTD_ACTIVE 0x80
|
||||
|
@ -239,15 +239,15 @@ typedef struct {
|
|||
#define EHCI_QTD_GET_TOGGLE(x) (((x) >> 31) & 0x1)
|
||||
#define EHCI_QTD_SET_TOGGLE(x) ((x) << 31)
|
||||
#define EHCI_QTD_TOGGLE_MASK 0x80000000
|
||||
ehci_physaddr_t qtd_buffer[EHCI_QTD_NBUFFERS];
|
||||
ehci_physaddr_t qtd_buffer_hi[EHCI_QTD_NBUFFERS];
|
||||
volatile ehci_physaddr_t qtd_buffer[EHCI_QTD_NBUFFERS];
|
||||
volatile ehci_physaddr_t qtd_buffer_hi[EHCI_QTD_NBUFFERS];
|
||||
} ehci_qtd_t;
|
||||
#define EHCI_QTD_ALIGN 32
|
||||
|
||||
/* Queue Head */
|
||||
typedef struct {
|
||||
ehci_link_t qh_link;
|
||||
u_int32_t qh_endp;
|
||||
volatile ehci_link_t qh_link;
|
||||
volatile u_int32_t qh_endp;
|
||||
#define EHCI_QH_GET_ADDR(x) (((x) >> 0) & 0x7f) /* endpoint addr */
|
||||
#define EHCI_QH_SET_ADDR(x) (x)
|
||||
#define EHCI_QH_ADDRMASK 0x0000007f
|
||||
|
@ -271,7 +271,7 @@ typedef struct {
|
|||
#define EHCI_QH_CTL 0x08000000
|
||||
#define EHCI_QH_GET_NRL(x) (((x) >> 28) & 0x0f) /* NAK reload */
|
||||
#define EHCI_QH_SET_NRL(x) ((x) << 28)
|
||||
u_int32_t qh_endphub;
|
||||
volatile u_int32_t qh_endphub;
|
||||
#define EHCI_QH_GET_SMASK(x) (((x) >> 0) & 0xff) /* intr sched mask */
|
||||
#define EHCI_QH_SET_SMASK(x) ((x) << 0)
|
||||
#define EHCI_QH_GET_CMASK(x) (((x) >> 8) & 0xff) /* split completion mask */
|
||||
|
@ -282,15 +282,15 @@ typedef struct {
|
|||
#define EHCI_QH_SET_PORT(x) ((x) << 23)
|
||||
#define EHCI_QH_GET_MULT(x) (((x) >> 30) & 0x03) /* pipe multiplier */
|
||||
#define EHCI_QH_SET_MULT(x) ((x) << 30)
|
||||
ehci_link_t qh_curqtd;
|
||||
ehci_qtd_t qh_qtd;
|
||||
volatile ehci_link_t qh_curqtd;
|
||||
volatile ehci_qtd_t qh_qtd;
|
||||
} ehci_qh_t;
|
||||
#define EHCI_QH_ALIGN 32
|
||||
|
||||
/* Periodic Frame Span Traversal Node */
|
||||
typedef struct {
|
||||
ehci_link_t fstn_link;
|
||||
ehci_link_t fstn_back;
|
||||
volatile ehci_link_t fstn_link;
|
||||
volatile ehci_link_t fstn_back;
|
||||
} ehci_fstn_t;
|
||||
#define EHCI_FSTN_ALIGN 32
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ohcireg.h,v 1.21 2005/12/11 12:24:01 christos Exp $ */
|
||||
/* $NetBSD: ohcireg.h,v 1.22 2006/10/08 11:52:48 scw Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/ohcireg.h,v 1.8 1999/11/17 22:33:40 n_hibma Exp $ */
|
||||
|
||||
|
||||
|
@ -136,9 +136,9 @@ typedef u_int32_t ohci_physaddr_t;
|
|||
|
||||
#define OHCI_NO_INTRS 32
|
||||
struct ohci_hcca {
|
||||
ohci_physaddr_t hcca_interrupt_table[OHCI_NO_INTRS];
|
||||
u_int32_t hcca_frame_number;
|
||||
ohci_physaddr_t hcca_done_head;
|
||||
volatile ohci_physaddr_t hcca_interrupt_table[OHCI_NO_INTRS];
|
||||
volatile u_int32_t hcca_frame_number;
|
||||
volatile ohci_physaddr_t hcca_done_head;
|
||||
#define OHCI_DONE_INTRS 1
|
||||
};
|
||||
#define OHCI_HCCA_SIZE 256
|
||||
|
@ -149,7 +149,7 @@ struct ohci_hcca {
|
|||
#define OHCI_PAGE_OFFSET(x) ((x) & 0xfff)
|
||||
|
||||
typedef struct {
|
||||
u_int32_t ed_flags;
|
||||
volatile u_int32_t ed_flags;
|
||||
#define OHCI_ED_GET_FA(s) ((s) & 0x7f)
|
||||
#define OHCI_ED_ADDRMASK 0x0000007f
|
||||
#define OHCI_ED_SET_FA(s) (s)
|
||||
|
@ -166,18 +166,18 @@ typedef struct {
|
|||
#define OHCI_ED_GET_MAXP(s) (((s) >> 16) & 0x07ff)
|
||||
#define OHCI_ED_SET_MAXP(s) ((s) << 16)
|
||||
#define OHCI_ED_MAXPMASK (0x7ff << 16)
|
||||
ohci_physaddr_t ed_tailp;
|
||||
ohci_physaddr_t ed_headp;
|
||||
volatile ohci_physaddr_t ed_tailp;
|
||||
volatile ohci_physaddr_t ed_headp;
|
||||
#define OHCI_HALTED 0x00000001
|
||||
#define OHCI_TOGGLECARRY 0x00000002
|
||||
#define OHCI_HEADMASK 0xfffffffc
|
||||
ohci_physaddr_t ed_nexted;
|
||||
volatile ohci_physaddr_t ed_nexted;
|
||||
} ohci_ed_t;
|
||||
/* #define OHCI_ED_SIZE 16 */
|
||||
#define OHCI_ED_ALIGN 16
|
||||
|
||||
typedef struct {
|
||||
u_int32_t td_flags;
|
||||
volatile u_int32_t td_flags;
|
||||
#define OHCI_TD_R 0x00040000 /* Buffer Rounding */
|
||||
#define OHCI_TD_DP_MASK 0x00180000 /* Direction / PID */
|
||||
#define OHCI_TD_SETUP 0x00000000
|
||||
|
@ -194,16 +194,16 @@ typedef struct {
|
|||
#define OHCI_TD_GET_EC(x) (((x) >> 26) & 3) /* Error Count */
|
||||
#define OHCI_TD_GET_CC(x) ((x) >> 28) /* Condition Code */
|
||||
#define OHCI_TD_NOCC 0xf0000000
|
||||
ohci_physaddr_t td_cbp; /* Current Buffer Pointer */
|
||||
ohci_physaddr_t td_nexttd; /* Next TD */
|
||||
ohci_physaddr_t td_be; /* Buffer End */
|
||||
volatile ohci_physaddr_t td_cbp; /* Current Buffer Pointer */
|
||||
volatile ohci_physaddr_t td_nexttd; /* Next TD */
|
||||
volatile ohci_physaddr_t td_be; /* Buffer End */
|
||||
} ohci_td_t;
|
||||
/* #define OHCI_TD_SIZE 16 */
|
||||
#define OHCI_TD_ALIGN 16
|
||||
|
||||
#define OHCI_ITD_NOFFSET 8
|
||||
typedef struct {
|
||||
u_int32_t itd_flags;
|
||||
volatile u_int32_t itd_flags;
|
||||
#define OHCI_ITD_GET_SF(x) ((x) & 0x0000ffff)
|
||||
#define OHCI_ITD_SET_SF(x) ((x) & 0xffff)
|
||||
#define OHCI_ITD_GET_DI(x) (((x) >> 21) & 7) /* Delay Interrupt */
|
||||
|
@ -213,10 +213,10 @@ typedef struct {
|
|||
#define OHCI_ITD_SET_FC(x) (((x)-1) << 24)
|
||||
#define OHCI_ITD_GET_CC(x) ((x) >> 28) /* Condition Code */
|
||||
#define OHCI_ITD_NOCC 0xf0000000
|
||||
ohci_physaddr_t itd_bp0; /* Buffer Page 0 */
|
||||
ohci_physaddr_t itd_nextitd; /* Next ITD */
|
||||
ohci_physaddr_t itd_be; /* Buffer End */
|
||||
u_int16_t itd_offset[OHCI_ITD_NOFFSET]; /* Buffer offsets */
|
||||
volatile ohci_physaddr_t itd_bp0; /* Buffer Page 0 */
|
||||
volatile ohci_physaddr_t itd_nextitd; /* Next ITD */
|
||||
volatile ohci_physaddr_t itd_be; /* Buffer End */
|
||||
volatile u_int16_t itd_offset[OHCI_ITD_NOFFSET];/* Buffer offsets */
|
||||
#define itd_pswn itd_offset /* Packet Status Word*/
|
||||
#define OHCI_ITD_PAGE_SELECT 0x00001000
|
||||
#define OHCI_ITD_MK_OFFS(len) (0xe000 | ((len) & 0x1fff))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: uhcireg.h,v 1.17 2006/03/10 17:18:54 jmcneill Exp $ */
|
||||
/* $NetBSD: uhcireg.h,v 1.18 2006/10/08 11:52:48 scw Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/uhcireg.h,v 1.12 1999/11/17 22:33:42 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -151,8 +151,8 @@ typedef u_int32_t uhci_physaddr_t;
|
|||
*/
|
||||
|
||||
typedef struct {
|
||||
uhci_physaddr_t td_link;
|
||||
u_int32_t td_status;
|
||||
volatile uhci_physaddr_t td_link;
|
||||
volatile u_int32_t td_status;
|
||||
#define UHCI_TD_GET_ACTLEN(s) (((s) + 1) & 0x3ff)
|
||||
#define UHCI_TD_ZERO_ACTLEN(t) ((t) | 0x3ff)
|
||||
#define UHCI_TD_BITSTUFF 0x00020000
|
||||
|
@ -168,7 +168,7 @@ typedef struct {
|
|||
#define UHCI_TD_GET_ERRCNT(s) (((s) >> 27) & 3)
|
||||
#define UHCI_TD_SET_ERRCNT(n) ((n) << 27)
|
||||
#define UHCI_TD_SPD 0x20000000
|
||||
u_int32_t td_token;
|
||||
volatile u_int32_t td_token;
|
||||
#define UHCI_TD_PID_IN 0x00000069
|
||||
#define UHCI_TD_PID_OUT 0x000000e1
|
||||
#define UHCI_TD_PID_SETUP 0x0000002d
|
||||
|
@ -182,7 +182,7 @@ typedef struct {
|
|||
#define UHCI_TD_SET_MAXLEN(l) (((l)-1) << 21)
|
||||
#define UHCI_TD_GET_MAXLEN(s) ((((s) >> 21) + 1) & 0x7ff)
|
||||
#define UHCI_TD_MAXLEN_MASK 0xffe00000
|
||||
u_int32_t td_buffer;
|
||||
volatile u_int32_t td_buffer;
|
||||
} uhci_td_t;
|
||||
|
||||
#define UHCI_TD_ERROR (UHCI_TD_BITSTUFF|UHCI_TD_CRCTO|UHCI_TD_BABBLE|UHCI_TD_DBUFFER|UHCI_TD_STALLED)
|
||||
|
@ -197,8 +197,8 @@ typedef struct {
|
|||
UHCI_TD_SET_DT(dt))
|
||||
|
||||
typedef struct {
|
||||
uhci_physaddr_t qh_hlink;
|
||||
uhci_physaddr_t qh_elink;
|
||||
volatile uhci_physaddr_t qh_hlink;
|
||||
volatile uhci_physaddr_t qh_elink;
|
||||
} uhci_qh_t;
|
||||
|
||||
#endif /* _DEV_PCI_UHCIREG_H_ */
|
||||
|
|
Loading…
Reference in New Issue