Embedded System Software I

Size: px
Start display at page:

Download "Embedded System Software I"

Transcription

1 Lee, Jae Heung

2 ?.. Application Area Application System Call Interface Virtual File System(VFS) Buffer Cache Network Subsystem Character Device Driver Block Device Driver Network Device Driver Device Interface Hardware Hardware 1

3 2

4 Kernel / User Address Space memcpy(), unsigned long copy_to_user(void *to, const void *from, unsigned long count) ; unsigned long copy_from_user(void *to, const void *from, unsigned long count) ; put_user(void *x, const void *a ddr) get_user(void *x, const void *a ddr) reentrant ( ) c o nc u rrent( ) semaphore spi n l oc k I / O -> ) L E D u n s i g n e d c h a r * a d d r ; a d d r = ( u n s i g n e d c h a r * ) ( 0 x f ) ; * a d d r = 0 x a 5 ; 3

5 -. - g et _ u ser( v oi d * x, c on st v oi d * ad d r) * a d d r x s i z eo f (a d d r ). ex) g et _ u s er ( c, g d a t a ); pu t _ u ser( v oi d * x, c on st v oi d * ad d r) * x u s er a d d r s i z eo f (a d d r ). ex) p u t _ u s er ( * a d d, ( u n s i g n ed s h o r t * ) ( g d a t a )); c opy _ t o_ u ser( v oi d * t o, v oi d * f rom, u n si g n ed l on g si z e) f r o m s i z e u s er t o. c opy _ f rom_ u ser( v oi d * t o, v oi d * f rom, u n si g n ed l on g si z e) u s er f r o m s i z e t o. 4

6 I / O u 8 i n b (u n s i g n ed i n t po r t ) u 1 6 i n w (u n s i g n ed i n t po r t ) u 3 2 i n l (u n s i g n ed i n t po r t ) I / O v o i d o u t b ( u 8 d a t a, u n s i g n ed i n t po r t ) v o i d o u t w ( u 1 6 d a t a, u n s i g n ed i n t po r t ) v o i d o u t l ( u 3 2 d a t a, u n s i g n ed i n t po r t ) 5

7 LED L E D M u s t u s e r e s i s t o r t o l i m i t c u r r e n t : D i s c r e t e L E D 8 Bit Write [ D0~D7 ] Ba s e A d d res s = 0x PXA255 Memory Controller MD(7:0) B U FF E R MA(22:20) Address Decoder CK CS4 6

8 LED LED M A P Discrete LED Control Register 7

9 LED LED I / O led (led. c) #include <linux/ioport.h> #include <asm/uaccess.h> #include <linux/module.h> #include <linux/fs.h> #include <asm/io.h> #define LEDIOPORT_MAJOR 0 // 0 #define LEDIOPORT_NAME "LED IO PORT" #define LEDIOPORT_MODULE_VERSION "LED IO PORT V0.1" #define LEDIOPORT_ADDRESS 0xf // LED #define LEDIOPORT_ADDRESS_RANGE 1 I/O port define static int ledioport_usage = 0; static int ledioport_major = 0; // LED int ledioport_open(struct inode *minode, struct file *mfile) { if(ledioport_usage!= 0) return -EBUSY; MOD_INC_USE_COUNT; ledioport_usage = 1; return 0; 8

10 LED (2) // LED int led_ioport_release(struct inode *minode, struct file *mfile) { MOD_DEC_USE_COUNT; ledioport_usage = 0; return 0; // LED ssize_t led_ioport_write_byte(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned char *addr; unsigned char c; get_user(c, gdata); addr = (unsigned char *)(LEDIOPORT_ADDRESS); *addr = c; return length; // static struct file_operations led_fops = { write : ledioport_write_byte, open : ledioport_open, release : ledioport_release, ; LED write 9

11 LED (3) // int init_module(void) { int result; Character device result =register_chrdev(ledioport_major, LEDIOPORT_NAME, &led_fops); if(result < 0) { LEDIOPORT_MAJOR :, 0 printk(kern_warning"can't get any major\n"); return result; LEDIOPORT_N AME : /p r o c /d e v i c e s l e d _f o p s :. ledioport_major = result; if(!check_region(ledioport_address,ledioport_address_range)) request_region(ledioport_address,ledioport_address_range,ledioport_name); else printk(kern_warning"can't get IO Region 0x%x\n",LEDIOPORT_ADDRESS); printk("init module, ledioport major number : %d\n",result); return 0; c h e c k _r e g i o n ( 0xf , 1) / / 0xf ? r e q u e s t _r e g i o n ( 0xf , 1, L E D I O P O R T V 0. 1 ) / / 0xf ~ 0xf I / O L E D I O P O R T V 0. 1 check_region I / O -> req u es t _region I / O -> rel ea s e_region I / O -> 1 0

12 LED (4) // void cleanup_module(void) { release_region(ledioport_address,ledioport_address_range) if(unregister_chrdev(ledioport_major,ledioport_name)) printk(kern_warning"%s DRIVER CLEANUP FALLED\n",LEDIOPORT_NAME); Character device c h e c k _r e g i o n ( 0xf , 1) / / 0xf ? r e q u e s t _r e g i o n ( 0xf , 1, L E D I O P O R T V 0. 1 ) / / 0xf ~ 0xf I / O L E D I O P O R T V 0. 1 r e l e a s e _r e g i o n ( 0 x f , 1 ) / / check_region I / O -> req u es t _region I / O -> rel ea s e_region I / O -> 1 1

13 LED #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> // test.c int main(int argc, char **argv) { int dev; char buff; if(argc <= 1) { printf("please input the parameter! ex)./test 0xa1\n"); return -1; // dev = open("/dev/ledioport", O_WRONLY); LED Device file open 1 2

