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
28Handle::Handle(int handle)
29	:
30	fHandle(handle)
31{
32}
33
34
35Handle::Handle(void)
36	:
37	fHandle(-1)
38{
39}
40
41
42Handle::~Handle()
43{
44}
45
46
47void
48Handle::SetHandle(int handle)
49{
50	fHandle = handle;
51}
52
53
54ssize_t
55Handle::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize)
56{
57	return B_ERROR;
58}
59
60
61ssize_t
62Handle::WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize)
63{
64	return B_ERROR;
65}
66
67
68off_t
69Handle::Size() const
70{
71	// ToDo: fix this!
72	return 1024LL * 1024 * 1024 * 1024;
73		// 1024 GB
74}
75
76
77// #pragma mark -
78
79
80CharHandle::CharHandle(int handle)
81	: Handle(handle)
82{
83}
84
85
86CharHandle::CharHandle(void)
87	: Handle()
88{
89}
90
91
92CharHandle::~CharHandle()
93{
94}
95
96
97ssize_t
98CharHandle::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
108ssize_t
109CharHandle::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