1 /*
2 * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7 #include <SupportDefs.h>
8 #include <platform/openfirmware/openfirmware.h>
9 #include <util/kernel_cpp.h>
10
11 #include "Handle.h"
12 #include "rom_calls.h"
13
14 /*
15 * (X)BIOS supports char and block devices with a separate namespace
16 * for char devs handle is {DEV_PRINTER, ... DEV_CONSOLE, ...}
17 * for block devs handle is either:
18 * - the partition number {0=A:, 2=C:...} in logical mode.
19 * - the drive number {0=A:, 1=B:, 2=ACSI-0, 10=SCSI-0, ...}
20 * in phys mode (RW_NOTRANSLATE).
21 * BlockHandle is in devices.cpp
22 *
23 * XXX: handle network devices ? not sure how TOS net extensions do this
24 * not sure it'll ever be supported anyway.
25 * XXX: BIOSDrive/BIOSHandle : public BlockHandle ?
26 */
27
Handle(int handle)28 Handle::Handle(int handle)
29 :
30 fHandle(handle)
31 {
32 }
33
34
Handle(void)35 Handle::Handle(void)
36 :
37 fHandle(-1)
38 {
39 }
40
41
~Handle()42 Handle::~Handle()
43 {
44 }
45
46
47 void
SetHandle(int handle)48 Handle::SetHandle(int handle)
49 {
50 fHandle = handle;
51 }
52
53
54 ssize_t
ReadAt(void * cookie,off_t pos,void * buffer,size_t bufferSize)55 Handle::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
56 {
57 return B_ERROR;
58 }
59
60
61 ssize_t
WriteAt(void * cookie,off_t pos,const void * buffer,size_t bufferSize)62 Handle::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
63 {
64 return B_ERROR;
65 }
66
67
68 off_t
Size() const69 Handle::Size() const
70 {
71 // ToDo: fix this!
72 return 1024LL * 1024 * 1024 * 1024;
73 // 1024 GB
74 }
75
76
77 // #pragma mark -
78
79
CharHandle(int handle)80 CharHandle::CharHandle(int handle)
81 : Handle(handle)
82 {
83 }
84
85
CharHandle(void)86 CharHandle::CharHandle(void)
87 : Handle()
88 {
89 }
90
91
~CharHandle()92 CharHandle::~CharHandle()
93 {
94 }
95
96
97 ssize_t
ReadAt(void * cookie,off_t pos,void * buffer,size_t bufferSize)98 CharHandle::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
99 {
100 char *string = (char *)buffer;
101 int i;
102
103
104 return bufferSize;
105 }
106
107
108 ssize_t
WriteAt(void * cookie,off_t pos,const void * buffer,size_t bufferSize)109 CharHandle::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
110 {
111 const char *string = (const char *)buffer;
112 int i;
113
114 return bufferSize;
115 }
116
117
118