Thread: What is the meaning of line while((dvp->csr & (READY | ERROR)) == 0)
hi friends
reading article on const , volatile type qualifiers page http://publications.gbdirect.co.uk/c..._volatile.html found following code page.
i not able understand meaning of line in bold, can please explain me.code:/* standard c example without const or volatile */ /* * declare device registers * whether use int or short * implementation dependent */ struct devregs{ unsigned short csr; /* control & status */ unsigned short data; /* data port */ }; /* bit patterns in csr */ #define error 0x1 #define ready 0x2 #define reset 0x4 /* absolute address of device */ #define devaddr ((struct devregs *)0xffff0004) /* number of such devices in system */ #define ndevs 4 /* * busy-wait function read byte device n. * check range of device number. * wait until ready or error * if no error, read byte, return * otherwise reset error, return 0xffff */ unsigned int read_dev(unsigned devno){ struct devregs *dvp = devaddr + devno; if(devno >= ndevs) return(0xffff); while((dvp->csr & (ready | error)) == 0) ; /* null - wait till done */ if(dvp->csr & error){ dvp->csr = reset; return(0xffff); } return((dvp->data) & 0xff); }
thank you.
basically, line loop until csr equal either ready or error. assume there's thread running somewhere update dvp's csr , data fields. loop check whether or not needs done (we're ready use data or there error.)
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] What is the meaning of line while((dvp->csr & (READY | ERROR)) == 0)
Ubuntu
Comments
Post a Comment