From: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
To: linux-ia64@vger.kernel.org
Subject: [RFC] How drivers notice a MCA on I/O read? [3/3]
Date: Tue, 18 Nov 2003 10:14:23 +0000 [thread overview]
Message-ID: <marc-linux-ia64-106915060530349@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-106915044130197@msgid-missing>
This is a sample of readb_check on kernel.
I certainly understand that some of this code should be written in assemblers,
but I‘m not sure in my skill to handle IA64 codes. I would appreciate any
comments and feedbacks.
-----
H.Seto <seto.hidetoshi@jp.fujitsu.com>
/******************************************************************************/
/************************************* MCA ************************************/
/******************************************************************************/
...
typedef struct {
void *start;
void *end;
} address_range;
int readb_check(unsigned char*, void*);
int readw_check(unsigned short*, void*);
int readl_check(unsigned int*, void*);
static address_range check_range[] = {
{(void*)readb_check, (void*)readw_check},
…
};
void MCA_Handler(struct pt_regs *ptregs)
{
/* 'ip' is index of register instruction pointer */
/* 'A' is index of register A */
…
/* statements for read_check */
for (int i = 0; i < sizeof(check_range)/sizeof(address_range); i ++) {
if (check_range[i].start <= ptregs['ip']
&& ptregs['ip'] <= check_range[i].end) {
if (ptregs['A'] = current->pid) {/* register A*/
ptregs['A'] = 0;
break;
}
}
}
…
}
…
/******************************************************************************/
/********************************** read_check ********************************/
/******************************************************************************/
__attribute__((noinline)) int readb_check(unsigned char *data, void *adrs)
{
int volatile B = current->pid;
register int volatile A asm("A") /* register A */
unsigned char ret;
A = B;
ret = read(adrs);
asm("mf.a"::);
if (A != B) {
return 0; /* false*/
} else {
*data = ret;
return 1; /* true */
}
}
__attribute__((noinline)) int readw_check(unsigned short *data, void *adrs)
{
…
/******************************************************************************/
/************************************ DRIVER **********************************/
/******************************************************************************/
…
DRIVER_MAIN()
{
unsigned char data;
int retry_count, i;
…
retry_count = N1;
for ( i = 0; i < retry_count; i ++ ) {
if (readb_check(&data, address1)) break;
}
if ( i = retry_count) {
/* error */
}
…
retry_count = N2;
for ( i = 0; i < retry_count; i ++ ) {
if (readb_check(&data, address2)) break;
}
if ( i = retry_count) {
/* error */
}
…
}
next prev parent reply other threads:[~2003-11-18 10:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-18 10:11 [RFC] How drivers notice a MCA on I/O read? [1/3] Hidetoshi Seto
2003-11-18 10:12 ` [RFC] How drivers notice a MCA on I/O read? [2/3] Hidetoshi Seto
2003-11-18 10:14 ` Hidetoshi Seto [this message]
2003-11-18 15:06 ` [RFC] How drivers notice a MCA on I/O read? [1/3] Zoltan Menyhart
2003-11-18 17:10 ` Jesse Barnes
2003-11-18 17:47 ` Luck, Tony
2003-11-19 16:45 ` Grant Grundler
2003-11-25 9:27 ` Hidetoshi Seto
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=marc-linux-ia64-106915060530349@msgid-missing \
--to=seto.hidetoshi@jp.fujitsu.com \
--cc=linux-ia64@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox