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? [2/3]
Date: Tue, 18 Nov 2003 10:12:35 +0000 [thread overview]
Message-ID: <marc-linux-ia64-106915049930244@msgid-missing> (raw)
In-Reply-To: <marc-linux-ia64-106915044130197@msgid-missing>
This is a sample of readb_check on driver (with Notifier).
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 ************************************/
/******************************************************************************/
struct notifier_block *driver_notifier_list = { 0, 0, 0};
EXPORT_SYMBOL(driver_notifer_list)
void MCA_Handler(struct pt_regs *ptregs)
{
/* 'ip' is index of register instruction pointer */
/* 'A' is index of register A */
int check = 0;
…
/* statements for read&mf */
if (ptregs['A'] = current->pid) {
int ret = notifier_call_chain(&driver_notifier_chain,
0, ptregs['ip']);
if ((ret&~NOTIFY_STOP_MASK) = NOTIFY_OK) {
ptregs['A'] = 0;
check = 1;
}
}
if (!check) reboot(); /* system down */
…
}
…
/******************************************************************************/
/************************************ DRIVER **********************************/
/******************************************************************************/
…
static struct notifer_block driver_notifer = {
.notifer_call = driver_notifer_hook,
};
typedef struct {
void *start;
void *end;
} address_range;
static __attribute__((noinline))
int readb_check(unsigned char *data, void *adrs)
{
int volatile B = current->pid;
register int 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 */
}
}
static __attribute__((noinline))
int readw_check(unsigned short *data, void *adrs)
…
/* fixme: specify address range from 'read(adrs)' to 'asm("mf.a"::)' */
static address_range check_range[] = {
{readb_check, readw_check},
…
};
static int driver_notifier_hook(struct notifier_block *this,
unsigned long event, void *data)
{
void *adr = data;
int res = NOTIFY_DONE;
int i;
for (i = 0; i < sizeof(check_range)/sizeof(address_range); i++ ) {
if (check_range[i].start < adr && adr < check_range[i].end) {
res = NOTIFY_STOP_MASK|NOTIFY_OK;
break;
}
}
return res;
}
static int __init driver_init(void)
{
…
notifier_chain_register(&driver_notifier_list, &driver_notifier);
…
}
static void __exit driver_exit(void)
{
notifier_chain_unregister(&driver_notifer_list, &driver_notifier);
…
}
module_init(driver_init);
module_exit(driver_exit);
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:12 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 ` Hidetoshi Seto [this message]
2003-11-18 10:14 ` [RFC] How drivers notice a MCA on I/O read? [3/3] Hidetoshi Seto
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-106915049930244@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