@@ -39,21 +39,44 @@ static int hvc_sbi_tty_get(uint32_t vtermno, char *buf, int count)
39
39
return i ;
40
40
}
41
41
42
- static const struct hv_ops hvc_sbi_ops = {
42
+ static const struct hv_ops hvc_sbi_v01_ops = {
43
43
.get_chars = hvc_sbi_tty_get ,
44
44
.put_chars = hvc_sbi_tty_put ,
45
45
};
46
46
47
- static int __init hvc_sbi_init ( void )
47
+ static int hvc_sbi_dbcn_tty_put ( uint32_t vtermno , const char * buf , int count )
48
48
{
49
- return PTR_ERR_OR_ZERO ( hvc_alloc ( 0 , 0 , & hvc_sbi_ops , 16 ) );
49
+ return sbi_debug_console_write ( buf , count );
50
50
}
51
- device_initcall (hvc_sbi_init );
52
51
53
- static int __init hvc_sbi_console_init ( void )
52
+ static int hvc_sbi_dbcn_tty_get ( uint32_t vtermno , char * buf , int count )
54
53
{
55
- hvc_instantiate (0 , 0 , & hvc_sbi_ops );
54
+ return sbi_debug_console_read (buf , count );
55
+ }
56
+
57
+ static const struct hv_ops hvc_sbi_dbcn_ops = {
58
+ .put_chars = hvc_sbi_dbcn_tty_put ,
59
+ .get_chars = hvc_sbi_dbcn_tty_get ,
60
+ };
61
+
62
+ static int __init hvc_sbi_init (void )
63
+ {
64
+ int err ;
65
+
66
+ if (sbi_debug_console_available ) {
67
+ err = PTR_ERR_OR_ZERO (hvc_alloc (0 , 0 , & hvc_sbi_dbcn_ops , 256 ));
68
+ if (err )
69
+ return err ;
70
+ hvc_instantiate (0 , 0 , & hvc_sbi_dbcn_ops );
71
+ } else if (IS_ENABLED (CONFIG_RISCV_SBI_V01 )) {
72
+ err = PTR_ERR_OR_ZERO (hvc_alloc (0 , 0 , & hvc_sbi_v01_ops , 256 ));
73
+ if (err )
74
+ return err ;
75
+ hvc_instantiate (0 , 0 , & hvc_sbi_v01_ops );
76
+ } else {
77
+ return - ENODEV ;
78
+ }
56
79
57
80
return 0 ;
58
81
}
59
- console_initcall ( hvc_sbi_console_init );
82
+ device_initcall ( hvc_sbi_init );
0 commit comments