14 LED if (dev!= -1){ if(argv[1][0] == '0' && (argv[1][1] == 'x' argv[1][1] == 'X')) // buff = (unsigned char)strtol(&argv[1][2],null,16); else buff = atoi(argv[1]); // write(dev,&buff,1); close(dev); else{ printf( "Device Open ERROR!\n"); exit(-1); LED On/Off return(0); 1 3

15 M M Makefile C C = a r m -l i n u x-g c c / / K E R N E L D I R = l i n u x r m k 4 -p xa 2 I N C L U D E D I R = -I $ ( K E R N E L D I R )/ i n c l u d e -I. / # # C F L A G S = -D K E R N E L -D M O D U L E -W a l l -O 2 -I $ ( I N C L U D E D I R ) O D U L E _ O B J S = l e d i o p o r t. o O D U L E _ S R C S = l e d i o p o r t. c # #,, T E S T _ T A R G E T = t e s t T E S T _ O B J S = t e s t. o T E S T _ S R C S = t e s t. c # # m a k e a l l a l l : $ ( M O D U L E _ O B J S ) $ ( T E S T _ T A R G E T ) # # $ ( M O D U L E _ O B J S ) : $ ( C C ) $ ( C F L A G S ) -c $ ( M O D U L E _ S R C S ) # # $ ( T E S T _ T A R G E T ) : $ ( T E S T _ O B J S ) $ ( C C ) $ ( T E S T _ O B J S ) -o # # m a k e c l e a n c l e a n : r m -f *. o r m -f $ ( T E S T _ T A R G E T ) 1 4

16 LED LED $ make LED led iop ort. o led _ test insm od loa d ing m k nod $ insmod ledioport.o Using ledioport.o Init module, ledioport major number : 253 $ mknod /dev/ledioport c $./test 0xff 1 5

17 7-segment display M a y u s e p a r a l l e l o r m u l t i p l e x e d i n p u t a f e g d b c 1 6

18 7 Segment 7 S e g m e n t LED 1 7

19 7 Segment 4 D i g i t 7 s e g m e n t Physical Address : 0x1030_ Segment LED Data Register Bit D1H D1G D1F D1E D1D D1C D1B D1A D2H D2G D2F D2E D2D D2C D2B D2A Reset x x x x x x x x x x x x x x x x Bits Name Description 7:0 D2H:D2A Digit 1 Segment Bit [ 0-A, 1-B, 2-C, 3-D, 4-E, 5-F, 6-G, 7-H ] 15:8 D1H:D1A Digit 2 Segment Bit [ 8-A, 9-B, 10-C, 11-D, 12-E, 13-F, 14-G, 15-H ] Physical Address : 0x1040_0000 Bit D4H D4G D4F D4E D4D D4C D4B D4A D3H D3G D3F D3E D3D D3C D3B D3A Reset x x x x x x x x x x x x x x x x Bits Name Description 7:0 15:8 D4A:D4H 7 Segment LED Data Register D3A:D3H Digit 3 Segment Bit [ 0-A, 1-B, 2-C, 3-D, 4-E, 5-F, 6-G, 7-H ] Digit 4 Segment Bit [ 8-A, 9-B, 10-C, 11-D, 12-E, 13-F, 14-G, 15-H ] 18

20 7 Segment (1) (segmentport.c) #include <linux/module.h>.. #include <linux/ioport.h> #define SEGMENTPORT_MAJOR 0 // 0 #define SEGMENTPORT_NAME "SEGMENT PORT" #define SEGMENTPORT_MODULE_VERSION "SEGMENT PORT V0.1" // #define SEGMENTPORT_ADDRESS_LOW 0xf // #define SEGMENTPORT_ADDRESS_HIGH 0xf #define SEGMENTPORT_ADDRESS_RANGE 4 I/O port define #define SEGMENTPORT_BASE 0xbb #define SEGMENT_WRITE_LOW _IOW(SEGMENTPORT_BASE,0,4) #define SEGMENT_WRITE_HIGH _IOW(SEGMENTPORT_BASE,1,4) unsigned int *addr_low; unsigned int *addr_high; //Global variable static int segmentport_usage = 0; static int segmentport_major = 0; 19

21 7 Segment (2) // 7 int segmentport_open(struct inode *minode, struct file *mfile) { if(segmentport_usage!= 0) return -EBUSY; MOD_INC_USE_COUNT; segmentport_usage = 1; addr_low = (unsigned int *)(SEGMENTPORT_ADDRESS_LOW); addr_high = (unsigned int *)(SEGMENTPORT_ADDRESS_HIGH); return 0; // 7 int segmentport_release(struct inode *minode, struct file *mfile) { MOD_DEC_USE_COUNT; segmentport_usage = 0; return 0; 2 0

22 7 Segment (3) // unsigned int Getsegcode(int x) { unsigned int code; switch (x) { case 0x0 : code = 0x3f; break; case 0x1 : code = 0x06; break; case 0x2 : code = 0x5b; break; case 0x3 : code = 0x4f; break; case 0x4 : code = 0x66; break; case 0x5 : code = 0x6d; break; case 0x6 : code = 0x7d; break; case 0x7 : code = 0x07; break; case 0x8 : code = 0x7f; break; case 0x9 : code = 0x6f; break; case 0xA : code = 0x77; break; case 0xB : code = 0x7c; break; case 0xC : code = 0x39; break; case 0xD : code = 0x5e; break; case 0xE : code = 0x79; break; case 0xF : code = 0x71; break; default : code = 0; break; return code; 7-segment code 2 1

23 7 Segment (4) // struct file_operations segment_fops = { write: segmentport_write, ioctl: segmentport_ioctl, open: segmentport_open, release: segmentport_release, ; // void cleanup_module(void) { release_region(segmentport_address_low,segmentport_address_ra NGE); release_region(segmentport_address_high,segmentport_address_ra NGE); if(!unregister_chrdev(segmentport_major,segmentport_name)) printk("driver : %s DRIVER CLEANUP Ok\n",SEGMENTPORT_NAME); else printk("driver : %s DRIVER CLEANUP FALLED\n",SEGMENTPORT_NAME); check_region I / O -> req u es t _region I / O -> rel ea s e_region I / O -> 2 2

24 7 Segment (5) // 7 void ShowSegment(unsigned short value) { unsigned int v0,v1,v2,v3; v0 = Getsegcode(value & 0xF); v1 = Getsegcode((value >> 4) & 0xF); v2 = Getsegcode((value >> 8) & 0xF); v3 = Getsegcode((value >> 12) & 0xF); *addr_low = (v1 << 8) v0; *addr_high = (v3 << 8) v2; // 7 ssize_t segmentport_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { unsigned short val; get_user(val,(unsigned short *)gdata); ShowSegment(val); return length; 2 3

25 7 Segment (6) // int segmentport_ioctl(struct inode *inode, struct file *file,unsigned int cmd,unsigned long gdata) { unsigned int val; unsigned int val_low,val_high; switch(cmd){ case SEGMENT_WRITE_LOW: get_user(val,(unsigned int *)gdata); val_low = val % 10; val_high = val / 10; val_low = Getsegcode(val_low); val_high = Getsegcode(val_high); *addr_low = (val_high << 8) val_low; break; case SEGMENT_WRITE_HIGH: get_user(val,(unsigned int *)gdata); val_low = val % 10; val_high = val / 10; cmd val_low = Getsegcode(val_low); val_high = Getsegcode(val_high); *addr_high = (val_high << 8) val_low; break; default: printk("driver : no such command!\n"); return -ENOTTY; return 0; 2 4

26 7 Segment (7) // int init_module(void) { int result; result = register_chrdev(segmentport_major,segmentport_name,&segment_fops); if(result < 0) { printk(kern_warning"can't get any major\n"); return result; segmentport_major = result; if(!check_region(segmentport_address_low,segmentport_address_range)!check_region(segmentport_address_high,segmentport_address_range)) { request_region(segmentport_address_low,segmentport_address_range,segmen TPORT_NAME); request_region(segmentport_address_high,segmentport_address_range,segmen TPORT_NAME); printk("init module, segmentport major number : %d\n",result); else printk("driver : unable to register this!\n"); return 0; check_region I / O -> req u es t _region I / O -> rel ea s e_region I / O -> 2 5

27 7 Segment int main() // counter. c { int dev; unsigned int low_counter, high_counter; char ch = 'y',command; // dev = open("/dev/segmentport", O_WRONLY); if(dev < 0) { printf("application : segment driver open fails!\n"); return -1; FND Device file open printf("\n 7Segment Counter\n\n"); printf(" \n"); printf(" r for start the counter\n"); printf(" s for stop the counter\n"); printf(" c for continue the counter\n"); printf(" q for exit\n"); printf(" \n"); 2 6

28 7 Segment high_counter = low_counter = 0; init_keyboard(); command = 'r'; // 7 file_operation 20 ioctl(dev,segment_write_low,&low_counter,4); ioctl(dev,segment_write_high,&high_counter,4); ioctl // 'q' while(ch!= 'q') { // 's' 7 if(command!= 's') { ioctl(dev,segment_write_low,&low_counter,4); ioctl(dev,segment_write_high,&high_counter,4); low_counter++; // 99 0 if(low_counter>99) { low_counter = 0; high_counter++; if(high_counter > 59) high_counter = 0; 2 7

29 7 Segment // Delay usleep(10000); if(kbhit()){ ch = readch(); switch(ch){ case 'r': low_counter = 0; high_counter = 0; command = 'r'; break; case 'c': command = 'r'; break; case 's': command = 's'; break; high_counter = low_counter = 0x0000; write(dev,&low_counter,sizeof(unsigned short)); // close_keyboard(); close(dev); return 0; 2 8

30 7 Segment // void init_keyboard() { tcgetattr(0,&initial_settings); new_settings = initial_settings; new_settings.c_lflag &= ~ICANON; new_settings.c_lflag &= ~ECHO; new_settings.c_lflag &= ~ISIG; new_settings.c_cc[vmin] = 1; new_settings.c_cc[vtime] = 0; tcsetattr(0,tcsanow,&new_settings); // void close_keyboard() { tcsetattr(0,tcsanow,&initial_settings); 2 9

31 7 Segment // int kbhit() { char ch; int nread; if(peek_character!= -1) return 1; new_settings.c_cc[vmin] = 0; tcsetattr(0,tcsanow,&new_settings); nread = read(0,&ch,1); new_settings.c_cc[vmin] = 1; tcsetattr(0,tcsanow,&new_settings); if(nread == 1) { peek_character = ch; return 1; return 0; // int readch() { char ch; if(peek_character!= -1) { ch = peek_character; peek_character = -1; return ch; read(0,&ch,1); return ch; 3 0

32 M M 7 Segment Makefile CC = arm-l i n u x -g c c / / K E R N E L D I R = / h o me / e mb e d d e d 4 / l i n u x rmk 4 -p x a2 I N CL U D E D I R = -I $ ( K E R N E L D I R ) / i n c l u d e -I. / # # CF L A G S = -D K E R N E L -D M O D U L E -W al l -O 2 -I $ ( I N CL U D E D I R ) O D U L E _ O B J S = s e g me n t p o rt. o O D U L E _ S R CS = s e g me n t p o rt. c # #,, T E S T _ T A R G E T = c o u n t e r T E S T _ O B J S = c o u n t e r. o T E S T _ S R CS = c o u n t e r. c # # mak e al l al l : $ ( M O D U L E _ O B J S ) $ ( T E S T _ T A R G E T ) # # $ ( M O D U L E _ O B J S ) : $ ( CC) $ ( CF L A G S ) -c $ ( M O D U L E _ S R CS ) # # $ ( T E S T _ T A R G E T ) : $ ( T E S T _ O B J S ) $ ( CC) $ ( T E S T _ O B J S ) -o # # mak e c l e an c l e an : rm -f *. o rm -f $ ( T E S T _ T A R G E T ) 3 1

33 7 Segment F N D $ make F N D fnd.o fnd_ t e s t i ns m od l oa di ng m k nod $ insmod segmentport.o Using segmentport.o Init module, segmentport major number : 253 $ mknod /dev/segmentport c $./counter 3 2

34 Text LCD T ex t L C D 2 0 C h a r a c t e r s x 2 L i ne s / B a c k l i g h t T y p e 3 3

35 Text LCD Text LCD 3 4

36 TEXT LCD 2 Instruction R e g iste r( IR ) D a ta R e g iste r( D R ). X sca l e Text LCD 1 1 ( D0 ~ D7, R S, R / W, E ) 2 ( R S, R / W ) ( D0 ~ D7 ), E n a b l e o n / o f f X s c a l e Text LCD D0~D7 : D8 : R S D9 : R / W D1 0 : E Instruction Register(IR) Data Register(DR) Text LCD Text LCD 35

37 LCD LCD RS R/W D7 D6 D5 D4 D3 D2 D1 D0 Executed Time Clear Display mS Return Home uS Entry Mode Set I/D S 40uS Display on/off Control D C S 40uS Cursor or Display Shift S/C R/L uS Function Set D/L N F uS Set CG RAM Address CG RAM Address 40uS Set DD RAM Address DD RAM Address 40uS Read Busy Flag and Address 0 1 BF Address Counter 40uS Data Write to CG RAM or DD RAM 1 0 Write Address 40uS Data Read to CG RAM or DD RAM 1 1 Read Address 40uS RS: Register Select, R/W:Read Write, E:Enable 36

38 LCD LCD write RS(D8) R/W(D9) low E(D10) high low Text Lcd ex) // textlcdport.c void setcommand (unsigned short command) { command &= 0x00FF; outl ( (command 0x0000), TEXTLCD_ADD); outl ( (command 0x0400), TEXTLCD_ADD); outl ( (command 0x0000), TEXTLCD_ADD); udelay(50); 8 command OR 0X 0000, 0x 0400, 0x 0000 OR E low -> high -> low 37

