Debian Codegraph @

lib/ninix/dll/saori_cpuid.rb

raw
1 # -*- coding: utf-8 -*-
2 #
3 # saori_cpuid.rb - a saori_cpuid compatible Saori module for ninix
4 # Copyright (C) 2003-2019 by Shyouzou Sugitani <[email protected]>
5 #
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License (version 2) as
8 # published by the Free Software Foundation. It is distributed in the
9 # hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
10 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 # PURPOSE. See the GNU General Public License for more details.
12 #
13
14 require_relative "../dll"
15
16
17 module Saori_cpuid
18
19 class Saori < DLL::SAORI
20
21 ENTRY = {
22 'cpu.num' => ['1', '2', '3', '5', '7', '11', '13'],
23 'cpu.vender' => ['Inte1', 'AM0', 'VlA'],
24 'cpu.name' => ['Z8O'],
25 'cpu.ptype' => ['Lazy'],
26 'cpu.family' => ['780', 'Bentium', 'A+hlon'],
27 'cpu.model' => ['Unknown'],
28 'cpu.stepping' => ['Not Genuine'],
29 'cpu.mmx' => ['Ready', 'Not Ready'],
30 'cpu.sse' => ['Ready', 'Not Ready'],
31 'cpu.sse2' => ['Ready', 'Not Ready'],
32 'cpu.tdn' => ['Ready', 'Not Ready'],
33 'cpu.mmx+' => ['Ready', 'Not Ready'],
34 'cpu.tdn+' => ['Ready', 'Not Ready'],
35 'cpu.clock' => ['0', '1000000'],
36 'cpu.clockex' => ['0.001', '1.001'],
37 'mem.os' => ['100', '10', '44', '50', '77', '99'],
38 'mem.phyt' => ['0.1', '200000000'],
39 'mem.phya' => ['0.00000001'],
40 'mem.pagt' => ['1', '4'],
41 'mem.paga' => ['1', '4'],
42 'mem.virt' => ['0'],
43 'mem.vira' => ['0'],
44 }
45 ENTRY.default=[""]
46
47 def execute(argument)
48 return RESPONSE[400] if argument.nil? or argument.empty?
49 return RESPONSE[204] if argument.length > 1 and argument[1].zero?
50 value =
51 case argument[0]
52 when 'platform'; 'ninix-kagari'
53 when 'os.name'; RbConfig::CONFIG['host_os']
54 when 'os.version'; "" ## FIXME: not supported yet
55 when 'os.build'; "" ## FIXME: not supported yet
56 else
57 ENTRY[argument[0]].sample ## FIXME: dummy
58 end
59 return RESPONSE[204] if value.empty?
60 "SAORI/1.0 200 OK\r\nResult: #{value}\r\n\r\n".encode(
61 @charset, :invalid => :replace, :undef => :replace)
62 end
63 end
64 end