UDI Tutorial & Driver Walk-Through Part 2 Kurt Gollhardt SCO Core OS Architect

Slides:



Advertisements
Similar presentations
Homework Reading Machine Projects Labs
Advertisements

R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
1 (Review of Prerequisite Material). Processes are an abstraction of the operation of computers. So, to understand operating systems, one must have a.
Module R2 CS450. Next Week R1 is due next Friday ▫Bring manuals in a binder - make sure to have a cover page with group number, module, and date. You.
Input and Output CS 215 Lecture #20.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Memory Management.
04/14/2008CSCI 315 Operating Systems Design1 I/O Systems Notice: The slides for this lecture have been largely based on those accompanying the textbook.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
DIRECT MEMORY ACCESS CS 147 Thursday July 5,2001 SEEMA RAI.
CS 333 Introduction to Operating Systems Class 11 – Virtual Memory (1)
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
CS 333 Introduction to Operating Systems Class 18 - File System Performance Jonathan Walpole Computer Science Portland State University.
I/O Systems CS 3100 I/O Hardware1. I/O Hardware Incredible variety of I/O devices Common concepts ◦Port ◦Bus (daisy chain or shared direct access) ◦Controller.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
1 Computer System Overview Chapter 1 Review of basic hardware concepts.
I/O Tanenbaum, ch. 5 p. 329 – 427 Silberschatz, ch. 13 p
The University of New Hampshire InterOperability Laboratory Serial ATA (SATA) Protocol Chapter 10 – Transport Layer.
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
Chapter 10: Input / Output Devices Dr Mohamed Menacer Taibah University
CS 11 C track: lecture 5 Last week: pointers This week: Pointer arithmetic Arrays and pointers Dynamic memory allocation The stack and the heap.
1 Computer System Overview Chapter 1. 2 n An Operating System makes the computing power available to users by controlling the hardware n Let us review.
Java: Chapter 1 Computer Systems Computer Programming II.
I/O Systems I/O Hardware Application I/O Interface
FINAL MPX DELIVERABLE Due when you schedule your interview and presentation.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
Chapter 4. INTERNAL REPRESENTATION OF FILES
Device Drivers CPU I/O Interface Device Driver DEVICECONTROL OPERATIONSDATA TRANSFER OPERATIONS Disk Seek to Sector, Track, Cyl. Seek Home Position.
UDI Tutorial & Driver Walk-Through Part 1 Kurt Gollhardt SCO Core OS Architect
Moving Arrays -- 1 Completion of ideas needed for a general and complete program Final concepts needed for Final Review for Final – Loop efficiency.
UDI HDK Roadmap Matt Kaufman Senior Software Engineer
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 13: I/O Systems I/O Hardware Application I/O Interface Kernel I/O Subsystem.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
CS333 Intro to Operating Systems Jonathan Walpole.
Silberschatz, Galvin and Gagne  Operating System Concepts Six Step Process to Perform DMA Transfer.
I/O, Devices & Device Drivers I/O subsystem It is the responsibility of the I/O subsystem of an OS to schedule, manage, & control the interactions between.
UDI Advanced Topics DMA and Interrupts Robert Lipe UDI Development Team Lead
CS 342 – Operating Systems Spring 2003 © Ibrahim Korpeoglu Bilkent University1 Input/Output – 2 I/O Software CS 342 – Operating Systems Ibrahim Korpeoglu.
Processor Memory Processor-memory bus I/O Device Bus Adapter I/O Device I/O Device Bus Adapter I/O Device I/O Device Expansion bus I/O Bus.
+ Storage Classes and Linkage. + Introduction Scope describe the region or regions of a program that can access and identifier Variables can be shared.
Silberschatz, Galvin, and Gagne  Applied Operating System Concepts Module 12: I/O Systems I/O hardwared Application I/O Interface Kernel I/O.
Linux Kernel Development Memory Management Pavel Sorokin Gyeongsang National University
1 Lecture 19: Unix signals and Terminal management n what is a signal n signal handling u kernel u user n signal generation n signal example usage n terminal.
UDI Network Drivers Network Interface Metalanguage Barry Feild SCO Server Products Group
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 4.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
UDI Architecture In-Depth Robert Lipe UDI Development Team Lead
CPS110: Implementing threads on a uni-processor Landon Cox January 29, 2008.
Chapter 13: I/O Systems.
Chapter 2: The Linux System Part 4
Module 12: I/O Systems I/O hardware Application I/O Interface
Jonathan Walpole Computer Science Portland State University
Processes and threads.
Process concept.
2P13 Week 2.
Computer System Overview
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Chapter 5: I/O Systems.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Outline Chapter 3: Processes Chapter 4: Threads So far - Next -
C Language B. DHIVYA 17PCA140 II MCA.
Internal Representation of Files
Lecture 12 Input/Output (programmer view)
Dynamic Binary Translators and Instrumenters
Module 12: I/O Systems I/O hardwared Application I/O Interface
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