39 LCD A d d r e s s Co u n t ( A C) AC D.D.R AM C.G.R AM Ad d r e s s Ad d r e s s I R, Ad d r e s s I R AC, D.D.R AM C.G.R AM. D D R AM x 00~ 0x 0F, 0x 4 0~ 0x 4 F 1, A 0B 0C 0D 0E 0F A 4B 4C 4D 4E 4F 38

40 LCD T e x t LCD Di s p l a y DA T A W r i t e DDRAM Address Set 1 B y te W ri te & Del a y 1 6 B y tes w ri te L i n e C h a n g e( f u n c ti o n set reg i ster) DDRAM Address Set 1 B y te W ri te & Del a y 1 6 B y tes w ri te 39

41 Text LCD (1) // void setcommand(unsigned short command){ command &= 0x00FF; outl((command 0x0000),TEXTLCDPORT_ADDRESS); outl((command 0x0400),TEXTLCDPORT_ADDRESS); outl((command & 0x0000),TEXTLCDPORT_ADDRESS); udelay(50); 8 command OR 0X 0000, 0x 0400, 0x 0000 OR // LCD void writebyte(char ch) { unsigned short data; data = ch & 0x00FF; E low -> high -> low outl((data 0x100),TEXTLCDPORT_ADDRESS); outl((data 0x500),TEXTLCDPORT_ADDRESS); outl((data 0x100),TEXTLCDPORT_ADDRESS); udelay(50); 4 0

42 Text LCD (2) // int clear_display(){ unsigned short command = 0x01; setcommand(command); udelay(2000); return 1; clear display (0x1) setcommand() Text LCD home( ) // int return_home(){ unsigned short command = 0x02; setcommand(command); udelay(2000); return 1; return home (0x02) setcommand() home 4 1

43 Text LCD (3) Entry Mode Set(0x04) increase nshift setcommand Text LCD // / int entry_mode_set(int increase, int nshift){ increase( [1], [0] ) unsigned short command = 0x04; nshift( [1], [0] ) command = increase? (command 0x2) : command; command = nshift? ( command 0x1) : command; setcommand(command); return 1; // On / Off,, int display_control(int display_enable, int cursor_enable, int nblink){ unsigned short command = 0x08; command = display_enable? (command 0x04) : command; command = cursor_enable? (command 0x02) : command; command = nblink? (command 0x01) : command; setcommand(command); Display on/off Control(0x08) display_enable cursor_enable, return 1; nbink [2],[1],[0] setcommand Text LCD display_enable( enable[1],disable[0]) cursor_enable( enable[1], disable[0]) nbink (on[1], off[0]) 4 2

44 Text LCD (4) // int cursor_shit(int set_screen, int set_rightshit){ unsigned short command = 0x10; command = set_screen? (command 0x08) : command; command = set_rightshit? (command 0x04) : command; setcommand(command); return 1; // LCD () int function_set(int rows, int nfonts){ unsigned short command = 0x30; Cursor or Display Shift(0x10) set_screen set_rightshit [3],[2] setcommand LCD set_screen ( set[1], clear[0]) set_rightshit( shift[1], [1]) if(rows == 2) command = 0x08; else if(rows == 1) command &= 0xf7; else return -1; command = nfonts? (command 0x04) : command; setcommand(command); return 1; function set (0x30) rows nfont [4],[3] setcommand TEXT LCD rows (2 [1], 1[0]) nfont (5x10 dot [1], 5 x 7 dot[0]) 4 3

45 Text LCD (5) //, LCD int set_ddram_address(int pos){ unsigned short command = 0x80; command += pos; setcommand(command); return 1; set DD RAM Address(0x80) pos command setcommand LCD pos 0x40 2 // LCD void initialize_textlcd(){ function_set(2,0); //Function Set:8bit,display 2lines,5x7 mod display_control(1,0,0); // Display on, Cursor off clear_display(); // Display clear entry_mode_set(1,0); // Entry Mode Set : shift right cursor return_home(); // go home LCD udelay(2000); 1. Function set( : 001x xx00) 2. Display ON/OFF Control(0000 1xxx) 3. Entry Mode Set( xx) 4. DD RAM 4 4

