2 * Simple routines for Celleb/Beat
4 * (C) Copyright 2006-2007 TOSHIBA CORPORATION
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/err.h>
24 #include <linux/rtc.h>
26 #include <asm/hvconsole.h>
29 #include "beat_wrapper.h"
32 void beat_restart(char *cmd
)
34 beat_shutdown_logical_partition(1);
37 void beat_power_off(void)
39 beat_shutdown_logical_partition(0);
42 u64 beat_halt_code
= 0x1000000000000000UL
;
46 beat_shutdown_logical_partition(beat_halt_code
);
49 int beat_set_rtc_time(struct rtc_time
*rtc_time
)
52 tim
= mktime(rtc_time
->tm_year
+1900,
53 rtc_time
->tm_mon
+1, rtc_time
->tm_mday
,
54 rtc_time
->tm_hour
, rtc_time
->tm_min
, rtc_time
->tm_sec
);
55 if (beat_rtc_write(tim
))
60 void beat_get_rtc_time(struct rtc_time
*rtc_time
)
64 if (beat_rtc_read(&tim
))
67 rtc_time
->tm_year
-= 1900;
68 rtc_time
->tm_mon
-= 1;
71 #define BEAT_NVRAM_SIZE 4096
73 ssize_t
beat_nvram_read(char *buf
, size_t count
, loff_t
*index
)
79 if (*index
>= BEAT_NVRAM_SIZE
)
82 if (i
+ count
> BEAT_NVRAM_SIZE
)
83 count
= BEAT_NVRAM_SIZE
- i
;
85 for (; count
!= 0; count
-= len
) {
87 if (len
> BEAT_NVRW_CNT
)
89 if (beat_eeprom_read(i
, len
, p
)) {
100 ssize_t
beat_nvram_write(char *buf
, size_t count
, loff_t
*index
)
106 if (*index
>= BEAT_NVRAM_SIZE
)
109 if (i
+ count
> BEAT_NVRAM_SIZE
)
110 count
= BEAT_NVRAM_SIZE
- i
;
112 for (; count
!= 0; count
-= len
) {
114 if (len
> BEAT_NVRW_CNT
)
116 if (beat_eeprom_write(i
, len
, p
)) {
127 ssize_t
beat_nvram_get_size(void)
129 return BEAT_NVRAM_SIZE
;
132 int beat_set_xdabr(unsigned long dabr
)
134 if (beat_set_dabr(dabr
, DABRX_KERNEL
| DABRX_USER
))
139 int64_t beat_get_term_char(u64 vterm
, u64
*len
, u64
*t1
, u64
*t2
)
144 ret
= beat_get_characters_from_console(vterm
, len
, (u8
*)db
);
152 int64_t beat_put_term_char(u64 vterm
, u64 len
, u64 t1
, u64 t2
)
158 return beat_put_characters_to_console(vterm
, len
, (u8
*)db
);
161 EXPORT_SYMBOL(beat_get_term_char
);
162 EXPORT_SYMBOL(beat_put_term_char
);
163 EXPORT_SYMBOL(beat_halt_code
);