blob: ead9612e54204a239b29372b9f915664c3445427 [file] [log] [blame]
Brad Bishope55ef3d2016-12-19 09:12:40 -05001/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include <iostream>
17#include <memory>
Brad Bishop9c7b6e02016-12-19 12:43:36 -050018#include <cstdlib>
Chiabing Leec923ce92017-09-06 15:58:26 +080019#include <string>
Patrick Venture1e6324f2017-06-01 14:07:05 -070020
21#include <phosphor-logging/elog-errors.hpp>
Matt Spinlerf9c83c42017-08-10 08:51:45 -050022#include "config.h"
Brad Bishope55ef3d2016-12-19 09:12:40 -050023#include "sensorset.hpp"
Brad Bishope55ef3d2016-12-19 09:12:40 -050024#include "hwmon.hpp"
25#include "sysfs.hpp"
Brad Bishopd499ca62016-12-19 09:24:50 -050026#include "mainloop.hpp"
Brad Bishopf3df6b42017-01-06 10:14:09 -050027#include "env.hpp"
Brad Bishope0b7d052017-01-06 15:30:23 -050028#include "thresholds.hpp"
Matthew Barthbf7b7b12017-03-07 15:46:59 -060029#include "targets.hpp"
Matthew Barth048ac872017-03-09 14:36:08 -060030#include "fan_speed.hpp"
Brad Bishope55ef3d2016-12-19 09:12:40 -050031
Patrick Venture1e6324f2017-06-01 14:07:05 -070032#include <xyz/openbmc_project/Sensor/Device/error.hpp>
33
34using namespace phosphor::logging;
35
Saqib Khan973886d2017-03-15 14:01:16 -050036// Initialization for Warning Objects
37decltype(Thresholds<WarningObject>::setLo) Thresholds<WarningObject>::setLo =
38 &WarningObject::warningLow;
39decltype(Thresholds<WarningObject>::setHi) Thresholds<WarningObject>::setHi =
40 &WarningObject::warningHigh;
41decltype(Thresholds<WarningObject>::getLo) Thresholds<WarningObject>::getLo =
42 &WarningObject::warningLow;
43decltype(Thresholds<WarningObject>::getHi) Thresholds<WarningObject>::getHi =
44 &WarningObject::warningHigh;
45decltype(Thresholds<WarningObject>::alarmLo) Thresholds<WarningObject>::alarmLo =
46 &WarningObject::warningAlarmLow;
47decltype(Thresholds<WarningObject>::alarmHi) Thresholds<WarningObject>::alarmHi =
48 &WarningObject::warningAlarmHigh;
49
50// Initialization for Critical Objects
51decltype(Thresholds<CriticalObject>::setLo) Thresholds<CriticalObject>::setLo =
52 &CriticalObject::criticalLow;
53decltype(Thresholds<CriticalObject>::setHi) Thresholds<CriticalObject>::setHi =
54 &CriticalObject::criticalHigh;
55decltype(Thresholds<CriticalObject>::getLo) Thresholds<CriticalObject>::getLo =
56 &CriticalObject::criticalLow;
57decltype(Thresholds<CriticalObject>::getHi) Thresholds<CriticalObject>::getHi =
58 &CriticalObject::criticalHigh;
59decltype(Thresholds<CriticalObject>::alarmLo) Thresholds<CriticalObject>::alarmLo =
60 &CriticalObject::criticalAlarmLow;
61decltype(Thresholds<CriticalObject>::alarmHi) Thresholds<CriticalObject>::alarmHi =
62 &CriticalObject::criticalAlarmHigh;
63
Chiabing Leec923ce92017-09-06 15:58:26 +080064// The gain and offset to adjust a value
65struct valueAdjust
66{
67 double gain = 1.0;
68 int offset = 0;
69};
70
71// Store the valueAdjust for sensors
72std::map<SensorSet::key_type, valueAdjust> sensorAdjusts;
73
Brad Bishop74aa4dd2017-01-06 09:50:31 -050074static constexpr auto typeAttrMap =
75{
76 // 1 - hwmon class
77 // 2 - unit
78 // 3 - sysfs scaling factor
79 std::make_tuple(
80 hwmon::type::ctemp,
81 ValueInterface::Unit::DegreesC,
Brad Bishopadd98512017-01-06 22:01:19 -050082 -3,
83 "temperature"),
Brad Bishop74aa4dd2017-01-06 09:50:31 -050084 std::make_tuple(
85 hwmon::type::cfan,
86 ValueInterface::Unit::RPMS,
Brad Bishopadd98512017-01-06 22:01:19 -050087 0,
88 "fan_tach"),
Brad Bishop74aa4dd2017-01-06 09:50:31 -050089 std::make_tuple(
90 hwmon::type::cvolt,
91 ValueInterface::Unit::Volts,
Brad Bishopadd98512017-01-06 22:01:19 -050092 -3,
93 "voltage"),
Brad Bishop5afe21a2017-01-06 20:44:05 -050094 std::make_tuple(
95 hwmon::type::ccurr,
96 ValueInterface::Unit::Amperes,
Brad Bishopadd98512017-01-06 22:01:19 -050097 -3,
98 "current"),
Brad Bishop5afe21a2017-01-06 20:44:05 -050099 std::make_tuple(
100 hwmon::type::cenergy,
101 ValueInterface::Unit::Joules,
Brad Bishopadd98512017-01-06 22:01:19 -0500102 -6,
103 "energy"),
Brad Bishop5afe21a2017-01-06 20:44:05 -0500104 std::make_tuple(
105 hwmon::type::cpower,
106 ValueInterface::Unit::Watts,
Brad Bishopadd98512017-01-06 22:01:19 -0500107 -6,
108 "power"),
Brad Bishop74aa4dd2017-01-06 09:50:31 -0500109};
110
111auto getHwmonType(decltype(typeAttrMap)::const_reference attrs)
112{
113 return std::get<0>(attrs);
114}
115
116auto getUnit(decltype(typeAttrMap)::const_reference attrs)
117{
118 return std::get<1>(attrs);
119}
120
121auto getScale(decltype(typeAttrMap)::const_reference attrs)
122{
123 return std::get<2>(attrs);
124}
125
Brad Bishopadd98512017-01-06 22:01:19 -0500126auto getNamespace(decltype(typeAttrMap)::const_reference attrs)
127{
128 return std::get<3>(attrs);
129}
130
Brad Bishop951a79e2017-01-06 21:55:11 -0500131using AttributeIterator = decltype(*typeAttrMap.begin());
132using Attributes
133 = std::remove_cv<std::remove_reference<AttributeIterator>::type>::type;
134
135auto getAttributes(const std::string& type, Attributes& attributes)
136{
137 // *INDENT-OFF*
138 auto a = std::find_if(
139 typeAttrMap.begin(),
140 typeAttrMap.end(),
141 [&](const auto & e)
142 {
143 return type == getHwmonType(e);
144 });
145 // *INDENT-ON*
146
147 if (a == typeAttrMap.end())
148 {
149 return false;
150 }
151
152 attributes = *a;
153 return true;
154}
155
Chiabing Leec923ce92017-09-06 15:58:26 +0800156int adjustValue(const SensorSet::key_type& sensor, int value)
157{
158 const auto& it = sensorAdjusts.find(sensor);
159 if (it != sensorAdjusts.end())
160 {
161 // Adjust based on gain and offset
162 value = static_cast<decltype(value)>(
163 static_cast<double>(value) * it->second.gain
164 + it->second.offset);
165 }
166 return value;
167}
168
Brad Bishope9fdee02017-01-06 10:43:29 -0500169auto addValue(const SensorSet::key_type& sensor,
Brad Bishop751043e2017-08-29 11:13:46 -0400170 const std::string& devPath,
171 sysfs::hwmonio::HwmonIO& ioAccess,
Brad Bishop4db64422017-02-16 11:33:32 -0500172 ObjectInfo& info)
Brad Bishope9fdee02017-01-06 10:43:29 -0500173{
Brad Bishop30dbcee2017-01-18 07:55:42 -0500174 static constexpr bool deferSignals = true;
175
Brad Bishope9fdee02017-01-06 10:43:29 -0500176 // Get the initial value for the value interface.
177 auto& bus = *std::get<sdbusplus::bus::bus*>(info);
178 auto& obj = std::get<Object>(info);
179 auto& objPath = std::get<std::string>(info);
180
Brad Bishop751043e2017-08-29 11:13:46 -0400181 auto val = 0;
182 try
183 {
184 // Retry for up to a second if device is busy
Brad Bishop754d38c2017-09-08 00:46:58 -0400185 // or has a transient error.
186 val = ioAccess.read(
Brad Bishop751043e2017-08-29 11:13:46 -0400187 sensor.first,
188 sensor.second,
Brad Bishop754d38c2017-09-08 00:46:58 -0400189 hwmon::entry::cinput,
190 sysfs::hwmonio::retries,
191 sysfs::hwmonio::delay);
Brad Bishop751043e2017-08-29 11:13:46 -0400192 }
193 catch (const std::system_error& e)
194 {
195 using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error;
196 report<ReadFailure>(
197 xyz::openbmc_project::Sensor::Device::
198 ReadFailure::CALLOUT_ERRNO(e.code().value()),
199 xyz::openbmc_project::Sensor::Device::
200 ReadFailure::CALLOUT_DEVICE_PATH(devPath.c_str()));
201
202 return static_cast<std::shared_ptr<ValueObject>>(nullptr);
Patrick Venture1e6324f2017-06-01 14:07:05 -0700203 }
204
Chiabing Leec923ce92017-09-06 15:58:26 +0800205 auto gain = getEnv("GAIN", sensor);
206 if (!gain.empty())
207 {
208 sensorAdjusts[sensor].gain = std::stod(gain);
209 }
210
211 auto offset = getEnv("OFFSET", sensor);
212 if (!offset.empty())
213 {
214 sensorAdjusts[sensor].offset = std::stoi(offset);
215 }
216
217 val = adjustValue(sensor, val);
218
Brad Bishop30dbcee2017-01-18 07:55:42 -0500219 auto iface = std::make_shared<ValueObject>(bus, objPath.c_str(), deferSignals);
Brad Bishope9fdee02017-01-06 10:43:29 -0500220 iface->value(val);
221
Brad Bishop951a79e2017-01-06 21:55:11 -0500222 Attributes attrs;
223 if (getAttributes(sensor.first, attrs))
Brad Bishope9fdee02017-01-06 10:43:29 -0500224 {
Brad Bishop951a79e2017-01-06 21:55:11 -0500225 iface->unit(getUnit(attrs));
226 iface->scale(getScale(attrs));
Brad Bishope9fdee02017-01-06 10:43:29 -0500227 }
228
229 obj[InterfaceType::VALUE] = iface;
230 return iface;
231}
232
Brad Bishopb9e2b072016-12-19 13:47:10 -0500233MainLoop::MainLoop(
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500234 sdbusplus::bus::bus&& bus,
Brad Bishopb9e2b072016-12-19 13:47:10 -0500235 const std::string& path,
Brad Bishopf3aa9ae2017-08-25 09:56:02 -0400236 const std::string& devPath,
Brad Bishopb9e2b072016-12-19 13:47:10 -0500237 const char* prefix,
238 const char* root)
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500239 : _bus(std::move(bus)),
Brad Bishop03e87352017-03-07 00:12:22 -0500240 _manager(_bus, root),
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500241 _shutdown(false),
Brad Bishopb8740fc2017-02-24 23:38:37 -0500242 _hwmonRoot(),
243 _instance(),
Brad Bishopf3aa9ae2017-08-25 09:56:02 -0400244 _devPath(devPath),
Brad Bishopb9e2b072016-12-19 13:47:10 -0500245 _prefix(prefix),
Brad Bishop3c344d32017-01-05 11:48:39 -0500246 _root(root),
Brad Bishop751043e2017-08-29 11:13:46 -0400247 state(),
248 ioAccess(path)
Brad Bishopd499ca62016-12-19 09:24:50 -0500249{
Brad Bishopb8740fc2017-02-24 23:38:37 -0500250 std::string p = path;
251 while (!p.empty() && p.back() == '/')
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500252 {
Brad Bishopb8740fc2017-02-24 23:38:37 -0500253 p.pop_back();
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500254 }
Brad Bishopb8740fc2017-02-24 23:38:37 -0500255
256 auto n = p.rfind('/');
257 if (n != std::string::npos)
258 {
259 _instance.assign(p.substr(n + 1));
260 _hwmonRoot.assign(p.substr(0, n));
261 }
262
263 assert(!_instance.empty());
264 assert(!_hwmonRoot.empty());
Brad Bishopd499ca62016-12-19 09:24:50 -0500265}
266
267void MainLoop::shutdown() noexcept
268{
269 _shutdown = true;
270}
271
272void MainLoop::run()
Brad Bishope55ef3d2016-12-19 09:12:40 -0500273{
274 // Check sysfs for available sensors.
Brad Bishop4db64422017-02-16 11:33:32 -0500275 auto sensors = std::make_unique<SensorSet>(_hwmonRoot + '/' + _instance);
Brad Bishope55ef3d2016-12-19 09:12:40 -0500276
Brad Bishop75b4ab82017-01-06 09:33:50 -0500277 for (auto& i : *sensors)
278 {
Tom Joseph1f8a9582017-06-12 20:10:59 +0530279 std::string label;
Brad Bishopf3df6b42017-01-06 10:14:09 -0500280
Tom Joseph1f8a9582017-06-12 20:10:59 +0530281 /*
282 * Check if the value of the MODE_<item><X> env variable for the sensor
283 * is "label", then read the sensor number from the <item><X>_label
284 * file. The name of the DBUS object would be the value of the env
285 * variable LABEL_<item><sensorNum>. If the MODE_<item><X> env variable
286 * does'nt exist, then the name of DBUS object is the value of the env
287 * variable LABEL_<item><X>.
288 */
289 auto mode = getEnv("MODE", i.first);
290 if (!mode.compare(hwmon::entry::label))
Brad Bishop73831cd2017-01-06 09:37:22 -0500291 {
Tom Joseph1f8a9582017-06-12 20:10:59 +0530292 label = getIndirectLabelEnv(
293 "LABEL", _hwmonRoot + '/' + _instance + '/', i.first);
294 if (label.empty())
295 {
296 continue;
297 }
298 }
299 else
300 {
301 // Ignore inputs without a label.
302 label = getEnv("LABEL", i.first);
303 if (label.empty())
304 {
305 continue;
306 }
Brad Bishop73831cd2017-01-06 09:37:22 -0500307 }
308
Brad Bishopadd98512017-01-06 22:01:19 -0500309 Attributes attrs;
310 if (!getAttributes(i.first.first, attrs))
311 {
312 continue;
313 }
314
Brad Bishop075f7a22017-01-06 09:45:08 -0500315 std::string objectPath{_root};
Brad Bishopb8740fc2017-02-24 23:38:37 -0500316 objectPath.append(1, '/');
Brad Bishopadd98512017-01-06 22:01:19 -0500317 objectPath.append(getNamespace(attrs));
Brad Bishopb8740fc2017-02-24 23:38:37 -0500318 objectPath.append(1, '/');
Brad Bishop075f7a22017-01-06 09:45:08 -0500319 objectPath.append(label);
320
Brad Bishopf7426cf2017-01-06 15:36:43 -0500321 ObjectInfo info(&_bus, std::move(objectPath), Object());
Brad Bishop751043e2017-08-29 11:13:46 -0400322 auto valueInterface = addValue(i.first, _devPath, ioAccess, info);
Patrick Venture1e6324f2017-06-01 14:07:05 -0700323 if (!valueInterface)
324 {
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500325#ifdef REMOVE_ON_FAIL
Patrick Venture1e6324f2017-06-01 14:07:05 -0700326 continue; /* skip adding this sensor for now. */
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500327#else
328 exit(EXIT_FAILURE);
329#endif
Patrick Venture1e6324f2017-06-01 14:07:05 -0700330 }
Brad Bishope0b7d052017-01-06 15:30:23 -0500331 auto sensorValue = valueInterface->value();
332 addThreshold<WarningObject>(i.first, sensorValue, info);
333 addThreshold<CriticalObject>(i.first, sensorValue, info);
Matthew Barthbf7b7b12017-03-07 15:46:59 -0600334 //TODO openbmc/openbmc#1347
335 // Handle application restarts to set/refresh fan speed values
Matt Spinler0a8de642017-05-11 10:59:39 -0500336 auto target = addTarget<hwmon::FanSpeed>(
Brad Bishop751043e2017-08-29 11:13:46 -0400337 i.first, ioAccess.path(), _devPath, info);
Matt Spinler0a8de642017-05-11 10:59:39 -0500338
339 if (target)
340 {
341 target->enable();
342 }
Brad Bishop075f7a22017-01-06 09:45:08 -0500343
Brad Bishop30dbcee2017-01-18 07:55:42 -0500344 // All the interfaces have been created. Go ahead
345 // and emit InterfacesAdded.
346 valueInterface->emit_object_added();
347
Brad Bishop075f7a22017-01-06 09:45:08 -0500348 auto value = std::make_tuple(
349 std::move(i.second),
350 std::move(label),
Brad Bishopf7426cf2017-01-06 15:36:43 -0500351 std::move(info));
Brad Bishop73831cd2017-01-06 09:37:22 -0500352
Brad Bishop75b4ab82017-01-06 09:33:50 -0500353 state[std::move(i.first)] = std::move(value);
354 }
355
Patrick Venture62503a42017-05-23 07:30:29 -0700356 /* If there are no sensors specified by labels, exit. */
357 if (0 == state.size())
358 {
359 return;
360 }
361
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500362 {
Brad Bishopb8740fc2017-02-24 23:38:37 -0500363 std::string busname{_prefix};
364 busname.append(1, '.');
365 busname.append(_instance);
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500366 _bus.request_name(busname.c_str());
367 }
368
Patrick Ventureab10f162017-05-22 09:44:50 -0700369 {
370 auto interval = getenv("INTERVAL");
371 if (interval)
372 {
373 _interval = strtoull(interval, NULL, 10);
374 }
375 }
376
Brad Bishope55ef3d2016-12-19 09:12:40 -0500377 // TODO: Issue#3 - Need to make calls to the dbus sensor cache here to
378 // ensure the objects all exist?
379
380 // Polling loop.
Brad Bishopd499ca62016-12-19 09:24:50 -0500381 while (!_shutdown)
Brad Bishope55ef3d2016-12-19 09:12:40 -0500382 {
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500383#ifdef REMOVE_ON_FAIL
Patrick Venture1e6324f2017-06-01 14:07:05 -0700384 std::vector<SensorSet::key_type> destroy;
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500385#endif
Brad Bishope55ef3d2016-12-19 09:12:40 -0500386 // Iterate through all the sensors.
Brad Bishop75b4ab82017-01-06 09:33:50 -0500387 for (auto& i : state)
Brad Bishope55ef3d2016-12-19 09:12:40 -0500388 {
Brad Bishop75b4ab82017-01-06 09:33:50 -0500389 auto& attrs = std::get<0>(i.second);
390 if (attrs.find(hwmon::entry::input) != attrs.end())
Brad Bishope55ef3d2016-12-19 09:12:40 -0500391 {
392 // Read value from sensor.
Patrick Venture1e6324f2017-06-01 14:07:05 -0700393 int value;
394 try
Brad Bishopdddb7152017-01-06 09:54:23 -0500395 {
Brad Bishop754d38c2017-09-08 00:46:58 -0400396 // Retry for up to a second if device is busy
397 // or has a transient error.
398
Brad Bishop751043e2017-08-29 11:13:46 -0400399 value = ioAccess.read(
400 i.first.first,
401 i.first.second,
Brad Bishop754d38c2017-09-08 00:46:58 -0400402 hwmon::entry::cinput,
403 sysfs::hwmonio::retries,
404 sysfs::hwmonio::delay);
Brad Bishope0b7d052017-01-06 15:30:23 -0500405
Chiabing Leec923ce92017-09-06 15:58:26 +0800406 value = adjustValue(i.first, value);
407
Patrick Venture1e6324f2017-06-01 14:07:05 -0700408 auto& objInfo = std::get<ObjectInfo>(i.second);
409 auto& obj = std::get<Object>(objInfo);
410
411 for (auto& iface : obj)
Brad Bishope0b7d052017-01-06 15:30:23 -0500412 {
Patrick Venture1e6324f2017-06-01 14:07:05 -0700413 auto valueIface = std::shared_ptr<ValueObject>();
414 auto warnIface = std::shared_ptr<WarningObject>();
415 auto critIface = std::shared_ptr<CriticalObject>();
416
417 switch (iface.first)
418 {
419 case InterfaceType::VALUE:
420 valueIface = std::experimental::any_cast<std::shared_ptr<ValueObject>>
421 (iface.second);
422 valueIface->value(value);
423 break;
424 case InterfaceType::WARN:
425 checkThresholds<WarningObject>(iface.second, value);
426 break;
427 case InterfaceType::CRIT:
428 checkThresholds<CriticalObject>(iface.second, value);
429 break;
430 default:
431 break;
432 }
Brad Bishope0b7d052017-01-06 15:30:23 -0500433 }
Brad Bishopdddb7152017-01-06 09:54:23 -0500434 }
Brad Bishop751043e2017-08-29 11:13:46 -0400435 catch (const std::system_error& e)
Patrick Venture1e6324f2017-06-01 14:07:05 -0700436 {
Brad Bishop751043e2017-08-29 11:13:46 -0400437 using namespace sdbusplus::xyz::openbmc_project::
438 Sensor::Device::Error;
439 report<ReadFailure>(
440 xyz::openbmc_project::Sensor::Device::
441 ReadFailure::CALLOUT_ERRNO(e.code().value()),
442 xyz::openbmc_project::Sensor::Device::
443 ReadFailure::CALLOUT_DEVICE_PATH(
444 _devPath.c_str()));
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500445#ifdef REMOVE_ON_FAIL
Patrick Venture1e6324f2017-06-01 14:07:05 -0700446 destroy.push_back(i.first);
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500447#else
448 exit(EXIT_FAILURE);
449#endif
Patrick Venture1e6324f2017-06-01 14:07:05 -0700450 }
Brad Bishope55ef3d2016-12-19 09:12:40 -0500451 }
452 }
453
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500454#ifdef REMOVE_ON_FAIL
Patrick Venture1e6324f2017-06-01 14:07:05 -0700455 for (auto& i : destroy)
456 {
457 state.erase(i);
458 }
Matt Spinlerf9c83c42017-08-10 08:51:45 -0500459#endif
Patrick Venture1e6324f2017-06-01 14:07:05 -0700460
Brad Bishop9c7b6e02016-12-19 12:43:36 -0500461 // Respond to DBus
462 _bus.process_discard();
463
Brad Bishope55ef3d2016-12-19 09:12:40 -0500464 // Sleep until next interval.
Brad Bishope55ef3d2016-12-19 09:12:40 -0500465 // TODO: Issue#6 - Optionally look at polling interval sysfs entry.
Patrick Ventureab10f162017-05-22 09:44:50 -0700466 _bus.wait(_interval);
Brad Bishope55ef3d2016-12-19 09:12:40 -0500467
468 // TODO: Issue#7 - Should probably periodically check the SensorSet
469 // for new entries.
470 }
Brad Bishope55ef3d2016-12-19 09:12:40 -0500471}
472
473// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4