46 Text LCD (6) // LCD static int textlcdport_open(struct inode *minode, struct file *mfile) { if(textlcdport_usage!= 0) return -EBUSY; MOD_INC_USE_COUNT; textlcdport_usage = 1; MOD_INC_USE_COUNT initialize_textlcd(); return 0; INITIALIZE_TEXTLCD LCD // LCD static int textlcdport_release(struct inode *minode, struct file *mfile) { MOD_DEC_USE_COUNT; textlcdport_usage = 0; return 0;. open MOD_INC_USE_COUNT MOD_DEC_USE_COUNT 4 5

47 Text LCD (7) // LCD static ssize_t textlcdport_write(struct file *inode, const char *gdata, size_t length, loff_t *off_what) { struct strcommand_varible strcommand; copy_from_user(&strcommand,gdata,32); if(strcommand.rows == 0) write_string(0,strcommand.buf,strcommand.strlength); else if(strcommand.rows == 1) write_string(1,strcommand.buf,strcommand.strlength); return length; write gdata length gdata Text LCD length copy_from_user writebyte LCD 4 6

48 Text LCD (8) // ioctl, static int textlcdport_ioctl(struct inode *inode, struct file *file,unsigned int cmd,unsigned long gdata) { struct strcommand_varible strcommand; copy_from_user(&strcommand,(char *)gdata,32); switch(cmd){ case TEXTLCD_COMMAND_SET: setcommand(strcommand.command); break; case TEXTLCD_FUNCTION_SET: function_set((int)(strcommand.rows+1),(int)(strcommand.nfonts)); break; case TEXTLCD_DISPLAY_CONTROL: display_control((int)strcommand.display_enable, (int)strcommand.cursor_enable,(int)strcommand.nblink); break; case TEXTLCD_CURSOR_SHIFT: usrsor_shit((int)strcommand.set_screen,(int)strcommand.set_rightshit); break; case TEXTLCD_ENTRY_MODE_SET: entry_mode_set((int)strcommand.increase,(int)strcommand.nshift); break; case TEXTLCD_RETURN_HOME: return_home(); break; case TEXTLCD_CLEAR: clear_display(); break; case TEXTLCD_DD_ADDRESS: set_ddram_address((int)strcommand.pos); break; case TEXTLCD_WRITE_BYTE: writebyte(strcommand.buf[0]); break; default: printk("driver : no such command!\n"); return -ENOTTY; return 0; ioctl. gdata strcommand_variable. cmd. LCD 4 7

49 Text LCD (9) // static struct file_operations textlcd_fops = { write : textlcdport_write, ioctl : textlcdport_ioctl, open : textlcdport_open, release : textlcdport_release, ; file_operations // LCD void cleanup_module(void) { release_region(textlcdport_address,textlcdport_address_range); if(unregister_chrdev(textlcdport_major,textlcdport_name)) printk(kern_warning"%s DRIVER CLEANUP FALLED\n",TEXTLCDPORT_NAME); rmmod 4 8

50 Text LCD (10) register_chrdev // LCD request_region I/O int init_module(void){ int result; result = register_chrdev(textlcdport_major,textlcdport_name,&textlcd_fops); if(result < 0) { printk(kern_warning"can't get any major\n"); return result; insmod textlcdport_major = result; if(!check_region(textlcdport_address,textlcdport_address_range)) request_region(textlcdport_address,textlcdport_address_range,textlcdport_name); else printk(kern_warning"can't get IO Region 0x%x\n",TEXTLCDPORT_ADDRESS); printk("init module, textlcdport major number : %d\n",result); return 0; check_region I / O -> req u es t _region I / O -> rel ea s e_region I / O -> 49

51 LCD // test.c #define TEXTLCDPORT_BASE #define TEXTLCD_COMMAND_SET #define TEXTLCD_FUNCTION_SET #define TEXTLCD_DISPLAY_CONTROL #define TEXTLCD_CURSOR_SHIFT #define TEXTLCD_ENTRY_MODE_SET #define TEXTLCD_RETURN_HOME #define TEXTLCD_CLEAR #define TEXTLCD_DD_ADDRESS #define TEXTLCD_WRITE_BYTE struct strcommand_varible { char rows; char nfonts; char display_enable; char cursor_enable; char nblink; char set_screen; char set_rightshit; char increase; char nshift; char pos; char command; char strlength; char buf[20]; ; 0xbc _IOW(TEXTLCDPORT_BASE,0,32) _IOW(TEXTLCDPORT_BASE,1,32) _IOW(TEXTLCDPORT_BASE,2,32) _IOW(TEXTLCDPORT_BASE,3,32) _IOW(TEXTLCDPORT_BASE,4,32) _IOW(TEXTLCDPORT_BASE,5,32) _IOW(TEXTLCDPORT_BASE,6,32) _IOW(TEXTLCDPORT_BASE,7,32) _IOW(TEXTLCDPORT_BASE,8,32) Text LCD 5 0

