Adrian Bunk | b00dc83 | 2008-05-19 16:52:27 -0700 | [diff] [blame] | 1 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | * devops.c: Device operations using the PROM. |
| 3 | * |
| 4 | * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu) |
| 5 | * Copyright (C) 1996,1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 6 | */ |
| 7 | #include <linux/types.h> |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/sched.h> |
| 10 | |
| 11 | #include <asm/openprom.h> |
| 12 | #include <asm/oplib.h> |
| 13 | |
| 14 | /* Open the device described by the string 'dstr'. Returns the handle |
| 15 | * to that device used for subsequent operations on that device. |
| 16 | * Returns 0 on failure. |
| 17 | */ |
| 18 | int |
David S. Miller | bff06d5 | 2005-09-22 20:11:33 -0700 | [diff] [blame] | 19 | prom_devopen(const char *dstr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | { |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 21 | unsigned long args[5]; |
| 22 | |
| 23 | args[0] = (unsigned long) "open"; |
| 24 | args[1] = 1; |
| 25 | args[2] = 1; |
| 26 | args[3] = (unsigned long) dstr; |
| 27 | args[4] = (unsigned long) -1; |
| 28 | |
| 29 | p1275_cmd_direct(args); |
| 30 | |
| 31 | return (int) args[4]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | /* Close the device described by device handle 'dhandle'. */ |
| 35 | int |
| 36 | prom_devclose(int dhandle) |
| 37 | { |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 38 | unsigned long args[4]; |
| 39 | |
| 40 | args[0] = (unsigned long) "close"; |
| 41 | args[1] = 1; |
| 42 | args[2] = 0; |
| 43 | args[3] = (unsigned int) dhandle; |
| 44 | |
| 45 | p1275_cmd_direct(args); |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | /* Seek to specified location described by 'seekhi' and 'seeklo' |
| 51 | * for device 'dhandle'. |
| 52 | */ |
| 53 | void |
| 54 | prom_seek(int dhandle, unsigned int seekhi, unsigned int seeklo) |
| 55 | { |
David S. Miller | 25edd69 | 2010-08-23 23:10:57 -0700 | [diff] [blame] | 56 | unsigned long args[7]; |
| 57 | |
| 58 | args[0] = (unsigned long) "seek"; |
| 59 | args[1] = 3; |
| 60 | args[2] = 1; |
| 61 | args[3] = (unsigned int) dhandle; |
| 62 | args[4] = seekhi; |
| 63 | args[5] = seeklo; |
| 64 | args[6] = (unsigned long) -1; |
| 65 | |
| 66 | p1275_cmd_direct(args); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | } |