1 #include "resource_id.h"
3 #include "resource_manager.h"
4 #include "arch/x86/rs232.h"
5 #include "services/service_manager.h"
6 #include "libs/delegate.h"
9 using namespace resources
;
11 rs232::rs232() : res_stream((resource_type
*)RESOURCE(rs232
)) {
12 set_access_control(new spinlock
);
14 delegate
<resource_result
*, rs232_mode
, int, int, parity_check
, int> *m_conf
= new delegate
<resource_result
*, rs232_mode
, int, int, parity_check
, int>;
15 m_conf
->method(this,&rs232::configure
);
16 add_ord_response("configure",m_conf
);
19 void rs232::read_bytes(char *data
, int count
) {
23 void rs232::write_dwords(const int *data
, int count
) {
27 void rs232::write_bytes(const char *data
, int count
) {
29 for (int i
= 0; i
< count
; i
++) {
30 arch::rs232_send(descr
.isaaddr
, data
[i
]);
35 void rs232::received(const char a
) {
39 resource_result
*rs232::configure(rs232_mode mode
, int speed
, int bits
,
40 parity_check parity
, int stop
) {
41 arch::rs232_configure(descr
.isaaddr
, mode
, speed
, bits
, parity
, stop
);
42 return GET_RESOURCES()->create_result();
45 bool rs232::init_device(isa_address iadr
) {
48 delegate
<void, const char> sp_hndl
;
49 sp_hndl
.method(this,&rs232::received
);
51 arch::rs232_init(descr
.isaaddr
, sp_hndl
);
58 void rs232::register_resource() {
59 resource_manager
*rman
= GET_RESOURCES();
61 delegate
<manes::object
*> *res
= new delegate
<manes::object
*>;
64 res
->function(create_object
<manes::object
,rs232
>);
65 resource_type
*rs232_type
= new resource_type(resource_type::device
, resource_type::stream_dev
,"rs232",*res
);
66 rman
->register_type(rs232_type
);