52 LCD int main(int argc, char **argv) { int i,dev; // char buf[20] = "artoa lab"; char welcom[20] = "Welcome to"; char welcom2[20] = "the embeded World!"; struct strcommand_varible strcommand; // strcommand.rows = 0; strcommand.nfonts = 0; strcommand.display_enable = 1; strcommand.cursor_enable = 0; strcommand.nblink = 0; strcommand.set_screen = 0; strcommand.set_rightshit= 1; strcommand.increase = 1; strcommand.nshift = 0; strcommand.pos = 10; strcommand.command = 1; strcommand.strlength = 18; 5 1

53 LCD // buf memcpy(&strcommand.buf[0],buf,20); // dev = open("/dev/textlcdport", O_WRONLY O_NDELAY ); if (dev!= -1) { write(dev,&strcommand,32); sleep(2); ioctl(dev,textlcd_clear,&strcommand,32); strcommand.pos = 0; ioctl(dev,textlcd_dd_address,&strcommand,32); for(i=0;i<10;i++) { memcpy(&strcommand.buf[0],&wellcom[i],1); ioctl(dev,textlcd_write_byte,&strcommand,32); sleep(2); strcommand.pos = 40; ioctl(dev,textlcd_dd_address,&strcommand,32); for(i=0;i<18;i++) { memcpy(&strcommand.buf[0],&wellcom2[i],20); ioctl(dev,textlcd_write_byte,&strcommand,32); ioctl TEXTLCD_DD_ADDRESS ioctl TEXTLCD_WRITE_BYTE close(dev); else { printf( "application : Device Open ERROR!\n"); exit(-1); return(0); 5 2

54 Text LCD Makefile CC = arm-linux-gcc // KERNELDIR = /home/embedded4/linux rmk4-pxa2 INCLUDEDIR = -I$(KERNELDIR)/include -I./ ## CFLAGS = -D KERNEL -DMODULE -Wall -O2 -I$(INCLUDEDIR) MODULE_OBJS = textlcdport.o MODULE_SRCS = textlcdport.c ##,, TEST_TARGET = test TEST_OBJS = test.o TEST_SRCS = test.c ## make all all: $(MODULE_OBJS) $(TEST_TARGET) ## $(MODULE_OBJS) : $(CC) $(CFLAGS) -c $(MODULE_SRCS) ## $(TEST_TARGET) : $(TEST_OBJS) $(CC) $(TEST_OBJS) -o $@ ## make clean clean: rm -f *.o rm -f $(TEST_TARGET) 5 3

55 Text LCD LCD $ make LCD lcd.o lcd_ t e s t i n s m od loa di n g m k n od $ insmod textlcdport.o Using textlcdport.o Init module, textlcdport major number : 252 $ mknod /dev/textlcdport c $./test 5 4

Step Motor. Step Motor Device Driver. Step Motor. Step Motor (2) Step Motor. Step Motor. source. open loop,

Step Motor. Step Motor Device Driver. Step Motor. Step Motor (2) Step Motor. Step Motor. source. open loop, Step Motor Device Driver Step Motor Step Motor Step Motor source Embedded System Lab. II Embedded System Lab. II 2 Step Motor (2) open loop, : : Pulse, Pulse,, -, +5%, step,, Step Motor Step Motor ( ),

More information

Linux Loadable Kernel Modules (LKM)

Linux Loadable Kernel Modules (LKM) Device Driver Linux Loadable Kernel Modules (LKM) A way dynamically ADD code to the Linux kernel LKM is usually used for dynamically add device drivers filesystem drivers system calls network drivers executable

More information

USB. Development of a USB device driver working on Linux and Control Interface. Takeshi Fukutani, Shoji Kodani and Tomokazu Takahashi

USB. Development of a USB device driver working on Linux and Control Interface. Takeshi Fukutani, Shoji Kodani and Tomokazu Takahashi Linux USB Development of a USB device driver working on Linux and Control Interface Takeshi Fukutani, Shoji Kodani and Tomokazu Takahashi Recently, it s becoming more popular to utilize Linux for controlling

More information

Interrupt Programming in Linux

Interrupt Programming in Linux errupt Programming in Linux PXA255 CPU Embedded System Lab. II Embedded System Lab. II 1 IR CPU intr request intr ack data/address status reg data reg mechanism Suppose a peripheral intermittently receives

More information

LCDs. Embedded Systems Interfacing. 20 September 2011

LCDs. Embedded Systems Interfacing. 20 September 2011 20 September 2011 How Polarizers Work How work How Color Work Other Technologies Reflective Nematic (no back light) Cholesteric Liquid Crystal Organic LED/Polymer LED Vacuum Florescent Display Display

More information

NPTEL Course Jan K. Gopinath Indian Institute of Science

NPTEL Course Jan K. Gopinath Indian Institute of Science Storage Systems NPTEL Course Jan 2012 (Lecture 17) K. Gopinath Indian Institute of Science Accessing Devices/Device Driver Many ways to access devices under linux Non-block based devices ( char ) - stream

More information

NPTEL Course Jan K. Gopinath Indian Institute of Science

NPTEL Course Jan K. Gopinath Indian Institute of Science Storage Systems NPTEL Course Jan 2012 (Lecture 18) K. Gopinath Indian Institute of Science Spinlocks & Semaphores Shared data betw different parts of code in kernel most common: access to data structures

More information

Linux Device Drivers. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5. Interrupts

Linux Device Drivers. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5. Interrupts Linux Device Drivers Dr. Wolfgang Koch Friedrich Schiller University Jena Department of Mathematics and Computer Science Jena, Germany wolfgang.koch@uni-jena.de Linux Device Drivers 1. Introduction 2.

More information

Linux drivers - Exercise

Linux drivers - Exercise Embedded Realtime Software Linux drivers - Exercise Scope Keywords Prerequisites Contact Learn how to implement a device driver for the Linux OS. Linux, driver Linux basic knowledges Roberto Bucher, roberto.bucher@supsi.ch

More information

Design and Implementation of an Asymmetric Multiprocessor Environment Within an SMP System. Roberto Mijat, ARM Santa Clara, October 2, 2007

Design and Implementation of an Asymmetric Multiprocessor Environment Within an SMP System. Roberto Mijat, ARM Santa Clara, October 2, 2007 Design and Implementation of an Asymmetric Multiprocessor Environment Within an SMP System Roberto Mijat, ARM Santa Clara, October 2, 2007 1 Agenda Design Principle ARM11 MPCore TM overview System s considerations

More information

Unix (Linux) Device Drivers

Unix (Linux) Device Drivers Unix (Linux) Device Drivers Kernel module that handles the interaction with an specific hardware device, hiding its operational details behind a common interface Three basic categories Character Block

More information

Operating systems for embedded systems. Embedded Operating Systems

Operating systems for embedded systems. Embedded Operating Systems Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource

More information

Operating systems for embedded systems

Operating systems for embedded systems Operating systems for embedded systems Embedded operating systems How do they differ from desktop operating systems? Programming model Process-based Event-based How is concurrency handled? How are resource

More information

REVISION HISTORY NUMBER DATE DESCRIPTION NAME

REVISION HISTORY NUMBER DATE DESCRIPTION NAME i ii REVISION HISTORY NUMBER DATE DESCRIPTION NAME iii Contents 1 The structure of a Linux kernel module 1 1.1 Install XV6...................................................... 1 1.2 Compile and load a

More information

Loadable Kernel Module

Loadable Kernel Module Instituto Superior de Engenharia do Porto Mestrado em Engenharia Eletrotécnica e de Computadores Arquitetura de Computadores Loadable Kernel Module The objective of this lesson is to analyze, compile and

More information

Character Device Drivers One Module - Multiple Devices

Character Device Drivers One Module - Multiple Devices Review from previous classes Three Types: Block, Character, and Network Interface Device Drivers MAJOR & MINOR numbers assigned register_chrdev_region(), alloc_chrdev_region(), unregister_chrdev_region()

More information

16COM / 40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

16COM / 40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD INTRODUCTION KS0066U is a dot matrix LCD driver & controller LSI whichis fabricated by low power CMOS technology It can display 1or 2 lines with the 5 8 dots format or 1 line with the 5 11 dots format

More information

Linux Device Driver in Action (LDDiA)

Linux Device Driver in Action (LDDiA) Linux Device Driver in Action (LDDiA) Duy-Ky Nguyen 2015-04-30 1. On Memory Any unit under user control must have a controller board (CB) with a controller unit (CU) and several devices (Dev.x) doing what

More information

If the display shift operation is used on a 20 x 4 display, the addressing is shifted as follows:

If the display shift operation is used on a 20 x 4 display, the addressing is shifted as follows: If the display shift operation is used on a 2 x 4 display, the addressing is shifted as follows: Left Shift Column 2 3... 8 9 2 line 2 3 2 3 4 line 2 4 42 43 52 53 54 line 3 5 6 7 26 27 28 line 4 55 56

More information

LCD. Configuration and Programming

LCD. Configuration and Programming LCD Configuration and Programming Interfacing and Programming with Input/Output Device: LCD LCD (liquid crystal display) is specifically manufactured to be used with microcontrollers, which means that

More information

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca.

The modules in this lab room are 4 line by 16 character display modules. The data sheet/users manual for the module is posted on My.Seneca. LCD Modules A common output display device used with low cost embedded systems is a character LCD display. The displays are available as complete modules with a standard microprocessor parallel interface.

More information

中显液晶 技术资料 中显控制器使用说明书 2009年3月15日 北京市海淀区中关村大街32号和盛大厦811室 电话 86 010 52926620 传真 86 010 52926621 企业网站.zxlcd.com

中显液晶 技术资料 中显控制器使用说明书 2009年3月15日 北京市海淀区中关村大街32号和盛大厦811室 电话 86 010 52926620 传真 86 010 52926621   企业网站.zxlcd.com http://wwwzxlcdcom 4 SEG / 6 COM DRIVER & CONTROLLER FOR DOT MATRIX LCD June 2 Ver Contents in this document are subject to change without notice No part of this document may be reproduced or transmitted

More information

16COM / 80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

16COM / 80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD INTRODUCTION KS0070B is a dot matrix LCD driver & controller LSI which is fabricated by low power CMOS technology. It is capable of displaying 1 or 2 lines with the 5 7 format or 1 line with the 5 10 dots

More information

7.4 Simple example of Linux drivers

7.4 Simple example of Linux drivers 407 7.4 Simple example of Linux drivers In the previous section, we introduce a simple Hello module driver, it is just some information from the serial port output, the board did not correspond to the

More information

CS C Primer. Tyler Szepesi. January 16, 2013

CS C Primer. Tyler Szepesi. January 16, 2013 January 16, 2013 Topics 1 Why C? 2 Data Types 3 Memory 4 Files 5 Endianness 6 Resources Why C? C is exteremely flexible and gives control to the programmer Allows users to break rigid rules, which are

More information

N720 OpenLinux Software User Guide Version 1.2

N720 OpenLinux Software User Guide Version 1.2 N720 Hardware User Guide () N720 OpenLinux Software User Guide Version 1.2 Copyright Copyright 2017 Neoway Technology Co., Ltd. All rights reserved. No part of this document may be reproduced or transmitted

More information

16COM/40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

16COM/40SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD 6COM/4SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD INTRODUCTION is a dot matrix LCD driver & controller LSI which is fabricated by low power CMOS technology It can display, 2-line with 5 x 8 or 5 x dots

More information

Kernel Modules. Kartik Gopalan

Kernel Modules. Kartik Gopalan Kernel Modules Kartik Gopalan Kernel Modules Allow code to be added to the kernel, dynamically Only those modules that are needed are loaded. Unload when no longer required - frees up memory and other

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight HW2 Due Thursday, July 19 th Midterm on Monday, July 23 th 10:50-11:50 in TBD (And regular exercises in between) POSIX

More information

CS 378 (Spring 2003)

CS 378 (Spring 2003) Department of Computer Sciences THE UNIVERSITY OF TEXAS AT AUSTIN CS 378 (Spring 2003) Linux Kernel Programming Yongguang Zhang (ygz@cs.utexas.edu) Copyright 2003, Yongguang Zhang This Lecture Device Driver

More information

34COM/60SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

34COM/60SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD 34COM/6SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD INTRODUCTION is a dot matrix LCD driver & controller LSI which is fabricated by low power CMOS technology It can display, 2 or 4 lines with 5 8 or 6 8

More information

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall

Preview. Process Control. What is process? Process identifier The fork() System Call File Sharing Race Condition. COSC350 System Software, Fall Preview Process Control What is process? Process identifier The fork() System Call File Sharing Race Condition COSC350 System Software, Fall 2015 1 Von Neumann Computer Architecture: An integrated set

More information

C1098 JPEG Module User Manual

C1098 JPEG Module User Manual C1098 JPEG Module User Manual General Description C1098 is VGA camera module performs as a JPEG compressed still camera that can be attached to a wireless or PDA host. Users can send out a snapshot command

More information

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction

AN1745. Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas. Introduction Order this document by /D Interfacing the HC705C8A to an LCD Module By Mark Glenewinkel Consumer Systems Group Austin, Texas Introduction More and more applications are requiring liquid crystal displays

More information

2-Type Series Pressurized Closures

2-Type Series Pressurized Closures 2-Type Series Pressurized Closures A complete pressure tight reenterable closure system for enclosing spliced connections of communications cables in a wide variety of applications. The 2-type Closure

More information

Finish up OS topics Group plans

Finish up OS topics Group plans Finish up OS topics Group plans Today Finish up and review Linux device driver stuff Walk example again See how it all goes together Discuss talking to MMIO RTOS (on board) Deferred interrupts Discussion

More information

Linux Device Drivers. 3. Char Drivers cont. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5.

Linux Device Drivers. 3. Char Drivers cont. 3. Char Drivers. 1. Introduction 2. Kernel Modules 3. Char Drivers 4. Advanced Char Drivers 5. Linux Device Drivers Dr. Wolfgang Koch Friedrich Schiller University Jena Department of Mathematics and Computer Science Jena, Germany wolfgang.koch@uni-jena.de Linux Device Drivers 1. Introduction 2.

More information

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute,

Virtual File System (VFS) Implementation in Linux. Tushar B. Kute, Virtual File System (VFS) Implementation in Linux Tushar B. Kute, http://tusharkute.com Virtual File System The Linux kernel implements the concept of Virtual File System (VFS, originally Virtual Filesystem

More information

16COM/80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD

16COM/80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD 6COM/80SEG DRIVER & CONTROLLER FOR DOT MATRIX LCD INTRODUCTION The is a dot matrix LCD driver & controller LSI which is fabricated by low power CMOS technology It is capable of displaying or 2 lines with

More information

How to write a Measurement Telnet Server

How to write a Measurement Telnet Server How to write a Measurement Telnet Server A measurement Telnet server allows you to access remote I/Os with a standard Telnet client program. The following samples shows a way to set the LEDs of a DNP/EVA2

More information

System calls and assembler

System calls and assembler System calls and assembler Michal Sojka sojkam1@fel.cvut.cz ČVUT, FEL License: CC-BY-SA 4.0 System calls (repetition from lectures) A way for normal applications to invoke operating system (OS) kernel's

More information

Linux Device Driver. Analog/Digital Signal Interfacing

Linux Device Driver. Analog/Digital Signal Interfacing Linux Device Driver Analog/Digital Signal Interfacing User Program & Kernel Interface Loadable Kernel Module(LKM) A new kernel module can be added on the fly (while OS is still running) LKMs are often

More information

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls

Lecture 3. Introduction to Unix Systems Programming: Unix File I/O System Calls Lecture 3 Introduction to Unix Systems Programming: Unix File I/O System Calls 1 Unix File I/O 2 Unix System Calls System calls are low level functions the operating system makes available to applications

More information

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line

Operating Systems. Lecture 06. System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line Operating Systems Lecture 06 System Calls (Exec, Open, Read, Write) Inter-process Communication in Unix/Linux (PIPE), Use of PIPE on command line March 04, 2013 exec() Typically the exec system call is

More information

ECE 4510/5530 Microcontroller Applications Week 9

ECE 4510/5530 Microcontroller Applications Week 9 ECE 45/553 Microcontroller Applications Week 9 Dr. Bradley J. Bazuin Associate Professor Department of Electrical and Computer Engineering College of Engineering and Applied Sciences Lab 7 & 8 Elements

More information

Dot Matrix LCD Controller Driver

Dot Matrix LCD Controller Driver PF22-7 SED27F/D Dot Matrix LCD Controller Driver /, / or /6 Duty Dot Matrix Drive ROM 24 characters Built-in Character Generator ROM and RAM ( RAM characters ) Maximum Simultaneous Display of Characters

More information

UNIX System Calls. Sys Calls versus Library Func

UNIX System Calls. Sys Calls versus Library Func UNIX System Calls Entry points to the kernel Provide services to the processes One feature that cannot be changed Definitions are in C For most system calls a function with the same name exists in the

More information

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014

CS5460/6460: Operating Systems. Lecture 24: Device drivers. Anton Burtsev April, 2014 CS5460/6460: Operating Systems Lecture 24: Device drivers Anton Burtsev April, 2014 Device drivers Conceptually Implement interface to hardware Expose some high-level interface to the kernel or applications

More information

Product Information. Features. Table of Contents EA DIP162 DN3LW EA DIP162 DHNLED EA DIP162 DNLED EA DIP162J DN3LW

Product Information. Features. Table of Contents EA DIP162 DN3LW EA DIP162 DHNLED EA DIP162 DNLED EA DIP162J DN3LW LCD Module with included HD44780 controller Product Information EA DIP162 DNLED EA DIP162 DHNLED EA DIP162 DN3LW EA DIP162J DN3LW LCD Module with two 16-character rows 6.68mm in height Same as previous,

More information

CSC 271 Software I: Utilities and Internals

CSC 271 Software I: Utilities and Internals CSC 271 Software I: Utilities and Internals Lecture 13 : An Introduction to File I/O in Linux File Descriptors All system calls for I/O operations refer to open files using a file descriptor (a nonnegative

More information

everything is a file main.c a.out /dev/sda1 /dev/tty2 /proc/cpuinfo file descriptor int

everything is a file main.c a.out /dev/sda1 /dev/tty2 /proc/cpuinfo file descriptor int everything is a file main.c a.out /dev/sda1 /dev/tty2 /proc/cpuinfo file descriptor int #include #include #include int open(const char *path, int flags); flagso_rdonly

More information

LMB202DBC LCD Module User Manual

LMB202DBC LCD Module User Manual LMB202DBC LCD Module User Manual Shenzhen TOPWAY Technology Co., Ltd. Rev. Descriptions Release Date 0.1 Prelimiay release 2005-03-01 URL Document Name LMB202DBC-Manual-Rev0.1.doc Page 1 of 11 Table of

More information

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems Deep C Multifile projects Getting it running Data types Typecasting Memory management Pointers Fabián E. Bustamante, Fall 2004 Multifile Projects Give your project a structure Modularized design Reuse

More information

The Beast We Call A3. CS 161: Lecture 10 3/7/17

The Beast We Call A3. CS 161: Lecture 10 3/7/17 The Beast We Call A3 CS 161: Lecture 10 3/7/17 But first... Unconfusing Three Confusions Where does the kernel live? Does every kind of processor use a twolevel page table? Does everything have an address?

More information

The device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware

The device driver (DD) implements these user functions, which translate system calls into device-specific operations that act on real hardware Introduction (Linux Device Drivers, 3rd Edition (www.makelinux.net/ldd3)) Device Drivers -> DD They are a well defined programming interface between the applications and the actual hardware They hide completely

More information

CSE 333 SECTION 3. POSIX I/O Functions

CSE 333 SECTION 3. POSIX I/O Functions CSE 333 SECTION 3 POSIX I/O Functions Administrivia Questions (?) HW1 Due Tonight Exercise 7 due Monday (out later today) POSIX Portable Operating System Interface Family of standards specified by the

More information

CS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015

CS165 Computer Security. Understanding low-level program execution Oct 1 st, 2015 CS165 Computer Security Understanding low-level program execution Oct 1 st, 2015 A computer lets you make more mistakes faster than any invention in human history - with the possible exceptions of handguns

More information

CS360 Midterm 1 - February 21, James S. Plank. Put all answers on the answer sheet. In all of these questions, please assume the following:

CS360 Midterm 1 - February 21, James S. Plank. Put all answers on the answer sheet. In all of these questions, please assume the following: CS360 Midterm 1 - February 21, 2017 - James S. Plank Put all answers on the answer sheet. In all of these questions, please assume the following: Pointers and longs are 4 bytes. The machine is little endian

More information

Introduction Reading Writing scull. Linux Device Drivers - char driver

Introduction Reading Writing scull. Linux Device Drivers - char driver Overview 1 2 3 4 Major, minor File Operations The file Structure The inode structure Registraction simplest driver, suitable for most simple devices, follow the book. Jernej Figure: Vičič. (Simple Character

More information

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A)

CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) CS 423 Operating System Design: Introduction to Linux Kernel Programming (MP1 Q&A) Professor Adam Bates Fall 2018 Learning Objectives: Talk about the relevant skills required in MP1 Announcements: MP1

More information

ModBus Communication protocol. The ModBus protocol is an industrial communications and distributed control system

ModBus Communication protocol. The ModBus protocol is an industrial communications and distributed control system ModBus Communication protocol ModBus Communication Standards The ModBus protocol is an industrial communications and distributed control system to integrate PLCs, computers, terminals, and other monitoring,

More information

Communication. Serial port programming

Communication. Serial port programming Applied mechatronics Communication. Serial port programming Sven Gestegård Robertz sven.robertz@cs.lth.se Department of Computer Science, Lund University 2017 Outline 1 Introduction 2 Terminal I/O programming

More information

UNIX System Programming

UNIX System Programming File I/O 경희대학교컴퓨터공학과 조진성 UNIX System Programming File in UNIX n Unified interface for all I/Os in UNIX ü Regular(normal) files in file system ü Special files for devices terminal, keyboard, mouse, tape,

More information

File: /home/young/mywork/7.cordic_accuracy/if.ghdl/ghdlif.print Page 1 of 15

File: /home/young/mywork/7.cordic_accuracy/if.ghdl/ghdlif.print Page 1 of 15 File: /home/young/mywork/7.cordic_accuracy/if.ghdl/ghdlif.print Page 1 of 15 makefile INCD = /home/young/mywork/inc LIBD = /home/young/mywork/lib SRC = cordic_beh.vhdl \ cordic_vtb.vhdl \ sendrecv.c \

More information

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016

Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE. Advanced Operating Systems A.A Exam date: 28 June 2016 Politecnico di Milano FACOLTÀ DI INGEGNERIA DELL INFORMAZIONE Advanced Operating Systems A.A. 2015-2016 Exam date: 28 June 2016 Prof. William FORNACIARI Surname (readable)... Matr... Name (readable)...

More information

What is a Process. Preview. What is a Process. What is a Process. Process Instruction Cycle. Process Instruction Cycle 3/14/2018.

What is a Process. Preview. What is a Process. What is a Process. Process Instruction Cycle. Process Instruction Cycle 3/14/2018. Preview Process Control What is process? Process identifier A key concept in OS is the process Process a program in execution Once a process is created, OS not only reserve space (in Memory) for the process

More information

DOT MATRIX CHARACTER LCD MODULE USER S MANUAL

DOT MATRIX CHARACTER LCD MODULE USER S MANUAL DOT MATRIX CHARACTER LCD MODULE USER S MANUAL OPTREX CORPORATION Apollo Display Technologies Inc. 194-22 Morris Ave. Holtsville NY 11742 Phone: (516) 654-1143 Fax: (516) 654-1496 www.apollodisplays.com

More information

Decisions II. Switch Statement. If else allows a 2 way decision Switch allows for n-way decisions

Decisions II. Switch Statement. If else allows a 2 way decision Switch allows for n-way decisions Switch Statement If else allows a 2 way decision Switch allows for n-way decisions switch(variable){ case val1: statement; case val2: statement; case val3: statement; default: statement; variable must

More information

COSC Operating Systems Design, Fall Lecture Note: Unnamed Pipe and Shared Memory. Unnamed Pipes

COSC Operating Systems Design, Fall Lecture Note: Unnamed Pipe and Shared Memory. Unnamed Pipes COSC4740-01 Operating Systems Design, Fall 2001 Lecture Note: Unnamed Pipe and Shared Memory Unnamed Pipes Pipes are a form of Inter-Process Communication (IPC) implemented on Unix and Linux variants.

More information

EE 354 September 16, 2016 C Sample Programs

EE 354 September 16, 2016 C Sample Programs EE 354 September 16, 2016 C Sample Programs //DataArray /* This program creates an array of data in code memory * that is 32 bytes long. Fill this array with the ascii codes for * the capital letters plus

More information

SSD1803. Product Preview. 100 x 34 STN LCD Segment / Common Mono Driver with Controller

SSD1803. Product Preview. 100 x 34 STN LCD Segment / Common Mono Driver with Controller SOLOMON SYSTECH SEMICONDUCTOR TECHNICAL DATA Crystalfontz Thiscontrolerdatasheetwasdownloadedfrom htp:/www.crystalfontz.com/controlers/ SSD1803 Product Preview 100 x 34 STN LCD Segment / Common Mono Driver

More information

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes. Unix-Linux 2 fork( ) system call is successful parent suspended child created fork( ) returns child pid to parent fork( ) returns zero value to child; zero is the pid of the swapper/scheduler process both

More information

unit: mm 3044B - QFP80A unit: mm QFP80D

unit: mm 3044B - QFP80A unit: mm QFP80D Ordering number: EN 3255C CMOS LSI LC7985NA, LC7985ND LCD Controller/Driver Overview Package Dimensions The LC7985 series devices are low-power CMOS ICs that incorporate dot-matrix character generator,

More information

libacarsd documentation 12. December 2003 libacarsd 1.46 ACARS Decoder Library ,2004 by KjM

libacarsd documentation 12. December 2003 libacarsd 1.46 ACARS Decoder Library ,2004 by KjM libacarsd 1.46 ACARS Decoder Library. 2003,2004 by KjM It is not allowed to monitor all radio frequencies in every country! Software that makes use of libacarsd as decoder should make

More information

Pipes. Pipes Implement a FIFO. Pipes (cont d) SWE 545. Pipes. A FIFO (First In, First Out) buffer is like a. Pipes are uni-directional

Pipes. Pipes Implement a FIFO. Pipes (cont d) SWE 545. Pipes. A FIFO (First In, First Out) buffer is like a. Pipes are uni-directional Pipes SWE 545 Pipes Pipes are a way to allow processes to communicate with each other Pipes implement one form of IPC (Interprocess Communication) This allows synchronization of process execution There

More information

JUL. 27, 2001 Version 1.0

JUL. 27, 2001 Version 1.0 S SPLC782A 6COM/8SEG Controller/Driver JUL. 27, 2 Version. SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLOGY CO. is

More information

518 Lecture Notes Week 3

518 Lecture Notes Week 3 518 Lecture Notes Week 3 (Sept. 15, 2014) 1/8 518 Lecture Notes Week 3 1 Topics Process management Process creation with fork() Overlaying an existing process with exec Notes on Lab 3 2 Process management

More information

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430 Week 2 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430 1 Why is the Shell Important? Shells provide us with a way to interact with the core system Executes programs on

More information

User s Guide ATM1602B

User s Guide ATM1602B User s Guide ATM1602B Liquid Crystal Display Module CONTENTS Mechanical Diagram. 2 Absolute Maximum Ratings 3 Description of Terminals... 3 Optical Characteristics 4 Electrical Characteristics 4 DC Characteristics.

More information

POSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017

POSIX Shared Memory. Linux/UNIX IPC Programming. Outline. Michael Kerrisk, man7.org c 2017 November 2017 Linux/UNIX IPC Programming POSIX Shared Memory Michael Kerrisk, man7.org c 2017 mtk@man7.org November 2017 Outline 10 POSIX Shared Memory 10-1 10.1 Overview 10-3 10.2 Creating and opening shared memory

More information

Designing and developing device drivers. Coding drivers

Designing and developing device drivers. Coding drivers Designing and developing device drivers Coding drivers Registering a driver 2 calls to register a driver defined in int register_chrdev_region(dev_t first, unsigned int count, char *name);

More information

LINPO TECHNOLOGY LTD SPECIFICATIONS OF LCD MODULE

LINPO TECHNOLOGY LTD SPECIFICATIONS OF LCD MODULE LINPO TECHNOLOGY LTD SPECIFICATIONS OF LCD MODULE PART NUMBER TECH1602B SERIES DATE JULY 28, 1998 CONTENTS Mechanical Diagram 2 Absolute Maximum Ratings 3 Description of Terminals 3 Optical Characteristics

More information

Linux Kernel Modules & Device Drivers April 9, 2012

Linux Kernel Modules & Device Drivers April 9, 2012 Linux Kernel Modules & Device Drivers April 9, 2012 Pacific University 1 Resources Linux Device Drivers,3rd Edition, Corbet, Rubini, Kroah- Hartman; O'Reilly kernel 2.6.10 we will use 3.1.9 The current

More information

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

CS 3113 Introduction to Operating Systems Midterm October 11, 2018 General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also

More information

CS 3113 Introduction to Operating Systems Midterm October 11, 2018

CS 3113 Introduction to Operating Systems Midterm October 11, 2018 General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also

More information

LCD MODULE 4x mm INCL. CONTROLLER SSD1803

LCD MODULE 4x mm INCL. CONTROLLER SSD1803 LCD MODULE 4x20-3.75mm INCL. CONTROLLER SSD1803 Issue 4.2013 EA DIP203J-4NLW EA DIP203G-4NLED Dimension 68 x 27 mm EA DIP203B-4NLW Dimension 75 x 27 mm FEATURES * HIGH CONTRAST LCD SUPERTWIST DISPLAY *

More information

Venstar Thermostat Adapter

Venstar Thermostat Adapter Developer Venstar Thermostat Adapter v001 Developer Venstar Thermostat Adapter Version 001 May 23, 2013 Revision History Rev Date Comments 001 05/23/13 Initial Release Page 1 of 13 Table of Contents 1

More information

NHD-C0216CZ-FSW-FBW-3V3

NHD-C0216CZ-FSW-FBW-3V3 NHD-C0216CZ-FSW-FBW-3V3 COG (Chip-on-Glass) Liquid Crystal Display Module NHD- Newhaven Display C0216- COG, 2 Lines x 16 Characters CZ- Model F- Transflective SW- Side White LED Backlight F- FSTN (+) B-

More information

Question F5: Caching [10 pts]

Question F5: Caching [10 pts] Question F5: Caching [ pts] SID: We have 6 KiB of RAM and two options for our cache. Both are two-way set associative with 256 B blocks, LRU replacement, and write-back policies. Cache A is size KiB and

More information

Simple char driver. for Linux. my_first.c: headers. my_first.c: file structure. Calcolatori Elettronici e Sistemi Operativi.

Simple char driver. for Linux. my_first.c: headers. my_first.c: file structure. Calcolatori Elettronici e Sistemi Operativi. Calcolatori Elettronici e Sistemi Operativi Simple char driver Simple char driver for Linux Code organization my_first.c driver code: Headers Macro definitions Device structure definition Globals and module

More information

PRE32 RS232 protocol v1.21 Tomas Andersson

PRE32 RS232 protocol v1.21 Tomas Andersson PRE32 RS232 protocol 2014-11-07 v1.21 Tomas Andersson Description This document describes the RS232 protocol used to control the PRE32 device. Command structure Commands are sent to the device using the

More information

Files. Eric McCreath

Files. Eric McCreath Files Eric McCreath 2 What is a file? Information used by a computer system may be stored on a variety of storage mediums (magnetic disks, magnetic tapes, optical disks, flash disks etc). However, as a

More information

RAYSTAR_OLED Application Note. OLED Character type

RAYSTAR_OLED Application Note. OLED Character type OLED Character type Version 26 Date: 2011/10/4 Date : 2011/10/4 FAE Department 1 1 RECORD OF REVISION 4 2 DESCRIPTION & FEATURES 5 3 APPLICATION CIRCUIT6 31 Parallel 8-bit 68/80 mode 6 32 Parallel 4-bit

More information

File Descriptors and Piping

File Descriptors and Piping File Descriptors and Piping CSC209: Software Tools and Systems Programming Furkan Alaca & Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Week 8 Today s topics File Descriptors

More information

CS240: Programming in C

CS240: Programming in C CS240: Programming in C Lecture 15: Unix interface: low-level interface Cristina Nita-Rotaru Lecture 15/Fall 2013 1 Streams Recap Higher-level interface, layered on top of the primitive file descriptor

More information

Lecture files in /home/hwang/cs375/lecture05 on csserver.

Lecture files in /home/hwang/cs375/lecture05 on csserver. Lecture 5 Lecture files in /home/hwang/cs375/lecture05 on csserver. cp -r /home/hwang/cs375/lecture05. scp -r user@csserver.evansville.edu:/home/hwang/cs375/lecture05. Project 1 posted, due next Thursday

More information

File: /home/young/mywork/7.cordic_accuracy/ghdl/print.file Page 1 of 13

File: /home/young/mywork/7.cordic_accuracy/ghdl/print.file Page 1 of 13 File: /home/young/mywork/7.cordic_accuracy/ghdl/print.file Page 1 of 13 makefile sendrecv.o: sendrecv.c gcc -c -Wall sendrecv.c cordic_vtb: sendrecv.o cordic_vtb.vhdl cp /home/young/mywork/5.cordic_vhdl/a.beh/cordic_pkg.vhdl.

More information

Operating Systems II BS degree in Computer Engineering Sapienza University of Rome Lecturer: Francesco Quaglia. Topics: 1.

Operating Systems II BS degree in Computer Engineering Sapienza University of Rome Lecturer: Francesco Quaglia. Topics: 1. Operating Systems II BS degree in Computer Engineering Sapienza University of Rome Lecturer: Francesco Quaglia Topics: 1. LINUX modules Modules basics A LINUX module is a software component which can be

More information

CS 241 Data Organization Binary

CS 241 Data Organization Binary CS 241 Data Organization Binary Brooke Chenoweth University of New Mexico Fall 2017 Combinations and Permutations In English we use the word combination loosely, without thinking if the order of things

More information