Index Index for
Section 9
Index Alphabetical
listing for M
Bottom of page Bottom of
page

map_unmap_screen(9r)

NAME

map_unmap_screen - Graphics: Creates the memory map for the specified device

SYNOPSIS

int (*ws_screen_functions->map_unmap_screen)( caddr_t screen_handle,, ws_depth_descriptor *depth,, ws_screen_descriptor *screen,, ws_map_control *mc );

ARGUMENTS

screen_handle Specifies the virtual address (handle) of device-specific information. Typically this is a pointer to a private data structure that may contain information such as the address of the hardware, state information, and other information that may be shared between drivers. The Workstation Subsystem allows separate handles for the cursor, colormap, and the screen functions. depth Specifies a pointer to the ws_depth_descriptor structure, which describes the attributes of the screens depth. screen Specifies a pointer to the ws_screen_descriptor structure, which describes the attributes of the screen. mc Specifies a pointer to the /usr/sys/include/sys/workstation.h structure, which controls the depth mapping.

DATA STRUCTURES

The map_unmap_screen function accesses the ws_depth_descriptor, ws_screen_descriptor, and ws_map_control structures defined in /usr/sys/include/sys/workstation.h.

DESCRIPTION

The map_unmap_screen function creates the memory map for the device specified by *screen. That is, it gets the user address for the frame buffer and hardware registers. When the function exits, the pixmap member of the ws_depth_descriptor structure contains the user-space address of the frame buffer, and the plane_mask member of the ws_depth_descriptor structure contains the user-space address of the I/O registers. The map_unmap_screen function must convert the I/O handle to a physical address, then convert the physical address to a kernel unmapped virtual address (kseg). The function passes the kseg to the ws_map_region routine, which performs the memory mapping.

RETURN VALUES

On success, the map_unmap_screen function returns 0 (zero). If it cannot map the frame buffers or registers, the function returns ENOMEM.

EXAMPLES

The following example shows how the myvga device driver implements the map_unmap_screen function: int myvga_map_unmap_screen(caddr_t screen_handle, ws_depth_descriptor *depths, ws_screen_descriptor *screen, ws_map_control *mp) { register struct myvga_type *scp = (struct myvga_type *)screen_handle; register ws_depth_descriptor *dp; io_handle_t handle; caddr_t temp; int nbytes; register struct controller *ctlr = myvgainfo[scp->unit]; if (myvga_developer_debug) printf("myvga_map_unmap_screen: entry\n"); /* Unmapping is not supported.) */ if (mp->map_unmap == UNMAP_SCREEN) return (EINVAL); /* * Do the mapping only once per screen. * Otherwise, assume the information is * available, and return. */ if ((IS_MYVGA_MAPPED(scp)) && (scp->mapped_pid == u.u_procp->p_pid)) { return(0); } dp = depths + mp->which_depth; /* * Convert the I/O handle to a physical address, * then convert the physical address to a kseg. */ handle = scp->mem_handle; temp = (caddr_t) iohandle_to_phys(handle, IOH_SPARSE_BYTE); temp = (caddr_t) PHYS_TO_KSEG(temp); /* * Calculate the size of the frame buffer by * subtracting the base address from the high * address of the frame buffer. */ nbytes = iohandle_to_phys(handle + HIGHMAP_SIZE, IOH_SPARSE_BYTE) - iohandle_to_phys(handle + 0, IOH_SPARSE_BYTE); /* Call ws_map_region to map the frame buffer in * user space, and place the address of the memory * map in the ws_depth_descriptor structure. */ dp->pixmap = ws_map_region(temp, NULL, nbytes, 0600, (int *)NULL); if (myvga_developer_debug) printf("myvga_map_unmap_screen: fb: "); printf("nbytes 0x%x handle 0x%lx kseg 0x%lx virt 0x%lx\n", nbytes, handle, temp, dp->pixmap); if (dp->pixmap == (caddr_t) NULL) return(ENOMEM); /* * Perform the same conversions for the I/O registers -- * from I/O handle to physical address to KSEG. */ handle = busphys_to_iohandle(IOREGS_BASE, BUS_IO, ctlr); temp = (caddr_t) iohandle_to_phys(handle, IOH_SPARSE_BYTE); temp = (caddr_t) PHYS_TO_KSEG(temp); /* * Calculate the size of the register space. */ nbytes = iohandle_to_phys(handle + IOREGS_SIZE, IOH_SPARSE_BYTE) - iohandle_to_phys(handle + 0, IOH_SPARSE_BYTE); /* * Call ws_map_region to map the registers in * user space, and place the address of the memory * map in the ws_depth_descriptor structure. */ dp->plane_mask = ws_map_region(temp, NULL, nbytes, 0600, (int *)NULL); if (myvga_developer_debug) printf("myvga_map_unmap_screen: regs: "); printf("nbytes 0x%x handle 0x%lx kseg 0x%lx virt 0x%lx\n", nbytes, handle, temp, dp->plane_mask); if (dp->plane_mask == (caddr_t)NULL) return(ENOMEM); SET_MYVGA_MAPPED(scp); scp->mapped_pid = u.u_procp->p_pid; return (0); }

FILES

/usr/sys/include/sys/workstation.h /usr/sys/include/sys/wsdevice.h

SEE ALSO

Data Structures: ws_depth_descriptor(9s), ws_map_control(9s), ws_screen_descriptor(9s), ws_screen_functions(9s)

Index Index for
Section 9
Index Alphabetical
listing for M
Top of page Top of
page