UDI Tutorial & Driver Walk-Through Part 2 Kurt Gollhardt SCO Core OS Architect

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 2 Overview Key Concepts Description of Sample Driver Walk-Through Additional Examples Hints & Tips

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 3 Walk-Through udi_cmos.c lines Primary region initialization 243 static const udi_primary_init_t udi_cmos_primary_init_info = { 244 &cmos_mgmt_ops, 245 0, /* mgmt_scratch_size */ 246 0, /* no children, so no enumeration */ 247 sizeof(cmos_region_data_t) 248 };

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 4 Walk-Through udi_cmos.c lines Channel ops initialization 255 static const udi_ops_init_t udi_cmos_ops_init_list[] = { 256 { 257 GIO_OPS_IDX, 258 CMOS_GIO_META, 260 UDI_GIO_PROVIDER_OPS_NUM, 261 0, /* no channel context */ 262 (udi_ops_vector_t *) &cmos_gio_provider_ops 263 },...

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 5 Walk-Through udi_cmos.c lines Control block initialization 292 static const udi_cb_init_t udi_cmos_cb_init_list[] = { 293 { 294 GIO_BIND_CB_IDX, 295 CMOS_GIO_META, 296 UDI_GIO_BIND_CB_NUM, 297 GIO_BIND_SCRATCH, 298 0, /* inline size */ 299 NULL /* inline layout */ 300 },...

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 6 Walk-Through udi_cmos.c lines Driver initialization structure 348 const udi_init_t udi_init_info = { 349 &udi_cmos_primary_init_info, 350 NULL, /* secondary_init_list */ 351 udi_cmos_ops_init_list, 352 udi_cmos_cb_init_list, 353 NULL, /* gcb_init_list */ 354 NULL /* cb_select_list */ 355 }; udi_init_info is only well-known global name

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 7 Walk-Through udi_cmos.c lines Handle channel events from parent (bridge) 365 static void 366 cmos_parent_channel_event(udi_channel_event_cb_t *channel_event_cb) 367 { 368 switch (channel_event_cb->event) { 369 case UDI_CHANNEL_BOUND: 370 /* Allocate a bus bind control block. */ 371 udi_cb_alloc(cmos_bind_to_parent_1, 372 UDI_GCB(channel_event_cb), 373 BUS_BIND_CB_IDX, 374 channel_event_cb->gcb.channel); 375 break; 378 default: 379 udi_channel_event_complete(channel_event_cb, UDI_OK); 380 } 381 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 8 Walk-Through udi_cmos.c lines Continue bind sequence after allocation 384 cmos_bind_to_parent_1( 385 udi_cb_t *gcb, 386 udi_cb_t *new_cb) 387 { 388 udi_bus_bind_cb_t *bus_bind_cb = 389 UDI_MCB(new_cb, udi_bus_bind_cb_t); /* Keep a link back to the channel event CB for the ack. */ 392 bus_bind_cb->gcb.initiator_context = gcb; /* Bind to the parent bus bridge driver. */ 395 udi_bus_bind_req(bus_bind_cb); 396 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 9 Walk-Through udi_cmos.c lines Received ack from bridge; map PIO device 400 static void 401 cmos_bus_bind_ack( 402 udi_bus_bind_cb_t *bus_bind_cb, 403 udi_ubit8_t preferred_endianness, 404 udi_status_t status) 405 { 406 cmos_region_data_t *rdata = bus_bind_cb->gcb.context; 418 rdata->bus_bind_cb = bus_bind_cb; 424 udi_pio_map(cmos_bus_bind_ack_1, UDI_GCB(bus_bind_cb), 425 CMOS_REGSET, CMOS_BASE, CMOS_LENGTH, 426 cmos_trans_read, 427 sizeof cmos_trans_read / sizeof(udi_pio_trans_t), 428 UDI_PIO_STRICTORDER, CMOS_PACE); 429 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 10 Walk-Through udi_cmos.c lines Map second PIO handle (2 trans lists) 434 cmos_bus_bind_ack_1( 435 udi_cb_t *gcb, 436 udi_pio_handle_t new_pio_handle) 437 { 438 cmos_region_data_t *rdata = gcb->context; 441 rdata->trans_read = new_pio_handle; udi_pio_map(cmos_bus_bind_ack_2, gcb, 444 CMOS_REGSET, CMOS_BASE, CMOS_LENGTH, 445 cmos_trans_write, 446 sizeof cmos_trans_write / sizeof(udi_pio_trans_t), 447 UDI_PIO_STRICTORDER, CMOS_PACE); 448 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 11 Walk-Through udi_cmos.c lines Bind sequence complete 451 cmos_bus_bind_ack_2( 452 udi_cb_t *gcb, 453 udi_pio_handle_t new_pio_handle) 454 { 455 cmos_region_data_t *rdata = gcb->context; 456 udi_channel_event_cb_t *channel_event_cb = 457 gcb->initiator_context; /* Save the PIO handle for later use. */ 460 rdata->trans_write = new_pio_handle; /* Let the MA know we've completed binding. */ 467 udi_channel_event_complete(channel_event_cb, UDI_OK); 468 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 12 Walk-Through udi_cmos.c lines Child bind and unbind –This driver has no per-child state 470 static void 471 cmos_gio_bind_req(udi_gio_bind_cb_t *gio_bind_cb) 472 { 473 udi_gio_bind_ack(gio_bind_cb, CMOS_DEVSIZE, 0, UDI_OK); 474 } static void 477 cmos_gio_unbind_req(udi_gio_bind_cb_t *gio_bind_cb) 478 { 479 udi_gio_unbind_ack(gio_bind_cb); 480 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 13 Walk-Through udi_cmos.c lines Transfer request operation - READ case 492 cmos_gio_xfer_req(udi_gio_xfer_cb_t *gio_xfer_cb) 493 { 494 udi_gio_rw_params_t *rw_params = gio_xfer_cb->tr_params; switch (gio_xfer_cb->op) { 502 case UDI_GIO_OP_READ: 503 udi_assert(rw_params->offset_hi == 0 && 504 rw_params->offset_lo < CMOS_DEVSIZE && 505 gio_xfer_cb->data_buf->buf_size < 506 CMOS_DEVSIZE - rw_params->offset_lo); 507 cmos_do_read(gio_xfer_cb, rw_params->offset_lo); 508 break;

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 14 Walk-Through udi_cmos.c lines Transfer request operation - WRITE case 509 case UDI_GIO_OP_WRITE: 510 udi_assert(rw_params->offset_hi == 0 && 511 rw_params->offset_lo < CMOS_DEVSIZE && 512 gio_xfer_cb->data_buf->buf_size < 513 CMOS_DEVSIZE - rw_params->offset_lo); 514 cmos_do_write(gio_xfer_cb, rw_params->offset_lo); 515 break; Transfer request operation - error case 516 default: 517 udi_gio_xfer_nak(gio_xfer_cb, UDI_STAT_NOT_UNDERSTOOD); 518 } 519 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 15 Walk-Through udi_cmos.c lines Initiate PIO transactions for READ request 525 cmos_do_read(udi_gio_xfer_cb_t *gio_xfer_cb, udi_ubit8_t addr) 526 { 527 cmos_region_data_t *rdata = gio_xfer_cb->gcb.context; 528 cmos_gio_xfer_scratch_t *gio_xfer_scratch = 529 gio_xfer_cb->gcb.scratch; gio_xfer_scratch->addr = addr; 536 gio_xfer_scratch->count = gio_xfer_cb->data_buf->buf_size; udi_pio_trans(cmos_do_read_1, gcb, 539 rdata->trans_read, 540 new_buf, NULL); 541 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 16 Walk-Through udi_cmos.c lines Complete READ request 544 cmos_do_read_1( 545 udi_cb_t *gcb, 546 udi_buf_t *new_buf, 547 udi_status_t status, 548 udi_ubit16_t result) 549 { 550 udi_gio_xfer_cb_t *gio_xfer_cb = 551 UDI_MCB(gcb, udi_gio_xfer_cb_t); /* udi_pio_trans may create a new buffer. */ 554 gio_xfer_cb->data_buf = new_buf; if (status == UDI_OK) 557 udi_gio_xfer_ack(gio_xfer_cb); 558 else 559 udi_gio_xfer_nak(gio_xfer_cb, status); 560 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 17 Walk-Through udi_cmos.c lines WRITE case identical to READ except: –Uses trans_write instead of trans_read –Special case for CMOS driver: 572 /* 573 * The first CMOS_RDONLY_SZ bytes of this device are not 574 * allowed to be written through this driver. Fail any 575 * attempt to write to these bytes. 576 */ 577 if (addr < CMOS_RDONLY_SZ) { 578 udi_gio_xfer_nak(gio_xfer_cb, 579 UDI_STAT_MISTAKEN_IDENTITY); 580 return; 581 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 18 Walk-Through udi_cmos.c lines Device Management - unbind from parent 616 cmos_devmgmt_req( 617 udi_mgmt_cb_t *cb, 618 udi_ubit8_t mgmt_op, udi_ubit8_t parent_id) 620 { 621 cmos_region_data_t *rdata = cb->gcb.context; 623 switch (mgmt_op) { 624 case UDI_DMGMT_UNBIND: 628 /* Keep a link back to this CB for use in the ack */ 629 rdata->bus_bind_cb->gcb.initiator_context = cb; 631 /* Do the metalanguage-specific unbind. */ 632 udi_bus_unbind_req(rdata->bus_bind_cb); 633 default: 634 udi_devmgmt_ack(cb, 0, UDI_OK); 635 } 636 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 19 Walk-Through udi_cmos.c lines Complete parent unbind sequence 639 cmos_bus_unbind_ack(udi_bus_bind_cb_t *bus_bind_cb) 640 { 641 udi_mgmt_cb_t *cb = bus_bind_cb->gcb.initiator_context; udi_cb_free(UDI_GCB(bus_bind_cb)); udi_devmgmt_ack(cb, 0, UDI_OK); 646 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 20 Walk-Through udi_cmos.c lines Final cleanup –Called after all children/parents unbound 649 cmos_final_cleanup_req(udi_mgmt_cb_t *cb) 650 { 651 /* 652 * We have nothing to free that wasn't already freed by 653 * unbinding children and parents. 654 */ 655 udi_final_cleanup_ack(cb); 656 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 21 PIO Transaction List for READ udi_cmos.c lines /* R0 <- SCRATCH_ADDR {offset into scratch of address} */ 175 { UDI_PIO_LOAD_IMM+UDI_PIO_R0, UDI_PIO_2BYTE, SCRATCH_ADDR }, 176 /* R1 <- address */ 177 { UDI_PIO_LOAD+UDI_PIO_SCRATCH+UDI_PIO_R0, 178 UDI_PIO_1BYTE, UDI_PIO_R1 }, 179 /* R0 <- SCRATCH_COUNT {offset into scratch of count} */ 180 { UDI_PIO_LOAD_IMM+UDI_PIO_R0, UDI_PIO_2BYTE, SCRATCH_COUNT }, 181 /* R2 <- count */ 182 { UDI_PIO_LOAD+UDI_PIO_SCRATCH+UDI_PIO_R0, 183 UDI_PIO_1BYTE, UDI_PIO_R2 }, 184 /* R0 <- 0 {current buffer offset} */ 185 { UDI_PIO_LOAD_IMM+UDI_PIO_R0, UDI_PIO_2BYTE, 0 },

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 22 PIO Transaction List for READ udi_cmos.c lines /* begin main loop */ 187 { UDI_PIO_LABEL, 0, 1 }, 188 /* output address from R1 to address register */ 189 { UDI_PIO_OUT+UDI_PIO_DIRECT+UDI_PIO_R1, 190 UDI_PIO_1BYTE, CMOS_ADDR }, 191 /* input value from data register into next buffer location */ 192 { UDI_PIO_IN+UDI_PIO_BUF+UDI_PIO_R0, 193 UDI_PIO_1BYTE, CMOS_DATA }, 194 /* decrement count (in R2) */ 195 { UDI_PIO_ADD_IMM+UDI_PIO_R2, UDI_PIO_1BYTE, (udi_ubit8_t)-1 }, 196 /* if count is zero, we're done */ 197 { UDI_PIO_CSKIP+UDI_PIO_R2, UDI_PIO_1BYTE, UDI_PIO_NZ }, 198 { UDI_PIO_END, UDI_PIO_2BYTE, 0 }, 199 /* increment address and buffer offset */ 200 { UDI_PIO_ADD_IMM+UDI_PIO_R1, UDI_PIO_1BYTE, 1 }, 201 { UDI_PIO_ADD_IMM+UDI_PIO_R0, UDI_PIO_1BYTE, 1 }, 202 /* go back to main loop */ 203 { UDI_PIO_BRANCH, 0, 1 }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 23 Additional Examples Memory Allocation Asynchronous service call udi_mem_alloc(callback, gcb, size, UDI_MEM_NOZERO); Callback static void callback( udi_cb_t *gcb, void *new_mem ) { /* continue */ }

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 24 Additional Examples Memory Allocation - Limits Size > limits.max_safe_alloc –Driver must cancel allocation if it takes too long »Start timer with udi_timer_start »Cancel allocation with udi_cancel »On success, cancel timer w/ udi_timer_cancel Size <= UDI_MIN_ALLOC_LIMIT –Don’t need runtime test

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 25 Additional Examples Timers Timer interval stored as udi_time_t –Seconds, nanoseconds udi_time_t interval = { 0, }; udi_timer_start(callback, gcb, interval); Timer callback static void callback(gcb); Cancelling a timer udi_timer_cancel(gcb);

F10: UDI Tutorial & Driver Walk-Through, Part 2 © 1999 SCO All Rights Reserved - Slide 26 Hints & Tips For debugging, try udi_debug_break(). To print debug info, use udi_trace_write(). Don’t forget to cancel pending timers during unbinding. Keep pools of control blocks and buffers instead of allocating new ones for each request.

Presenter’s Notes Cover Page Go to “Notes Page View” to see this one Put this page at end of presentation so numbering of slides will remain accurate.