answer
stringlengths 15
1.25M
|
|---|
# IMAP folder support
# This program is free software; you can redistribute it and/or modify
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
import email
import random
import binascii
import re
import time
from sys import exc_info
from .Base import BaseFolder
from offlineimap import imaputil, imaplibutil, OfflineImapError
from offlineimap.imaplib2 import MonthNames
class IMAPFolder(BaseFolder):
def __init__(self, imapserver, name, repository):
name = imaputil.dequote(name)
self.sep = imapserver.delim
super(IMAPFolder, self).__init__(name, repository)
self.expunge = repository.getexpunge()
self.root = None # imapserver.root
self.imapserver = imapserver
self.messagelist = None
self.randomgenerator = random.Random()
#self.ui is set in BaseFolder
def selectro(self, imapobj, force = False):
"""Select this folder when we do not need write access.
Prefer SELECT to EXAMINE if we can, since some servers
(Courier) do not stabilize UID validity until the folder is
selected.
.. todo: Still valid? Needs verification
:param: Enforce new SELECT even if we are on that folder already.
:returns: raises :exc:`OfflineImapError` severity FOLDER on error"""
try:
imapobj.select(self.getfullname(), force = force)
except imapobj.readonly:
imapobj.select(self.getfullname(), readonly = True, force = force)
def suggeststhreads(self):
return 1
def waitforthread(self):
self.imapserver.connectionwait()
def <API key>(self):
return 'MSGCOPY_' + self.repository.getname()
def get_uidvalidity(self):
"""Retrieve the current connections UIDVALIDITY value
UIDVALIDITY value will be cached on the first call.
:returns: The UIDVALIDITY as (long) number."""
if hasattr(self, '_uidvalidity'):
# use cached value if existing
return self._uidvalidity
imapobj = self.imapserver.acquireconnection()
try:
# SELECT (if not already done) and get current UIDVALIDITY
self.selectro(imapobj)
typ, uidval = imapobj.response('UIDVALIDITY')
assert uidval != [None] and uidval != None, \
"response('UIDVALIDITY') returned [None]!"
self._uidvalidity = long(uidval[-1])
return self._uidvalidity
finally:
self.imapserver.releaseconnection(imapobj)
def quickchanged(self, statusfolder):
# An IMAP folder has definitely changed if the number of
# messages or the UID of the last message have changed. Otherwise
# only flag changes could have occurred.
retry = True # Should we attempt another round or exit?
while retry:
retry = False
imapobj = self.imapserver.acquireconnection()
try:
# Select folder and get number of messages
restype, imapdata = imapobj.select(self.getfullname(), True,
True)
self.imapserver.releaseconnection(imapobj)
except OfflineImapError as e:
# retry on dropped connections, raise otherwise
self.imapserver.releaseconnection(imapobj, True)
if e.severity == OfflineImapError.ERROR.FOLDER_RETRY:
retry = True
else: raise
except:
# cleanup and raise on all other errors
self.imapserver.releaseconnection(imapobj, True)
raise
# 1. Some mail servers do not return an EXISTS response
# if the folder is empty. 2. ZIMBRA servers can return
# multiple EXISTS replies in the form 500, 1000, 1500,
# 1623 so check for potentially multiple replies.
if imapdata == [None]:
return True
maxmsgid = 0
for msgid in imapdata:
maxmsgid = max(long(msgid), maxmsgid)
# Different number of messages than last time?
if maxmsgid != statusfolder.getmessagecount():
return True
return False
def cachemessagelist(self):
maxage = self.config.getdefaultint("Account %s" % self.accountname,
"maxage", -1)
maxsize = self.config.getdefaultint("Account %s" % self.accountname,
"maxsize", -1)
self.messagelist = {}
imapobj = self.imapserver.acquireconnection()
try:
res_type, imapdata = imapobj.select(self.getfullname(), True, True)
if imapdata == [None] or imapdata[0] == '0':
# Empty folder, no need to populate message list
return
# By default examine all UIDs in this folder
msgsToFetch = '1:*'
if (maxage != -1) | (maxsize != -1):
search_cond = "(";
if(maxage != -1):
#find out what the oldest message is that we should look at
oldest_struct = time.gmtime(time.time() - (60*60*24*maxage))
if oldest_struct[0] < 1900:
raise OfflineImapError("maxage setting led to year %d. "
"Abort syncing." % oldest_struct[0],
OfflineImapError.ERROR.REPO)
search_cond += "SINCE %02d-%s-%d" % (
oldest_struct[2],
MonthNames[oldest_struct[1]],
oldest_struct[0])
if(maxsize != -1):
if(maxage != -1): # There are two conditions, add space
search_cond += " "
search_cond += "SMALLER %d" % maxsize
search_cond += ")"
res_type, res_data = imapobj.search(None, search_cond)
if res_type != 'OK':
raise OfflineImapError("SEARCH in folder [%s]%s failed. "
"Search string was '%s'. Server responded '[%s] %s'" % (
self.getrepository(), self,
search_cond, res_type, res_data),
OfflineImapError.ERROR.FOLDER)
# Result UIDs are seperated by space, coalesce into ranges
msgsToFetch = imaputil.uid_sequence(res_data[0].split())
if not msgsToFetch:
return # No messages to sync
# Get the flags and UIDs for these. single-quotes prevent
# imaplib2 from quoting the sequence.
res_type, response = imapobj.fetch("'%s'" % msgsToFetch,
'(FLAGS UID)')
if res_type != 'OK':
raise OfflineImapError("FETCHING UIDs in folder [%s]%s failed. "
"Server responded '[%s] %s'" % (
self.getrepository(), self,
res_type, response),
OfflineImapError.ERROR.FOLDER)
finally:
self.imapserver.releaseconnection(imapobj)
for messagestr in response:
# looks like: '1 (FLAGS (\\Seen Old) UID 4807)' or None if no msg
# Discard initial message number.
if messagestr == None:
continue
messagestr = messagestr.split(' ', 1)[1]
options = imaputil.flags2hash(messagestr)
if not 'UID' in options:
self.ui.warn('No UID in message with options %s' %\
str(options),
minor = 1)
else:
uid = long(options['UID'])
flags = imaputil.flagsimap2maildir(options['FLAGS'])
rtime = imaplibutil.Internaldate2epoch(messagestr)
self.messagelist[uid] = {'uid': uid, 'flags': flags, 'time': rtime}
def getmessagelist(self):
return self.messagelist
def getmessage(self, uid):
"""Retrieve message with UID from the IMAP server (incl body)
:returns: the message body or throws and OfflineImapError
(probably severity MESSAGE) if e.g. no message with
this UID could be found.
"""
imapobj = self.imapserver.acquireconnection()
try:
fails_left = 2 # retry on dropped connection
while fails_left:
try:
imapobj.select(self.getfullname(), readonly = True)
res_type, data = imapobj.uid('fetch', str(uid),
'(BODY.PEEK[])')
fails_left = 0
except imapobj.abort as e:
# Release dropped connection, and get a new one
self.imapserver.releaseconnection(imapobj, True)
imapobj = self.imapserver.acquireconnection()
self.ui.error(e, exc_info()[2])
fails_left -= 1
if not fails_left:
raise e
if data == [None] or res_type != 'OK':
#IMAP server says bad request or UID does not exist
severity = OfflineImapError.ERROR.MESSAGE
reason = "IMAP server '%s' failed to fetch message UID '%d'."\
"Server responded: %s %s" % (self.getrepository(), uid,
res_type, data)
if data == [None]:
#IMAP server did not find a message with this UID
reason = "IMAP server '%s' does not have a message "\
"with UID '%s'" % (self.getrepository(), uid)
raise OfflineImapError(reason, severity)
# data looks now e.g. [('320 (UID 17061 BODY[]
# {2565}','msgbody....')] we only asked for one message,
# and that msg is in data[0]. msbody is in [0][1]
data = data[0][1].replace("\r\n", "\n")
if len(data)>200:
dbg_output = "%s...%s" % (str(data)[:150],
str(data)[-50:])
else:
dbg_output = data
self.ui.debug('imap', "Returned object from fetching %d: '%s'" %
(uid, dbg_output))
finally:
self.imapserver.releaseconnection(imapobj)
return data
def getmessagetime(self, uid):
return self.messagelist[uid]['time']
def getmessageflags(self, uid):
return self.messagelist[uid]['flags']
def <API key>(self, content):
"""Returns a unique X-OfflineIMAP header
Generate an 'X-OfflineIMAP' mail header which contains a random
unique value (which is based on the mail content, and a random
number). This header allows us to fetch a mail after APPENDing
it to an IMAP server and thus find out the UID that the server
assigned it.
:returns: (headername, headervalue) tuple, consisting of strings
headername == 'X-OfflineIMAP' and headervalue will be a
random string
"""
headername = 'X-OfflineIMAP'
# We need a random component too. If we ever upload the same
# mail twice (e.g. in different folders), we would still need to
# get the UID for the correct one. As we won't have too many
# mails with identical content, the randomness requirements are
# not extremly critial though.
# compute unsigned crc32 of 'content' as unique hash
# NB: crc32 returns unsigned only starting with python 3.0
headervalue = str( binascii.crc32(content) & 0xffffffff ) + '-'
headervalue += str(self.randomgenerator.randint(0,9999999999))
return (headername, headervalue)
def <API key>(self, content, headername, headervalue):
self.ui.debug('imap',
'<API key>: called to add %s: %s' % (headername,
headervalue))
insertionpoint = content.find("\r\n\r\n")
self.ui.debug('imap', '<API key>: insertionpoint = %d' % insertionpoint)
leader = content[0:insertionpoint]
self.ui.debug('imap', '<API key>: leader = %s' % repr(leader))
if insertionpoint == 0 or insertionpoint == -1:
newline = ''
insertionpoint = 0
else:
newline = "\r\n"
newline += "%s: %s" % (headername, headervalue)
self.ui.debug('imap', '<API key>: newline = ' + repr(newline))
trailer = content[insertionpoint:]
self.ui.debug('imap', '<API key>: trailer = ' + repr(trailer))
return leader + newline + trailer
def <API key>(self, imapobj, headername, headervalue):
self.ui.debug('imap', '<API key> called for %s: %s' % \
(headername, headervalue))
# Now find the UID it got.
headervalue = imapobj._quote(headervalue)
try:
matchinguids = imapobj.uid('search', 'HEADER', headername, headervalue)[1][0]
except imapobj.error as err:
# IMAP server doesn't implement search or had a problem.
self.ui.debug('imap', "<API key>: got IMAP error '%s' while attempting to UID SEARCH for message with header %s" % (err, headername))
return 0
self.ui.debug('imap', '<API key> got initial matchinguids: ' + repr(matchinguids))
if matchinguids == '':
self.ui.debug('imap', "<API key>: UID SEARCH for message with header %s yielded no results" % headername)
return 0
matchinguids = matchinguids.split(' ')
self.ui.debug('imap', '<API key>: matchinguids now ' + \
repr(matchinguids))
if len(matchinguids) != 1 or matchinguids[0] == None:
raise ValueError("While attempting to find UID for message with "
"header %s, got wrong-sized matchinguids of %s" %\
(headername, str(matchinguids)))
return long(matchinguids[0])
def <API key>(self, imapobj, headername, headervalue):
""" We fetch all new mail headers and search for the right
X-OfflineImap line by hand. The response from the server has form:
(
'OK',
[
(
'185 (RFC822.HEADER {1789}',
'... mail headers ...'
),
' UID 2444)',
(
'186 (RFC822.HEADER {1789}',
'... 2nd mail headers ...'
),
' UID 2445)'
]
)
We need to locate the UID just after mail headers containing our
X-OfflineIMAP line.
Returns UID when found, 0 when not found.
"""
self.ui.debug('imap', '<API key> called for %s: %s' % \
(headername, headervalue))
# run "fetch X:* rfc822.header"
# since we stored the mail we are looking for just recently, it would
# not be optimal to fetch all messages. So we'll find highest message
# UID in our local messagelist and search from there (exactly from
# UID+1). That works because UIDs are guaranteed to be unique and
# ascending.
if self.getmessagelist():
start = 1+max(self.getmessagelist().keys())
else:
# Folder was empty - start from 1
start = 1
# Imaplib quotes all parameters of a string type. That must not happen
# with the range X:*. So we use bytearray to stop imaplib from getting
# in our way
result = imapobj.uid('FETCH', bytearray('%d:*' % start), 'rfc822.header')
if result[0] != 'OK':
raise OfflineImapError('Error fetching mail headers: ' + '. '.join(result[1]),
OfflineImapError.ERROR.MESSAGE)
result = result[1]
found = 0
for item in result:
if found == 0 and type(item) == type( () ):
# Walk just tuples
if re.search("(?:^|\\r|\\n)%s:\s*%s(?:\\r|\\n)" % (headername, headervalue),
item[1], flags=re.IGNORECASE):
found = 1
elif found == 1:
if type(item) == type (""):
uid = re.search("UID\s+(\d+)", item, flags=re.IGNORECASE)
if uid:
return int(uid.group(1))
else:
self.ui.warn("Can't parse FETCH response, can't find UID: %s", result.__repr__())
else:
self.ui.warn("Can't parse FETCH response, we awaited string: %s", result.__repr__())
return 0
def <API key>(self, content, rtime=None):
"""Parses mail and returns an INTERNALDATE string
It will use information in the following order, falling back as an attempt fails:
- rtime parameter
- Date header of email
We return None, if we couldn't find a valid date. In this case
the IMAP server will use the server local time when appening
(per RFC).
Note, that imaplib's Time2Internaldate is inherently broken as
it returns localized date strings which are invalid for IMAP
servers. However, that function is called for *every* append()
internally. So we need to either pass in `None` or the correct
string (in which case Time2Internaldate() will do nothing) to
append(). The output of this function is designed to work as
input to the imapobj.append() function.
TODO: We should probably be returning a bytearray rather than a
string here, because the IMAP server will expect plain
ASCII. However, imaplib.Time2INternaldate currently returns a
string so we go with the same for now.
:param rtime: epoch timestamp to be used rather than analyzing
the email.
:returns: string in the form of "DD-Mmm-YYYY HH:MM:SS +HHMM"
(including double quotes) or `None` in case of failure
(which is fine as value for append)."""
if rtime is None:
message = email.message_from_string(content)
# parsedate returns a 9-tuple that can be passed directly to
# time.mktime(); Will be None if missing or not in a valid
# format. Note that indexes 6, 7, and 8 of the result tuple are
# not usable.
datetuple = email.utils.parsedate(message.get('Date'))
if datetuple is None:
#could not determine the date, use the local time.
return None
#make it a real struct_time, so we have named attributes
datetuple = time.struct_time(datetuple)
else:
#rtime is set, use that instead
datetuple = time.localtime(rtime)
try:
# Check for invalid dates
if datetuple[0] < 1981:
raise ValueError
# Check for invalid dates
datetuple_check = time.localtime(time.mktime(datetuple))
if datetuple[:2] != datetuple_check[:2]:
raise ValueError
except (ValueError, OverflowError):
# Argh, sometimes it's a valid format but year is 0102
# or something. Argh. It seems that Time2Internaldate
# will rause a ValueError if the year is 0102 but not 1902,
# but some IMAP servers nonetheless choke on 1902.
self.ui.debug('imap', "Message with invalid date %s. Server will use local time." \
% datetuple)
return None
#produce a string representation of datetuple that works as
#INTERNALDATE
num2mon = {1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun',
7:'Jul', 8:'Aug', 9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'}
#tm_isdst coming from email.parsedate is not usable, we still use it here, mhh
if datetuple.tm_isdst == '1':
zone = -time.altzone
else:
zone = -time.timezone
offset_h, offset_m = divmod(zone//60, 60)
internaldate = '"%02d-%s-%04d %02d:%02d:%02d %+03d%02d"' \
% (datetuple.tm_mday, num2mon[datetuple.tm_mon], datetuple.tm_year, \
datetuple.tm_hour, datetuple.tm_min, datetuple.tm_sec, offset_h, offset_m)
return internaldate
def savemessage(self, uid, content, flags, rtime):
"""Save the message on the Server
This backend always assigns a new uid, so the uid arg is ignored.
This function will update the self.messagelist dict to contain
the new message after sucessfully saving it.
See folder/Base for details. Note that savemessage() does not
check against dryrun settings, so you need to ensure that
savemessage is never called in a dryrun mode.
:param rtime: A timestamp to be used as the mail date
:returns: the UID of the new message as assigned by the server. If the
message is saved, but it's UID can not be found, it will
return 0. If the message can't be written (folder is
read-only for example) it will return -1."""
self.ui.savemessage('imap', uid, flags, self)
# already have it, just save modified flags
if uid > 0 and self.uidexists(uid):
self.savemessageflags(uid, flags)
return uid
retry_left = 2 # succeeded in APPENDING?
imapobj = self.imapserver.acquireconnection()
try:
while retry_left:
# UIDPLUS extension provides us with an APPENDUID response.
use_uidplus = 'UIDPLUS' in imapobj.capabilities
# get the date of the message, so we can pass it to the server.
date = self.<API key>(content, rtime)
content = re.sub("(?<!\r)\n", "\r\n", content)
if not use_uidplus:
# insert a random unique header that we can fetch later
(headername, headervalue) = self.<API key>(
content)
self.ui.debug('imap', 'savemessage: header is: %s: %s' %\
(headername, headervalue))
content = self.<API key>(content, headername,
headervalue)
if len(content)>200:
dbg_output = "%s...%s" % (content[:150], content[-50:])
else:
dbg_output = content
self.ui.debug('imap', "savemessage: date: %s, content: '%s'" %
(date, dbg_output))
try:
# Select folder for append and make the box READ-WRITE
imapobj.select(self.getfullname())
except imapobj.readonly:
# readonly exception. Return original uid to notify that
# we did not save the message. (see savemessage in Base.py)
self.ui.msgtoreadonly(self, uid, content, flags)
return uid
#Do the APPEND
try:
(typ, dat) = imapobj.append(self.getfullname(),
imaputil.flagsmaildir2imap(flags),
date, content)
retry_left = 0 # Mark as success
except imapobj.abort as e:
# connection has been reset, release connection and retry.
retry_left -= 1
self.imapserver.releaseconnection(imapobj, True)
imapobj = self.imapserver.acquireconnection()
if not retry_left:
raise OfflineImapError("Saving msg in folder '%s', "
"repository '%s' failed (abort). Server reponded: %s\n"
"Message content was: %s" %
(self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE)
self.ui.error(e, exc_info()[2])
except imapobj.error as e: # APPEND failed
# If the server responds with 'BAD', append()
# raise()s directly. So we catch that too.
# drop conn, it might be bad.
self.imapserver.releaseconnection(imapobj, True)
imapobj = None
raise OfflineImapError("Saving msg folder '%s', repo '%s'"
"failed (error). Server reponded: %s\nMessage content was: "
"%s" % (self, self.getrepository(), str(e), dbg_output),
OfflineImapError.ERROR.MESSAGE)
# Checkpoint. Let it write out stuff, etc. Eg searches for
# just uploaded messages won't work if we don't do this.
(typ,dat) = imapobj.check()
assert(typ == 'OK')
# get the new UID. Test for APPENDUID response even if the
# server claims to not support it, as e.g. Gmail does :-(
if use_uidplus or imapobj.<API key>('APPENDUID', True):
# get new UID from the APPENDUID response, it could look
# like OK [APPENDUID 38505 3955] APPEND completed with
# 38505 bein folder UIDvalidity and 3955 the new UID.
# note: we would want to use .response() here but that
# often seems to return [None], even though we have
# data. TODO
resp = imapobj.<API key>('APPENDUID')
if resp == [None]:
self.ui.warn("Server supports UIDPLUS but got no APPENDUID "
"appending a message.")
return 0
uid = long(resp[-1].split(' ')[1])
if uid == 0:
self.ui.warn("savemessage: Server supports UIDPLUS, but"
" we got no usable uid back. APPENDUID reponse was "
"'%s'" % str(resp))
else:
# we don't support UIDPLUS
uid = self.<API key>(imapobj, headername,
headervalue)
# See docs for savemessage in Base.py for explanation
# of this and other return values
if uid == 0:
self.ui.debug('imap', 'savemessage: attempt to get new UID '
'UID failed. Search headers manually.')
uid = self.<API key>(imapobj, headername,
headervalue)
self.ui.warn('imap', "savemessage: Searching mails for new "
"Message-ID failed. Could not determine new UID.")
finally:
self.imapserver.releaseconnection(imapobj)
if uid: # avoid UID FETCH 0 crash happening later on
self.messagelist[uid] = {'uid': uid, 'flags': flags}
self.ui.debug('imap', 'savemessage: returning new UID %d' % uid)
return uid
def savemessageflags(self, uid, flags):
"""Change a message's flags to `flags`.
Note that this function does not check against dryrun settings,
so you need to ensure that it is never called in a
dryrun mode."""
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
self.ui.flagstoreadonly(self, [uid], flags)
return
result = imapobj.uid('store', '%d' % uid, 'FLAGS',
imaputil.flagsmaildir2imap(flags))
assert result[0] == 'OK', 'Error with store: ' + '. '.join(result[1])
finally:
self.imapserver.releaseconnection(imapobj)
result = result[1][0]
if not result:
self.messagelist[uid]['flags'] = flags
else:
flags = imaputil.flags2hash(imaputil.imapsplit(result)[1])['FLAGS']
self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(flags)
def addmessageflags(self, uid, flags):
self.addmessagesflags([uid], flags)
def <API key>(self, uidlist, flags):
self.<API key>('+', uidlist, flags)
def addmessagesflags(self, uidlist, flags):
"""This is here for the sake of UIDMaps.py -- deletemessages must
add flags and get a converted UID, and if we don't have noconvert,
then UIDMaps will try to convert it twice."""
self.<API key>(uidlist, flags)
def deletemessageflags(self, uid, flags):
self.deletemessagesflags([uid], flags)
def deletemessagesflags(self, uidlist, flags):
self.<API key>('-', uidlist, flags)
def <API key>(self, operation, uidlist, flags):
if len(uidlist) > 101:
# Hack for those IMAP ervers with a limited line length
self.<API key>(operation, uidlist[:100], flags)
self.<API key>(operation, uidlist[100:], flags)
return
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
self.ui.flagstoreadonly(self, uidlist, flags)
return
r = imapobj.uid('store',
imaputil.uid_sequence(uidlist),
operation + 'FLAGS',
imaputil.flagsmaildir2imap(flags))
assert r[0] == 'OK', 'Error with store: ' + '. '.join(r[1])
r = r[1]
finally:
self.imapserver.releaseconnection(imapobj)
# Some IMAP servers do not always return a result. Therefore,
# only update the ones that it talks about, and manually fix
# the others.
needupdate = list(uidlist)
for result in r:
if result == None:
# Compensate for servers that don't return anything from
# STORE.
continue
attributehash = imaputil.flags2hash(imaputil.imapsplit(result)[1])
if not ('UID' in attributehash and 'FLAGS' in attributehash):
# Compensate for servers that don't return a UID attribute.
continue
flagstr = attributehash['FLAGS']
uid = long(attributehash['UID'])
self.messagelist[uid]['flags'] = imaputil.flagsimap2maildir(flagstr)
try:
needupdate.remove(uid)
except ValueError: # Let it slide if it's not in the list
pass
for uid in needupdate:
if operation == '+':
self.messagelist[uid]['flags'] |= flags
elif operation == '-':
self.messagelist[uid]['flags'] -= flags
def change_message_uid(self, uid, new_uid):
"""Change the message from existing uid to new_uid
If the backend supports it. IMAP does not and will throw errors."""
raise OfflineImapError('IMAP backend cannot change a messages UID from '
'%d to %d' % (uid, new_uid),
OfflineImapError.ERROR.MESSAGE)
def deletemessage(self, uid):
self.<API key>([uid])
def deletemessages(self, uidlist):
self.<API key>(uidlist)
def <API key>(self, uidlist):
# Weed out ones not in self.messagelist
uidlist = [uid for uid in uidlist if self.uidexists(uid)]
if not len(uidlist):
return
self.<API key>(uidlist, set('T'))
imapobj = self.imapserver.acquireconnection()
try:
try:
imapobj.select(self.getfullname())
except imapobj.readonly:
self.ui.deletereadonly(self, uidlist)
return
if self.expunge:
assert(imapobj.expunge()[0] == 'OK')
finally:
self.imapserver.releaseconnection(imapobj)
for uid in uidlist:
del self.messagelist[uid]
|
/* ScriptData
SDName: Boss_Maexxna
SD%Complete: 80
SDComment:
SDCategory: Naxxramas
EndScriptData */
#include "precompiled.h"
#define SPELL_WEBTRAP 28622 //Spell is normally used by the webtrap on the wall NOT by Maexxna
#define SPELL_WEBSPRAY 29484
#define H_SPELL_WEBSPRAY 54125
#define SPELL_POISONSHOCK 28741
#define H_SPELL_POISONSHOCK 54122
#define <API key> 28776
#define <API key> 54121
#define SPELL_FRENZY 54123
#define H_SPELL_FRENZY 54124
#define <API key> 29434
#define LOC_X1 3546.796
#define LOC_Y1 -3869.082
#define LOC_Z1 296.450
#define LOC_X2 3531.271
#define LOC_Y2 -3847.424
#define LOC_Z2 299.450
#define LOC_X3 3497.067
#define LOC_Y3 -3843.384
#define LOC_Z3 302.384
struct TRINITY_DLL_DECL mob_webwrapAI : public ScriptedAI
{
mob_webwrapAI(Creature *c) : ScriptedAI(c) {}
uint64 victimGUID;
void Reset()
{
victimGUID = 0;
}
void SetVictim(Unit* victim)
{
if(victim)
{
victimGUID = victim->GetGUID();
victim->CastSpell(victim, SPELL_WEBTRAP, true);
}
}
void DamageTaken(Unit *done_by, uint32 &damage)
{
if(damage > m_creature->GetHealth())
{
if(victimGUID)
{
Unit* victim = NULL;
victim = Unit::GetUnit((*m_creature), victimGUID);
victim-><API key>(SPELL_WEBTRAP);
}
}
}
void Aggro(Unit *who)
{
}
void MoveInLineOfSight(Unit *who)
{
}
void UpdateAI(const uint32 diff)
{
}
};
struct TRINITY_DLL_DECL boss_maexxnaAI : public ScriptedAI
{
boss_maexxnaAI(Creature *c) : ScriptedAI(c) {}
uint32 WebTrap_Timer;
uint32 WebSpray_Timer;
uint32 PoisonShock_Timer;
uint32 <API key>;
uint32 <API key>;
bool Enraged;
void Reset()
{
WebTrap_Timer = 20000; //20 sec init, 40 sec normal
WebSpray_Timer = 40000; //40 seconds
PoisonShock_Timer = 20000; //20 seconds
<API key> = 30000; //30 seconds
<API key> = 30000; //30 sec init, 40 sec normal
Enraged = false;
}
void Aggro(Unit *who)
{
}
void DoCastWebWrap()
{
std::list<HostilReference *> t_list = m_creature->getThreatManager().getThreatList();
std::vector<Unit *> targets;
//This spell doesn't work if we only have 1 player on threat list
if(t_list.size() < 2)
return;
//begin + 1 , so we don't target the one with the highest threat
std::list<HostilReference *>::iterator itr = t_list.begin();
std::advance(itr, 1);
for( ; itr!= t_list.end(); ++itr) //store the threat list in a different container
{
Unit *target = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
//only on alive players
if(target && target->isAlive() && target->GetTypeId() == TYPEID_PLAYER )
targets.push_back( target);
}
while(targets.size() > 3)
//cut down to size if we have more than 3 targets
targets.erase(targets.begin()+rand()%targets.size());
int i = 0;
for(std::vector<Unit *>::iterator itr = targets.begin(); itr!= targets.end(); ++itr, ++i)
{
// Teleport the 3 targets to a location on the wall and summon a Web Wrap on them
Unit *target = *itr;
Creature* Wrap = NULL;
if(target)
{
switch(i)
{
case 0:
DoTeleportPlayer(target, LOC_X1, LOC_Y1, LOC_Z1, target->GetOrientation());
Wrap = m_creature->SummonCreature(16486, LOC_X1, LOC_Y1, LOC_Z1, 0, <API key>, 120000);
break;
case 1:
DoTeleportPlayer(target, LOC_X2, LOC_Y2, LOC_Z2, target->GetOrientation());
Wrap = m_creature->SummonCreature(16486, LOC_X2, LOC_Y2, LOC_Z2, 0, <API key>, 120000);
break;
case 2:
DoTeleportPlayer(target, LOC_X3, LOC_Y3, LOC_Z3, target->GetOrientation());
Wrap = m_creature->SummonCreature(16486, LOC_X3, LOC_Y3, LOC_Z3, 0, <API key>, 120000);
break;
}
if(Wrap)
{
Wrap->setFaction(m_creature->getFaction());
((mob_webwrapAI*)Wrap->AI())->SetVictim(target);
}
}
}
}
void UpdateAI(const uint32 diff)
{
if (!UpdateVictim())
return;
//WebTrap_Timer
if (WebTrap_Timer < diff)
{
DoCastWebWrap();
WebTrap_Timer = 40000;
}else WebTrap_Timer -= diff;
//WebSpray_Timer
if (WebSpray_Timer < diff)
{
DoCast(m_creature->getVictim(), SPELL_WEBSPRAY);
WebSpray_Timer = 40000;
}else WebSpray_Timer -= diff;
//PoisonShock_Timer
if (PoisonShock_Timer < diff)
{
DoCast(m_creature->getVictim(), SPELL_POISONSHOCK);
PoisonShock_Timer = 20000;
}else PoisonShock_Timer -= diff;
//<API key>
if (<API key> < diff)
{
DoCast(m_creature->getVictim(), <API key>);
<API key> = 30000;
}else <API key> -= diff;
//<API key>
if (<API key> < diff)
{
DoCast(m_creature, <API key>);
<API key> = 40000;
}else <API key> -= diff;
//Enrage if not already enraged and below 30%
if (!Enraged && (m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) < 30)
{
DoCast(m_creature,SPELL_FRENZY);
Enraged = true;
}
<API key>();
}
};
CreatureAI* GetAI_mob_webwrap(Creature* _Creature)
{
return new mob_webwrapAI (_Creature);
}
CreatureAI* GetAI_boss_maexxna(Creature *_Creature)
{
return new boss_maexxnaAI (_Creature);
}
void AddSC_boss_maexxna()
{
Script *newscript;
newscript = new Script;
newscript->Name="boss_maexxna";
newscript->GetAI = &GetAI_boss_maexxna;
newscript->RegisterSelf();
newscript = new Script;
newscript->Name="mob_webwrap";
newscript->GetAI = &GetAI_mob_webwrap;
newscript->RegisterSelf();
}
|
#ifndef ENFUSESTACK_H
#define ENFUSESTACK_H
// Qt includes
#include <QTreeWidget>
#include <QString>
#include <QPixmap>
#include <QPoint>
#include <QList>
#include <QIcon>
// KDE includes
#include <kurl.h>
#include <kfileitem.h>
// Local includes
#include "enfusesettings.h"
namespace KIPI
{
class Interface;
}
using namespace KIPI;
namespace <API key>
{
class EnfuseStackItem : public QTreeWidgetItem
{
public:
EnfuseStackItem(QTreeWidget* const parent);
virtual ~EnfuseStackItem();
/** Return the preview image url assigned to item.
*/
KUrl url() const;
void setEnfuseSettings(const EnfuseSettings& settings);
EnfuseSettings enfuseSettings() const;
void setOn(bool b);
bool isOn() const;
void <API key>(const QPixmap& pix);
void setThumbnail(const QPixmap& pix);
void setProcessedIcon(const QIcon& icon);
bool asValidThumb() const;
private:
class EnfuseStackItemPriv;
EnfuseStackItemPriv* const d;
};
class EnfuseStackList : public QTreeWidget
{
Q_OBJECT
public:
EnfuseStackList(QWidget* const parent);
virtual ~EnfuseStackList();
void setTemplateFileName(<API key>::OutputFormat, const QString&);
void setThumbnail(const KUrl& url, const QImage& img);
void setOnItem(const KUrl& url, bool on);
void removeItem(const KUrl& url);
void clearSelected();
void addItem(const KUrl& url, const EnfuseSettings& settings);
void processingItem(const KUrl& url, bool run);
void processedItem(const KUrl& url, bool success);
QList<EnfuseSettings> settingsList();
Q_SIGNALS:
void signalItemClicked(const KUrl&);
private:
EnfuseStackItem* findItemByUrl(const KUrl& url);
private Q_SLOTS:
void slotItemClicked(QTreeWidgetItem*);
void slotContextMenu(const QPoint&);
void slotRemoveItem();
void <API key>();
private:
class EnfuseStackListPriv;
EnfuseStackListPriv* const d;
};
} // namespace <API key>
#endif /* ENFUSESTACK_H */
|
#include "setup.h"
#ifdef HAVE_GSSAPI
#ifdef HAVE_OLD_GSSMIT
#define <API key> gss_nt_service_name
#define NCOMPAT 1
#endif
#ifndef CURL_DISABLE_HTTP
#include "urldata.h"
#include "sendf.h"
#include "curl_gssapi.h"
#include "rawstr.h"
#include "curl_base64.h"
#include "http_negotiate.h"
#include "curl_memory.h"
#include "url.h"
#ifdef HAVE_SPNEGO
# include <spnegohelp.h>
# ifdef USE_SSLEAY
# ifdef USE_OPENSSL
# include <openssl/objects.h>
# else
# include <objects.h>
# endif
# else
# error "Can't compile SPNEGO support without OpenSSL."
# endif
#endif
#define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h>
/* The last #include file should be: */
#include "memdebug.h"
static int
get_gss_name(struct connectdata *conn, bool proxy, gss_name_t *server)
{
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
OM_uint32 major_status, minor_status;
gss_buffer_desc <API key>;
char name[2048];
const char* service;
/* GSSAPI implementation by Globus (known as GSI) requires the name to be
of form "<service>/<fqdn>" instead of <service>@<fqdn> (ie. slash instead
of at-sign). Also GSI servers are often identified as 'host' not 'khttp'.
Change following lines if you want to use GSI */
/* IIS uses the <service>@<fqdn> form but uses 'http' as the service name */
if(neg_ctx->gss)
service = "KHTTP";
else
service = "HTTP";
token.length = strlen(service) + 1 + strlen(proxy ? conn->proxy.name :
conn->host.name) + 1;
if(token.length + 1 > sizeof(name))
return EMSGSIZE;
snprintf(name, sizeof(name), "%s@%s", service, proxy ? conn->proxy.name :
conn->host.name);
token.value = (void *) name;
major_status = gss_import_name(&minor_status,
&token,
<API key>,
server);
return GSS_ERROR(major_status) ? -1 : 0;
}
static void
log_gss_error(struct connectdata *conn, OM_uint32 error_status,
const char *prefix)
{
OM_uint32 maj_stat, min_stat;
OM_uint32 msg_ctx = 0;
gss_buffer_desc status_string;
char buf[1024];
size_t len;
snprintf(buf, sizeof(buf), "%s", prefix);
len = strlen(buf);
do {
maj_stat = gss_display_status(&min_stat,
error_status,
GSS_C_MECH_CODE,
GSS_C_NO_OID,
&msg_ctx,
&status_string);
if(sizeof(buf) > len + status_string.length + 1) {
snprintf(buf + len, sizeof(buf) - len,
": %s", (char*) status_string.value);
len += status_string.length;
}
gss_release_buffer(&min_stat, &status_string);
} while(!GSS_ERROR(maj_stat) && msg_ctx != 0);
infof(conn->data, "%s", buf);
}
/* returning zero (0) means success, everything else is treated as "failure"
with no care exactly what the failure was */
int <API key>(struct connectdata *conn, bool proxy,
const char *header)
{
struct SessionHandle *data = conn->data;
struct negotiatedata *neg_ctx = proxy?&data->state.proxyneg:
&data->state.negotiate;
OM_uint32 major_status, minor_status, minor_status2;
gss_buffer_desc input_<API key>;
gss_buffer_desc output_<API key>;
int ret;
size_t len;
size_t rawlen = 0;
bool gss;
const char* protocol;
CURLcode error;
while(*header && ISSPACE(*header))
header++;
if(checkprefix("GSS-Negotiate", header)) {
protocol = "GSS-Negotiate";
gss = TRUE;
}
else if(checkprefix("Negotiate", header)) {
protocol = "Negotiate";
gss = FALSE;
}
else
return -1;
if(neg_ctx->context) {
if(neg_ctx->gss != gss) {
return -1;
}
}
else {
neg_ctx->protocol = protocol;
neg_ctx->gss = gss;
}
if(neg_ctx->context && neg_ctx->status == GSS_S_COMPLETE) {
/* We finished successfully our part of authentication, but server
* rejected it (since we're again here). Exit with an error since we
* can't invent anything better */
<API key>(data);
return -1;
}
if(neg_ctx->server_name == NULL &&
(ret = get_gss_name(conn, proxy, &neg_ctx->server_name)))
return ret;
header += strlen(neg_ctx->protocol);
while(*header && ISSPACE(*header))
header++;
len = strlen(header);
if(len > 0) {
error = Curl_base64_decode(header,
(unsigned char **)&input_token.value, &rawlen);
if(error || rawlen == 0)
return -1;
input_token.length = rawlen;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if(checkprefix("Negotiate", header)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
size_t spnegoTokenLength = 0;
unsigned char * mechToken = NULL;
size_t mechTokenLength = 0;
if(input_token.value == NULL)
return CURLE_OUT_OF_MEMORY;
spnegoToken = malloc(input_token.length);
if(spnegoToken == NULL)
return CURLE_OUT_OF_MEMORY;
spnegoTokenLength = input_token.length;
object = OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if(!<API key>(spnegoToken,
spnegoTokenLength,
NULL,
NULL,
&mechToken,
&mechTokenLength,
NULL,
NULL)) {
free(spnegoToken);
spnegoToken = NULL;
infof(data, "Parse SPNEGO Target Token failed\n");
}
else {
free(input_token.value);
input_token.value = malloc(mechTokenLength);
if(input_token.value == NULL)
return CURLE_OUT_OF_MEMORY;
memcpy(input_token.value, mechToken,mechTokenLength);
input_token.length = mechTokenLength;
free(mechToken);
mechToken = NULL;
infof(data, "Parse SPNEGO Target Token succeeded\n");
}
}
#endif
}
major_status = <API key>(data,
&minor_status,
&neg_ctx->context,
neg_ctx->server_name,
<API key>,
&input_token,
&output_token,
NULL);
if(input_token.length > 0)
gss_release_buffer(&minor_status2, &input_token);
neg_ctx->status = major_status;
if(GSS_ERROR(major_status)) {
/* <API key>(data) ??? */
log_gss_error(conn, minor_status,
"<API key>() failed: ");
return -1;
}
if(output_token.length == 0) {
return -1;
}
neg_ctx->output_token = output_token;
/* conn->bits.close = FALSE; */
return 0;
}
CURLcode <API key>(struct connectdata *conn, bool proxy)
{
struct negotiatedata *neg_ctx = proxy?&conn->data->state.proxyneg:
&conn->data->state.negotiate;
char *encoded = NULL;
size_t len = 0;
char *userp;
CURLcode error;
#ifdef HAVE_SPNEGO /* Handle SPNEGO */
if(checkprefix("Negotiate", neg_ctx->protocol)) {
ASN1_OBJECT * object = NULL;
int rc = 1;
unsigned char * spnegoToken = NULL;
size_t spnegoTokenLength = 0;
unsigned char * responseToken = NULL;
size_t responseTokenLength = 0;
responseToken = malloc(neg_ctx->output_token.length);
if(responseToken == NULL)
return CURLE_OUT_OF_MEMORY;
memcpy(responseToken, neg_ctx->output_token.value,
neg_ctx->output_token.length);
responseTokenLength = neg_ctx->output_token.length;
object=OBJ_txt2obj ("1.2.840.113554.1.2.2", 1);
if(!<API key> (object,
responseToken,
responseTokenLength,
&spnegoToken,
&spnegoTokenLength)) {
free(responseToken);
responseToken = NULL;
infof(conn->data, "Make SPNEGO Initial Token failed\n");
}
else {
free(responseToken);
responseToken = NULL;
free(neg_ctx->output_token.value);
neg_ctx->output_token.value = malloc(spnegoTokenLength);
if(neg_ctx->output_token.value == NULL) {
free(spnegoToken);
spnegoToken = NULL;
return CURLE_OUT_OF_MEMORY;
}
memcpy(neg_ctx->output_token.value, spnegoToken,spnegoTokenLength);
neg_ctx->output_token.length = spnegoTokenLength;
free(spnegoToken);
spnegoToken = NULL;
infof(conn->data, "Make SPNEGO Initial Token succeeded\n");
}
}
#endif
error = Curl_base64_encode(conn->data,
neg_ctx->output_token.value,
neg_ctx->output_token.length,
&encoded, &len);
if(error) {
Curl_safefree(neg_ctx->output_token.value);
neg_ctx->output_token.value = NULL;
return error;
}
if(len == 0) {
Curl_safefree(neg_ctx->output_token.value);
neg_ctx->output_token.value = NULL;
return <API key>;
}
userp = aprintf("%sAuthorization: %s %s\r\n", proxy ? "Proxy-" : "",
neg_ctx->protocol, encoded);
if(proxy)
conn->allocptr.proxyuserpwd = userp;
else
conn->allocptr.userpwd = userp;
free(encoded);
<API key> (conn->data);
return (userp == NULL) ? CURLE_OUT_OF_MEMORY : CURLE_OK;
}
static void cleanup(struct negotiatedata *neg_ctx)
{
OM_uint32 minor_status;
if(neg_ctx->context != GSS_C_NO_CONTEXT)
<API key>(&minor_status, &neg_ctx->context, GSS_C_NO_BUFFER);
if(neg_ctx->output_token.length != 0)
gss_release_buffer(&minor_status, &neg_ctx->output_token);
if(neg_ctx->server_name != GSS_C_NO_NAME)
gss_release_name(&minor_status, &neg_ctx->server_name);
memset(neg_ctx, 0, sizeof(*neg_ctx));
}
void <API key>(struct SessionHandle *data)
{
cleanup(&data->state.negotiate);
cleanup(&data->state.proxyneg);
}
#endif
#endif
|
<?php
require_once MODX_CORE_PATH.'model/modx/processors/resource/getnodes.class.php';
class <API key> extends <API key> {
protected $pid;
protected $parent_id;
/** {@inheritDoc} */
public function initialize() {
$initialize = parent::initialize();
$this->pid = $this->getProperty('currentResource');
if ($res = $this->modx->getObject('msProduct', $this->pid)) {
$this->parent_id = $res->get('parent');
}
return $initialize;
}
/** {@inheritDoc} */
public function getResourceQuery() {
$resourceColumns = array(
'id'
,'pagetitle'
,'longtitle'
,'alias'
,'description'
,'parent'
,'published'
,'deleted'
,'isfolder'
,'menuindex'
,'menutitle'
,'hidemenu'
,'class_key'
,'context_key'
);
$this->itemClass= 'modResource';
$c= $this->modx->newQuery($this->itemClass);
$c->leftJoin('modResource', 'Child', array('modResource.id = Child.parent'));
$c->leftJoin('msCategoryMember', 'Member', array('modResource.id = Member.category_id AND Member.product_id = '.$this->pid));
$c->select($this->modx->getSelectColumns('modResource', 'modResource', '', $resourceColumns));
$c->select(array(
'childrenCount' => 'COUNT(Child.id)',
'member' => 'category_id'
));
$c->where(array(
'context_key' => $this->contextKey
,'show_in_tree' => true
,'isfolder' => true
));
if (empty($this->startNode) && !empty($this->defaultRootId)) {
$c->where(array(
'id:IN' => explode(',', $this->defaultRootId),
'parent:NOT IN' => explode(',', $this->defaultRootId),
));
} else {
$c->where(array(
'parent' => $this->startNode,
));
}
$c->groupby($this->modx->getSelectColumns('modResource', 'modResource', '', $resourceColumns), '');
$c->sortby('modResource.'.$this->getProperty('sortBy'),$this->getProperty('sortDir'));
return $c;
}
/** {@inheritDoc} */
public function prepareContextNode(modContext $context) {
$context->prepare();
return array(
'text' => $context->get('key')
,'id' => $context->get('key') . '_0'
,'pk' => $context->get('key')
,'ctx' => $context->get('key')
,'leaf' => false
,'cls' => 'icon-context'
,'iconCls' => $this->modx->getOption('<API key>', null, 'tree-context')
,'qtip' => $context->get('description') != '' ? strip_tags($context->get('description')) : ''
,'type' => 'modContext'
);
}
/** {@inheritDoc} */
public function prepareResourceNode(modResource $resource) {
$qtipField = $this->getProperty('qtipField');
$nodeField = $this->getProperty('nodeField');
$hasChildren = (int)$resource->get('childrenCount') > 0 && $resource->get('<API key>') == 0 ? true : false;
// Assign an icon class based on the class_key
$class = $iconCls = array();
$classKey = strtolower($resource->get('class_key'));
if (substr($classKey, 0, 3) == 'mod') {
$classKey = substr($classKey, 3);
}
$classKeyIcon = $this->modx->getOption('mgr_tree_icon_' . $classKey, null, 'tree-resource');
$iconCls[] = $classKeyIcon;
$class[] = 'icon-'.strtolower(str_replace('mod','',$resource->get('class_key')));
if (!$resource->isfolder) {
$class[] = 'x-tree-node-leaf icon-resource';
}
if (!$resource->get('published')) $class[] = 'unpublished';
if ($resource->get('deleted')) $class[] = 'deleted';
if ($resource->get('hidemenu')) $class[] = 'hidemenu';
if ($hasChildren) {
$class[] = 'haschildren';
$iconCls[] = $this->modx->getOption('<API key>', null, 'tree-folder');
$iconCls[] = 'parent-resource';
}
$qtip = '';
if (!empty($qtipField)) {
$qtip = '<b>'.strip_tags($resource->$qtipField).'</b>';
} else {
if ($resource->longtitle != '') {
$qtip = '<b>'.strip_tags($resource->longtitle).'</b><br />';
}
if ($resource->description != '') {
$qtip = '<i>'.strip_tags($resource->description).'</i>';
}
}
$idNote = $this->modx->hasPermission('<API key>') ? ' <span dir="ltr">('.$resource->id.')</span>' : '';
$itemArray = array(
'text' => strip_tags($resource->$nodeField).$idNote,
'id' => $resource->context_key . '_'.$resource->id,
'pk' => $resource->id,
'cls' => implode(' ',$class),
'iconCls' => implode(' ',$iconCls),
'type' => 'modResource',
'classKey' => $resource->class_key,
'ctx' => $resource->context_key,
'<API key>' => $resource-><API key>,
'qtip' => $qtip,
'checked' => !empty($resource->member) || $resource->id == $this->parent_id ? true : false,
'disabled' => $resource->id == $this->parent_id ? true : false
);
if (!$hasChildren) {
$itemArray['hasChildren'] = false;
$itemArray['children'] = array();
$itemArray['expanded'] = true;
} else {
$itemArray['hasChildren'] = true;
}
if ($itemArray['classKey'] != 'msCategory') {
unset($itemArray['checked']);
}
return $itemArray;
}
}
return '<API key>';
|
using System.Collections.Generic;
class C
{
class ArrayReadOnlyList<T>
{
T [] array;
bool is_value_type;
public ArrayReadOnlyList ()
{
}
public T this [int index]
{
get
{
return array [index];
}
}
public IEnumerator<T> GetEnumerator ()
{
for (int i = 0; i < array.Length; i++)
yield return array [i];
}
}
public static void Main ()
{
}
}
|
package org.opencloudb.net.mysql;
/**
* @author mycatload data infile
*/
public class EmptyPacket extends MySQLPacket {
public static final byte[] EMPTY = new byte[] { 0, 0, 0,3 };
@Override
public int calcPacketSize() {
return 0;
}
@Override
protected String getPacketInfo() {
return "MySQL Empty Packet";
}
}
|
<?php
session_start();
/////////////////////////////////////////// SEGURIDAD /////////////////////////////////////////////
if(!array_key_exists("la_logusr",$_SESSION))
{
print "<script language=JavaScript>";
print "location.href='../<API key>.php'";
print "</script>";
}
$ls_logusr=$_SESSION["la_logusr"];
$ls_codnom=$_SESSION["la_nomina"]["codnom"];
require_once("class_folder/<API key>.php");
$io_fun_nomina=new <API key>();
$io_fun_nomina-><API key>("SNO","<API key>.php",$ls_codnom,$ls_permisos,$la_seguridad,$la_permisos);
/////////////////////////////////////////// SEGURIDAD /////////////////////////////////////////////
require_once("sigesp_sno.php");
$io_sno=new sigesp_sno();
global $ls_sueint;
$ls_sueint=trim($io_sno->uf_select_config("SNO","NOMINA","DENOMINACION SUELDO INTEGRAL","C",""));
unset($io_sno);
function uf_limpiarvariables()
{
// Function: uf_limpiarvariables
// Access: private
// Creado Por: Ing. Yesenia Moreno
global $ls_codper,$ls_nomper,$li_codvac,$ld_fecvenvac,$ld_fecdisvac,$ld_fecreivac,$ls_stavac,$li_diavac,$li_diaadivac;
global $li_diabonvac,$li_diaadibon,$li_diapenvac,$li_diafer,$li_sabdom,$li_sueintvac,$li_sueintbonvac,$ls_obsvac;
global $ls_diapag,$ls_pagcan,$li_dianorvac,$ls_persalvac,$ls_peringvac,$li_quisalvac,$li_quireivac,$la_stavac,$ls_existe;
global $ls_operacion,$ls_desnom,$io_fun_nomina,$ls_desper,$ld_fechasper,$li_diapervac,$ls_pagpersal,$li_salvacper;
require_once("sigesp_sno.php");
$io_sno=new sigesp_sno();
$lb_valido=$io_sno-><API key>();
$ls_desnom="";
$ls_peractnom="";
$ls_desper="";
$ld_fechasper="";
if($lb_valido==false)
{
print "<script language=JavaScript>";
print "location.href='sigespwindow_blank.php'";
print "</script>";
}
else
{
$ls_desnom=$_SESSION["la_nomina"]["desnom"];
$ls_peractnom=$_SESSION["la_nomina"]["peractnom"];
$ls_desper=$_SESSION["la_nomina"]["descripcionperiodo"];
$ld_fechasper=$io_sno->io_funciones-><API key>($_SESSION["la_nomina"]["fechasper"]);
}
$li_salvacper=trim($io_sno->uf_select_config("SNO","NOMINA","SALIDA VACACION","0","C"));
$ls_codper="";
$ls_nomper="";
$li_codvac=0;
$ld_fecvenvac="dd/mm/aaaa";
$ld_fecdisvac="dd/mm/aaaa";
$ld_fecreivac="dd/mm/aaaa";
$ls_stavac="";
$li_diavac=0;
$li_diaadivac=0;
$li_diabonvac=0;
$li_diaadibon=0;
$li_diapenvac=0;
$li_diafer=0;
$li_sabdom=0;
$li_sueintvac=0;
$li_sueintbonvac=0;
$ls_obsvac="";
$ls_diapag="";
$ls_pagcan="";
$li_dianorvac=0;
$ls_peringvac="";
$ls_persalvac="";
$li_quisalvac=0;
$li_quireivac=0;
$la_stavac[0]="";
$la_stavac[1]="";
$li_diapervac=0;
$ls_pagpersal=0;
$ls_existe=$io_fun_nomina->uf_obtenerexiste();
$ls_operacion=$io_fun_nomina->uf_obteneroperacion();
unset($io_sno);
}
function uf_load_variables()
{
// Function: uf_load_variables
// Access: private
// Creado Por: Ing. Yesenia Moreno
global $ls_codper, $ls_nomper, $li_codvac, $ld_fecvenvac, $ld_fecdisvac, $ld_fecreivac, $ls_stavac, $li_diavac, $li_diaadivac;
global $li_diabonvac, $li_diaadibon, $li_diapenvac, $li_diafer, $li_sabdom, $li_sueintvac, $li_sueintbonvac, $ls_obsvac, $li_diapag;
global $li_pagcan, $li_dianorvac,$ls_persalvac,$ls_peringvac,$li_quisalvac,$li_quireivac,$li_diapervac,$ls_pagpersal, $io_fun_nomina,$li_salvacper;
$ls_codper=$_POST["txtcodper"];
$ls_nomper=$_POST["txtnomper"];
$li_codvac=$_POST["txtcodvac"];
$ld_fecvenvac=$_POST["txtfecvenvac"];
$ld_fecdisvac=$_POST["txtfecdisvac"];
$ld_fecreivac=$_POST["txtfecreivac"];
$ls_stavac=$_POST["cmbstavac"];
$li_diavac=$_POST["txtdiavac"];
$li_diaadivac=$_POST["txtdiaadivac"];
$li_diabonvac=$_POST["txtdiabonvac"];
$li_diaadibon=$_POST["txtdiaadibon"];
$li_diapenvac=$_POST["txtdiapenvac"];
$li_diafer=$_POST["txtdiafer"];
$li_sabdom=$_POST["txtsabdom"];
$li_sueintvac=$_POST["txtsueintvac"];
$li_sueintbonvac=$_POST["txtsueintbonvac"];
$ls_obsvac=$_POST["txtobsvac"];
$li_dianorvac=$_POST["txtdianorvac"];
$ls_peringvac=$_POST["txtperingvac"];
$ls_persalvac=$_POST["txtpersalvac"];
$li_quisalvac=$_POST["txtquisalvac"];
$li_quireivac=$_POST["txtquireivac"];
$li_diapervac=$_POST["txtdiapervac"];
$li_salvacper=$_POST["txtsalvacper"];
$li_diapag=$io_fun_nomina->uf_obtenervalor("chkdiapag","0");
$li_pagcan=$io_fun_nomina->uf_obtenervalor("chkpagcan","0");
$ls_pagpersal=$io_fun_nomina->uf_obtenervalor("chkpagpersal","0");
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http:
<html>
<head>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/disabled_keys.js"></script>
<script language="javascript">
if(document.all)
{
document.onkeydown = function(){
if(window.event && (window.event.keyCode == 122 || window.event.keyCode == 116 || window.event.ctrlKey)){
window.event.keyCode = 505;
}
if(window.event.keyCode == 505){
return false;
}
}
}
</script>
<title >Programar Vacaciones </title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
<!
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #EFEBEF;
}
a:link {
color: #006699;
}
a:visited {
color: #006699;
}
a:active {
color: #006699;
}
</style>
<script type="text/javascript" language="JavaScript1.2" src="js/stm31.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="js/funcion_nomina.js"></script>
<script type="text/javascript" language="JavaScript1.2" src="../shared/js/validaciones.js"></script>
<script language="javascript" src="../shared/js/js_intra/datepickercontrol.js"></script>
<link href="../shared/css/tablas.css" rel="stylesheet" type="text/css">
<link href="css/nomina.css" rel="stylesheet" type="text/css">
<link href="../shared/css/ventanas.css" rel="stylesheet" type="text/css">
<link href="../shared/css/cabecera.css" rel="stylesheet" type="text/css">
<link href="../shared/css/general.css" rel="stylesheet" type="text/css">
<link href="../shared/js/css_intra/datepickercontrol.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
require_once("<API key>.php");
$io_vacacion=new <API key>();
uf_limpiarvariables();
switch ($ls_operacion)
{
case "REPROGRAMAR":
uf_load_variables();
list($lb_valido,$lb_correcto)=$io_vacacion-><API key>($ls_codper,$ld_fecdisvac,$li_diavac,$li_diabonvac,
$li_diaadivac,$li_diaadibon,
$ld_fecvenvac,$ld_fecreivac,$li_sabdom,$li_diafer,$ls_persalvac,
$ls_peringvac,$li_dianorvac,$ls_obsvac,$li_quisalvac,$li_quireivac,
$li_sueintvac,$li_diapervac);
if($lb_valido==false)
{
uf_load_variables();
}
$io_fun_nomina->uf_seleccionarcombo("1-2",$ls_stavac,$la_stavac,2);
if($li_diapag==1)
{
$ls_diapag="checked";
}
else
{
$ls_diapag="";
}
if($li_pagcan==1)
{
$ls_pagcan="checked";
}
else
{
$ls_pagcan="";
}
break;
case "GUARDAR":
uf_load_variables();
$li_sueintgralvac=$li_sueintvac;
list($lb_valido,$lb_correcto)=$io_vacacion-><API key>($ls_codper,$ld_fecdisvac,$li_diavac,$li_diabonvac,
$li_diaadivac,$li_diaadibon,
$ld_fecvenvac,$ld_fecreivac,$li_sabdom,$li_diafer,
$ls_persalvac,$ls_peringvac,$li_dianorvac,
$ls_obsvac,$li_quisalvac,$li_quireivac,
$li_sueintvac,$li_diapervac);
if($lb_correcto)
{
$lb_valido=$io_vacacion->uf_update_vacacion($ls_codper,$li_codvac,$ld_fecvenvac,$ld_fecdisvac,$ld_fecreivac,
$ls_stavac,$li_diavac,$li_diaadivac,$li_diabonvac,$li_diaadibon,
$li_diapenvac,$li_diafer,$li_sabdom,$li_sueintgralvac,$li_sueintbonvac,
$ls_obsvac,$li_diapag,$li_pagcan,$li_dianorvac,$ls_peringvac,
$ls_persalvac,$li_quisalvac,$li_quireivac,$ls_pagpersal,
$la_seguridad);
if($lb_valido)
{
uf_limpiarvariables();
$ls_existe="FALSE";
}
else
{
$io_fun_nomina->uf_seleccionarcombo("1-2",$ls_stavac,$la_stavac,2);
if($li_diapag==1)
{
$ls_diapag="checked";
}
else
{
$ls_diapag="";
}
if($li_pagcan==1)
{
$ls_pagcan="checked";
}
else
{
$ls_pagcan="";
}
}
}
else
{
uf_limpiarvariables();
}
break;
}
$io_vacacion->uf_destructor();
unset($io_vacacion);
?>
<table width="762" border="0" align="center" cellpadding="0" cellspacing="0" class="contorno">
<tr>
<td width="780" height="30" colspan="11" class="cd-logo"><img src="../shared/imagebank/header.jpg" width="778" height="40"></td>
</tr>
<tr>
<td width="432" height="20" colspan="11" bgcolor="#E7E7E7">
<table width="762" border="0" align="center" cellpadding="0" cellspacing="0">
<td width="432" height="20" bgcolor="#E7E7E7" class="descripcion_sistema"><?php print $ls_desnom;?></td>
<td width="346" bgcolor="#E7E7E7"><div align="right"><span class="letras-pequenas"><?php print $ls_desper;?></span></div></td>
<tr>
<td height="20" bgcolor="#E7E7E7" class="descripcion_sistema"> </td>
<td bgcolor="#E7E7E7" class="letras-pequenas"><div align="right"><b><?php print $_SESSION["la_nomusu"]." ".$_SESSION["la_apeusu"];?></b></div></td></tr>
</table>
</td>
</tr>
<tr>
<td height="20" colspan="11" bgcolor="#E7E7E7" class="cd-menu"><script type="text/javascript" language="JavaScript1.2" src="js/menu_nomina.js"></script></td>
</tr>
<tr>
<td width="780" height="13" colspan="11" class="toolbar"></td>
</tr>
<tr>
<td height="20" width="25" class="toolbar"><div align="center"><a href="javascript: ue_guardar();"><img src="../shared/imagebank/tools20/grabar.gif" title='Guardar 'alt="Grabar" width="20" height="20" border="0"></a></div></td>
<td class="toolbar" width="25"><div align="center"><a href="javascript: ue_buscar();"><img src="../shared/imagebank/tools20/buscar.gif" title='Buscar' alt="Buscar" width="20" height="20" border="0"></a></div></td>
<td class="toolbar" width="25"><div align="center"><a href="javascript: ue_cerrar();"><img src="../shared/imagebank/tools20/salir.gif" title='Salir' alt="Salir" width="20" height="20" border="0"></a></div></td>
<td class="toolbar" width="25"><div align="center"><img src="../shared/imagebank/tools20/ayuda.gif" title='Ayuda' alt="Ayuda" width="20" height="20"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="25"><div align="center"></div></td>
<td class="toolbar" width="530"> </td>
</tr>
</table>
<p> </p>
<form name="form1" method="post" action="">
<?php
/////////////////////////////////////////// SEGURIDAD /////////////////////////////////////////////
$io_fun_nomina->uf_print_permisos($ls_permisos,$la_permisos,$ls_logusr,"location.href='<API key>.php'");
unset($io_fun_nomina);
/////////////////////////////////////////// SEGURIDAD /////////////////////////////////////////////
?>
<table width="650" height="138" border="0" align="center" cellpadding="0" cellspacing="0" class="formato-blanco">
<tr>
<td>
<p> </p>
<table width="600" border="0" align="center" cellpadding="1" cellspacing="0" class="formato-blanco">
<tr class="titulo-ventana">
<td height="20" colspan="4" class="titulo-ventana">Programar Vacaciones </td>
</tr>
<tr>
<td height="22"> </td>
<td colspan="3"> </td>
</tr>
<tr>
<td width="145" height="22"><div align="right">Personal</div></td>
<td colspan="3"><div align="left">
<input name="txtcodper" type="text" id="txtcodper" value="<?php print $ls_codper;?>" size="13" maxlength="10" readonly>
<input name="txtnomper" type="text" class="sin-borde" id="txtnomper" value="<?php print $ls_nomper;?>" size="60" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Código</div></td>
<td width="148"><div align="left">
<input name="txtcodvac" type="text" id="txtcodvac" value="<?php print $li_codvac;?>" size="13" maxlength="10">
</div></td>
<td width="153"><div align="right">Vencimiento</div></td>
<td width="144"><div align="left">
<input name="txtfecvenvac" type="text" id="txtfecvenvac" value="<?php print $ld_fecvenvac;?>" size="15" maxlength="10" onKeyDown="javascript:ue_formato_fecha(this,'/',patron,true,event);" onBlur="javascript: <API key>(this);" datepicker="true" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Estado Actual </div></td>
<td colspan="3"><div align="left">
<select name="cmbstavac" id="cmbstavac">
<option value="" selected>--Seleccione Una--</option>
<option value="1" <?php print $la_stavac[0];?>>Vencidas</option>
<option value="2" <?php print $la_stavac[1];?>>Programadas</option>
</select>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Fecha Distrute </div></td>
<td>
<div align="left">
<input name="txtfecdisvac" type="text" id="txtfecdisvac" value="<?php print $ld_fecdisvac;?>" size="15" maxlength="10" datepicker="true" onKeyDown="javascript:ue_formato_fecha(this,'/',patron,true,event);" onBlur="javascript:<API key>(this); ue_reprogramar();">
</div></td>
<td><div align="right">Fecha Reingreso</div></td>
<td><div align="left">
<input name="txtfecreivac" type="text" id="txtfecreivac" value="<?php print $ld_fecreivac;?>" size="15" maxlength="10" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Perído de Salida </div></td>
<td><div align="left">
<input name="txtpersalvac" type="text" id="txtpersalvac" value="<?php print $ls_persalvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Perído de Reingreso </div></td>
<td><div align="left">
<input name="txtperingvac" type="text" id="txtperingvac" value="<?php print $ls_peringvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Quincena de Salida </div></td>
<td><div align="left">
<input name="txtquisalvac" type="text" id="txtquisalvac" value="<?php print $li_quisalvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Quincena de Reingreso</div></td>
<td><div align="left">
<input name="txtquireivac" type="text" id="txtquireivac" value="<?php print $li_quireivac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Nº Días </div></td>
<td>
<div align="left">
<input name="txtdiavac" type="text" id="txtdiavac" value="<?php print $li_diavac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Nº Días Adicionales </div></td>
<td><div align="left">
<input name="txtdiaadivac" type="text" id="txtdiaadivac" value="<?php print $li_diaadivac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Nº Días Bono </div></td>
<td>
<div align="left">
<input name="txtdiabonvac" type="text" id="txtdiabonvac" value="<?php print $li_diabonvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Nº Días Adicionales Bono </div></td>
<td><div align="left">
<input name="txtdiaadibon" type="text" id="txtdiaadibon" value="<?php print $li_diaadibon;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Nº Feriados</div></td>
<td>
<div align="left">
<input name="txtdiafer" type="text" id="txtdiafer" value="<?php print $li_diafer;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Nº Sábados y Domingos </div></td>
<td><div align="left">
<input name="txtsabdom" type="text" id="txtsabdom" value="<?php print $li_sabdom;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Nº Pendientes </div></td>
<td>
<div align="left">
<input name="txtdiapenvac" type="text" id="txtdiapenvac" value="<?php print $li_diapenvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
<td><div align="right">Nº Días de Permiso Descontables de Vacaciones </div></td>
<td><div align="left">
<input name="txtdiapervac" type="text" id="txtdiapervac" value="<?php print $li_diapervac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Total de Días de Vacaciones </div></td>
<td>
<div align="left">
<input name="txtdianorvac" type="text" id="txtdianorvac" value="<?php print $li_dianorvac;?>" size="6" maxlength="3" onKeyUp="javascript: ue_validarnumero(this);" readonly>
</div></td>
</tr>
<tr>
<td height="22"><div align="right"><?php if ($ls_sueint==""){print "Sueldo Integral Bono";}else{print $ls_sueint." Bono";}?> </div></td>
<td>
<div align="left">
<input name="txtsueintbonvac" type="text" id="txtsueintbonvac" value="<?php print $li_sueintbonvac;?>" size="23" maxlength="20" onKeyPress="return(ue_formatonumero(this,'.',',',event))" style="text-align:right" readonly>
</div></td>
<td><div align="right"><?php if ($ls_sueint==""){print "Sueldo Integral Vacaciones";}else{print $ls_sueint." Vacaciones";}?></div></td>
<td><div align="left">
<input name="txtsueintvac" type="text" id="txtsueintvac" value="<?php print $li_sueintvac;?>" size="23" maxlength="20" onKeyPress="return(ue_formatonumero(this,'.',',',event))" style="text-align:right" <?php if(intval($li_sueintvac)>0){ print "readonly";};?>>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Días Disfrutados </div></td>
<td><div align="left">
<input name="chkdiapag" type="checkbox" id="chkdiapag" value="1" <?php print $ls_diapag;?>>
</div></td>
<td><div align="right">Vacaciones Canceladas </div></td>
<td><div align="left">
<input name="chkpagcan" type="checkbox" id="chkpagcan" value="1" <?php print $ls_pagcan;?>>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Pagar Vacaciones en el Periodo de Salida</div></td>
<td><div align="left">
<input name="chkpagpersal" type="checkbox" id="chkpagpersal" value="1" <?php print $ls_pagpersal;?>>
</div></td>
</tr>
<tr>
<td height="22"><div align="right">Observación</div></td>
<td colspan="3"><div align="left">
<textarea name="txtobsvac" cols="80" rows="3" id="txtobsvac" onKeyPress="javascript: ue_validarcomillas(this);" value="<?php print $ls_obsvac;?>"></textarea>
</div></td>
</tr>
<tr>
<td height="22"> </td>
<td colspan="3"><input name="operacion" type="hidden" id="operacion">
<input name="txtsalvacper" type="hidden" id="txtsalvacper" value="<?php print $li_salvacper;?>">
<input name="existe" type="hidden" id="existe" value="<?php print $ls_existe;?>">
<input name="fecfinper" type="hidden" id="fecfinper" value="<?php print $ld_fechasper;?>"></td>
</tr>
</table>
<p> </p></td>
</tr>
</table>
</form>
<p> </p>
</body>
<script language="javascript">
function ue_reprogramar()
{
f=document.form1;
f.operacion.value="REPROGRAMAR";
f.action="<API key>.php";
f.submit();
}
function ue_guardar()
{
f=document.form1;
li_incluir=f.incluir.value;
li_cambiar=f.cambiar.value;
lb_existe=f.existe.value;
li_salvacper=f.txtsalvacper.value;
if(((lb_existe=="TRUE")&&(li_cambiar==1))||(lb_existe=="FALSE")&&(li_incluir==1))
{
valido=true;
codper=ue_validarvacio(f.txtcodper.value);
codvac=ue_validarvacio(f.txtcodvac.value);
stavac=ue_validarvacio(f.cmbstavac.value);
fecvenvac=ue_validarvacio(f.txtfecvenvac.value);
fecdisvac=ue_validarvacio(f.txtfecdisvac.value);
fecreivac=ue_validarvacio(f.txtfecreivac.value);
persalvac=ue_validarvacio(f.txtpersalvac.value);
peringvac=ue_validarvacio(f.txtperingvac.value);
messal=fecdisvac.substring(3,5);
mesvac=fecvenvac.substring(3,5);
anosal=fecdisvac.substring(6,10);
anovac=fecvenvac.substring(6,10);
if ((li_salvacper=='1')&&((messal<mesvac)&&(anosal==anovac)))
{
if ((parseInt(messal)+1)!=parseInt(mesvac))
{
alert("Las vacaciones solamente pueden ser programadas desde el mes anterior de la Fecha de Vencimiento.");
valido=false
}
}
else
{
if((!ue_comparar_fechas(fecvenvac,fecdisvac))&&(li_salvacper=='0'))
{
alert("La fecha de Disfrute es menor que la de Vencimiento.");
valido=false
}
else if((!ue_comparar_fechas(fecvenvac,fecdisvac))&&(li_salvacper=='1')&&(anosal!=anovac))
{
alert("La fecha de Disfrute es menor que la de Vencimiento.");
valido=false
}
if((!ue_comparar_fechas(fecdisvac,fecreivac))&&(li_salvacper=='0')&&(valido))
{
alert("La fecha de Reingreso es menor que la de Disfrute.");
valido=false
}
}
if(valido)
{
if ((codper!="")&&(codvac!="")&&(stavac!=""))
{
f.operacion.value="GUARDAR";
f.action="<API key>.php";
f.submit();
}
else
{
alert("Debe llenar todos los datos.");
}
}
}
else
{
alert("No tiene permiso para realizar esta operacion");
}
}
function ue_cerrar()
{
location.href = "<API key>.php";
}
function ue_buscar()
{
f=document.form1;
li_leer=f.leer.value;
if (li_leer==1)
{
window.open("<API key>.php","catalogo","menubar=no,toolbar=no,scrollbars=yes,width=530,height=400,left=50,top=50,location=no,resizable=no");
}
else
{
alert("No tiene permiso para realizar esta operacion");
}
}
var patron = new Array(2,2,4);
var patron2 = new Array(1,3,3,3,3);
</script>
</html>
|
// modification, are permitted provided that the following conditions are met:
// and/or other materials provided with the distribution.
// * Neither the name of ARM Limited nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This file is auto generated using tools/<API key>.py.
// PLEASE DO NOT EDIT.
#ifndef <API key>
#define <API key>
const uint64_t kExpected_fmul_d[] = {
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x7ff8000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff8000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0008000000000000,
0x0008000000000000,
0x0008000000000000,
0x0010000000000000,
0x0010000000000000,
0x0010000000000001,
0x0018000000000000,
0x0044000000000000,
0x400fffffffffffff,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8008000000000000,
0x8008000000000000,
0x8008000000000000,
0x8010000000000000,
0x8010000000000000,
0x8010000000000001,
0x8018000000000000,
0x8044000000000000,
0xc00fffffffffffff,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0008000000000000,
0x3fcffffffffffffe,
0x3fcfffffffffffff,
0x3fd0000000000000,
0x3fdffffffffffffe,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe7ffffffffffff,
0x4013ffffffffffff,
0x7fdffffffffffffe,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e6,
0x0007ffffffffffff,
0x0000000000000000,
0x8000000000000000,
0x8008000000000000,
0xbfcffffffffffffe,
0xbfcfffffffffffff,
0xbfd0000000000000,
0xbfdffffffffffffe,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe7ffffffffffff,
0xc013ffffffffffff,
0xffdffffffffffffe,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e6,
0x8007ffffffffffff,
0x8000000000000000,
0x0000000000000000,
0x0008000000000000,
0x3fcfffffffffffff,
0x3fd0000000000000,
0x3fd0000000000001,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe8000000000000,
0x4014000000000000,
0x7fdfffffffffffff,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e6,
0x0008000000000000,
0x0000000000000000,
0x8000000000000000,
0x8008000000000000,
0xbfcfffffffffffff,
0xbfd0000000000000,
0xbfd0000000000001,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe8000000000000,
0xc014000000000000,
0xffdfffffffffffff,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e6,
0x8008000000000000,
0x8000000000000000,
0x0000000000000000,
0x0008000000000000,
0x3fd0000000000000,
0x3fd0000000000001,
0x3fd0000000000002,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe0000000000002,
0x3fe8000000000002,
0x4014000000000001,
0x7fe0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e7,
0x0008000000000000,
0x0000000000000001,
0x8000000000000000,
0x8008000000000000,
0xbfd0000000000000,
0xbfd0000000000001,
0xbfd0000000000002,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe0000000000002,
0xbfe8000000000002,
0xc014000000000001,
0xffe0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e7,
0x8008000000000000,
0x8000000000000001,
0x0000000000000000,
0x0010000000000000,
0x3fdffffffffffffe,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3feffffffffffffe,
0x3fefffffffffffff,
0x3ff0000000000000,
0x3ff7ffffffffffff,
0x4023ffffffffffff,
0x7feffffffffffffe,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x000fffffffffffff,
0x0000000000000001,
0x8000000000000000,
0x8010000000000000,
0xbfdffffffffffffe,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfeffffffffffffe,
0xbfefffffffffffff,
0xbff0000000000000,
0xbff7ffffffffffff,
0xc023ffffffffffff,
0xffeffffffffffffe,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x800fffffffffffff,
0x8000000000000001,
0x0000000000000000,
0x0010000000000000,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fefffffffffffff,
0x3ff0000000000000,
0x3ff0000000000001,
0x3ff8000000000000,
0x4024000000000000,
0x7fefffffffffffff,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x000fffffffffffff,
0x0000000000000001,
0x8000000000000000,
0x8010000000000000,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfefffffffffffff,
0xbff0000000000000,
0xbff0000000000001,
0xbff8000000000000,
0xc024000000000000,
0xffefffffffffffff,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x800fffffffffffff,
0x8000000000000001,
0x0000000000000000,
0x0010000000000001,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe0000000000002,
0x3ff0000000000000,
0x3ff0000000000001,
0x3ff0000000000002,
0x3ff8000000000002,
0x4024000000000001,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x0010000000000000,
0x0000000000000001,
0x8000000000000000,
0x8010000000000001,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe0000000000002,
0xbff0000000000000,
0xbff0000000000001,
0xbff0000000000002,
0xbff8000000000002,
0xc024000000000001,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x8010000000000000,
0x8000000000000001,
0x0000000000000000,
0x0018000000000000,
0x3fe7ffffffffffff,
0x3fe8000000000000,
0x3fe8000000000002,
0x3ff7ffffffffffff,
0x3ff8000000000000,
0x3ff8000000000002,
0x4002000000000000,
0x402e000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x0001b4e81b4e81b4,
0x0017fffffffffffe,
0x0000000000000002,
0x8000000000000000,
0x8018000000000000,
0xbfe7ffffffffffff,
0xbfe8000000000000,
0xbfe8000000000002,
0xbff7ffffffffffff,
0xbff8000000000000,
0xbff8000000000002,
0xc002000000000000,
0xc02e000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x8001b4e81b4e81b4,
0x8017fffffffffffe,
0x8000000000000002,
0x0000000000000000,
0x0044000000000000,
0x4013ffffffffffff,
0x4014000000000000,
0x4014000000000001,
0x4023ffffffffffff,
0x4024000000000000,
0x4024000000000001,
0x402e000000000000,
0x4059000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x000b60b60b60b602,
0x0043ffffffffffff,
0x000000000000000a,
0x8000000000000000,
0x8044000000000000,
0xc013ffffffffffff,
0xc014000000000000,
0xc014000000000001,
0xc023ffffffffffff,
0xc024000000000000,
0xc024000000000001,
0xc02e000000000000,
0xc059000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x800b60b60b60b602,
0x8043ffffffffffff,
0x800000000000000a,
0x0000000000000000,
0x400fffffffffffff,
0x7fdffffffffffffe,
0x7fdfffffffffffff,
0x7fe0000000000000,
0x7feffffffffffffe,
0x7fefffffffffffff,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x3fd23456789abccf,
0x400ffffffffffffd,
0x3ccfffffffffffff,
0x8000000000000000,
0xc00fffffffffffff,
0xffdffffffffffffe,
0xffdfffffffffffff,
0xffe0000000000000,
0xffeffffffffffffe,
0xffefffffffffffff,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0xbfd23456789abccf,
0xc00ffffffffffffd,
0xbccfffffffffffff,
0x7ff8000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff8000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0xfff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0xfff923456789abcd,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff8000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x000091a2b3c4d5e6,
0x000091a2b3c4d5e6,
0x000091a2b3c4d5e7,
0x000123456789abcd,
0x000123456789abcd,
0x000123456789abcd,
0x0001b4e81b4e81b4,
0x000b60b60b60b602,
0x3fd23456789abccf,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x800091a2b3c4d5e6,
0x800091a2b3c4d5e6,
0x800091a2b3c4d5e7,
0x800123456789abcd,
0x800123456789abcd,
0x800123456789abcd,
0x8001b4e81b4e81b4,
0x800b60b60b60b602,
0xbfd23456789abccf,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0007ffffffffffff,
0x0008000000000000,
0x0008000000000000,
0x000fffffffffffff,
0x000fffffffffffff,
0x0010000000000000,
0x0017fffffffffffe,
0x0043ffffffffffff,
0x400ffffffffffffd,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8007ffffffffffff,
0x8008000000000000,
0x8008000000000000,
0x800fffffffffffff,
0x800fffffffffffff,
0x8010000000000000,
0x8017fffffffffffe,
0x8043ffffffffffff,
0xc00ffffffffffffd,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000001,
0x0000000000000001,
0x0000000000000001,
0x0000000000000001,
0x0000000000000002,
0x000000000000000a,
0x3ccfffffffffffff,
0x7ff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000001,
0x8000000000000001,
0x8000000000000001,
0x8000000000000001,
0x8000000000000002,
0x800000000000000a,
0xbccfffffffffffff,
0xfff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x7ff8000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff8000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8008000000000000,
0x8008000000000000,
0x8008000000000000,
0x8010000000000000,
0x8010000000000000,
0x8010000000000001,
0x8018000000000000,
0x8044000000000000,
0xc00fffffffffffff,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0008000000000000,
0x0008000000000000,
0x0008000000000000,
0x0010000000000000,
0x0010000000000000,
0x0010000000000001,
0x0018000000000000,
0x0044000000000000,
0x400fffffffffffff,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8008000000000000,
0xbfcffffffffffffe,
0xbfcfffffffffffff,
0xbfd0000000000000,
0xbfdffffffffffffe,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe7ffffffffffff,
0xc013ffffffffffff,
0xffdffffffffffffe,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e6,
0x8007ffffffffffff,
0x8000000000000000,
0x0000000000000000,
0x0008000000000000,
0x3fcffffffffffffe,
0x3fcfffffffffffff,
0x3fd0000000000000,
0x3fdffffffffffffe,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe7ffffffffffff,
0x4013ffffffffffff,
0x7fdffffffffffffe,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e6,
0x0007ffffffffffff,
0x0000000000000000,
0x8000000000000000,
0x8008000000000000,
0xbfcfffffffffffff,
0xbfd0000000000000,
0xbfd0000000000001,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe8000000000000,
0xc014000000000000,
0xffdfffffffffffff,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e6,
0x8008000000000000,
0x8000000000000000,
0x0000000000000000,
0x0008000000000000,
0x3fcfffffffffffff,
0x3fd0000000000000,
0x3fd0000000000001,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe8000000000000,
0x4014000000000000,
0x7fdfffffffffffff,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e6,
0x0008000000000000,
0x0000000000000000,
0x8000000000000000,
0x8008000000000000,
0xbfd0000000000000,
0xbfd0000000000001,
0xbfd0000000000002,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe0000000000002,
0xbfe8000000000002,
0xc014000000000001,
0xffe0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800091a2b3c4d5e7,
0x8008000000000000,
0x8000000000000001,
0x0000000000000000,
0x0008000000000000,
0x3fd0000000000000,
0x3fd0000000000001,
0x3fd0000000000002,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe0000000000002,
0x3fe8000000000002,
0x4014000000000001,
0x7fe0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000091a2b3c4d5e7,
0x0008000000000000,
0x0000000000000001,
0x8000000000000000,
0x8010000000000000,
0xbfdffffffffffffe,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfeffffffffffffe,
0xbfefffffffffffff,
0xbff0000000000000,
0xbff7ffffffffffff,
0xc023ffffffffffff,
0xffeffffffffffffe,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x800fffffffffffff,
0x8000000000000001,
0x0000000000000000,
0x0010000000000000,
0x3fdffffffffffffe,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3feffffffffffffe,
0x3fefffffffffffff,
0x3ff0000000000000,
0x3ff7ffffffffffff,
0x4023ffffffffffff,
0x7feffffffffffffe,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x000fffffffffffff,
0x0000000000000001,
0x8000000000000000,
0x8010000000000000,
0xbfdfffffffffffff,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfefffffffffffff,
0xbff0000000000000,
0xbff0000000000001,
0xbff8000000000000,
0xc024000000000000,
0xffefffffffffffff,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x800fffffffffffff,
0x8000000000000001,
0x0000000000000000,
0x0010000000000000,
0x3fdfffffffffffff,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fefffffffffffff,
0x3ff0000000000000,
0x3ff0000000000001,
0x3ff8000000000000,
0x4024000000000000,
0x7fefffffffffffff,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x000fffffffffffff,
0x0000000000000001,
0x8000000000000000,
0x8010000000000001,
0xbfe0000000000000,
0xbfe0000000000001,
0xbfe0000000000002,
0xbff0000000000000,
0xbff0000000000001,
0xbff0000000000002,
0xbff8000000000002,
0xc024000000000001,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800123456789abcd,
0x8010000000000000,
0x8000000000000001,
0x0000000000000000,
0x0010000000000001,
0x3fe0000000000000,
0x3fe0000000000001,
0x3fe0000000000002,
0x3ff0000000000000,
0x3ff0000000000001,
0x3ff0000000000002,
0x3ff8000000000002,
0x4024000000000001,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000123456789abcd,
0x0010000000000000,
0x0000000000000001,
0x8000000000000000,
0x8018000000000000,
0xbfe7ffffffffffff,
0xbfe8000000000000,
0xbfe8000000000002,
0xbff7ffffffffffff,
0xbff8000000000000,
0xbff8000000000002,
0xc002000000000000,
0xc02e000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x8001b4e81b4e81b4,
0x8017fffffffffffe,
0x8000000000000002,
0x0000000000000000,
0x0018000000000000,
0x3fe7ffffffffffff,
0x3fe8000000000000,
0x3fe8000000000002,
0x3ff7ffffffffffff,
0x3ff8000000000000,
0x3ff8000000000002,
0x4002000000000000,
0x402e000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x0001b4e81b4e81b4,
0x0017fffffffffffe,
0x0000000000000002,
0x8000000000000000,
0x8044000000000000,
0xc013ffffffffffff,
0xc014000000000000,
0xc014000000000001,
0xc023ffffffffffff,
0xc024000000000000,
0xc024000000000001,
0xc02e000000000000,
0xc059000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x800b60b60b60b602,
0x8043ffffffffffff,
0x800000000000000a,
0x0000000000000000,
0x0044000000000000,
0x4013ffffffffffff,
0x4014000000000000,
0x4014000000000001,
0x4023ffffffffffff,
0x4024000000000000,
0x4024000000000001,
0x402e000000000000,
0x4059000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x000b60b60b60b602,
0x0043ffffffffffff,
0x000000000000000a,
0x8000000000000000,
0xc00fffffffffffff,
0xffdffffffffffffe,
0xffdfffffffffffff,
0xffe0000000000000,
0xffeffffffffffffe,
0xffefffffffffffff,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0xbfd23456789abccf,
0xc00ffffffffffffd,
0xbccfffffffffffff,
0x0000000000000000,
0x400fffffffffffff,
0x7fdffffffffffffe,
0x7fdfffffffffffff,
0x7fe0000000000000,
0x7feffffffffffffe,
0x7fefffffffffffff,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x3fd23456789abccf,
0x400ffffffffffffd,
0x3ccfffffffffffff,
0x7ff8000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff8000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0x7ff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0x7ff923456789abcd,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff8000000000000,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0xfff923456789abcd,
0x7ff8000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0xfff0000000000000,
0x7ff8000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x7ff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x800091a2b3c4d5e6,
0x800091a2b3c4d5e6,
0x800091a2b3c4d5e7,
0x800123456789abcd,
0x800123456789abcd,
0x800123456789abcd,
0x8001b4e81b4e81b4,
0x800b60b60b60b602,
0xbfd23456789abccf,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x000091a2b3c4d5e6,
0x000091a2b3c4d5e6,
0x000091a2b3c4d5e7,
0x000123456789abcd,
0x000123456789abcd,
0x000123456789abcd,
0x0001b4e81b4e81b4,
0x000b60b60b60b602,
0x3fd23456789abccf,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8007ffffffffffff,
0x8008000000000000,
0x8008000000000000,
0x800fffffffffffff,
0x800fffffffffffff,
0x8010000000000000,
0x8017fffffffffffe,
0x8043ffffffffffff,
0xc00ffffffffffffd,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0007ffffffffffff,
0x0008000000000000,
0x0008000000000000,
0x000fffffffffffff,
0x000fffffffffffff,
0x0010000000000000,
0x0017fffffffffffe,
0x0043ffffffffffff,
0x400ffffffffffffd,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000001,
0x8000000000000001,
0x8000000000000001,
0x8000000000000001,
0x8000000000000002,
0x800000000000000a,
0xbccfffffffffffff,
0xfff0000000000000,
0x7ff923456789abcd,
0x7ff8000000000000,
0x7ff923456789abcd,
0xfff0000000000000,
0x8000000000000000,
0x8000000000000000,
0x8000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000001,
0x0000000000000001,
0x0000000000000001,
0x0000000000000001,
0x0000000000000002,
0x000000000000000a,
0x3ccfffffffffffff,
0x7ff0000000000000,
0xfff923456789abcd,
0xfff8000000000000,
0xfff923456789abcd,
0x7ff0000000000000,
0x0000000000000000,
0x0000000000000000,
0x0000000000000000,
};
const unsigned <API key> = 1444;
#endif // <API key>
|
#ifndef H2C_PATTERN_LIST_H
#define H2C_PATTERN_LIST_H
#include <vector>
#include <hydrogen/object.h>
namespace H2Core
{
class Pattern;
/**
* PatternList is a collection of patterns
*/
class PatternList : public H2Core::Object
{
H2_OBJECT
public:
/** constructor */
PatternList();
/** destructor */
~PatternList();
/**
* copy constructor
* \param other
*/
PatternList( PatternList* other );
/** returns the numbers of patterns */
int size() const;
/**
* add a pattern to the list
* \param pattern a pointer to the pattern to add
*/
void operator<<( Pattern* new_pattern );
/**
* get a pattern from the list
* \param idx the index to get the pattern from
*/
Pattern* operator[]( int idx );
/**
* add a pattern to the list
* \param pattern a pointer to the pattern to add
*/
void add( Pattern* pattern );
/**
* insert a pattern into the list
* \param idx the index to insert the pattern at
* \param pattern a pointer to the pattern to add
*/
void insert( int idx, Pattern* pattern );
/**
* get a pattern from the list
* \param idx the index to get the pattern from
*/
Pattern* get( int idx );
/**
* remove the pattern at a given index, does not delete it
* \param idx the index
* \return a pointer to the removed pattern
*/
Pattern* del( int idx );
/**
* remove a pattern from the list, does not delete it
* \param pattern the pattern to be removed
* \return a pointer to the removed pattern, 0 if not found
*/
Pattern* del( Pattern* pattern );
/**
* get the index of the pattern within the patterns
* \param pattern a pointer to the pattern to find
* \return -1 if not found
*/
int index( Pattern* pattern );
/**
* replace the pattern at a given index with a new one
* \param idx the index
* \param pattern the new pattern to insert
* \return a pointer to the removed pattern, 0 if index out of bounds
*/
Pattern* replace( int idx, Pattern* pattern );
/**
* empty the pattern list
*/
void clear();
/**
* mark all patterns as old
*/
void set_to_old();
/**
* find a pattern within the patterns
* \param name the name of the pattern to find
* \return 0 if not found
*/
Pattern* find( const QString& name );
/**
* swap the patterns of two different indexes
* \param idx_a the first index
* \param idx_b the second index
*/
void swap( int idx_a, int idx_b );
/**
* move a pattern from a position to another
* \param idx_a the start index
* \param idx_b the finish index
*/
void move( int idx_a, int idx_b );
/**
* call <API key> on each pattern
*/
void <API key>();
/**
* call del_virtual_pattern on each pattern
* \param pattern the pattern to remove where it's found
*/
void virtual_pattern_del( Pattern* pattern );
private:
std::vector<Pattern*> __patterns; ///< the list of patterns
};
// DEFINITIONS
inline int PatternList::size() const
{
return __patterns.size();
}
inline void PatternList::clear()
{
__patterns.clear();
}
};
#endif // H2C_PATTERN_LIST_H
/* vim: set softtabstop=4 expandtab: */
|
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <linux/irq.h>
#include <linux/i2c.h>
#include <linux/i2c/sx150x.h>
#include <linux/i2c/isl9519.h>
#include <linux/gpio.h>
#include <linux/msm_ssbi.h>
#include <linux/regulator/msm-gpio-regulator.h>
#include <linux/mfd/pm8xxx/pm8921.h>
#include <linux/mfd/pm8xxx/pm8xxx-adc.h>
#include <linux/regulator/consumer.h>
#include <linux/spi/spi.h>
#include <linux/slimbus/slimbus.h>
#include <linux/bootmem.h>
#ifdef CONFIG_ANDROID_PMEM
#include <linux/android_pmem.h>
#endif
#include <linux/cyttsp-qc.h>
#include <linux/dma-mapping.h>
#include <linux/platform_data/qcom_crypto_device.h>
#include <linux/platform_data/qcom_wcnss_device.h>
#include <linux/leds.h>
#include <linux/leds-pm8xxx.h>
#include <linux/i2c/atmel_mxt_ts.h>
#include <linux/msm_tsens.h>
#include <linux/ks8851.h>
#include <linux/i2c/isa1200.h>
#include <linux/memory.h>
#include <linux/memblock.h>
#include <linux/msm_thermal.h>
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/setup.h>
#include <asm/hardware/gic.h>
#include <asm/mach/mmc.h>
#include <mach/board.h>
#include <mach/msm_tspp.h>
#include <mach/msm_iomap.h>
#include <mach/msm_spi.h>
#include <mach/msm_serial_hs.h>
#ifdef <API key>
#include <mach/msm_hsusb.h>
#else
#include <linux/usb/msm_hsusb.h>
#endif
#include <linux/usb/android.h>
#include <mach/usbdiag.h>
#include <mach/socinfo.h>
#include <mach/rpm.h>
#include <mach/gpiomux.h>
#include <mach/msm_bus_board.h>
#include <mach/msm_memtypes.h>
#include <mach/dma.h>
#include <mach/msm_dsps.h>
#include <mach/msm_xo.h>
#include <mach/restart.h>
#ifdef <API key>
#include <linux/mfd/wcd9xxx/core.h>
#include <linux/mfd/wcd9xxx/pdata.h>
#endif
#include <linux/smsc3503.h>
#include <linux/msm_ion.h>
#include <mach/ion.h>
#include <mach/mdm2.h>
#include <mach/mdm-peripheral.h>
#include <mach/msm_rtb.h>
#include <mach/msm_cache_dump.h>
#include <mach/scm.h>
#include <mach/iommu_domains.h>
#include <mach/kgsl.h>
#include <linux/fmem.h>
#include "timer.h"
#include "devices.h"
#include "devices-msm8x60.h"
#include "spm.h"
#include "board-8960.h"
#include "pm.h"
#include <mach/cpuidle.h>
#include "rpm_resources.h"
#include <mach/mpm.h>
#include "smd_private.h"
#include "pm-boot.h"
#include "msm_watchdog.h"
#if defined(CONFIG_BT) && defined(<API key>)
#include <linux/wlan_plat.h>
#include <linux/mutex.h>
#endif
static struct platform_device <API key> = {
.name = "iris_fm",
.id = -1,
};
#define KS8851_RST_GPIO 89
#define KS8851_IRQ_GPIO 90
#define MHL_GPIO_INT 4
#define MHL_GPIO_RESET 15
#if defined(CONFIG_GPIO_SX150X) || defined(<API key>)
struct <API key> msm8960_sx150x_data[] = {
[SX150X_CAM] = {
.gpio_base = <API key>,
.oscio_is_gpo = false,
.io_pullup_ena = 0x0,
.io_pulldn_ena = 0xc0,
.io_open_drain_ena = 0x0,
.irq_summary = -1,
},
[SX150X_LIQUID] = {
.gpio_base = <API key>,
.oscio_is_gpo = false,
.io_pullup_ena = 0x0c08,
.io_pulldn_ena = 0x4060,
.io_open_drain_ena = 0x000c,
.io_polarity = 0,
.irq_summary = -1,
},
};
#endif
#define MSM_PMEM_ADSP_SIZE 0x7800000
#define MSM_PMEM_AUDIO_SIZE 0x4CF000
#define MSM_PMEM_SIZE 0x2800000 /* 40 Mbytes */
#define <API key> 0x4000000 /* 64 Mbytes */
#define <API key> 0x4000000 /* 64 Mbytes */
#ifdef <API key>
#define HOLE_SIZE 0x20000
#define MSM_CONTIG_MEM_SIZE 0x65000
#ifdef CONFIG_MSM_IOMMU
#define MSM_ION_MM_SIZE 0x3800000 /* Need to be multiple of 64K */
#define MSM_ION_SF_SIZE 0x0
#define MSM_ION_QSECOM_SIZE 0x780000 /* (7.5MB) */
#define MSM_ION_HEAP_NUM 7
#else
#define MSM_ION_MM_SIZE MSM_PMEM_ADSP_SIZE
#define MSM_ION_SF_SIZE MSM_PMEM_SIZE
#define MSM_ION_QSECOM_SIZE 0x600000 /* (6MB) */
#define MSM_ION_HEAP_NUM 8
#endif
#define MSM_ION_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 128kb */
#define MSM_ION_MFC_SIZE SZ_8K
#define MSM_ION_AUDIO_SIZE MSM_PMEM_AUDIO_SIZE
#define <API key> (MSM_ION_MM_SIZE + 0x600000)
#define <API key> <API key>
#define <API key> <API key>
#define MSM_MM_FW_SIZE (0x200000 - HOLE_SIZE) /* 2mb -128kb*/
#define <API key> (0xa0000000 - (MSM_ION_MM_FW_SIZE + \
HOLE_SIZE))
#define MAX_FIXED_AREA_SIZE 0x10000000
#define MSM8960_FW_START <API key>
static unsigned msm_ion_sf_size = MSM_ION_SF_SIZE;
#else
#define MSM_CONTIG_MEM_SIZE 0x110C000
#define MSM_ION_HEAP_NUM 1
#endif
#ifdef <API key>
static unsigned msm_contig_mem_size = MSM_CONTIG_MEM_SIZE;
static int __init <API key>(char *p)
{
msm_contig_mem_size = memparse(p, NULL);
return 0;
}
early_param("msm_contig_mem_size", <API key>);
#endif
#ifdef CONFIG_ANDROID_PMEM
static unsigned pmem_size = MSM_PMEM_SIZE;
static unsigned pmem_param_set;
static int __init pmem_size_setup(char *p)
{
pmem_size = memparse(p, NULL);
pmem_param_set = 1;
return 0;
}
early_param("pmem_size", pmem_size_setup);
static unsigned pmem_adsp_size = MSM_PMEM_ADSP_SIZE;
static int __init <API key>(char *p)
{
pmem_adsp_size = memparse(p, NULL);
return 0;
}
early_param("pmem_adsp_size", <API key>);
static unsigned pmem_audio_size = MSM_PMEM_AUDIO_SIZE;
static int __init <API key>(char *p)
{
pmem_audio_size = memparse(p, NULL);
return 0;
}
early_param("pmem_audio_size", <API key>);
#endif
#ifdef CONFIG_ANDROID_PMEM
#ifndef <API key>
static struct <API key> android_pmem_pdata = {
.name = "pmem",
.allocator_type = <API key>,
.cached = 1,
.memory_type = MEMTYPE_EBI1,
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 0,
.dev = {.platform_data = &android_pmem_pdata},
};
static struct <API key> <API key> = {
.name = "pmem_adsp",
.allocator_type = <API key>,
.cached = 0,
.memory_type = MEMTYPE_EBI1,
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 2,
.dev = { .platform_data = &<API key> },
};
static struct <API key> <API key> = {
.name = "pmem_audio",
.allocator_type = <API key>,
.cached = 0,
.memory_type = MEMTYPE_EBI1,
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 4,
.dev = { .platform_data = &<API key> },
};
#endif /*<API key>*/
#endif /*CONFIG_ANDROID_PMEM*/
struct fmem_platform_data msm8960_fmem_pdata = {
};
#define DSP_RAM_BASE_8960 0x8da00000
#define DSP_RAM_SIZE_8960 0x1800000
static int <API key> = 0xDEADDEAD;
static struct resource <API key>[] = {
{
.name = "msm_dspcrashd",
.start = DSP_RAM_BASE_8960,
.end = DSP_RAM_BASE_8960 + DSP_RAM_SIZE_8960,
.flags = IORESOURCE_DMA,
},
};
static struct platform_device <API key> = {
.name = "msm_dspcrashd",
.num_resources = ARRAY_SIZE(<API key>),
.resource = <API key>,
.dev = { .platform_data = &<API key> },
};
static struct memtype_reserve <API key>[] __initdata = {
[MEMTYPE_SMI] = {
},
[MEMTYPE_EBI0] = {
.flags = <API key>,
},
[MEMTYPE_EBI1] = {
.flags = <API key>,
},
};
static void __init reserve_rtb_memory(void)
{
#if defined(CONFIG_MSM_RTB)
<API key>[MEMTYPE_EBI1].size += msm8960_rtb_pdata.size;
#endif
}
static void __init size_pmem_devices(void)
{
#ifdef CONFIG_ANDROID_PMEM
#ifndef <API key>
<API key>.size = pmem_adsp_size;
if (!pmem_param_set) {
if (<API key>())
pmem_size = <API key>;
if (<API key>())
pmem_size = <API key>;
}
android_pmem_pdata.size = pmem_size;
<API key>.size = MSM_PMEM_AUDIO_SIZE;
#endif /*<API key>*/
#endif /*CONFIG_ANDROID_PMEM*/
}
#ifdef CONFIG_ANDROID_PMEM
#ifndef <API key>
static void __init reserve_memory_for(struct <API key> *p)
{
<API key>[p->memory_type].size += p->size;
}
#endif /*<API key>*/
#endif /*CONFIG_ANDROID_PMEM*/
static void __init reserve_pmem_memory(void)
{
#ifdef CONFIG_ANDROID_PMEM
#ifndef <API key>
reserve_memory_for(&<API key>);
reserve_memory_for(&android_pmem_pdata);
reserve_memory_for(&<API key>);
#endif
<API key>[MEMTYPE_EBI1].size += msm_contig_mem_size;
#endif
}
static int <API key>(unsigned int paddr)
{
return MEMTYPE_EBI1;
}
#define FMEM_ENABLED 0
#ifdef CONFIG_ION_MSM
#ifdef <API key>
static struct ion_cp_heap_pdata <API key> = {
.permission_type = <API key>,
.align = SZ_64K,
.reusable = FMEM_ENABLED,
.mem_is_fmem = FMEM_ENABLED,
.fixed_position = FIXED_MIDDLE,
.iommu_map_all = 1,
.iommu_2x_map_domain = VIDEO_DOMAIN,
};
static struct ion_cp_heap_pdata <API key> = {
.permission_type = <API key>,
.align = PAGE_SIZE,
.reusable = 0,
.mem_is_fmem = FMEM_ENABLED,
.fixed_position = FIXED_HIGH,
};
static struct ion_co_heap_pdata <API key> = {
.adjacent_mem_id = INVALID_HEAP_ID,
.align = PAGE_SIZE,
.mem_is_fmem = 0,
};
static struct ion_co_heap_pdata <API key> = {
.adjacent_mem_id = ION_CP_MM_HEAP_ID,
.align = SZ_128K,
.mem_is_fmem = FMEM_ENABLED,
.fixed_position = FIXED_LOW,
};
#endif
/**
* These heaps are listed in the order they will be allocated. Due to
* video hardware restrictions and content protection the FW heap has to
* be allocated adjacent (below) the MM heap and the MFC heap has to be
* allocated after the MM heap to ensure MFC heap is not more than 256MB
* away from the base address of the FW heap.
* However, the order of FW heap and MM heap doesn't matter since these
* two heaps are taken care of by separate code to ensure they are adjacent
* to each other.
* Don't swap the order unless you know what you are doing!
*/
static struct ion_platform_data msm8960_ion_pdata = {
.nr = MSM_ION_HEAP_NUM,
.heaps = {
{
.id = ION_SYSTEM_HEAP_ID,
.type = <API key>,
.name = <API key>,
},
#ifdef <API key>
{
.id = ION_CP_MM_HEAP_ID,
.type = ION_HEAP_TYPE_CP,
.name = ION_MM_HEAP_NAME,
.size = MSM_ION_MM_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
{
.id = <API key>,
.type = <API key>,
.name = <API key>,
.size = MSM_ION_MM_FW_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
{
.id = ION_CP_MFC_HEAP_ID,
.type = ION_HEAP_TYPE_CP,
.name = ION_MFC_HEAP_NAME,
.size = MSM_ION_MFC_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
#ifndef CONFIG_MSM_IOMMU
{
.id = ION_SF_HEAP_ID,
.type = <API key>,
.name = ION_SF_HEAP_NAME,
.size = MSM_ION_SF_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
#endif
{
.id = ION_IOMMU_HEAP_ID,
.type = ION_HEAP_TYPE_IOMMU,
.name = ION_IOMMU_HEAP_NAME,
},
{
.id = ION_QSECOM_HEAP_ID,
.type = <API key>,
.name = <API key>,
.size = MSM_ION_QSECOM_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
{
.id = ION_AUDIO_HEAP_ID,
.type = <API key>,
.name = ION_AUDIO_HEAP_NAME,
.size = MSM_ION_AUDIO_SIZE,
.memory_type = ION_EBI_TYPE,
.extra_data = (void *) &<API key>,
},
#endif
}
};
static struct platform_device msm8960_ion_dev = {
.name = "ion-msm",
.id = 1,
.dev = { .platform_data = &msm8960_ion_pdata },
};
#endif
struct platform_device msm8960_fmem_device = {
.name = "fmem",
.id = 1,
.dev = { .platform_data = &msm8960_fmem_pdata },
};
static void __init <API key>(void)
{
unsigned int i;
if (!pmem_param_set) {
if (<API key>())
msm_ion_sf_size = <API key>;
if (<API key>())
msm_ion_sf_size = <API key>;
if (<API key>() ||
<API key>()) {
for (i = 0; i < msm8960_ion_pdata.nr; i++) {
if (msm8960_ion_pdata.heaps[i].id ==
ION_SF_HEAP_ID) {
msm8960_ion_pdata.heaps[i].size =
msm_ion_sf_size;
pr_debug("msm_ion_sf_size 0x%x\n",
msm_ion_sf_size);
break;
}
}
}
}
}
static void __init reserve_mem_for_ion(enum ion_memory_types mem_type,
unsigned long size)
{
<API key>[mem_type].size += size;
}
static void __init <API key>(unsigned long fixed_area_size)
{
#if defined(CONFIG_ION_MSM) && defined(<API key>)
int ret;
if (fixed_area_size > MAX_FIXED_AREA_SIZE)
panic("fixed area size is larger than %dM\n",
MAX_FIXED_AREA_SIZE >> 20);
reserve_info->fixed_area_size = fixed_area_size;
reserve_info->fixed_area_start = MSM8960_FW_START;
ret = memblock_remove(reserve_info->fixed_area_start,
reserve_info->fixed_area_size);
BUG_ON(ret);
#endif
}
/**
* Reserve memory for ION and calculate amount of reusable memory for fmem.
* We only reserve memory for heaps that are not reusable. However, we only
* support one reusable heap at the moment so we ignore the reusable flag for
* other than the first heap with reusable flag set. Also handle special case
* for video heaps (MM,FW, and MFC). Video requires heaps MM and MFC to be
* at a higher address than FW in addition to not more than 256MB away from the
* base address of the firmware. This means that if MM is reusable the other
* two heaps must be allocated in the same region as FW. This is handled by the
* mem_is_fmem flag in the platform data. In addition the MM heap must be
* adjacent to the FW heap for content protection purposes.
*/
static void __init reserve_ion_memory(void)
{
#if defined(CONFIG_ION_MSM) && defined(<API key>)
unsigned int i;
unsigned int reusable_count = 0;
unsigned int fixed_size = 0;
unsigned int fixed_low_size, fixed_middle_size, fixed_high_size;
unsigned long fixed_low_start, fixed_middle_start, fixed_high_start;
<API key>();
msm8960_fmem_pdata.size = 0;
msm8960_fmem_pdata.reserved_size_low = 0;
msm8960_fmem_pdata.reserved_size_high = 0;
msm8960_fmem_pdata.align = PAGE_SIZE;
fixed_low_size = 0;
fixed_middle_size = 0;
fixed_high_size = 0;
/* We only support 1 reusable heap. Check if more than one heap
* is specified as reusable and set as non-reusable if found.
*/
for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
const struct ion_platform_heap *heap =
&(msm8960_ion_pdata.heaps[i]);
if (heap->type == ION_HEAP_TYPE_CP && heap->extra_data) {
struct ion_cp_heap_pdata *data = heap->extra_data;
reusable_count += (data->reusable) ? 1 : 0;
if (data->reusable && reusable_count > 1) {
pr_err("%s: Too many heaps specified as "
"reusable. Heap %s was not configured "
"as reusable.\n", __func__, heap->name);
data->reusable = 0;
}
}
}
for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
struct ion_platform_heap *heap =
&(msm8960_ion_pdata.heaps[i]);
int align = SZ_4K;
int iommu_map_all = 0;
int adjacent_mem_id = INVALID_HEAP_ID;
if (heap->extra_data) {
int fixed_position = NOT_FIXED;
int mem_is_fmem = 0;
switch (heap->type) {
case ION_HEAP_TYPE_CP:
mem_is_fmem = ((struct ion_cp_heap_pdata *)
heap->extra_data)->mem_is_fmem;
fixed_position = ((struct ion_cp_heap_pdata *)
heap->extra_data)->fixed_position;
align = ((struct ion_cp_heap_pdata *)
heap->extra_data)->align;
iommu_map_all =
((struct ion_cp_heap_pdata *)
heap->extra_data)->iommu_map_all;
break;
case <API key>:
mem_is_fmem = ((struct ion_co_heap_pdata *)
heap->extra_data)->mem_is_fmem;
fixed_position = ((struct ion_co_heap_pdata *)
heap->extra_data)->fixed_position;
adjacent_mem_id = ((struct ion_co_heap_pdata *)
heap->extra_data)->adjacent_mem_id;
break;
default:
break;
}
if (iommu_map_all) {
if (heap->size & (SZ_64K-1)) {
heap->size = ALIGN(heap->size, SZ_64K);
pr_info("Heap %s not aligned to 64K. Adjusting size to %x\n",
heap->name, heap->size);
}
}
if (mem_is_fmem && adjacent_mem_id != INVALID_HEAP_ID)
msm8960_fmem_pdata.align = align;
if (fixed_position != NOT_FIXED)
fixed_size += heap->size;
else
reserve_mem_for_ion(MEMTYPE_EBI1, heap->size);
if (fixed_position == FIXED_LOW)
fixed_low_size += heap->size;
else if (fixed_position == FIXED_MIDDLE)
fixed_middle_size += heap->size;
else if (fixed_position == FIXED_HIGH)
fixed_high_size += heap->size;
if (mem_is_fmem)
msm8960_fmem_pdata.size += heap->size;
}
}
if (!fixed_size)
return;
if (msm8960_fmem_pdata.size) {
msm8960_fmem_pdata.reserved_size_low = fixed_low_size +
HOLE_SIZE;
msm8960_fmem_pdata.reserved_size_high = fixed_high_size;
}
/* Since the fixed area may be carved out of lowmem,
* make sure the length is a multiple of 1M.
*/
fixed_size = (fixed_size + MSM_MM_FW_SIZE + SECTION_SIZE - 1)
& SECTION_MASK;
<API key>(fixed_size);
fixed_low_start = <API key>;
fixed_middle_start = fixed_low_start + fixed_low_size + HOLE_SIZE;
fixed_high_start = fixed_middle_start + fixed_middle_size;
for (i = 0; i < msm8960_ion_pdata.nr; ++i) {
struct ion_platform_heap *heap = &(msm8960_ion_pdata.heaps[i]);
if (heap->extra_data) {
int fixed_position = NOT_FIXED;
struct ion_cp_heap_pdata *pdata = NULL;
switch (heap->type) {
case ION_HEAP_TYPE_CP:
pdata =
(struct ion_cp_heap_pdata *)heap->extra_data;
fixed_position = pdata->fixed_position;
break;
case <API key>:
fixed_position = ((struct ion_co_heap_pdata *)
heap->extra_data)->fixed_position;
break;
default:
break;
}
switch (fixed_position) {
case FIXED_LOW:
heap->base = fixed_low_start;
break;
case FIXED_MIDDLE:
heap->base = fixed_middle_start;
pdata->secure_base = fixed_middle_start
- HOLE_SIZE;
pdata->secure_size = HOLE_SIZE + heap->size;
break;
case FIXED_HIGH:
heap->base = fixed_high_start;
break;
default:
break;
}
}
}
#endif
}
static void __init reserve_mdp_memory(void)
{
<API key>(<API key>);
}
static void __init <API key>(void)
{
#ifdef <API key>
unsigned int total;
total = <API key>.l1_size +
<API key>.l2_size;
<API key>[MEMTYPE_EBI1].size += total;
#endif
}
static void __init <API key>(void)
{
size_pmem_devices();
reserve_pmem_memory();
reserve_ion_memory();
reserve_mdp_memory();
reserve_rtb_memory();
<API key>();
}
static struct reserve_info <API key> __initdata = {
.<API key> = <API key>,
.<API key> = <API key>,
.reserve_fixed_area = <API key>,
.paddr_to_memtype = <API key>,
};
static int <API key>(void)
{
return 1<<29;
}
static void __init <API key>(void)
{
struct membank *mb = &meminfo.bank[meminfo.nr_banks - 1];
unsigned long bank_size;
unsigned long low, high;
bank_size = <API key>();
<API key>.bank_size = bank_size;
low = meminfo.bank[0].start;
high = mb->start + mb->size;
/* Check if 32 bit overflow occured */
if (high < mb->start)
high = ~0UL;
if (high < MAX_FIXED_AREA_SIZE + <API key>)
panic("fixed area extends beyond end of memory\n");
low &= ~(bank_size - 1);
if (high - low <= bank_size)
goto no_dmm;
#ifdef CONFIG_ENABLE_DMM
<API key>.<API key> = mb->start -
<API key> + mb->size;
<API key>.max_unstable_size = <API key>;
pr_info("low unstable address %lx max size %lx bank size %lx\n",
<API key>.<API key>,
<API key>.max_unstable_size,
<API key>.bank_size);
return;
#endif
no_dmm:
<API key>.<API key> = high;
<API key>.max_unstable_size = 0;
}
static void __init place_movable_zone(void)
{
#ifdef CONFIG_ENABLE_DMM
<API key> = <API key>.<API key>;
<API key> = <API key>.max_unstable_size;
pr_info("movable zone start %lx size %lx\n",
<API key>, <API key>);
#endif
}
static void __init <API key>(void)
{
reserve_info = &<API key>;
<API key>();
place_movable_zone();
}
static char prim_panel_name[PANEL_NAME_MAX_LEN];
static char ext_panel_name[PANEL_NAME_MAX_LEN];
static int __init prim_display_setup(char *param)
{
if (strnlen(param, PANEL_NAME_MAX_LEN))
strlcpy(prim_panel_name, param, PANEL_NAME_MAX_LEN);
return 0;
}
early_param("prim_display", prim_display_setup);
static int __init ext_display_setup(char *param)
{
if (strnlen(param, PANEL_NAME_MAX_LEN))
strlcpy(ext_panel_name, param, PANEL_NAME_MAX_LEN);
return 0;
}
early_param("ext_display", ext_display_setup);
static void __init msm8960_reserve(void)
{
<API key>(prim_panel_name, ext_panel_name);
msm_reserve();
if (msm8960_fmem_pdata.size) {
#if defined(CONFIG_ION_MSM) && defined(<API key>)
if (reserve_info->fixed_area_size) {
msm8960_fmem_pdata.phys =
reserve_info->fixed_area_start + MSM_MM_FW_SIZE;
pr_info("mm fw at %lx (fixed) size %x\n",
reserve_info->fixed_area_start, MSM_MM_FW_SIZE);
pr_info("fmem start %lx (fixed) size %lx\n",
msm8960_fmem_pdata.phys,
msm8960_fmem_pdata.size);
}
#endif
}
}
static int <API key>(u64 start, u64 size,
int change_type)
{
return <API key>(start, size, change_type);
}
static void __init <API key>(void)
{
<API key>();
}
#ifdef <API key>
#define <API key> (NR_MSM_IRQS + NR_GPIO_IRQS + NR_PM8921_IRQS)
/* Micbias setting is based on 8660 CDP/MTP/FLUID requirement
* 4 micbiases are used to power various analog and digital
* microphones operating at 1800 mV. Technically, all micbiases
* can source from single cfilter since all microphones operate
* at the same voltage level. The arrangement below is to make
* sure all cfilters are exercised. LDO_H regulator ouput level
* does not need to be as high as 2.85V. It is choosen for
* microphone sensitivity purpose.
*/
static struct wcd9xxx_pdata tabla_platform_data = {
.<API key> = {
.name = "tabla-slave",
.e_addr = {0, 0, 0x10, 0, 0x17, 2},
},
.irq = MSM_GPIO_TO_INT(62),
.irq_base = <API key>,
.num_irqs = NR_WCD9XXX_IRQS,
.reset_gpio = <API key>(34),
.micbias = {
.ldoh_v = TABLA_LDOH_2P85_V,
.cfilt1_mv = 1800,
.cfilt2_mv = 2700,
.cfilt3_mv = 1800,
.bias1_cfilt_sel = TABLA_CFILT1_SEL,
.bias2_cfilt_sel = TABLA_CFILT2_SEL,
.bias3_cfilt_sel = TABLA_CFILT3_SEL,
.bias4_cfilt_sel = TABLA_CFILT3_SEL,
},
.regulator = {
{
.name = "CDC_VDD_CP",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_RX",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_TX",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "VDDIO_CDC",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "VDDD_CDC_D",
.min_uV = 1225000,
.max_uV = 1250000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_A_1P2V",
.min_uV = 1225000,
.max_uV = 1250000,
.optimum_uA = <API key>,
},
},
};
static struct slim_device msm_slim_tabla = {
.name = "tabla-slim",
.e_addr = {0, 1, 0x10, 0, 0x17, 2},
.dev = {
.platform_data = &tabla_platform_data,
},
};
static struct wcd9xxx_pdata <API key> = {
.<API key> = {
.name = "tabla-slave",
.e_addr = {0, 0, 0x60, 0, 0x17, 2},
},
.irq = MSM_GPIO_TO_INT(62),
.irq_base = <API key>,
.num_irqs = NR_WCD9XXX_IRQS,
.reset_gpio = <API key>(34),
.micbias = {
.ldoh_v = TABLA_LDOH_2P85_V,
.cfilt1_mv = 1800,
.cfilt2_mv = 2700,
.cfilt3_mv = 1800,
.bias1_cfilt_sel = TABLA_CFILT1_SEL,
.bias2_cfilt_sel = TABLA_CFILT2_SEL,
.bias3_cfilt_sel = TABLA_CFILT3_SEL,
.bias4_cfilt_sel = TABLA_CFILT3_SEL,
},
.regulator = {
{
.name = "CDC_VDD_CP",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_RX",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_TX",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "VDDIO_CDC",
.min_uV = 1800000,
.max_uV = 1800000,
.optimum_uA = <API key>,
},
{
.name = "VDDD_CDC_D",
.min_uV = 1225000,
.max_uV = 1250000,
.optimum_uA = <API key>,
},
{
.name = "CDC_VDDA_A_1P2V",
.min_uV = 1225000,
.max_uV = 1250000,
.optimum_uA = <API key>,
},
},
};
static struct slim_device msm_slim_tabla20 = {
.name = "tabla2x-slim",
.e_addr = {0, 1, 0x60, 0, 0x17, 2},
.dev = {
.platform_data = &<API key>,
},
};
#endif
static struct slim_boardinfo msm_slim_devices[] = {
#ifdef <API key>
{
.bus_num = 1,
.slim_slave = &msm_slim_tabla,
},
{
.bus_num = 1,
.slim_slave = &msm_slim_tabla20,
},
#endif
/* add more slimbus slaves as needed */
};
#define MSM_WCNSS_PHYS 0x03000000
#define MSM_WCNSS_SIZE 0x280000
static struct resource <API key>[] = {
{
.start = <API key>,
.end = <API key>,
.name = "wcnss_wlanrx_irq",
.flags = IORESOURCE_IRQ,
},
{
.start = <API key>,
.end = <API key>,
.name = "wcnss_wlantx_irq",
.flags = IORESOURCE_IRQ,
},
{
.start = MSM_WCNSS_PHYS,
.end = MSM_WCNSS_PHYS + MSM_WCNSS_SIZE - 1,
.name = "wcnss_mmio",
.flags = IORESOURCE_MEM,
},
{
.start = 84,
.end = 88,
.name = "wcnss_gpios_5wire",
.flags = IORESOURCE_IO,
},
};
static struct qcom_wcnss_opts qcom_wcnss_pdata = {
.has_48mhz_xo = 1,
};
static struct platform_device <API key> = {
.name = "wcnss_wlan",
.id = 0,
.num_resources = ARRAY_SIZE(<API key>),
.resource = <API key>,
.dev = {.platform_data = &qcom_wcnss_pdata},
};
#ifdef CONFIG_QSEECOM
/* qseecom bus scaling */
static struct msm_bus_vectors <API key>[] = {
{
.src = MSM_BUS_MASTER_SPS,
.dst = <API key>,
.ib = 0,
.ab = 0,
},
{
.src = MSM_BUS_MASTER_SPS,
.dst = MSM_BUS_SLAVE_SPS,
.ib = 0,
.ab = 0,
},
{
.src = MSM_BUS_MASTER_SPDM,
.dst = MSM_BUS_SLAVE_SPDM,
.ib = 0,
.ab = 0,
},
};
static struct msm_bus_vectors <API key>[] = {
{
.src = MSM_BUS_MASTER_SPS,
.dst = <API key>,
.ib = (492 * 8) * 1000000UL,
.ab = (492 * 8) * 100000UL,
},
{
.src = MSM_BUS_MASTER_SPS,
.dst = MSM_BUS_SLAVE_SPS,
.ib = (492 * 8) * 1000000UL,
.ab = (492 * 8) * 100000UL,
},
{
.src = MSM_BUS_MASTER_SPDM,
.dst = MSM_BUS_SLAVE_SPDM,
.ib = 0,
.ab = 0,
},
};
static struct msm_bus_vectors <API key>[] = {
{
.src = MSM_BUS_MASTER_SPS,
.dst = <API key>,
.ib = 0,
.ab = 0,
},
{
.src = MSM_BUS_MASTER_SPS,
.dst = MSM_BUS_SLAVE_SPS,
.ib = 0,
.ab = 0,
},
{
.src = MSM_BUS_MASTER_SPDM,
.dst = MSM_BUS_SLAVE_SPDM,
.ib = (64 * 8) * 1000000UL,
.ab = (64 * 8) * 100000UL,
},
};
static struct msm_bus_paths <API key>[] = {
{
ARRAY_SIZE(<API key>),
<API key>,
},
{
ARRAY_SIZE(<API key>),
<API key>,
},
{
ARRAY_SIZE(<API key>),
<API key>,
},
};
static struct msm_bus_scale_pdata qseecom_bus_pdata = {
<API key>,
ARRAY_SIZE(<API key>),
.name = "qsee",
};
static struct platform_device qseecom_device = {
.name = "qseecom",
.id = 0,
.dev = {
.platform_data = &qseecom_bus_pdata,
},
};
#endif
#if defined(<API key>) || \
defined(<API key>) || \
defined(<API key>) || \
defined(<API key>)
#define QCE_SIZE 0x10000
#define QCE_0_BASE 0x18500000
#define QCE_HW_KEY_SUPPORT 0
#define <API key> 1
#define <API key> 1
#define QCE_CE_SHARED 0
/* Begin Bus scaling definitions */
static struct msm_bus_vectors <API key>[] = {
{
.src = <API key>,
.dst = <API key>,
.ab = 0,
.ib = 0,
},
{
.src = <API key>,
.dst = <API key>,
.ab = 0,
.ib = 0,
},
};
static struct msm_bus_vectors <API key>[] = {
{
.src = <API key>,
.dst = <API key>,
.ab = 70000000UL,
.ib = 70000000UL,
},
{
.src = <API key>,
.dst = <API key>,
.ab = 2480000000UL,
.ib = 2480000000UL,
},
};
static struct msm_bus_paths <API key>[] = {
{
ARRAY_SIZE(<API key>),
<API key>,
},
{
ARRAY_SIZE(<API key>),
<API key>,
},
};
static struct msm_bus_scale_pdata <API key> = {
<API key>,
ARRAY_SIZE(<API key>),
.name = "cryptohw",
};
/* End Bus Scaling Definitions*/
static struct resource qcrypto_resources[] = {
[0] = {
.start = QCE_0_BASE,
.end = QCE_0_BASE + QCE_SIZE - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "crypto_channels",
.start = DMOV_CE_IN_CHAN,
.end = DMOV_CE_OUT_CHAN,
.flags = IORESOURCE_DMA,
},
[2] = {
.name = "crypto_crci_in",
.start = DMOV_CE_IN_CRCI,
.end = DMOV_CE_IN_CRCI,
.flags = IORESOURCE_DMA,
},
[3] = {
.name = "crypto_crci_out",
.start = DMOV_CE_OUT_CRCI,
.end = DMOV_CE_OUT_CRCI,
.flags = IORESOURCE_DMA,
},
};
static struct resource qcedev_resources[] = {
[0] = {
.start = QCE_0_BASE,
.end = QCE_0_BASE + QCE_SIZE - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "crypto_channels",
.start = DMOV_CE_IN_CHAN,
.end = DMOV_CE_OUT_CHAN,
.flags = IORESOURCE_DMA,
},
[2] = {
.name = "crypto_crci_in",
.start = DMOV_CE_IN_CRCI,
.end = DMOV_CE_IN_CRCI,
.flags = IORESOURCE_DMA,
},
[3] = {
.name = "crypto_crci_out",
.start = DMOV_CE_OUT_CRCI,
.end = DMOV_CE_OUT_CRCI,
.flags = IORESOURCE_DMA,
},
};
#endif
#if defined(<API key>) || \
defined(<API key>)
static struct msm_ce_hw_support <API key> = {
.ce_shared = QCE_CE_SHARED,
.shared_ce_resource = <API key>,
.hw_key_support = QCE_HW_KEY_SUPPORT,
.sha_hmac = <API key>,
.bus_scale_table = &<API key>,
};
static struct platform_device qcrypto_device = {
.name = "qcrypto",
.id = 0,
.num_resources = ARRAY_SIZE(qcrypto_resources),
.resource = qcrypto_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
.platform_data = &<API key>,
},
};
#endif
#if defined(<API key>) || \
defined(<API key>)
static struct msm_ce_hw_support <API key> = {
.ce_shared = QCE_CE_SHARED,
.shared_ce_resource = <API key>,
.hw_key_support = QCE_HW_KEY_SUPPORT,
.sha_hmac = <API key>,
.bus_scale_table = &<API key>,
};
static struct platform_device qcedev_device = {
.name = "qce",
.id = 0,
.num_resources = ARRAY_SIZE(qcedev_resources),
.resource = qcedev_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
.platform_data = &<API key>,
},
};
#endif
static struct mdm_platform_data sglte_platform_data = {
.mdm_version = "4.0",
.ramdump_delay_ms = 1000,
.soft_reset_inverted = 1,
.<API key> = NULL,
.ramdump_timeout_ms = 600000,
.<API key> = 1,
.<API key> = 1,
};
#define MSM_TSIF0_PHYS (0x18200000)
#define MSM_TSIF1_PHYS (0x18201000)
#define MSM_TSIF_SIZE (0x200)
#define MSM_TSPP_PHYS (0x18202000)
#define MSM_TSPP_SIZE (0x1000)
#define MSM_TSPP_BAM_PHYS (0x18204000)
#define MSM_TSPP_BAM_SIZE (0x2000)
#define TSIF_0_CLK GPIO_CFG(75, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_0_EN GPIO_CFG(76, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_0_DATA GPIO_CFG(77, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_0_SYNC GPIO_CFG(82, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_1_CLK GPIO_CFG(79, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_1_EN GPIO_CFG(80, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_1_DATA GPIO_CFG(81, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_1_SYNC GPIO_CFG(78, 1, GPIO_CFG_INPUT, \
GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
static const struct msm_gpio tsif_gpios[] = {
{ .gpio_cfg = TSIF_0_CLK, .label = "tsif0_clk", },
{ .gpio_cfg = TSIF_0_EN, .label = "tsif0_en", },
{ .gpio_cfg = TSIF_0_DATA, .label = "tsif0_data", },
{ .gpio_cfg = TSIF_0_SYNC, .label = "tsif0_sync", },
{ .gpio_cfg = TSIF_1_CLK, .label = "tsif1_clk", },
{ .gpio_cfg = TSIF_1_EN, .label = "tsif1_en", },
{ .gpio_cfg = TSIF_1_DATA, .label = "tsif1_data", },
{ .gpio_cfg = TSIF_1_SYNC, .label = "tsif1_sync", },
};
static struct resource tspp_resources[] = {
[0] = {
.flags = IORESOURCE_IRQ,
.start = TSIF_TSPP_IRQ,
.end = TSIF1_IRQ,
},
[1] = {
.flags = IORESOURCE_MEM,
.start = MSM_TSIF0_PHYS,
.end = MSM_TSIF0_PHYS + MSM_TSIF_SIZE - 1,
},
[2] = {
.flags = IORESOURCE_MEM,
.start = MSM_TSIF1_PHYS,
.end = MSM_TSIF1_PHYS + MSM_TSIF_SIZE - 1,
},
[3] = {
.flags = IORESOURCE_MEM,
.start = MSM_TSPP_PHYS,
.end = MSM_TSPP_PHYS + MSM_TSPP_SIZE - 1,
},
[4] = {
.flags = IORESOURCE_MEM,
.start = MSM_TSPP_BAM_PHYS,
.end = MSM_TSPP_BAM_PHYS + MSM_TSPP_BAM_SIZE - 1,
},
};
static struct <API key> tspp_platform_data = {
.num_gpios = ARRAY_SIZE(tsif_gpios),
.gpios = tsif_gpios,
.tsif_pclk = "tsif_pclk",
.tsif_ref_clk = "tsif_ref_clk",
};
static struct platform_device msm_device_tspp = {
.name = "msm_tspp",
.id = 0,
.num_resources = ARRAY_SIZE(tspp_resources),
.resource = tspp_resources,
.dev = {
.platform_data = &tspp_platform_data
},
};
#define MSM_SHARED_RAM_PHYS 0x80000000
static void __init msm8960_map_io(void)
{
msm_shared_ram_phys = MSM_SHARED_RAM_PHYS;
msm_map_msm8960_io();
if (socinfo_init() < 0)
pr_err("socinfo_init() failed!\n");
}
static void __init msm8960_init_irq(void)
{
struct msm_mpm_device_data *data = NULL;
#ifdef CONFIG_MSM_MPM
data = &<API key>;
#endif
<API key>(data);
gic_init(0, GIC_PPI_START, MSM_QGIC_DIST_BASE,
(void *)MSM_QGIC_CPU_BASE);
}
static void __init msm8960_init_buses(void)
{
#ifdef <API key>
<API key>();
<API key>.rpm_enabled = 1;
<API key>.rpm_enabled = 1;
msm_bus_apps_fabric.dev.platform_data =
&<API key>;
msm_bus_sys_fabric.dev.platform_data = &<API key>;
if (cpu_is_msm8960ab()) {
<API key>.rpm_enabled = 1;
msm_bus_mm_fabric.dev.platform_data =
&<API key>;
} else {
<API key>.rpm_enabled = 1;
msm_bus_mm_fabric.dev.platform_data =
&<API key>;
}
msm_bus_sys_fpb.dev.platform_data = &<API key>;
msm_bus_cpss_fpb.dev.platform_data = &<API key>;
#endif
}
static struct <API key> <API key> = {
.max_clock_speed = 15060000,
.infinite_mode = 0xFFC0,
};
#ifdef <API key>
static struct <API key> msm_otg_pdata;
#else
static int wr_phy_init_seq[] = {
0x44, 0x80, /* set VBUS valid threshold
and disconnect valid threshold */
0x68, 0x81, /* update DC voltage level */
0x14, 0x82, /* set preemphasis and rise/fall time */
0x13, 0x83, /* set source impedance adjusment */
-1};
static int <API key>[] = {
0x44, 0x80,/* set VBUS valid threshold
and disconnect valid threshold */
0x6C, 0x81,/* update DC voltage level */
0x18, 0x82,/* set preemphasis and rise/fall time */
0x23, 0x83,/* set source impedance sdjusment */
-1};
static int sglte_phy_init_seq[] = {
0x44, 0x80, /* set VBUS valid threshold
and disconnect valid threshold */
0x6A, 0x81, /* update DC voltage level */
0x24, 0x82, /* set preemphasis and rise/fall time */
0x13, 0x83, /* set source impedance adjusment */
-1};
#ifdef <API key>
/* Bandwidth requests (zero) if no vote placed */
static struct msm_bus_vectors usb_init_vectors[] = {
{
.src = MSM_BUS_MASTER_SPS,
.dst = <API key>,
.ab = 0,
.ib = 0,
},
};
/* Bus bandwidth requests in Bytes/sec */
static struct msm_bus_vectors usb_max_vectors[] = {
{
.src = MSM_BUS_MASTER_SPS,
.dst = <API key>,
.ab = 60000000, /* At least 480Mbps on bus. */
.ib = 960000000, /* MAX bursts rate */
},
};
static struct msm_bus_paths <API key>[] = {
{
ARRAY_SIZE(usb_init_vectors),
usb_init_vectors,
},
{
ARRAY_SIZE(usb_max_vectors),
usb_max_vectors,
},
};
static struct msm_bus_scale_pdata usb_bus_scale_pdata = {
<API key>,
ARRAY_SIZE(<API key>),
.name = "usb",
};
#endif
#define <API key> 40
static struct <API key> msm_otg_pdata = {
.mode = USB_OTG,
.otg_control = OTG_PMIC_CONTROL,
.phy_type = <API key>,
.pmic_id_irq = <API key>(PM8921_IRQ_BASE),
.power_budget = 750,
#ifdef <API key>
.bus_scale_table = &usb_bus_scale_pdata,
.mpm_otgsessvld_int = <API key>,
#endif
#ifdef <API key>
.mhl_dev_name = "sii8334",
#endif
};
#endif
#ifdef <API key>
#define HSIC_HUB_RESET_GPIO 91
static struct <API key> msm_hsic_pdata = {
.strobe = 150,
.data = 151,
};
static struct <API key> hsic_hub_pdata = {
.hub_reset = HSIC_HUB_RESET_GPIO,
};
#else
static struct <API key> msm_hsic_pdata;
static struct <API key> hsic_hub_pdata;
#endif
static struct platform_device smsc_hub_device = {
.name = "msm_smsc_hub",
.id = -1,
.dev = {
.platform_data = &hsic_hub_pdata,
},
};
#define PID_MAGIC_ID 0x71432909
#define SERIAL_NUM_MAGIC_ID 0x61945374
#define <API key> 127
#define DLOAD_USB_BASE_ADD 0x2A03F0C8
struct magic_num_struct {
uint32_t pid;
uint32_t serial_num;
};
struct dload_struct {
uint32_t reserved1;
uint32_t reserved2;
uint32_t reserved3;
uint16_t reserved4;
uint16_t pid;
char serial_number[<API key>];
uint16_t reserved5;
struct magic_num_struct magic_struct;
};
static int <API key>(uint32_t pid, const char *snum)
{
struct dload_struct __iomem *dload = 0;
dload = ioremap(DLOAD_USB_BASE_ADD, sizeof(*dload));
if (!dload) {
pr_err("%s: cannot remap I/O memory region: %08x\n",
__func__, DLOAD_USB_BASE_ADD);
return -ENXIO;
}
pr_debug("%s: dload:%p pid:%x serial_num:%s\n",
__func__, dload, pid, snum);
/* update pid */
dload->magic_struct.pid = PID_MAGIC_ID;
dload->pid = pid;
/* update serial number */
dload->magic_struct.serial_num = 0;
if (!snum) {
memset(dload->serial_number, 0, <API key>);
goto out;
}
dload->magic_struct.serial_num = SERIAL_NUM_MAGIC_ID;
strlcpy(dload->serial_number, snum, <API key>);
out:
iounmap(dload);
return 0;
}
static struct <API key> android_usb_pdata = {
.<API key> = <API key>,
};
static struct platform_device android_usb_device = {
.name = "android_usb",
.id = -1,
.dev = {
.platform_data = &android_usb_pdata,
},
};
static uint8_t <API key>[] __initdata = {
0x03, 0x0f,
};
static uint8_t <API key>[] __initdata = {
0x00, 0x05, 0x03, 0x0D,
0x0B, 0x00, 0x0f,
};
static uint8_t <API key>[] __initdata = {
0x00, 0x24, 0x54, 0x10,
0x09, 0x03, 0x01,
0x10, 0x54, 0x30, 0x0C,
0x24, 0x30, 0x0f,
};
static uint8_t <API key>[] __initdata = {
0x00, 0x24, 0x54, 0x10,
0x09, 0x07, 0x01, 0x0B,
0x10, 0x54, 0x30, 0x0C,
0x24, 0x30, 0x0f,
};
static struct msm_spm_seq_entry <API key>[] __initdata = {
[0] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[1] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[2] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[3] = {
.mode = <API key>,
.notify_rpm = true,
.cmd = <API key>,
},
};
static struct msm_spm_seq_entry <API key>[] __initdata = {
[0] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[1] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[2] = {
.mode = <API key>,
.notify_rpm = true,
.cmd = <API key>,
},
};
static struct <API key> msm_spm_data[] __initdata = {
[0] = {
.reg_base_addr = MSM_SAW0_BASE,
.reg_init_values[<API key>] = 0x1F,
#if defined(CONFIG_MSM_AVS_HW)
.reg_init_values[<API key>] = 0x50589464,
.reg_init_values[<API key>] = 0x00020000,
#endif
.reg_init_values[<API key>] = 0x01,
.reg_init_values[<API key>] = 0x03020004,
.reg_init_values[<API key>] = 0x0084009C,
.reg_init_values[<API key>] = 0x00A4001C,
.vctl_timeout_us = 50,
.num_modes = ARRAY_SIZE(<API key>),
.modes = <API key>,
},
[1] = {
.reg_base_addr = MSM_SAW1_BASE,
.reg_init_values[<API key>] = 0x1F,
#if defined(CONFIG_MSM_AVS_HW)
.reg_init_values[<API key>] = 0x50589464,
.reg_init_values[<API key>] = 0x00020000,
#endif
.reg_init_values[<API key>] = 0x01,
.reg_init_values[<API key>] = 0x02020204,
.reg_init_values[<API key>] = 0x0060009C,
.reg_init_values[<API key>] = 0x0000001C,
.vctl_timeout_us = 50,
.num_modes = ARRAY_SIZE(<API key>),
.modes = <API key>,
},
};
static uint8_t <API key>[] __initdata = {
0x00, 0x20, 0x03, 0x20,
0x00, 0x0f,
};
static uint8_t <API key>[] __initdata = {
0x00, 0x20, 0x34, 0x64,
0x48, 0x07, 0x48, 0x20,
0x50, 0x64, 0x04, 0x34,
0x50, 0x0f,
};
static uint8_t <API key>[] __initdata = {
0x00, 0x10, 0x34, 0x64,
0x48, 0x07, 0x48, 0x10,
0x50, 0x64, 0x04, 0x34,
0x50, 0x0F,
};
static struct msm_spm_seq_entry msm_spm_l2_seq_list[] __initdata = {
[0] = {
.mode = <API key>,
.notify_rpm = false,
.cmd = <API key>,
},
[1] = {
.mode = <API key>,
.notify_rpm = true,
.cmd = <API key>,
},
[2] = {
.mode = <API key>,
.notify_rpm = true,
.cmd = <API key>,
},
};
static struct <API key> msm_spm_l2_data[] __initdata = {
[0] = {
.reg_base_addr = MSM_SAW_L2_BASE,
.reg_init_values[<API key>] = 0x00,
.reg_init_values[<API key>] = 0x02020204,
.reg_init_values[<API key>] = 0x00A000AE,
.reg_init_values[<API key>] = 0x00A00020,
.modes = msm_spm_l2_seq_list,
.num_modes = ARRAY_SIZE(msm_spm_l2_seq_list),
},
};
#define <API key> 47
#define <API key> 89
#define PM_HAP_EN_GPIO <API key>(33)
#define PM_HAP_LEN_GPIO <API key>(20)
static struct msm_xo_voter *xo_handle_d1;
static int isa1200_power(int on)
{
int rc = 0;
int hap_oe_gpio = <API key>;
if (<API key>() == <API key>)
hap_oe_gpio = <API key>;
gpio_set_value(hap_oe_gpio, !!on);
rc = on ? msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_ON) :
msm_xo_mode_vote(xo_handle_d1, MSM_XO_MODE_OFF);
if (rc < 0) {
pr_err("%s: failed to %svote for TCXO D1 buffer%d\n",
__func__, on ? "" : "de-", rc);
goto err_xo_vote;
}
return 0;
err_xo_vote:
gpio_set_value(hap_oe_gpio, !on);
return rc;
}
static int isa1200_dev_setup(bool enable)
{
int rc = 0;
int hap_oe_gpio = <API key>;
struct pm_gpio hap_gpio_config = {
.direction = PM_GPIO_DIR_OUT,
.pull = PM_GPIO_PULL_NO,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
.vin_sel = 2,
.output_buffer = <API key>,
.output_value = 0,
};
if (<API key>() == <API key>)
hap_oe_gpio = <API key>;
if (enable == true) {
rc = pm8xxx_gpio_config(PM_HAP_EN_GPIO, &hap_gpio_config);
if (rc) {
pr_err("%s: pm8921 gpio %d config failed(%d)\n",
__func__, PM_HAP_EN_GPIO, rc);
return rc;
}
rc = pm8xxx_gpio_config(PM_HAP_LEN_GPIO, &hap_gpio_config);
if (rc) {
pr_err("%s: pm8921 gpio %d config failed(%d)\n",
__func__, PM_HAP_LEN_GPIO, rc);
return rc;
}
rc = gpio_request(hap_oe_gpio, "hap_shft_lvl_oe");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, hap_oe_gpio, rc);
return rc;
}
rc = <API key>(hap_oe_gpio, 0);
if (rc) {
pr_err("%s: Unable to set direction\n", __func__);
goto free_gpio;
}
xo_handle_d1 = msm_xo_get(MSM_XO_TCXO_D1, "isa1200");
if (IS_ERR(xo_handle_d1)) {
rc = PTR_ERR(xo_handle_d1);
pr_err("%s: failed to get the handle for D1(%d)\n",
__func__, rc);
goto gpio_set_dir;
}
} else {
gpio_free(hap_oe_gpio);
msm_xo_put(xo_handle_d1);
}
return 0;
gpio_set_dir:
gpio_set_value(hap_oe_gpio, 0);
free_gpio:
gpio_free(hap_oe_gpio);
return rc;
}
static struct isa1200_regulator isa1200_reg_data[] = {
{
.name = "vcc_i2c",
.min_uV = ISA_I2C_VTG_MIN_UV,
.max_uV = ISA_I2C_VTG_MAX_UV,
.load_uA = ISA_I2C_CURR_UA,
},
};
static struct <API key> isa1200_1_pdata = {
.name = "vibrator",
.dev_setup = isa1200_dev_setup,
.power_on = isa1200_power,
.hap_en_gpio = PM_HAP_EN_GPIO,
.hap_len_gpio = PM_HAP_LEN_GPIO,
.max_timeout = 15000,
.mode_ctrl = PWM_GEN_MODE,
.pwm_fd = {
.pwm_div = 256,
},
.is_erm = false,
.smart_en = true,
.ext_clk_en = true,
.chip_en = 1,
.regulator_info = isa1200_reg_data,
.num_regulators = ARRAY_SIZE(isa1200_reg_data),
};
static struct i2c_board_info <API key>[] __initdata = {
{
I2C_BOARD_INFO("isa1200_1", 0x90>>1),
},
};
#define CYTTSP_TS_GPIO_IRQ 11
#define <API key> 50
#define <API key> 52
/*virtual key support */
static ssize_t tma340_vkeys_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return snprintf(buf, 200,
__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":73:1120:97:97"
":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":230:1120:97:97"
":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":389:1120:97:97"
":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":544:1120:97:97"
"\n");
}
static struct kobj_attribute tma340_vkeys_attr = {
.attr = {
.mode = S_IRUGO,
},
.show = &tma340_vkeys_show,
};
static struct attribute *<API key>[] = {
&tma340_vkeys_attr.attr,
NULL
};
static struct attribute_group <API key> = {
.attrs = <API key>,
};
static int <API key>(struct i2c_client *client)
{
int rc = 0;
static struct kobject *<API key>;
tma340_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
<API key> = <API key>("board_properties",
NULL);
if (<API key>)
rc = sysfs_create_group(<API key>,
&<API key>);
if (!<API key> || rc)
pr_err("%s: failed to create board_properties\n",
__func__);
return 0;
}
static struct cyttsp_regulator regulator_data[] = {
{
.name = "vdd",
.min_uV = <API key>,
.max_uV = <API key>,
.hpm_load_uA = <API key>,
.lpm_load_uA = <API key>,
},
/* TODO: Remove after runtime PM is enabled in I2C driver */
{
.name = "vcc_i2c",
.min_uV = CY_I2C_VTG_MIN_UV,
.max_uV = CY_I2C_VTG_MAX_UV,
.hpm_load_uA = CY_I2C_CURR_UA,
.lpm_load_uA = <API key>,
},
};
static struct <API key> cyttsp_pdata = {
.panel_maxx = 634,
.panel_maxy = 1166,
.disp_maxx = 616,
.disp_maxy = 1023,
.disp_minx = 0,
.disp_miny = 16,
.flags = 0x01,
.gen = CY_GEN3,
.use_st = CY_USE_ST,
.use_mt = CY_USE_MT,
.use_hndshk = CY_SEND_HNDSHK,
.use_trk_id = CY_USE_TRACKING_ID,
.use_sleep = <API key> | <API key>,
.use_gestures = CY_USE_GESTURES,
.fw_fname = "cyttsp_8960_cdp.hex",
/* activate up to 4 groups
* and set active distance
*/
.gest_set = CY_GEST_GRP1 | CY_GEST_GRP2 |
CY_GEST_GRP3 | CY_GEST_GRP4 |
CY_ACT_DIST,
.act_intrvl = 10,
.tch_tmout = 200,
.lp_intrvl = 30,
.sleep_gpio = <API key>,
.resout_gpio = <API key>,
.irq_gpio = CYTTSP_TS_GPIO_IRQ,
.regulator_info = regulator_data,
.num_regulators = ARRAY_SIZE(regulator_data),
.init = <API key>,
.correct_fw_ver = 9,
};
static struct i2c_board_info cyttsp_info[] __initdata = {
{
I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
.platform_data = &cyttsp_pdata,
#ifndef CY_USE_TIMER
.irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
#endif /* CY_USE_TIMER */
},
};
/* configuration data for mxt1386 */
static const u8 mxt1386_config_data[] = {
/* T6 Object */
0, 0, 0, 0, 0, 0,
/* T38 Object */
11, 2, 0, 11, 11, 11, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T7 Object */
100, 16, 50,
/* T8 Object */
8, 0, 0, 0, 0, 0, 8, 14, 50, 215,
/* T9 Object */
131, 0, 0, 26, 42, 0, 32, 63, 3, 5,
0, 2, 1, 113, 10, 10, 8, 10, 255, 2,
85, 5, 0, 0, 20, 20, 75, 25, 202, 29,
10, 10, 45, 46,
/* T15 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
/* T18 Object */
0, 0,
/* T22 Object */
5, 0, 0, 0, 0, 0, 0, 0, 30, 0,
0, 0, 5, 8, 10, 13, 0,
/* T24 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
/* T25 Object */
3, 0, 188, 52, 52, 33, 0, 0, 0, 0,
0, 0, 0, 0,
/* T27 Object */
0, 0, 0, 0, 0, 0, 0,
/* T28 Object */
0, 0, 0, 8, 12, 60,
/* T40 Object */
0, 0, 0, 0, 0,
/* T41 Object */
0, 0, 0, 0, 0, 0,
/* T43 Object */
0, 0, 0, 0, 0, 0,
};
/* configuration data for mxt1386e using V1.0 firmware */
static const u8 <API key>[] = {
/* T6 Object */
0, 0, 0, 0, 0, 0,
/* T38 Object */
12, 1, 0, 17, 1, 12, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T7 Object */
100, 16, 50,
/* T8 Object */
25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
/* T9 Object */
131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
0, 5, 5, 0, 10, 30, 10, 10, 255, 2,
85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
10, 5, 0, 0, 0,
/* T18 Object */
0, 0,
/* T24 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
/* T25 Object */
3, 0, 60, 115, 156, 99,
/* T27 Object */
0, 0, 0, 0, 0, 0, 0,
/* T40 Object */
0, 0, 0, 0, 0,
/* T42 Object */
2, 0, 255, 0, 255, 0, 0, 0, 0, 0,
/* T43 Object */
0, 0, 0, 0, 0, 0, 0,
/* T46 Object */
64, 0, 20, 20, 0, 0, 0, 0, 0,
/* T47 Object */
0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
/* T48 Object */
31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T56 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 99, 33,
};
/* configuration data for mxt1386e using V2.1 firmware */
static const u8 <API key>[] = {
/* T6 Object */
0, 0, 0, 0, 0, 0,
/* T38 Object */
12, 4, 0, 5, 7, 12, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T7 Object */
100, 16, 50,
/* T8 Object */
25, 0, 20, 20, 0, 0, 20, 50, 0, 0,
/* T9 Object */
139, 0, 0, 26, 42, 0, 32, 80, 2, 5,
0, 5, 5, 79, 10, 30, 10, 10, 255, 2,
85, 5, 10, 10, 10, 10, 135, 55, 70, 40,
10, 5, 0, 0, 0,
/* T18 Object */
0, 0,
/* T24 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
/* T25 Object */
1, 0, 60, 115, 156, 99,
/* T27 Object */
0, 0, 0, 0, 0, 0, 0,
/* T40 Object */
0, 0, 0, 0, 0,
/* T42 Object */
0, 0, 255, 0, 255, 0, 0, 0, 0, 0,
/* T43 Object */
0, 0, 0, 0, 0, 0, 0, 64, 0, 8,
16,
/* T46 Object */
64, 0, 16, 16, 0, 0, 0, 0, 0,
/* T47 Object */
0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
/* T48 Object */
1, 64, 64, 0, 0, 0, 0, 0, 0, 0,
48, 40, 0, 10, 10, 0, 0, 100, 10, 80,
0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
52, 0, 12, 0, 17, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T56 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
2, 99, 33, 0, 149, 24, 193, 255, 255, 255,
255,
};
/* configuration data for mxt1386e on 3D SKU using V2.1 firmware */
static const u8 <API key>[] = {
/* T6 Object */
0, 0, 0, 0, 0, 0,
/* T38 Object */
13, 1, 0, 23, 2, 12, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T7 Object */
100, 10, 50,
/* T8 Object */
25, 0, 20, 20, 0, 0, 0, 0, 0, 0,
/* T9 Object */
131, 0, 0, 26, 42, 0, 32, 80, 2, 5,
0, 5, 5, 0, 10, 30, 10, 10, 175, 4,
127, 7, 26, 21, 17, 19, 143, 35, 207, 40,
20, 5, 54, 49, 0,
/* T18 Object */
0, 0,
/* T24 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
/* T25 Object */
0, 0, 72, 113, 168, 97,
/* T27 Object */
0, 0, 0, 0, 0, 0, 0,
/* T40 Object */
0, 0, 0, 0, 0,
/* T42 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* T43 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
/* T46 Object */
68, 0, 16, 16, 0, 0, 0, 0, 0,
/* T47 Object */
0, 0, 0, 0, 0, 0, 3, 64, 66, 0,
/* T48 Object */
31, 64, 64, 0, 0, 0, 0, 0, 0, 0,
32, 50, 0, 10, 10, 0, 0, 100, 10, 90,
0, 0, 0, 0, 0, 0, 0, 10, 1, 30,
52, 10, 5, 0, 33, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0,
/* T56 Object */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0,
};
#define MXT_TS_GPIO_IRQ 11
#define MXT_TS_LDO_EN_GPIO 50
#define MXT_TS_RESET_GPIO 52
static void mxt_init_hw_liquid(void)
{
int rc;
rc = gpio_request(MXT_TS_LDO_EN_GPIO, "mxt_ldo_en_gpio");
if (rc) {
pr_err("%s: unable to request mxt_ldo_en_gpio [%d]\n",
__func__, MXT_TS_LDO_EN_GPIO);
return;
}
rc = <API key>(MXT_TS_LDO_EN_GPIO, 1);
if (rc) {
pr_err("%s: unable to set_direction for mxt_ldo_en_gpio [%d]\n",
__func__, MXT_TS_LDO_EN_GPIO);
goto err_ldo_gpio_req;
}
return;
err_ldo_gpio_req:
gpio_free(MXT_TS_LDO_EN_GPIO);
}
static struct mxt_config_info mxt_config_array_2d[] = {
{
.config = mxt1386_config_data,
.config_length = ARRAY_SIZE(mxt1386_config_data),
.family_id = 0xA0,
.variant_id = 0x0,
.version = 0x10,
.build = 0xAA,
.bootldr_id = <API key>,
},
{
.config = <API key>,
.config_length = ARRAY_SIZE(<API key>),
.family_id = 0xA0,
.variant_id = 0x2,
.version = 0x10,
.build = 0xAA,
.bootldr_id = <API key>,
.fw_name = "<API key>.hex",
},
{
.config = <API key>,
.config_length = ARRAY_SIZE(<API key>),
.family_id = 0xA0,
.variant_id = 0x7,
.version = 0x21,
.build = 0xAA,
.bootldr_id = <API key>,
.fw_name = "<API key>.hex",
},
{
/* The config data for V2.2.AA is the same as for V2.1.AA */
.config = <API key>,
.config_length = ARRAY_SIZE(<API key>),
.family_id = 0xA0,
.variant_id = 0x7,
.version = 0x22,
.build = 0xAA,
.bootldr_id = <API key>,
},
};
static struct mxt_platform_data <API key> = {
.config_array = mxt_config_array_2d,
.config_array_size = ARRAY_SIZE(mxt_config_array_2d),
.panel_minx = 0,
.panel_maxx = 1365,
.panel_miny = 0,
.panel_maxy = 767,
.disp_minx = 0,
.disp_maxx = 1365,
.disp_miny = 0,
.disp_maxy = 767,
.irqflags = <API key>,
.i2c_pull_up = true,
.reset_gpio = MXT_TS_RESET_GPIO,
.irq_gpio = MXT_TS_GPIO_IRQ,
};
static struct mxt_config_info mxt_config_array_3d[] = {
{
.config = <API key>,
.config_length = ARRAY_SIZE(<API key>),
.family_id = 0xA0,
.variant_id = 0x7,
.version = 0x21,
.build = 0xAA,
},
};
static struct mxt_platform_data <API key> = {
.config_array = mxt_config_array_3d,
.config_array_size = ARRAY_SIZE(mxt_config_array_3d),
.panel_minx = 0,
.panel_maxx = 1919,
.panel_miny = 0,
.panel_maxy = 1199,
.disp_minx = 0,
.disp_maxx = 1919,
.disp_miny = 0,
.disp_maxy = 1199,
.irqflags = <API key>,
.i2c_pull_up = true,
.reset_gpio = MXT_TS_RESET_GPIO,
.irq_gpio = MXT_TS_GPIO_IRQ,
};
static struct i2c_board_info mxt_device_info[] __initdata = {
{
I2C_BOARD_INFO("atmel_mxt_ts", 0x5b),
.irq = MSM_GPIO_TO_INT(MXT_TS_GPIO_IRQ),
},
};
static struct <API key> mhl_platform_data = {
.irq = MSM_GPIO_TO_INT(4),
.gpio_mhl_int = MHL_GPIO_INT,
.gpio_mhl_reset = MHL_GPIO_RESET,
.gpio_mhl_power = 0,
.gpio_hdmi_mhl_mux = 0,
};
static struct i2c_board_info sii_device_info[] __initdata = {
{
#ifdef <API key>
/*
* keeps SI 8334 as the default
* MHL TX
*/
I2C_BOARD_INFO("sii8334", 0x39),
.platform_data = &mhl_platform_data,
#endif
#ifdef <API key>
I2C_BOARD_INFO("Sil-9244", 0x39),
.irq = MSM_GPIO_TO_INT(15),
#endif /* CONFIG_MSM_HDMI_MHL */
.flags = I2C_CLIENT_WAKE,
},
};
static struct <API key> <API key> = {
.clk_freq = 100000,
.src_clk_rate = 24000000,
};
static struct <API key> <API key> = {
.clk_freq = 100000,
.src_clk_rate = 24000000,
};
static struct <API key> <API key> = {
.clk_freq = 100000,
.src_clk_rate = 24000000,
};
static struct <API key> <API key> = {
.clk_freq = 100000,
.src_clk_rate = 24000000,
};
static struct ks8851_pdata spi_eth_pdata = {
.irq_gpio = KS8851_IRQ_GPIO,
.rst_gpio = KS8851_RST_GPIO,
};
static struct spi_board_info spi_eth_info[] __initdata = {
{
.modalias = "ks8851",
.irq = MSM_GPIO_TO_INT(KS8851_IRQ_GPIO),
.max_speed_hz = 19200000,
.bus_num = 0,
.chip_select = 0,
.mode = SPI_MODE_0,
.platform_data = &spi_eth_pdata
},
};
static struct spi_board_info spi_board_info[] __initdata = {
{
.modalias = "<API key>",
.max_speed_hz = 10800000,
.bus_num = 0,
.chip_select = 1,
.mode = SPI_MODE_0,
},
};
static struct platform_device <API key> = {
.name = "saw-regulator",
.id = 0,
.dev = {
.platform_data = &<API key>,
},
};
static struct platform_device <API key> = {
.name = "saw-regulator",
.id = 1,
.dev = {
.platform_data = &<API key>,
},
};
static struct tsens_platform_data msm_tsens_pdata = {
.slope = {910, 910, 910, 910, 910},
.tsens_factor = 1000,
.hw_type = MSM_8960,
.tsens_num_sensor = 5,
};
static struct platform_device msm_tsens_device = {
.name = "tsens8960-tm",
.id = -1,
};
static struct msm_thermal_data msm_thermal_pdata = {
.sensor_id = 0,
.poll_ms = 250,
.limit_temp_degC = 60,
.<API key> = 10,
.freq_step = 2,
};
#ifdef <API key>
static struct platform_device fish_battery_device = {
.name = "fish_battery",
};
#endif
#ifdef CONFIG_BATTERY_BCL
static struct platform_device battery_bcl_device = {
.name = "<API key>",
.id = -1,
};
#endif
static struct platform_device <API key> __devinitdata = {
.name = <API key>,
.id = <API key>(7),
.dev = {
.platform_data = &<API key>[GPIO_VREG_ID_EXT_5V],
},
};
static struct platform_device <API key> __devinitdata = {
.name = <API key>,
.id = 91,
.dev = {
.platform_data = &<API key>[GPIO_VREG_ID_EXT_L2],
},
};
static struct platform_device <API key> __devinitdata = {
.name = <API key>,
.id = <API key>(17),
.dev = {
.platform_data =
&<API key>[<API key>],
},
};
static struct platform_device <API key> __devinitdata = {
.name = <API key>,
.id = <API key>(42),
.dev = {
.platform_data =
&<API key>[<API key>],
},
};
static struct platform_device <API key> __devinitdata = {
.name = "rpm-regulator",
.id = -1,
.dev = {
.platform_data = &<API key>,
},
};
#ifdef <API key>
static int <API key>(int on)
{
int ret = 0, i;
int uart_gpios[] = {93, 94, 95, 96};
for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
if (on) {
ret = gpio_request(uart_gpios[i], NULL);
if (ret) {
pr_err("%s: unable to request uart gpio[%d]\n",
__func__, uart_gpios[i]);
break;
}
} else {
gpio_free(uart_gpios[i]);
}
}
if (ret && on && i)
for (; i >= 0; i
gpio_free(uart_gpios[i]);
return ret;
}
static struct <API key> msm_uart_dm9_pdata = {
.gpio_config = <API key>,
};
static int <API key>(int on)
{
int ret = 0, i;
int uart_gpios[] = {34, 35, 36, 37};
for (i = 0; i < ARRAY_SIZE(uart_gpios); i++) {
if (on) {
ret = gpio_request(uart_gpios[i], NULL);
if (ret) {
pr_err("%s: unable to request uart gpio[%d]\n",
__func__, uart_gpios[i]);
break;
}
} else {
gpio_free(uart_gpios[i]);
}
}
if (ret && on && i)
for (; i >= 0; i
gpio_free(uart_gpios[i]);
return ret;
}
static struct <API key> msm_uart_dm8_pdata = {
.gpio_config = <API key>,
};
#else
static struct <API key> msm_uart_dm8_pdata;
static struct <API key> msm_uart_dm9_pdata;
#endif
#if defined(CONFIG_BT) && defined(<API key>)
enum WLANBT_STATUS {
WLANOFF_BTOFF = 1,
WLANOFF_BTON,
WLANON_BTOFF,
WLANON_BTON
};
static DEFINE_MUTEX(ath_wlanbt_mutex);
static int <API key> = 26;
static int ath_wlanbt_status = WLANOFF_BTOFF;
static int <API key>(int on)
{
int rc;
if (on) {
rc = gpio_request(<API key>, "wlan sys_rst_n");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, <API key>, rc);
return rc;
}
rc = <API key>(<API key>, 0);
msleep(200);
rc = <API key>(<API key>, 1);
msleep(100);
} else {
gpio_set_value(<API key>, 0);
rc = <API key>(<API key>);
msleep(100);
gpio_free(<API key>);
}
return 0;
};
static int ath6kl_wlan_power(int on)
{
int ret = 0;
mutex_lock(&ath_wlanbt_mutex);
if (on) {
if (ath_wlanbt_status == WLANOFF_BTOFF) {
ret = <API key>(1);
ath_wlanbt_status = WLANON_BTOFF;
} else if (ath_wlanbt_status == WLANOFF_BTON)
ath_wlanbt_status = WLANON_BTON;
} else {
if (ath_wlanbt_status == WLANON_BTOFF) {
ret = <API key>(0);
ath_wlanbt_status = WLANOFF_BTOFF;
} else if (ath_wlanbt_status == WLANON_BTON)
ath_wlanbt_status = WLANOFF_BTON;
}
mutex_unlock(&ath_wlanbt_mutex);
pr_debug("%s on= %d, wlan_status= %d\n",
__func__, on, ath_wlanbt_status);
return ret;
};
static struct wifi_platform_data ath6kl_wifi_control = {
.set_power = ath6kl_wlan_power,
};
static struct platform_device <API key> = {
.name = "ath6kl_power",
.dev = {
.platform_data = &ath6kl_wifi_control,
},
};
static struct resource bluesleep_resources[] = {
{
.name = "gpio_host_wake",
.start = 27,
.end = 27,
.flags = IORESOURCE_IO,
},
{
.name = "gpio_ext_wake",
.start = 29,
.end = 29,
.flags = IORESOURCE_IO,
},
{
.name = "host_wake",
.start = MSM_GPIO_TO_INT(27),
.end = MSM_GPIO_TO_INT(27),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device <API key> = {
.name = "bluesleep",
.id = -1,
.num_resources = ARRAY_SIZE(bluesleep_resources),
.resource = bluesleep_resources,
};
static struct platform_device msm_bt_power_device = {
.name = "bt_power",
};
static int gpio_bt_sys_rest_en = 28;
static int bluetooth_power(int on)
{
int rc;
mutex_lock(&ath_wlanbt_mutex);
if (on) {
if (ath_wlanbt_status == WLANOFF_BTOFF) {
<API key>(1);
ath_wlanbt_status = WLANOFF_BTON;
} else if (ath_wlanbt_status == WLANON_BTOFF)
ath_wlanbt_status = WLANON_BTON;
rc = gpio_request(gpio_bt_sys_rest_en, "bt sys_rst_n");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, gpio_bt_sys_rest_en, rc);
mutex_unlock(&ath_wlanbt_mutex);
return rc;
}
rc = <API key>(gpio_bt_sys_rest_en, 0);
msleep(20);
rc = <API key>(gpio_bt_sys_rest_en, 1);
msleep(100);
} else {
gpio_set_value(gpio_bt_sys_rest_en, 0);
rc = <API key>(gpio_bt_sys_rest_en);
msleep(100);
gpio_free(gpio_bt_sys_rest_en);
if (ath_wlanbt_status == WLANOFF_BTON) {
<API key>(0);
ath_wlanbt_status = WLANOFF_BTOFF;
} else if (ath_wlanbt_status == WLANON_BTON)
ath_wlanbt_status = WLANON_BTOFF;
}
mutex_unlock(&ath_wlanbt_mutex);
pr_debug("%s on= %d, wlan_status= %d\n",
__func__, on, ath_wlanbt_status);
return 0;
};
static void __init bt_power_init(void)
{
msm_bt_power_device.dev.platform_data = &bluetooth_power;
return;
};
#else
#define bt_power_init(x) do {} while (0)
#endif
static struct platform_device *common_devices[] __initdata = {
&msm8960_device_dmov,
&msm_device_smd,
&msm_device_uart_dm6,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
#ifndef CONFIG_MSM_DSPS
&<API key>,
#endif
&msm_slim_ctrl,
&<API key>,
#if defined(CONFIG_BT) && defined(<API key>)
&<API key>,
&msm_bt_power_device,
&<API key>,
#endif
#if defined(CONFIG_QSEECOM)
&qseecom_device,
#endif
#if defined(<API key>) || \
defined(<API key>)
&qcrypto_device,
#endif
#if defined(<API key>) || \
defined(<API key>)
&qcedev_device,
#endif
#ifdef CONFIG_MSM_ROTATOR
&msm_rotator_device,
#endif
&msm_device_sps,
#ifdef <API key>
&fish_battery_device,
#endif
#ifdef CONFIG_BATTERY_BCL
&battery_bcl_device,
#endif
&msm8960_fmem_device,
#ifdef CONFIG_ANDROID_PMEM
#ifndef <API key>
&<API key>,
&<API key>,
&<API key>,
#endif
#endif
&msm_device_bam_dmux,
&<API key>,
#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
#ifdef <API key>
&msm_device_tsif[1],
#else
&msm_device_tsif[0],
#endif
#endif
&msm_device_tspp,
#ifdef <API key>
&msm_device_rng,
#endif
#ifdef CONFIG_ION_MSM
&msm8960_ion_dev,
#endif
&msm8960_rpm_device,
&<API key>,
&<API key>,
&<API key>,
&msm_device_tz_log,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&msm8960_rtb_device,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&msm_tsens_device,
};
static struct platform_device *cdp_devices[] __initdata = {
&msm_8960_q6_lpass,
&msm_8960_riva,
&msm_pil_tzapps,
&msm_pil_dsps,
&msm_pil_vidc,
&msm8960_device_otg,
&<API key>,
&<API key>,
&android_usb_device,
&msm_pcm,
&msm_multi_ch_pcm,
&msm_lowlatency_pcm,
&msm_pcm_routing,
&msm_cpudai0,
&msm_cpudai1,
&<API key>,
&<API key>,
&msm_cpudai_hdmi_rx,
&msm_cpudai_bt_rx,
&msm_cpudai_bt_tx,
&msm_cpudai_fm_rx,
&msm_cpudai_fm_tx,
&<API key>,
&<API key>,
&msm_cpu_fe,
&msm_stub_codec,
#ifdef CONFIG_MSM_GEMINI
&<API key>,
#endif
#ifdef CONFIG_MSM_MERCURY
&<API key>,
#endif
&msm_voice,
&msm_voip,
&msm_lpa_pcm,
&<API key>,
&<API key>,
&<API key>,
&<API key>,
&msm_pcm_afe,
&msm_compr_dsp,
&<API key>,
&<API key>,
&<API key>,
&msm_pcm_hostless,
&msm_bus_apps_fabric,
&msm_bus_sys_fabric,
&msm_bus_mm_fabric,
&msm_bus_sys_fpb,
&msm_bus_cpss_fpb,
};
#define MSM_GSBI4_PHYS 0x16300000
#define GSBI_DUAL_MODE_CODE 0x60
static void __init msm8960_i2c_init(void)
{
if (<API key>() == <API key>) {
/* Setting protocol code to 0x60 for dual UART/I2C in GSBI4 */
void *gsbi_mem = ioremap_nocache(MSM_GSBI4_PHYS, 4);
writel_relaxed(GSBI_DUAL_MODE_CODE, gsbi_mem);
mb();
iounmap(gsbi_mem);
<API key>.<API key> = 1;
<API key>.keep_ahb_clk_on = 1;
}
<API key>.dev.platform_data =
&<API key>;
<API key>.dev.platform_data =
&<API key>;
<API key>.dev.platform_data =
&<API key>;
<API key>.dev.platform_data =
&<API key>;
}
static void __init msm8960_gfx_init(void)
{
struct <API key> *kgsl_3d0_pdata =
msm_kgsl_3d0.dev.platform_data;
uint32_t <API key> = socinfo_get_version();
/* Fixup data that needs to change based on GPU ID */
if (cpu_is_msm8960ab()) {
kgsl_3d0_pdata->chipid = ADRENO_CHIPID(3, 2, 1, 0);
/* 8960PRO nominal clock rate is 325Mhz instead of 320Mhz */
kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 325000000;
} else {
kgsl_3d0_pdata->iommu_count = 1;
if (<API key>(<API key>) == 1) {
kgsl_3d0_pdata->pwrlevel[0].gpu_freq = 320000000;
kgsl_3d0_pdata->pwrlevel[1].gpu_freq = 266667000;
}
if (<API key>(<API key>) >= 3) {
/* 8960v3 GPU registers returns 5 for patch release
* but it should be 6, so dummy up the chipid here
* based the platform type
*/
kgsl_3d0_pdata->chipid = ADRENO_CHIPID(2, 2, 0, 6);
}
}
/* Register the 3D core */
<API key>(&msm_kgsl_3d0);
/* Register the 2D cores if we are not 8960PRO */
if (!cpu_is_msm8960ab()) {
<API key>(&msm_kgsl_2d0);
<API key>(&msm_kgsl_2d1);
}
}
static struct msm_rpmrs_level msm_rpmrs_levels[] = {
{
<API key>,
MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
true,
1, 784, 180000, 100,
},
{
<API key>,
MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
true,
415, 715, 340827, 475,
},
{
<API key>,
MSM_RPMRS_LIMITS(ON, ACTIVE, MAX, ACTIVE),
true,
1300, 228, 1200000, 2000,
},
{
<API key>,
MSM_RPMRS_LIMITS(ON, GDHS, MAX, ACTIVE),
false,
2000, 138, 1208400, 3200,
},
{
<API key>,
MSM_RPMRS_LIMITS(ON, HSFS_OPEN, ACTIVE, RET_HIGH),
false,
6000, 119, 1850300, 9000,
},
{
<API key>,
MSM_RPMRS_LIMITS(OFF, GDHS, MAX, ACTIVE),
false,
9200, 68, 2839200, 16400,
},
{
<API key>,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, MAX, ACTIVE),
false,
10300, 63, 3128000, 18200,
},
{
<API key>,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, ACTIVE, RET_HIGH),
false,
18000, 10, 4602600, 27000,
},
{
<API key>,
MSM_RPMRS_LIMITS(OFF, HSFS_OPEN, RET_HIGH, RET_LOW),
false,
20000, 2, 5752000, 32000,
},
};
static struct <API key> msm_rpmrs_data __initdata = {
.levels = &msm_rpmrs_levels[0],
.num_levels = ARRAY_SIZE(msm_rpmrs_levels),
.vdd_mem_levels = {
[<API key>] = 750000,
[<API key>] = 750000,
[<API key>] = 1050000,
[<API key>] = 1150000,
},
.vdd_dig_levels = {
[<API key>] = 500000,
[<API key>] = 750000,
[<API key>] = 950000,
[<API key>] = 1150000,
},
.vdd_mask = 0x7FFFFF,
.rpmrs_target_id = {
[<API key>] = MSM_RPM_ID_PXO_CLK,
[<API key>] = MSM_RPM_ID_LAST,
[<API key>] = <API key>,
[<API key>] = <API key>,
[<API key>] = <API key>,
[<API key>] = <API key>,
[<API key>] = MSM_RPM_ID_RPM_CTL,
},
};
static struct <API key> msm_pm_boot_pdata __initdata = {
.mode = <API key>,
};
#ifdef CONFIG_I2C
#define I2C_SURF 1
#define I2C_FFA (1 << 1)
#define I2C_RUMI (1 << 2)
#define I2C_SIM (1 << 3)
#define I2C_FLUID (1 << 4)
#define I2C_LIQUID (1 << 5)
struct i2c_registry {
u8 machs;
int bus;
struct i2c_board_info *info;
int len;
};
/* Sensors DSPS platform data */
#ifdef CONFIG_MSM_DSPS
#define <API key> "dsps"
#endif /* CONFIG_MSM_DSPS */
static void __init msm8960_init_dsps(void)
{
#ifdef CONFIG_MSM_DSPS
struct <API key> *pdata =
msm_dsps_device.dev.platform_data;
pdata->pil_name = <API key>;
pdata->gpios = NULL;
pdata->gpios_num = 0;
<API key>(&msm_dsps_device);
#endif /* CONFIG_MSM_DSPS */
}
static int <API key> = 1;
static DEFINE_MUTEX(hsic_status_lock);
void peripheral_connect()
{
mutex_lock(&hsic_status_lock);
if (<API key>)
goto out;
platform_device_add(&<API key>);
<API key> = 1;
out:
mutex_unlock(&hsic_status_lock);
}
EXPORT_SYMBOL(peripheral_connect);
void <API key>()
{
mutex_lock(&hsic_status_lock);
if (!<API key>)
goto out;
platform_device_del(&<API key>);
<API key> = 0;
out:
mutex_unlock(&hsic_status_lock);
}
EXPORT_SYMBOL(<API key>);
static void __init <API key>(void)
{
uint32_t version = socinfo_get_version();
if (<API key>(version) == 1)
return;
if (<API key>())
<API key>(&smsc_hub_device);
}
static void __init msm8960_init_hsic(void)
{
#ifdef <API key>
uint32_t version = socinfo_get_version();
if (<API key>(version) == 1)
return;
if (<API key>())
<API key>(&<API key>);
#endif
}
#ifdef <API key>
static struct isl_platform_data isl_data __initdata = {
.valid_n_gpio = 0, /* Not required when notify-by-pmic */
.<API key> = NULL, /* Not required when notify-by-pmic */
.max_system_voltage = 4200,
.min_system_voltage = 3200,
.chgcurrent = 1900,
.term_current = 0,
.input_current = 2048,
};
static struct i2c_board_info <API key>[] __initdata = {
{
I2C_BOARD_INFO("isl9519q", 0x9),
.irq = 0, /* Not required when notify-by-pmic */
.platform_data = &isl_data,
},
};
#endif /* <API key> */
static struct i2c_board_info <API key>[] __initdata = {
{
I2C_BOARD_INFO("sx1508q", 0x20),
.platform_data = &msm8960_sx150x_data[SX150X_LIQUID]
},
};
static struct i2c_registry msm8960_i2c_devices[] __initdata = {
#ifdef <API key>
{
I2C_LIQUID,
<API key>,
<API key>,
ARRAY_SIZE(<API key>),
},
#endif /* <API key> */
{
I2C_SURF | I2C_FFA | I2C_FLUID,
<API key>,
cyttsp_info,
ARRAY_SIZE(cyttsp_info),
},
{
I2C_LIQUID,
<API key>,
mxt_device_info,
ARRAY_SIZE(mxt_device_info),
},
{
I2C_SURF | I2C_FFA | I2C_LIQUID,
<API key>,
sii_device_info,
ARRAY_SIZE(sii_device_info),
},
{
I2C_LIQUID | I2C_FFA,
<API key>,
<API key>,
ARRAY_SIZE(<API key>),
},
{
I2C_LIQUID,
<API key>,
<API key>,
ARRAY_SIZE(<API key>),
},
};
#endif /* CONFIG_I2C */
static void __init <API key>(void)
{
#ifdef CONFIG_I2C
u8 mach_mask = 0;
int i;
#ifdef CONFIG_MSM_CAMERA
struct i2c_registry <API key> = {
I2C_SURF | I2C_FFA | I2C_FLUID | I2C_LIQUID | I2C_RUMI,
<API key>,
<API key>.board_info,
<API key>.num_i2c_board_info,
};
#endif
/* Build the matching 'supported_machs' bitmask */
if (<API key>())
mach_mask = I2C_SURF;
else if (<API key>())
mach_mask = I2C_FLUID;
else if (<API key>())
mach_mask = I2C_LIQUID;
else if (<API key>())
mach_mask = I2C_FFA;
else
pr_err("unmatched machine ID in <API key>\n");
if (<API key>()) {
if (<API key>(<API key>()) == 3)
mxt_device_info[0].platform_data =
&<API key>;
else
mxt_device_info[0].platform_data =
&<API key>;
}
/* Run the array and install devices as appropriate */
for (i = 0; i < ARRAY_SIZE(msm8960_i2c_devices); ++i) {
if (msm8960_i2c_devices[i].machs & mach_mask)
<API key>(msm8960_i2c_devices[i].bus,
msm8960_i2c_devices[i].info,
msm8960_i2c_devices[i].len);
}
if (!mhl_platform_data.gpio_mhl_power)
pr_debug("mhl device configured for ext debug board\n");
#ifdef CONFIG_MSM_CAMERA
if (<API key>.machs & mach_mask)
<API key>(<API key>.bus,
<API key>.info,
<API key>.len);
#endif
#endif
}
static void __init msm8960_tsens_init(void)
{
if (cpu_is_msm8960())
if (<API key>(socinfo_get_version()) == 1)
return;
<API key>(&msm_tsens_pdata);
}
static void __init msm8960_cdp_init(void)
{
if (meminfo_init(SYS_MEMORY, SZ_256M) < 0)
pr_err("meminfo_init() failed!\n");
<API key>(&msm_gpio_device);
msm8960_tsens_init();
msm_thermal_init(&msm_thermal_pdata);
BUG_ON(msm_rpm_init(&msm8960_rpm_data));
BUG_ON(<API key>(&msm_rpmrs_data));
<API key>();
if (msm_xo_init())
pr_err("Failed to initialize XO votes\n");
<API key>();
<API key>(&<API key>);
msm_clock_init(&<API key>);
if (<API key>())
msm_otg_pdata.mhl_enable = true;
msm8960_device_otg.dev.platform_data = &msm_otg_pdata;
if (<API key>() || <API key>() ||
<API key>()) {
/* Due to availability of USB Switch in SGLTE Platform
* it requires different HSUSB PHY settings compare to
* 8960 MTP/CDP platform.
*/
if (<API key>() == <API key>)
msm_otg_pdata.phy_init_seq = sglte_phy_init_seq;
else
msm_otg_pdata.phy_init_seq = wr_phy_init_seq;
} else if (<API key>()) {
msm_otg_pdata.phy_init_seq =
<API key>;
}
android_usb_pdata.swfi_latency =
msm_rpmrs_levels[0].latency_us;
<API key>.dev.platform_data = &msm_hsic_pdata;
if (<API key>(socinfo_get_version()) >= 2 &&
<API key>())
<API key>.dev.parent = &smsc_hub_device.dev;
<API key>();
<API key>.dev.platform_data =
&<API key>;
<API key>(spi_board_info, ARRAY_SIZE(spi_board_info));
if (<API key>() != <API key>)
<API key>(spi_eth_info, ARRAY_SIZE(spi_eth_info));
msm8960_init_pmic();
if (<API key>() || (<API key>() &&
(<API key>() == <API key>)))
<API key>[0].platform_data = &isa1200_1_pdata;
msm8960_i2c_init();
msm8960_gfx_init();
msm_spm_init(msm_spm_data, ARRAY_SIZE(msm_spm_data));
msm_spm_l2_init(msm_spm_l2_data);
msm8960_init_buses();
<API key>(msm8960_footswitch, <API key>);
if (<API key>())
<API key>(&<API key>);
if (<API key>())
<API key>(&<API key>);
if (<API key>() == <API key>)
<API key>(&<API key>);
else
<API key>(&<API key>);
/* For 8960 Fusion 2.2 Primary IPC */
if (<API key>() == <API key>) {
msm_uart_dm9_pdata.wakeup_irq = gpio_to_irq(94); /* GSBI9(2) */
msm_device_uart_dm9.dev.platform_data = &msm_uart_dm9_pdata;
<API key>(&msm_device_uart_dm9);
}
/* For 8960 Standalone External Bluetooth Interface */
if (<API key>() != <API key>) {
msm_device_uart_dm8.dev.platform_data = &msm_uart_dm8_pdata;
<API key>(&msm_device_uart_dm8);
}
if (cpu_is_msm8960ab())
<API key>(&<API key>);
else
<API key>(&<API key>);
<API key>(common_devices, ARRAY_SIZE(common_devices));
<API key>();
<API key>();
/* Don't add modem devices on APQ targets */
if (socinfo_get_id() != 124) {
<API key>(&msm_8960_q6_mss_fw);
<API key>(&msm_8960_q6_mss_sw);
}
<API key>(cdp_devices, ARRAY_SIZE(cdp_devices));
<API key>();
msm8960_init_hsic();
msm8960_init_mmc();
if (<API key>())
mxt_init_hw_liquid();
<API key>();
msm8960_init_fb();
<API key>(msm_slim_devices,
ARRAY_SIZE(msm_slim_devices));
msm8960_init_dsps();
change_memory_power = &<API key>;
BUG_ON(msm_pm_boot_init(&msm_pm_boot_pdata));
bt_power_init();
if (<API key>() == <API key>) {
mdm_sglte_device.dev.platform_data = &sglte_platform_data;
<API key>(&mdm_sglte_device);
}
<API key>(1);
}
MACHINE_START(MSM8960_CDP, "QCT MSM8960 CDP")
.map_io = msm8960_map_io,
.reserve = msm8960_reserve,
.init_irq = msm8960_init_irq,
.handle_irq = gic_handle_irq,
.timer = &msm_timer,
.init_machine = msm8960_cdp_init,
.init_early = <API key>,
.init_very_early = <API key>,
.restart = msm_restart,
MACHINE_END
MACHINE_START(MSM8960_MTP, "QCT MSM8960 MTP")
.map_io = msm8960_map_io,
.reserve = msm8960_reserve,
.init_irq = msm8960_init_irq,
.handle_irq = gic_handle_irq,
.timer = &msm_timer,
.init_machine = msm8960_cdp_init,
.init_early = <API key>,
.init_very_early = <API key>,
.restart = msm_restart,
MACHINE_END
MACHINE_START(MSM8960_FLUID, "QCT MSM8960 FLUID")
.map_io = msm8960_map_io,
.reserve = msm8960_reserve,
.init_irq = msm8960_init_irq,
.handle_irq = gic_handle_irq,
.timer = &msm_timer,
.init_machine = msm8960_cdp_init,
.init_early = <API key>,
.init_very_early = <API key>,
.restart = msm_restart,
MACHINE_END
MACHINE_START(MSM8960_LIQUID, "QCT MSM8960 LIQUID")
.map_io = msm8960_map_io,
.reserve = msm8960_reserve,
.init_irq = msm8960_init_irq,
.handle_irq = gic_handle_irq,
.timer = &msm_timer,
.init_machine = msm8960_cdp_init,
.init_early = <API key>,
.init_very_early = <API key>,
.restart = msm_restart,
MACHINE_END
|
#include <stdio_ext.h>
#include "libioP.h"
void
__fpurge (FILE *fp)
{
if (fp->_mode > 0)
{
/* Wide-char stream. */
if (_IO_in_backup (fp))
<API key> (fp);
fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
}
else
{
/* Byte stream. */
if (_IO_in_backup (fp))
<API key> (fp);
fp->_IO_read_end = fp->_IO_read_ptr;
fp->_IO_write_ptr = fp->_IO_write_base;
}
}
|
function c168917.initial_effect(c)
--spsummon
local e1=Effect.CreateEffect(c)
e1:SetDescription(aux.Stringid(168917,0))
e1:SetProperty(<API key>)
e1:SetCategory(<API key>)
e1:SetType(<API key>)
e1:SetCountLimit(1)
e1:SetRange(LOCATION_MZONE)
e1:SetTarget(c168917.sptg)
e1:SetOperation(c168917.spop)
c:RegisterEffect(e1)
end
function c168917.filter(c,e,tp)
return c:IsFaceup() and c:IsSetCard(0x30) and c:<API key>(e,0,tp,false,false,POS_FACEUP_DEFENSE)
end
function c168917.sptg(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:IsLocation(LOCATION_SZONE) and chkc:IsControler(tp) and c168917.filter(chkc,e,tp) end
if chk==0 then return Duel.GetLocationCount(tp,LOCATION_MZONE)>0
and Duel.IsExistingTarget(c168917.filter,tp,LOCATION_SZONE,0,1,nil,e,tp) end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
local g=Duel.SelectTarget(tp,c168917.filter,tp,LOCATION_SZONE,0,1,1,nil,e,tp)
Duel.SetOperationInfo(0,<API key>,g,1,0,0)
end
function c168917.spop(e,tp,eg,ep,ev,re,r,rp)
local tc=Duel.GetFirstTarget()
if tc:IsRelateToEffect(e) and Duel.SpecialSummon(tc,0,tp,tp,false,false,POS_FACEUP_DEFENSE)~=0 then
local e1=Effect.CreateEffect(e:GetHandler())
e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetCode(<API key>)
e1:SetReset(RESET_EVENT+RESETS_REDIRECT)
e1:SetValue(LOCATION_REMOVED)
tc:RegisterEffect(e1,true)
end
end
|
#include "../unit_fixture.h"
namespace testsuite
{
namespace classes
{
class variant: public unit_fixture
{
private:
typedef unit_fixture super;
protected:
public:
<API key>(variant)
{
TEST_CASE(getValue);
TEST_CASE(<API key>);
TEST_CASE(<API key>);
}
/**
* Test variant::getValue()
*
*
*/
void getValue();
/**
* Test variant::<API key>()
*
*
*/
void <API key>();
/**
* Test variant::<API key>()
*
*
*/
void <API key>();
};
REGISTER_FIXTURE(variant);
} /* namespace classes */
} /* namespace testsuite */
|
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
?>
<div id="<API key>">
<?php if($isMember){ ?>
<p><?php echo JText::_('<API key>'); ?></p>
<?php }else{ ?>
<p><?php echo JText::sprintf('<API key>', $event->title );?></p>
<?php } ?>
</div>
|
<?php
/**
* Test class for \Magento\Framework\View\Layout\Element
*/
namespace Magento\Framework\View\Test\Unit\Layout;
use \Magento\Framework\View\Layout\GeneratorPool;
use \Magento\Framework\View\Layout\ScheduledStructure;
use \Magento\Framework\View\Layout\Data\Structure as DataStructure;
class GeneratorPoolTest extends \<API key>
{
/**
* @var \Magento\Framework\View\Layout\ScheduledStructure\Helper|\<API key>
*/
protected $helperMock;
/**
* @var \Magento\Framework\View\Layout\Reader\Context|\<API key>
*/
protected $readerContextMock;
/**
* @var \Magento\Framework\View\Layout\Generator\Context|\<API key>
*/
protected $<API key>;
/**
* @var ScheduledStructure
*/
protected $scheduledStructure;
/**
* @var \Magento\Framework\View\Layout\Data\Structure|\<API key>
*/
protected $structureMock;
/**
* @var GeneratorPool
*/
protected $model;
/**
* @return void
*/
protected function setUp()
{
// ScheduledStructure
$this->readerContextMock = $this->getMockBuilder('Magento\Framework\View\Layout\Reader\Context')
-><API key>()
->getMock();
$this->scheduledStructure = new ScheduledStructure();
$this->readerContextMock->expects($this->any())->method('<API key>')
->willReturn($this->scheduledStructure);
// DataStructure
$this-><API key> = $this->getMockBuilder('Magento\Framework\View\Layout\Generator\Context')
-><API key>()
->getMock();
$this->structureMock = $this->getMockBuilder('Magento\Framework\View\Layout\Data\Structure')
-><API key>()
->setMethods(['reorderChildElement'])
->getMock();
$this-><API key>->expects($this->any())->method('getStructure')
->willReturn($this->structureMock);
$this->helperMock = $this->getMockBuilder('Magento\Framework\View\Layout\ScheduledStructure\Helper')
-><API key>()
->getMock();
$helperObjectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->model = $helperObjectManager->getObject(
'Magento\Framework\View\Layout\GeneratorPool',
[
'helper' => $this->helperMock,
'generators' => $this->getGeneratorsMocks()
]
);
}
/**
* @return \<API key>[]
*/
protected function getGeneratorsMocks()
{
$firstGenerator = $this->getMock('Magento\Framework\View\Layout\GeneratorInterface');
$firstGenerator->expects($this->any())->method('getType')->willReturn('first_generator');
$firstGenerator->expects($this->atLeastOnce())->method('process');
$secondGenerator = $this->getMock('Magento\Framework\View\Layout\GeneratorInterface');
$secondGenerator->expects($this->any())->method('getType')->willReturn('second_generator');
$secondGenerator->expects($this->atLeastOnce())->method('process');
return [$firstGenerator, $secondGenerator];
}
/**
* @param array $schedule
* @param array $expectedSchedule
* @return void
* @dataProvider processDataProvider
*/
public function testProcess($schedule, $expectedSchedule)
{
foreach ($schedule['structure'] as $structureElement) {
$this->scheduledStructure->setStructureElement($structureElement, []);
}
$reorderMap = [];
foreach ($schedule['sort'] as $elementName => $sort) {
list($parentName, $sibling, $isAfter) = $sort;
$this->scheduledStructure-><API key>($parentName, $elementName, $sibling, $isAfter);
$reorderMap[] = [$parentName, $elementName, $sibling, $isAfter];
}
foreach ($schedule['move'] as $elementName => $move) {
$this->scheduledStructure->setElementToMove($elementName, $move);
list($destination, $sibling, $isAfter) = $move;
$reorderMap[] = [$destination, $elementName, $sibling, $isAfter];
}
$invocation = $this->structureMock->expects($this->any())->method('reorderChildElement');
<API key>([$invocation, 'withConsecutive'], $reorderMap);
foreach ($schedule['remove'] as $remove) {
$this->scheduledStructure-><API key>($remove);
}
$this->helperMock->expects($this->atLeastOnce())->method('scheduleElement')
->with($this->scheduledStructure, $this->structureMock, $this->anything())
->willReturnCallback(function ($scheduledStructure, $structure, $elementName) use ($schedule) {
/**
* @var $scheduledStructure ScheduledStructure
* @var $structure DataStructure
*/
$this->assertContains($elementName, $schedule['structure']);
$scheduledStructure-><API key>($elementName);
$scheduledStructure->setElement($elementName, []);
$structure-><API key>($elementName, 'block', 'someClass');
});
$this->model->process($this->readerContextMock, $this-><API key>);
$this->assertEquals($expectedSchedule, $this->scheduledStructure->getElements());
}
/**
* Data provider fo testProcess
*
* @return array
*/
public function processDataProvider()
{
return [
[
'schedule' => [
'structure' => [
'first.element',
'second.element',
'third.element',
'remove.element',
'sort.element',
],
'move' => [
'third.element' => ['second.element', 'sibling', false, 'alias'],
],
'remove' => ['remove.element'],
'sort' => [
'sort.element' => ['second.element', 'sibling', false, 'alias'],
],
],
'<API key>' => [
'first.element' => [], 'second.element' => [], 'third.element' => [], 'sort.element' => []
],
],
];
}
}
|
<?php
require_once dirname(__FILE__).'/IFestiEngine.php';
abstract class FestiPlugin implements IFestiEngine
{
protected $_wpUrl;
protected $_wpPluginsUrl;
protected $_pluginDirName;
protected $_pluginMainFile;
protected $_pluginPath;
protected $_pluginUrl;
protected $_pluginCachePath;
protected $_pluginCacheUrl;
protected $_pluginStaticPath;
protected $_pluginStaticUrl;
protected $_pluginCssPath;
protected $_pluginCssUrl;
protected $_pluginImagesPath;
protected $_pluginImagesUrl;
protected $_pluginJsPath;
protected $_pluginJsUrl;
protected $_pluginTemplatePath;
protected $_pluginTemplateUrl;
protected $<API key>;
protected $_pluginLanguagesUrl;
protected $_languageDomain = '';
protected $_optionsPrefix = '';
protected $_fileSystem = '';
public function __construct($pluginMainFile)
{
$this->_wpUrl = get_site_url();
$this->_wpUrl = $this->makeUniversalLink($this->_wpUrl);
$this->_wpPluginsUrl = plugins_url('/');
$this->_wpPluginsUrl = $this->makeUniversalLink($this->_wpPluginsUrl);
$this->_pluginDirName = plugin_basename(dirname($pluginMainFile)).'/';
$this->_pluginMainFile = $pluginMainFile;
$this->_pluginPath = plugin_dir_path($pluginMainFile);
$this->_pluginUrl = plugins_url('/', $pluginMainFile);
$this->_pluginUrl = $this->makeUniversalLink($this->_pluginUrl);
$this->_pluginCachePath = $this->_pluginPath.'cache/';
$this->_pluginCacheUrl = $this->_pluginUrl.'cache/';
$this->_pluginStaticPath = $this->_pluginPath.'static/';
$this->_pluginStaticUrl = $this->_pluginUrl.'static/';
$this->_pluginCssPath = $this->_pluginStaticPath.'styles/';
$this->_pluginCssUrl = $this->_pluginStaticUrl.'styles/';
$this->_pluginImagesPath = $this->_pluginStaticPath.'images/';
$this->_pluginImagesUrl = $this->_pluginStaticUrl.'images/';
$this->_pluginJsPath = $this->_pluginStaticPath.'js/';
$this->_pluginJsUrl = $this->_pluginStaticUrl.'js/';
$this->_pluginTemplatePath = $this->_pluginPath.'templates/';
$this->_pluginTemplateUrl = $this->_pluginUrl.'templates/';
$this-><API key> = $this->_pluginDirName.'languages/';
$this->onInit();
} // end __construct
public function makeUniversalLink($url = '')
{
$protocols = array(
'http:',
'https:'
);
foreach ($protocols as $protocol) {
$url = str_replace($protocol, '', $url);
}
return $url;
} // end makeUniversalLink
protected function onInit()
{
<API key>(
$this->_pluginMainFile,
array(&$this, 'onInstall')
);
<API key>(
$this->_pluginMainFile,
array(&$this, 'onUninstall')
);
if (defined('WP_BLOG_ADMIN')) {
$this->onBackendInit();
} else {
$this->onFrontendInit();
}
} // end onInit
protected function onBackendInit()
{
} // end onBackendInit
protected function onFrontendInit()
{
} // end onFrontendInit
public function onInstall()
{
} // end onInstall
public function onUninstall()
{
} // end onUninstall
public function getLanguageDomain()
{
return $this->_languageDomain;
} // end getLanguageDomain
public function getPluginPath()
{
return $this->_pluginPath;
} // end getPluginPath
public function getPluginCachePath($fileName)
{
return $this->_pluginCachePath.$fileName.'.php';
} // end getPluginCachePath
public function getPluginStaticPath($fileName)
{
return $this->_pluginStaticPath.$fileName;
} // end pluginStaticPath
public function getPluginCssPath($fileName)
{
return $this->_pluginCssPath.$fileName;
} // end pluginCssPath
public function getPluginImagesPath($fileName)
{
return $this->_pluginImagesPath.$fileName;
} // end pluginImagesPath
public function getPluginJsPath($fileName)
{
return $this->_pluginJsPath.$fileName;
} // end pluginJsPath
public function <API key>($fileName)
{
return $this->_pluginTemplatePath.$fileName;
} // end <API key>
public function <API key>()
{
return $this-><API key>;
} // end <API key>
public function getPluginUrl()
{
return $this->_pluginUrl;
} // end getPluginUrl
public function getPluginCacheUrl()
{
return $this->_pluginCacheUrl;
} // end getPluginCacheUrl
public function getPluginStaticUrl()
{
return $this->_pluginStaticUrl;
} // end getPluginStaticUrl
public function getPluginCssUrl($fileName)
{
return $this->_pluginCssUrl.$fileName;
} // end getPluginCssUrl
public function getPluginImagesUrl($fileName)
{
return $this->_pluginImagesUrl.$fileName;
} // end getPluginImagesUrl
public function getPluginJsUrl($fileName)
{
return $this->_pluginJsUrl.$fileName;
} // end getPluginJsUrl
public function <API key>($fileName)
{
return $this->_pluginTemplateUrl.$fileName;
} // end <API key>
public function isPluginActive($pluginMainFilePath)
{
if (is_multisite())
{
$activPlugins = get_site_option('<API key>');
$result = array_key_exists($pluginMainFilePath, $activPlugins);
if ($result) {
return true;
}
}
$activPlugins = get_option('active_plugins');
return in_array($pluginMainFilePath, $activPlugins);
} // end isPluginActive
public function addActionListener(
$hook, $method, $priority = 10, $acceptedArgs = 1
)
{
add_action($hook, array(&$this, $method), $priority, $acceptedArgs);
} // end addActionListener
public function addFilterListener(
$hook, $method, $priority = 10, $acceptedArgs = 1
)
{
add_filter($hook, array(&$this, $method), $priority, $acceptedArgs);
} // end addFilterListener
public function <API key>($tag, $method)
{
add_shortcode(
$tag,
array(&$this, $method)
);
} // end <API key>
public function getOptions($optionName)
{
$options = $this->getCache($optionName);
if (!$options){
$options = get_option($this->_optionsPrefix.$optionName);
}
$options = json_decode($options, true);
return $options;
} // end getOptions
public function getCache($fileName)
{
$file = $this->getPluginCachePath($fileName);
if (!file_exists($file)) {
return false;
}
$content = include($file);
return $content;
} //end getCache
public function updateOptions($optionName, $values = array())
{
$values = $this-><API key>($values);
$value = json_encode($values);
update_option($this->_optionsPrefix.$optionName, $value);
$result = $this->updateCacheFile($optionName, $value);
return $result;
} // end updateOptions
private function <API key>($options = array())
{
foreach ($options as $key => $value) {
if (is_string($value)) {
$result = str_replace("'", '"', $value);
$options[$key] = stripslashes($result);
}
}
return $options;
} // end <API key>
public function updateCacheFile($fileName, $values)
{
if (!$this->_fileSystem) {
$this->_fileSystem = $this-><API key>();
}
if (!$this->_fileSystem) {
return false;
}
if (!$this->_fileSystem->is_writable($this->_pluginCachePath)) {
return false;
}
$content = "<?php return '".$values."';";
$filePath = $this->getPluginCachePath($fileName);
$this->_fileSystem->put_contents($filePath, $content, 0777);
} //end updateCacheFile
public function &<API key>($method = 'direct')
{
$wpFileSystem = false;
if ($this-><API key>()) {
$wpFileSystem = $GLOBALS['wp_filesystem'];
}
if (!$wpFileSystem) {
define('FS_METHOD', $method);
WP_Filesystem();
$wpFileSystem = $GLOBALS['wp_filesystem'];
}
return $wpFileSystem;
} // end doWriteCacheToFile
private function <API key>()
{
return array_key_exists('wp_filesystem', $GLOBALS);
} // end <API key>
public function <API key>($handle, $file = '', $deps = '')
{
$version = '';
$inFooter = '';
$args = func_get_args();
if (isset($args[3])) {
$version = $args[3];
}
if (isset($args[4])) {
$inFooter = $args[4];
}
$src = '';
if ($file) {
$src = $this->getPluginJsUrl($file);
}
if ($deps) {
$deps = array($deps);
}
wp_enqueue_script($handle, $src, $deps, $version, $inFooter);
} // end <API key>
public function <API key>(
$handle, $file = false, $deps = array()
)
{
$version = false;
$media = 'all';
$args = func_get_args();
if (isset($args[3])) {
$version = $args[3];
}
if (isset($args[4])) {
$media = $args[4];
}
$src = '';
if ($file) {
$src = $this->getPluginCssUrl($file);
}
if ($deps) {
$deps = array($deps);
}
wp_enqueue_style($handle, $src, $deps, $version, $media);
} // end <API key>
public function fetch($template, $vars = array())
{
if ($vars) {
extract($vars);
}
ob_start();
$templatePath = $this-><API key>($template);
include $templatePath;
$content = ob_get_clean();
return $content;
} // end fetch
public function getUrl()
{
$url = $_SERVER['REQUEST_URI'];
$args = func_get_args();
if (!$args) {
return $url;
}
if (!is_array($args[0])) {
$url = $args[0];
$args = array_slice($args, 1);
}
if (isset($args[0]) && is_array($args[0])) {
$data = parse_url($url);
if (array_key_exists('query', $data)) {
$url = $data['path'];
parse_str($data['query'], $params);
foreach ($args[0] as $key => $value) {
if ($value != '') {
continue;
}
unset($args[0][$key]);
if (array_key_exists($key, $params)) {
unset($params[$key]);
}
}
$args[0] = array_merge($params, $args[0]);
}
$seperator = preg_match("#\?#Umis", $url) ? '&' : '?';
$url .= $seperator.http_build_query($args[0]);
}
return $url;
} // end getUrl
public function displayError($error)
{
$this->displayMessage($error, 'error');
} // end displayError
public function displayUpdate($text)
{
$this->displayMessage($text, 'updated');
} // end displayUpdate
public function displayMessage($text, $type)
{
$message = __(
$text,
$this->_languageDomain
);
$template = 'message.phtml';
$vars = array(
'type' => $type,
'message' => $message
);
echo $this->fetch($template, $vars);
}// end displayMessage
}
|
/* Implementation of root handler */
/* Date Ver Who Comment */
/* 09.03.15 1.00 Lad Created */
#define __CASCLIB_SELF__
#include "../CascLib.h"
#include "../CascCommon.h"
// Common support
int RootHandler_Insert(TRootHandler * pRootHandler, const char * szFileName, LPBYTE pbEncodingKey)
{
if(pRootHandler == NULL || pRootHandler->Insert == NULL)
return ERROR_NOT_SUPPORTED;
return pRootHandler->Insert(pRootHandler, szFileName, pbEncodingKey);
}
LPBYTE RootHandler_Search(TRootHandler * pRootHandler, struct _TCascSearch * pSearch, PDWORD PtrFileSize, PDWORD PtrLocaleFlags, PDWORD PtrFileDataId)
{
// Check if the root structure is valid at all
if(pRootHandler == NULL)
return NULL;
return pRootHandler->Search(pRootHandler, pSearch, PtrFileSize, PtrLocaleFlags, PtrFileDataId);
}
void <API key>(TRootHandler * pRootHandler, struct _TCascSearch * pSearch)
{
// Check if the root structure is valid at all
if(pRootHandler != NULL)
{
pRootHandler->EndSearch(pRootHandler, pSearch);
}
}
LPBYTE RootHandler_GetKey(TRootHandler * pRootHandler, const char * szFileName)
{
// Check if the root structure is valid at all
if(pRootHandler == NULL)
return NULL;
return pRootHandler->GetKey(pRootHandler, szFileName);
}
void RootHandler_Dump(TCascStorage * hs, LPBYTE pbRootHandler, DWORD cbRootHandler, const TCHAR * szNameFormat, const TCHAR * szListFile, int nDumpLevel)
{
TDumpContext * dc;
// Only if the ROOT provider suports the dump option
if(hs->pRootHandler != NULL && hs->pRootHandler->Dump != NULL)
{
// Create the dump file
dc = CreateDumpContext(hs, szNameFormat);
if(dc != NULL)
{
// Dump the content and close the file
hs->pRootHandler->Dump(hs, dc, pbRootHandler, cbRootHandler, szListFile, nDumpLevel);
dump_close(dc);
}
}
}
void RootHandler_Close(TRootHandler * pRootHandler)
{
// Check if the root structure is allocated at all
if(pRootHandler != NULL)
{
pRootHandler->Close(pRootHandler);
}
}
DWORD <API key>(TRootHandler * pRootHandler, const char * szFileName)
{
// Check if the root structure is valid at all
if(pRootHandler == NULL)
return NULL;
return pRootHandler->GetFileId(pRootHandler, szFileName);
}
|
using System;
using System.Collections;
namespace Brunet.Applications {
/**
<summary>Determines the current operating system, between Linux and
Windows. This is a static class unified class rather than have other
parts of the code look at Environment.OSVersion.Platform and figure
information from there.</summary>
*/
public class OSDependent {
<summary>Operating System enumeration</summary>
public enum OS {
Linux = 0,
Windows = 1
}
<summary>Contains the current operating system.</summary>
public static readonly OS OSVersion;
<summary>Static constructor to setup OSVersion</summary>
static OSDependent() {
int p = (int) Environment.OSVersion.Platform;
if ((p == 4) || (p == 128)) {
OSVersion = OS.Linux;
}
else {
OSVersion = OS.Windows;
}
}
}
}
|
<?php
defined('_JEXEC') or die( 'Restricted access' );
jimport('joomla.filesystem.file');
jimport('joomla.installer.helper');
require_once(JPATH_ROOT.DS.'administrator'.DS.'components'.DS.'com_imageshow'.DS.'classes'.DS.'jsn_is_installer.php');
class JSNISInstallPackage extends JObject {
var $_tmpFolder;
var $_packageExtracts;
var $_methods;
var $_error = false;
var $_msgError = '';
var $_config;
function __construct()
{
$this->_config = JFactory::getConfig();
$this->_tmpFolder = $this->_config->getValue('config.tmp_path');
parent::__construct();
}
function install($packagePath)
{
$this->_packagePath = $packagePath;
if (!JFile::exists($this->_packagePath)) {
$this->_msgError = JText::_('<API key>');
$this->_error = true;
return false;
}
$this->_unpackPackage();
$this->_installPackage();
return true;
}
function _unpackPackage()
{
$this->_packageExtract = JInstallerHelper::unpack($this->_packagePath);
}
function _installPackage()
{
return true;
}
/**
* check fille will be uploaded
* @return true/false
*/
function checkFileUpload()
{
if (!is_array($this->_fileInfo))
{
JError::raiseWarning('SOME_ERROR_CODE', JText::_('<API key>'));
return false;
}
if ($this->_fileInfo['error'] || $this->_fileInfo['size'] < 1)
{
JError::raiseWarning('SOME_ERROR_CODE', JText::_('<API key>'));
return false;
}
return true;
}
/**
* upload fille
* @return file path or false on failure
*/
function uploadFile()
{
if ($this->checkFileUpload())
{
$tmpDEST = $this->_config->getValue('config.tmp_path').DS.$this->_fileInfo['name'];
$tmpSRC = $this->_fileInfo['tmp_name'];
jimport('joomla.filesystem.file');
if (JFile::upload($tmpSRC, $tmpDEST)) {
return $this->_packagePath = $tmpDEST;
} else {
return false;
}
}
return false;
}
/**
*
* install manual jns plugins
* @param $fileinfo get from Jrequest type = files
* @return true/false
*/
function installManual($fileInfo = null)
{
if (!is_array($fileInfo)) return false;
$this->_fileInfo = $fileInfo;
if ($this->uploadFile())
{
$this->_unpackPackage();
$this->_installPackage();
return true;
}
return false;
}
}
|
#include "<API key>.h"
const unsigned int TIMES_WIDTH = 300U;
const unsigned int BORDER_SIZE = 5U;
<API key>::<API key>(wxWindow* parent, int id, const wxString& title, unsigned int timeout, unsigned int ackTime, unsigned int frameWaitTime) :
wxPanel(parent, id),
m_title(title),
m_timeout(NULL),
m_ackTime(NULL),
m_frameWaitTime(NULL)
{
wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
wxStaticText* timeoutLabel = new wxStaticText(this, -1, _("Timeout (secs)"));
sizer->Add(timeoutLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
m_timeout = new wxSlider(this, -1, timeout, 0, 300, wxDefaultPosition, wxSize(TIMES_WIDTH, -1), wxSL_HORIZONTAL | wxSL_LABELS);
sizer->Add(m_timeout, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
wxStaticText* ackTimeLabel = new wxStaticText(this, -1, _("Ack Time (ms)"));
sizer->Add(ackTimeLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
if (ackTime < 100U)
ackTime = 500U;
m_ackTime = new wxSlider(this, -1, ackTime, 100, 2000, wxDefaultPosition, wxSize(TIMES_WIDTH, -1), wxSL_HORIZONTAL | wxSL_LABELS);
sizer->Add(m_ackTime, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
wxStaticText* frameWaitTimeLabel = new wxStaticText(this, -1, _("Frame Wait Time (ms)"));
sizer->Add(frameWaitTimeLabel, 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE);
m_frameWaitTime = new wxSlider(this, -1, frameWaitTime, 10, 500, wxDefaultPosition, wxSize(TIMES_WIDTH, -1), wxSL_HORIZONTAL | wxSL_LABELS);
sizer->Add(m_frameWaitTime, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE);
SetAutoLayout(true);
SetSizer(sizer);
}
<API key>::~<API key>()
{
}
bool <API key>::Validate()
{
return true;
}
unsigned int <API key>::getTimeout() const
{
return m_timeout->GetValue();
}
unsigned int <API key>::getAckTime() const
{
return m_ackTime->GetValue();
}
unsigned int <API key>::getFrameWaitTime() const
{
return m_frameWaitTime->GetValue();
}
|
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/list.h>
#include <linux/cdev.h>
#include <linux/init.h>
#include <linux/io.h>
#include <linux/device.h>
#include <linux/sched.h>
#include <linux/pm_runtime.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/delay.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/poll.h>
#include <linux/wait.h>
#include <linux/bitops.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/rpm-smd-regulator.h>
#include <linux/msm-sps.h>
#include <linux/wakelock.h>
#include <linux/timer.h>
#include <linux/jiffies.h>
#include <linux/qcom_tspp.h>
#include <linux/debugfs.h>
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/string.h>
#include <linux/msm-bus.h>
#include <linux/interrupt.h>
#define TSPP_TSIF_INSTANCES 2
#define TSPP_GPIOS_PER_TSIF 4
#define TSPP_FILTER_TABLES 3
#define TSPP_MAX_DEVICES 1
#define TSPP_NUM_CHANNELS 16
#define TSPP_NUM_PRIORITIES 16
#define TSPP_NUM_KEYS 8
#define INVALID_CHANNEL 0xFFFFFFFF
#define <API key> (8 * 1024 - 1)
#define TSPP_PACKET_LENGTH 188
#define <API key> (TSPP_PACKET_LENGTH)
#define <API key> (32 * 1024 - 1)
#define TSPP_USE_DMA_POOL(buff_size) ((buff_size) < PAGE_SIZE)
#define TSPP_NUM_BUFFERS (<API key> - 1)
#define <API key> 60
#define SPS_DESCRIPTOR_SIZE 8
#define <API key> 2
#define TSPP_DEBUG(msg...)
#define TSIF_STS_CTL_OFF (0x0)
#define TSIF_TIME_LIMIT_OFF (0x4)
#define TSIF_CLK_REF_OFF (0x8)
#define TSIF_LPBK_FLAGS_OFF (0xc)
#define TSIF_LPBK_DATA_OFF (0x10)
#define TSIF_TEST_CTL_OFF (0x14)
#define TSIF_TEST_MODE_OFF (0x18)
#define TSIF_TEST_RESET_OFF (0x1c)
#define <API key> (0x20)
#define <API key> (0x24)
#define TSIF_DATA_PORT_OFF (0x100)
#define TSIF_STS_CTL_EN_IRQ BIT(28)
#define <API key> BIT(27)
#define <API key> BIT(26)
#define <API key> BIT(25)
#define <API key> BIT(24)
#define <API key> BIT(23)
#define <API key> BIT(21)
#define <API key> BIT(20)
#define <API key> BIT(19)
#define <API key> BIT(18)
#define <API key> BIT(17)
#define <API key> BIT(16)
#define TSIF_STS_CTL_SPARE BIT(15)
#define <API key> BIT(11)
#define <API key> BIT(10)
#define <API key> BIT(9)
#define <API key> BIT(8)
#define TSIF_STS_CTL_EN_TCR BIT(7)
#define <API key> BIT(6)
#define TSIF_STS_CTL_MODE_2 BIT(5)
#define TSIF_STS_CTL_EN_DM BIT(4)
#define TSIF_STS_CTL_STOP BIT(3)
#define TSIF_STS_CTL_START BIT(0)
#define TSPP_RST 0x00
#define TSPP_CLK_CONTROL 0x04
#define TSPP_CONFIG 0x08
#define TSPP_CONTROL 0x0C
#define TSPP_PS_DISABLE 0x10
#define TSPP_MSG_IRQ_STATUS 0x14
#define TSPP_MSG_IRQ_MASK 0x18
#define TSPP_IRQ_STATUS 0x1C
#define TSPP_IRQ_MASK 0x20
#define TSPP_IRQ_CLEAR 0x24
#define <API key>(_n) (0x28 + (_n << 2))
#define TSPP_STATUS 0x68
#define <API key> 0x6C
#define <API key> 0x70
#define TSPP_SYSTEM_KEY(_n) (0x74 + (_n << 2))
#define TSPP_CBC_INIT_VAL(_n) (0x94 + (_n << 2))
#define TSPP_DATA_KEY_RESET 0x9C
#define TSPP_KEY_VALID 0xA0
#define TSPP_KEY_ERROR 0xA4
#define TSPP_TEST_CTRL 0xA8
#define TSPP_VERSION 0xAC
#define TSPP_GENERICS 0xB0
#define TSPP_NOP 0xB4
#define TSPP_RST_RESET BIT(0)
#define <API key> BIT(9)
#define <API key> BIT(8)
#define <API key> BIT(7)
#define <API key> BIT(6)
#define <API key> BIT(5)
#define <API key> BIT(4)
#define <API key> BIT(3)
#define <API key> BIT(2)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define <API key>(_a, _b) (_a = (_a & 0xF0) | \
((_b & 0xF) << 8))
#define <API key>(_a) ((_a >> 8) & 0xF)
#define <API key> BIT(7)
#define <API key> BIT(6)
#define <API key> BIT(5)
#define <API key> BIT(4)
#define <API key> BIT(3)
#define <API key> BIT(2)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define <API key> BIT(5)
#define <API key> BIT(4)
#define <API key> BIT(3)
#define <API key> BIT(2)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define TSPP_MSG_TSPP_IRQ BIT(2)
#define TSPP_MSG_TSIF_1_IRQ BIT(1)
#define TSPP_MSG_TSIF_0_IRQ BIT(0)
#define <API key> BIT(19)
#define <API key> BIT(18)
#define <API key> BIT(17)
#define <API key> BIT(16)
#define <API key>(_n) BIT((_n))
#define <API key> BIT(3)
#define <API key> BIT(2)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define <API key> BIT(10)
#define <API key> BIT(6)
#define <API key> BIT(2)
#define <API key> BIT(0)
#define <API key> BIT(12)
#define <API key> BIT(7)
#define <API key> BIT(2)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define <API key> 0x800
#define <API key> 0x880
#define <API key> 0x900
#define <API key> 0x980
#define TSPP_PIPE_CONTEXT 0x990
#define <API key> 0x998
#define TSPP_TSP_BUFF_WORD(_n) (0xC10 + (_n << 2))
#define TSPP_DATA_KEY 0xCD0
struct debugfs_entry {
const char *name;
mode_t mode;
int offset;
};
static const struct debugfs_entry debugfs_tsif_regs[] = {
{"sts_ctl", S_IRUGO | S_IWUSR, TSIF_STS_CTL_OFF},
{"time_limit", S_IRUGO | S_IWUSR, TSIF_TIME_LIMIT_OFF},
{"clk_ref", S_IRUGO | S_IWUSR, TSIF_CLK_REF_OFF},
{"lpbk_flags", S_IRUGO | S_IWUSR, TSIF_LPBK_FLAGS_OFF},
{"lpbk_data", S_IRUGO | S_IWUSR, TSIF_LPBK_DATA_OFF},
{"test_ctl", S_IRUGO | S_IWUSR, TSIF_TEST_CTL_OFF},
{"test_mode", S_IRUGO | S_IWUSR, TSIF_TEST_MODE_OFF},
{"test_reset", S_IWUSR, TSIF_TEST_RESET_OFF},
{"test_export", S_IRUGO | S_IWUSR, <API key>},
{"test_current", S_IRUGO, <API key>},
{"data_port", S_IRUSR, TSIF_DATA_PORT_OFF},
};
static const struct debugfs_entry debugfs_tspp_regs[] = {
{"rst", S_IRUGO | S_IWUSR, TSPP_RST},
{"clk_control", S_IRUGO | S_IWUSR, TSPP_CLK_CONTROL},
{"config", S_IRUGO | S_IWUSR, TSPP_CONFIG},
{"control", S_IRUGO | S_IWUSR, TSPP_CONTROL},
{"ps_disable", S_IRUGO | S_IWUSR, TSPP_PS_DISABLE},
{"msg_irq_status", S_IRUGO | S_IWUSR, TSPP_MSG_IRQ_STATUS},
{"msg_irq_mask", S_IRUGO | S_IWUSR, TSPP_MSG_IRQ_MASK},
{"irq_status", S_IRUGO | S_IWUSR, TSPP_IRQ_STATUS},
{"irq_mask", S_IRUGO | S_IWUSR, TSPP_IRQ_MASK},
{"irq_clear", S_IRUGO | S_IWUSR, TSPP_IRQ_CLEAR},
{"status", S_IRUGO | S_IWUSR, TSPP_STATUS},
{"curr_tsp_header", S_IRUGO | S_IWUSR, <API key>},
{"curr_pid_filter", S_IRUGO | S_IWUSR, <API key>},
{"data_key_reset", S_IRUGO | S_IWUSR, TSPP_DATA_KEY_RESET},
{"key_valid", S_IRUGO | S_IWUSR, TSPP_KEY_VALID},
{"key_error", S_IRUGO | S_IWUSR, TSPP_KEY_ERROR},
{"test_ctrl", S_IRUGO | S_IWUSR, TSPP_TEST_CTRL},
{"version", S_IRUGO | S_IWUSR, TSPP_VERSION},
{"generics", S_IRUGO | S_IWUSR, TSPP_GENERICS},
{"pid_filter_table0", S_IRUGO | S_IWUSR, <API key>},
{"pid_filter_table1", S_IRUGO | S_IWUSR, <API key>},
{"pid_filter_table2", S_IRUGO | S_IWUSR, <API key>},
{"tsp_total_num", S_IRUGO | S_IWUSR, <API key>},
{"tsp_ignored_num", S_IRUGO | S_IWUSR, <API key> + 4},
{"tsp_err_ind_num", S_IRUGO | S_IWUSR, <API key> + 8},
{"tsp_sync_err_num", S_IRUGO | S_IWUSR, <API key> + 16},
{"pipe_context", S_IRUGO | S_IWUSR, TSPP_PIPE_CONTEXT},
{"pipe_performance", S_IRUGO | S_IWUSR, <API key>},
{"data_key", S_IRUGO | S_IWUSR, TSPP_DATA_KEY}
};
struct tspp_pid_filter {
u32 filter;
u32 config;
};
#define <API key> BIT(7)
#define <API key> BIT(6)
#define <API key> BIT(5)
#define FILTER_DECRYPT BIT(4)
#define <API key>(_p) (_p->config & FILTER_DECRYPT)
#define <API key>(_p) (_p->config & 0xF)
#define <API key>(_p, _b) (_p->config = \
(_p->config & ~0xF) | (_b & 0xF))
#define <API key>(_p) ((_p->filter >> 30) & 0x3)
#define <API key>(_p, _b) (_p->filter = \
(_p->filter & ~(0x3<<30)) | ((_b & 0x3) << 30))
#define FILTER_GET_PIPE_PID(_p) ((_p->filter >> 13) & 0x1FFF)
#define FILTER_SET_PIPE_PID(_p, _b) (_p->filter = \
(_p->filter & ~(0x1FFF<<13)) | ((_b & 0x1FFF) << 13))
#define FILTER_GET_PID_MASK(_p) (_p->filter & 0x1FFF)
#define FILTER_SET_PID_MASK(_p, _b) (_p->filter = \
(_p->filter & ~0x1FFF) | (_b & 0x1FFF))
#define <API key>(_p) ((_p->config >> 30) & 0x3)
#define <API key>(_p, _b) (_p->config = \
(_p->config & ~(0x3<<30)) | ((_b & 0x3) << 30))
#define <API key>(_p) ((_p->config >> 8) & 0x7)
#define <API key>(_p, _b) (_p->config = \
(_p->config & ~(0x7<<8)) | ((_b & 0x7) << 8))
struct <API key> {
u32 tsp_total;
u32 tsp_ignored;
u32 tsp_error;
u32 tsp_sync;
};
struct <API key> {
u16 pes_bytes_left;
u16 count;
u32 tsif_suffix;
} __packed;
#define CONTEXT_GET_STATE(_a) (_a & 0x3)
#define <API key> BIT(11)
#define <API key>(_a) ((_a >> 12) & 0xF)
#define MSEC_TO_JIFFIES(msec) ((msec) * HZ / 1000)
struct <API key> {
u32 tsp_total;
u32 ps_duplicate_tsp;
u32 tsp_no_payload;
u32 tsp_broken_ps;
u32 ps_total_num;
u32 ps_continuity_error;
u32 ps_length_error;
u32 pes_sync_error;
};
struct tspp_tsif_device {
void __iomem *base;
u32 time_limit;
u32 ref_count;
enum tspp_tsif_mode mode;
int clock_inverse;
int data_inverse;
int sync_inverse;
int enable_inverse;
u32 tsif_irq;
struct dentry *dent_tsif;
struct dentry *debugfs_tsif_regs[ARRAY_SIZE(debugfs_tsif_regs)];
u32 stat_rx;
u32 stat_overflow;
u32 stat_lost_sync;
u32 stat_timeout;
};
enum tspp_buf_state {
<API key>,
<API key>,
TSPP_BUF_STATE_DATA,
<API key>
};
struct tspp_mem_buffer {
struct tspp_mem_buffer *next;
struct sps_mem_buffer sps;
struct <API key> desc;
enum tspp_buf_state state;
size_t filled;
int read_index;
};
struct tspp_channel {
struct tspp_device *pdev;
struct sps_pipe *pipe;
struct sps_connect config;
struct sps_register_event event;
struct tspp_mem_buffer *data;
struct tspp_mem_buffer *read;
struct tspp_mem_buffer *waiting;
struct tspp_mem_buffer *locked;
wait_queue_head_t in_queue;
u32 id;
int used;
int key;
u32 buffer_size;
u32 max_buffers;
u32 buffer_count;
u32 filter_count;
u32 int_freq;
enum tspp_source src;
enum tspp_mode mode;
tspp_notifier *notifier;
void *notify_data;
u32 <API key>;
struct timer_list expiration_timer;
struct dma_pool *dma_pool;
tspp_memfree *memfree;
void *user_info;
};
struct <API key> {
struct tspp_pid_filter filter[TSPP_NUM_PRIORITIES];
};
struct tspp_key_entry {
u32 even_lsb;
u32 even_msb;
u32 odd_lsb;
u32 odd_msb;
};
struct tspp_key_table {
struct tspp_key_entry entry[TSPP_NUM_KEYS];
};
struct tspp_pinctrl {
struct pinctrl *pinctrl;
struct pinctrl_state *disabled;
struct pinctrl_state *tsif0_mode1;
struct pinctrl_state *tsif0_mode2;
struct pinctrl_state *tsif1_mode1;
struct pinctrl_state *tsif1_mode2;
struct pinctrl_state *dual_mode1;
struct pinctrl_state *dual_mode2;
bool tsif0_active;
bool tsif1_active;
};
struct tspp_device {
struct list_head devlist;
struct platform_device *pdev;
void __iomem *base;
uint32_t tsif_bus_client;
unsigned int tspp_irq;
unsigned int bam_irq;
unsigned long bam_handle;
struct sps_bam_props bam_props;
struct wake_lock wake_lock;
spinlock_t spinlock;
struct tasklet_struct tlet;
struct tspp_tsif_device tsif[TSPP_TSIF_INSTANCES];
struct clk *tsif_pclk;
struct clk *tsif_ref_clk;
struct regulator *tsif_vreg;
struct <API key> *filters[TSPP_FILTER_TABLES];
struct tspp_channel channels[TSPP_NUM_CHANNELS];
struct tspp_key_table *tspp_key_table;
struct <API key> *<API key>;
struct <API key> *tspp_pipe_context;
struct <API key> *<API key>;
bool req_irqs;
struct mutex mutex;
struct tspp_pinctrl pinctrl;
struct dentry *dent;
struct dentry *debugfs_regs[ARRAY_SIZE(debugfs_tspp_regs)];
};
static int tspp_key_entry;
static u32 channel_id;
static LIST_HEAD(tspp_devices);
static irqreturn_t tspp_isr(int irq, void *dev)
{
struct tspp_device *device = dev;
u32 status, mask;
u32 data;
status = readl_relaxed(device->base + TSPP_IRQ_STATUS);
mask = readl_relaxed(device->base + TSPP_IRQ_MASK);
status &= mask;
if (!status) {
dev_warn(&device->pdev->dev, "Spurious interrupt");
return IRQ_NONE;
}
if (status & <API key>) {
data = readl_relaxed(device->base + TSPP_KEY_ERROR);
dev_info(&device->pdev->dev, "key error 0x%x", data);
}
if (status & <API key>) {
data = readl_relaxed(device->base + TSPP_KEY_VALID);
dev_info(&device->pdev->dev, "key invalidated: 0x%x", data);
}
if (status & <API key>)
dev_info(&device->pdev->dev, "key switched");
if (status & 0xffff)
dev_info(&device->pdev->dev, "broken pipe %i", status & 0xffff);
writel_relaxed(status, device->base + TSPP_IRQ_CLEAR);
wmb();
return IRQ_HANDLED;
}
static irqreturn_t tsif_isr(int irq, void *dev)
{
struct tspp_tsif_device *tsif_device = dev;
u32 sts_ctl = ioread32(tsif_device->base + TSIF_STS_CTL_OFF);
if (!(sts_ctl & (<API key> |
<API key> |
<API key> |
<API key>)))
return IRQ_NONE;
if (sts_ctl & <API key>)
tsif_device->stat_overflow++;
if (sts_ctl & <API key>)
tsif_device->stat_lost_sync++;
if (sts_ctl & <API key>)
tsif_device->stat_timeout++;
iowrite32(sts_ctl, tsif_device->base + TSIF_STS_CTL_OFF);
wmb();
return IRQ_HANDLED;
}
static void <API key>(struct sps_event_notify *notify)
{
struct tspp_device *pdev;
if (!notify || !notify->user)
return;
pdev = notify->user;
tasklet_schedule(&pdev->tlet);
}
static void <API key>(unsigned long data)
{
struct tspp_device *pdev = (struct tspp_device *)data;
if (pdev)
tasklet_schedule(&pdev->tlet);
}
static void <API key>(unsigned long data)
{
int i;
int complete;
unsigned long flags;
struct sps_iovec iovec;
struct tspp_channel *channel;
struct tspp_device *device = (struct tspp_device *)data;
spin_lock_irqsave(&device->spinlock, flags);
for (i = 0; i < TSPP_NUM_CHANNELS; i++) {
complete = 0;
channel = &device->channels[i];
if (!channel->used || !channel->waiting)
continue;
if (channel-><API key>)
del_timer(&channel->expiration_timer);
while (channel->waiting->state == <API key>) {
if (sps_get_iovec(channel->pipe, &iovec) != 0) {
pr_err("tspp: Error in iovec on channel %i",
channel->id);
break;
}
if (iovec.size == 0)
break;
if (iovec.addr != channel->waiting->sps.phys_base)
pr_err("tspp: buffer mismatch %pa",
&channel->waiting->sps.phys_base);
complete = 1;
channel->waiting->state = TSPP_BUF_STATE_DATA;
channel->waiting->filled = iovec.size;
channel->waiting->read_index = 0;
if (channel->src == TSPP_SOURCE_TSIF0)
device->tsif[0].stat_rx++;
else if (channel->src == TSPP_SOURCE_TSIF1)
device->tsif[1].stat_rx++;
channel->waiting = channel->waiting->next;
}
if (complete) {
<API key>(&channel->in_queue);
if (channel->notifier)
channel->notifier(channel->id,
channel->notify_data);
}
if (channel-><API key>)
mod_timer(&channel->expiration_timer,
jiffies +
MSEC_TO_JIFFIES(
channel-><API key>));
}
<API key>(&device->spinlock, flags);
}
static int tspp_config_gpios(struct tspp_device *device,
enum tspp_source source,
int enable)
{
int ret;
struct pinctrl_state *s;
struct tspp_pinctrl *p = &device->pinctrl;
bool mode2;
if (<API key>(&device->mutex))
return -ERESTARTSYS;
switch (source) {
case TSPP_SOURCE_TSIF0:
mode2 = device->tsif[0].mode == TSPP_TSIF_MODE_2;
if (enable == p->tsif1_active) {
if (enable)
s = mode2 ? p->dual_mode2 : p->dual_mode1;
else
s = p->disabled;
} else if (enable) {
s = mode2 ? p->tsif0_mode2 : p->tsif0_mode1;
} else {
s = mode2 ? p->tsif1_mode2 : p->tsif1_mode1;
}
ret = <API key>(p->pinctrl, s);
if (!ret)
p->tsif0_active = enable;
break;
case TSPP_SOURCE_TSIF1:
mode2 = device->tsif[1].mode == TSPP_TSIF_MODE_2;
if (enable == p->tsif0_active) {
if (enable)
s = mode2 ? p->dual_mode2 : p->dual_mode1;
else
s = p->disabled;
} else if (enable) {
s = mode2 ? p->tsif1_mode2 : p->tsif1_mode1;
} else {
s = mode2 ? p->tsif0_mode2 : p->tsif0_mode1;
}
ret = <API key>(p->pinctrl, s);
if (!ret)
p->tsif1_active = enable;
break;
default:
pr_err("%s: invalid source %d\n", __func__, source);
mutex_unlock(&device->mutex);
return -EINVAL;
}
if (ret)
pr_err("%s: failed to change pinctrl state, ret=%d\n",
__func__, ret);
mutex_unlock(&device->mutex);
return ret;
}
static int tspp_get_pinctrl(struct tspp_device *device)
{
struct pinctrl *pinctrl;
struct pinctrl_state *state;
pinctrl = devm_pinctrl_get(&device->pdev->dev);
if (IS_ERR(pinctrl)) {
pr_err("%s: Unable to get pinctrl handle\n", __func__);
return -EINVAL;
}
device->pinctrl.pinctrl = pinctrl;
state = <API key>(pinctrl, "disabled");
if (IS_ERR(state)) {
pr_err("%s: Unable to find state %s\n",
__func__, "disabled");
return -EINVAL;
}
device->pinctrl.disabled = state;
state = <API key>(pinctrl, "tsif0-mode1");
if (IS_ERR(state)) {
pr_err("%s: Unable to find state %s\n",
__func__, "tsif0-mode1");
return -EINVAL;
}
device->pinctrl.tsif0_mode1 = state;
state = <API key>(pinctrl, "tsif0-mode2");
if (IS_ERR(state)) {
pr_err("%s: Unable to find state %s\n",
__func__, "tsif0-mode2");
return -EINVAL;
}
device->pinctrl.tsif0_mode2 = state;
device->pinctrl.tsif0_active = false;
device->pinctrl.tsif1_active = false;
return 0;
}
static int tspp_clock_start(struct tspp_device *device)
{
int rc;
if (device == NULL) {
pr_err("tspp: Can't start clocks, invalid device\n");
return -EINVAL;
}
if (device->tsif_bus_client) {
rc = <API key>(
device->tsif_bus_client, 1);
if (rc) {
pr_err("tspp: Can't enable bus\n");
return -EBUSY;
}
}
if (device->tsif_vreg) {
rc = <API key>(device->tsif_vreg,
<API key>,
<API key>);
if (rc) {
pr_err("Unable to set CX voltage.\n");
if (device->tsif_bus_client)
<API key>(
device->tsif_bus_client, 0);
return rc;
}
}
if (device->tsif_pclk && clk_prepare_enable(device->tsif_pclk) != 0) {
pr_err("tspp: Can't start pclk");
if (device->tsif_vreg) {
<API key>(device->tsif_vreg,
<API key>,
<API key>);
}
if (device->tsif_bus_client)
<API key>(
device->tsif_bus_client, 0);
return -EBUSY;
}
if (device->tsif_ref_clk &&
clk_prepare_enable(device->tsif_ref_clk) != 0) {
pr_err("tspp: Can't start ref clk");
<API key>(device->tsif_pclk);
if (device->tsif_vreg) {
<API key>(device->tsif_vreg,
<API key>,
<API key>);
}
if (device->tsif_bus_client)
<API key>(
device->tsif_bus_client, 0);
return -EBUSY;
}
return 0;
}
static void tspp_clock_stop(struct tspp_device *device)
{
int rc;
if (device == NULL) {
pr_err("tspp: Can't stop clocks, invalid device\n");
return;
}
if (device->tsif_pclk)
<API key>(device->tsif_pclk);
if (device->tsif_ref_clk)
<API key>(device->tsif_ref_clk);
if (device->tsif_vreg) {
rc = <API key>(device->tsif_vreg,
<API key>,
<API key>);
if (rc)
pr_err("Unable to set CX voltage.\n");
}
if (device->tsif_bus_client) {
rc = <API key>(
device->tsif_bus_client, 0);
if (rc)
pr_err("tspp: Can't disable bus\n");
}
}
static int tspp_start_tsif(struct tspp_tsif_device *tsif_device)
{
int start_hardware = 0;
u32 ctl;
if (tsif_device->ref_count == 0) {
start_hardware = 1;
} else if (tsif_device->ref_count > 0) {
ctl = readl_relaxed(tsif_device->base + TSIF_STS_CTL_OFF);
if ((ctl & TSIF_STS_CTL_START) != 1) {
pr_warn("tspp: tsif hw not started but ref count > 0");
start_hardware = 1;
}
}
if (start_hardware) {
ctl = TSIF_STS_CTL_EN_IRQ |
TSIF_STS_CTL_EN_DM |
<API key> |
<API key> |
<API key>;
if (tsif_device->clock_inverse)
ctl |= <API key>;
if (tsif_device->data_inverse)
ctl |= <API key>;
if (tsif_device->sync_inverse)
ctl |= <API key>;
if (tsif_device->enable_inverse)
ctl |= <API key>;
switch (tsif_device->mode) {
case <API key>:
ctl |= <API key> |
<API key> |
<API key>;
break;
case TSPP_TSIF_MODE_1:
ctl |= <API key> |
TSIF_STS_CTL_EN_TCR;
break;
case TSPP_TSIF_MODE_2:
ctl |= <API key> |
TSIF_STS_CTL_EN_TCR |
TSIF_STS_CTL_MODE_2;
break;
default:
pr_warn("tspp: unknown tsif mode 0x%x",
tsif_device->mode);
}
writel_relaxed(ctl, tsif_device->base + TSIF_STS_CTL_OFF);
writel_relaxed(tsif_device->time_limit,
tsif_device->base + TSIF_TIME_LIMIT_OFF);
wmb();
writel_relaxed(ctl | TSIF_STS_CTL_START,
tsif_device->base + TSIF_STS_CTL_OFF);
wmb();
}
ctl = readl_relaxed(tsif_device->base + TSIF_STS_CTL_OFF);
if (!(ctl & TSIF_STS_CTL_START))
return -EBUSY;
tsif_device->ref_count++;
return 0;
}
static void tspp_stop_tsif(struct tspp_tsif_device *tsif_device)
{
if (tsif_device->ref_count == 0)
return;
tsif_device->ref_count
if (tsif_device->ref_count == 0) {
writel_relaxed(TSIF_STS_CTL_STOP,
tsif_device->base + TSIF_STS_CTL_OFF);
wmb();
}
}
static int <API key>(struct tspp_device *pdev)
{
int i;
int count = 0;
for (i = 0; i < TSPP_NUM_CHANNELS; i++)
count += (pdev->channels[i].used ? 1 : 0);
return count;
}
static struct tspp_device *tspp_find_by_id(int id)
{
struct tspp_device *dev;
list_for_each_entry(dev, &tspp_devices, devlist) {
if (dev->pdev->id == id)
return dev;
}
return NULL;
}
static int tspp_get_key_entry(void)
{
int i;
for (i = 0; i < TSPP_NUM_KEYS; i++) {
if (!(tspp_key_entry & (1 << i))) {
tspp_key_entry |= (1 << i);
return i;
}
}
return 1 < TSPP_NUM_KEYS;
}
static void tspp_free_key_entry(int entry)
{
if (entry > TSPP_NUM_KEYS) {
pr_err("tspp_free_key_entry: index out of bounds");
return;
}
tspp_key_entry &= ~(1 << entry);
}
static int tspp_alloc_buffer(u32 channel_id, struct <API key> *desc,
u32 size, struct dma_pool *dma_pool, tspp_allocator *alloc, void *user)
{
if (size < <API key> ||
size > <API key>) {
pr_err("tspp: bad buffer size %i", size);
return -ENOMEM;
}
if (alloc) {
TSPP_DEBUG("tspp using alloc function");
desc->virt_base = alloc(channel_id, size,
&desc->phys_base, user);
} else {
if (!dma_pool)
desc->virt_base = dma_alloc_coherent(NULL, size,
&desc->phys_base, GFP_KERNEL);
else
desc->virt_base = dma_pool_alloc(dma_pool, GFP_KERNEL,
&desc->phys_base);
if (desc->virt_base == 0) {
pr_err("tspp: dma buffer allocation failed %i\n", size);
return -ENOMEM;
}
}
desc->size = size;
return 0;
}
static int tspp_queue_buffer(struct tspp_channel *channel,
struct tspp_mem_buffer *buffer)
{
int rc;
u32 flags = 0;
if (channel->int_freq < 1)
channel->int_freq = 1;
if (buffer->desc.id % channel->int_freq == channel->int_freq-1)
flags = SPS_IOVEC_FLAG_INT;
rc = sps_transfer_one(channel->pipe,
buffer->sps.phys_base,
buffer->sps.size,
channel->pdev,
flags);
if (rc < 0)
return rc;
buffer->state = <API key>;
return 0;
}
static int tspp_global_reset(struct tspp_device *pdev)
{
u32 i, val;
for (i = 0; i < TSPP_TSIF_INSTANCES; i++) {
pdev->tsif[i].ref_count = 1;
tspp_stop_tsif(&pdev->tsif[i]);
pdev->tsif[i].time_limit = <API key>;
pdev->tsif[i].clock_inverse = 0;
pdev->tsif[i].data_inverse = 0;
pdev->tsif[i].sync_inverse = 0;
pdev->tsif[i].enable_inverse = 0;
}
writel_relaxed(TSPP_RST_RESET, pdev->base + TSPP_RST);
wmb();
for (i = 0; i < TSPP_FILTER_TABLES; i++)
memset_io(pdev->filters[i],
0, sizeof(struct <API key>));
val = (2 << TSPP_NUM_CHANNELS) - 1;
writel_relaxed(val, pdev->base + TSPP_PS_DISABLE);
val = readl_relaxed(pdev->base + TSPP_CONTROL);
writel_relaxed(val | <API key>,
pdev->base + TSPP_CONTROL);
wmb();
memset_io(pdev-><API key>, 0,
sizeof(struct <API key>));
memset_io(pdev->tspp_pipe_context, 0,
sizeof(struct <API key>));
memset_io(pdev-><API key>, 0,
sizeof(struct <API key>));
wmb();
writel_relaxed(val & ~<API key>,
pdev->base + TSPP_CONTROL);
wmb();
val = readl_relaxed(pdev->base + TSPP_CONFIG);
val &= ~(<API key> |
<API key> |
<API key>);
<API key>(val, TSPP_PACKET_LENGTH);
writel_relaxed(val, pdev->base + TSPP_CONFIG);
writel_relaxed(0x0007ffff, pdev->base + TSPP_IRQ_MASK);
writel_relaxed(0x000fffff, pdev->base + TSPP_IRQ_CLEAR);
writel_relaxed(0, pdev->base + TSPP_RST);
wmb();
tspp_key_entry = 0;
return 0;
}
static void tspp_channel_init(struct tspp_channel *channel,
struct tspp_device *pdev)
{
channel->pdev = pdev;
channel->data = NULL;
channel->read = NULL;
channel->waiting = NULL;
channel->locked = NULL;
channel->id = channel_id++;
channel->used = 0;
channel->buffer_size = <API key>;
channel->max_buffers = TSPP_NUM_BUFFERS;
channel->buffer_count = 0;
channel->filter_count = 0;
channel->int_freq = 1;
channel->src = TSPP_SOURCE_NONE;
channel->mode = TSPP_MODE_DISABLED;
channel->notifier = NULL;
channel->notify_data = NULL;
channel-><API key> = 0;
channel->memfree = NULL;
channel->user_info = NULL;
init_waitqueue_head(&channel->in_queue);
}
static void tspp_set_tsif_mode(struct tspp_channel *channel,
enum tspp_tsif_mode mode)
{
int index;
switch (channel->src) {
case TSPP_SOURCE_TSIF0:
index = 0;
break;
case TSPP_SOURCE_TSIF1:
index = 1;
break;
default:
pr_warn("tspp: can't set mode for non-tsif source %d",
channel->src);
return;
}
channel->pdev->tsif[index].mode = mode;
}
static void <API key>(struct tspp_channel *channel,
int clock_inverse, int data_inverse,
int sync_inverse, int enable_inverse)
{
int index;
switch (channel->src) {
case TSPP_SOURCE_TSIF0:
index = 0;
break;
case TSPP_SOURCE_TSIF1:
index = 1;
break;
default:
return;
}
channel->pdev->tsif[index].clock_inverse = clock_inverse;
channel->pdev->tsif[index].data_inverse = data_inverse;
channel->pdev->tsif[index].sync_inverse = sync_inverse;
channel->pdev->tsif[index].enable_inverse = enable_inverse;
}
static int <API key>(u32 size, enum tspp_mode mode)
{
u32 alignment;
switch (mode) {
case TSPP_MODE_RAW:
alignment = (TSPP_PACKET_LENGTH + 4);
if (size % alignment)
return 0;
return 1;
case <API key>:
alignment = TSPP_PACKET_LENGTH;
if (size % alignment)
return 0;
return 1;
case TSPP_MODE_DISABLED:
case TSPP_MODE_PES:
default:
return 1;
}
}
static u32 <API key>(u32 size, enum tspp_mode mode)
{
u32 new_size;
u32 alignment;
switch (mode) {
case TSPP_MODE_RAW:
alignment = (TSPP_PACKET_LENGTH + 4);
break;
case <API key>:
alignment = TSPP_PACKET_LENGTH;
break;
case TSPP_MODE_DISABLED:
case TSPP_MODE_PES:
default:
alignment = 1;
break;
}
new_size = (((size + alignment - 1) / alignment) * alignment);
return new_size;
}
static void <API key>(u32 channel_id, struct tspp_channel *channel)
{
int i;
struct tspp_mem_buffer *pbuf, *temp;
pbuf = channel->data;
for (i = 0; i < channel->buffer_count; i++) {
if (pbuf->desc.phys_base) {
if (channel->memfree) {
channel->memfree(channel_id,
pbuf->desc.size,
pbuf->desc.virt_base,
pbuf->desc.phys_base,
channel->user_info);
} else {
if (!channel->dma_pool)
dma_free_coherent(
&channel->pdev->pdev->dev,
pbuf->desc.size,
pbuf->desc.virt_base,
pbuf->desc.phys_base);
else
dma_pool_free(channel->dma_pool,
pbuf->desc.virt_base,
pbuf->desc.phys_base);
}
pbuf->desc.phys_base = 0;
}
pbuf->desc.virt_base = 0;
pbuf->state = <API key>;
temp = pbuf;
pbuf = pbuf->next;
kfree(temp);
}
}
static int msm_tspp_req_irqs(struct tspp_device *device)
{
int rc;
int i;
int j;
rc = request_irq(device->tspp_irq, tspp_isr, IRQF_SHARED,
dev_name(&device->pdev->dev), device);
if (rc) {
dev_err(&device->pdev->dev,
"failed to request TSPP IRQ %d : %d",
device->tspp_irq, rc);
return rc;
}
for (i = 0; i < TSPP_TSIF_INSTANCES; i++) {
rc = request_irq(device->tsif[i].tsif_irq,
tsif_isr, IRQF_SHARED, dev_name(&device->pdev->dev),
&device->tsif[i]);
if (rc) {
dev_err(&device->pdev->dev,
"failed to request TSIF%d IRQ: %d",
i, rc);
goto failed;
}
}
device->req_irqs = true;
return 0;
failed:
free_irq(device->tspp_irq, device);
for (j = 0; j < i; j++)
free_irq(device->tsif[j].tsif_irq, device);
return rc;
}
static inline void msm_tspp_free_irqs(struct tspp_device *device)
{
int i;
for (i = 0; i < TSPP_TSIF_INSTANCES; i++) {
if (device->tsif[i].tsif_irq)
free_irq(device->tsif[i].tsif_irq, &device->tsif[i]);
}
if (device->tspp_irq)
free_irq(device->tspp_irq, device);
device->req_irqs = false;
}
int tspp_open_stream(u32 dev, u32 channel_id,
struct tspp_select_source *source)
{
u32 val;
int rc;
struct tspp_device *pdev;
struct tspp_channel *channel;
bool req_irqs = false;
TSPP_DEBUG("tspp_open_stream %i %i %i %i",
dev, channel_id, source->source, source->mode);
if (dev >= TSPP_MAX_DEVICES) {
pr_err("tspp: device id out of range");
return -ENODEV;
}
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_str: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
channel->src = source->source;
tspp_set_tsif_mode(channel, source->mode);
<API key>(channel, source->clk_inverse,
source->data_inverse, source->sync_inverse,
source->enable_inverse);
if (!pdev->req_irqs && (source->source == TSPP_SOURCE_TSIF0 ||
source->source == TSPP_SOURCE_TSIF1)) {
rc = msm_tspp_req_irqs(pdev);
if (rc) {
pr_err("tspp: error requesting irqs\n");
return rc;
}
req_irqs = true;
}
switch (source->source) {
case TSPP_SOURCE_TSIF0:
if (tspp_config_gpios(pdev, channel->src, 1) != 0) {
rc = -EBUSY;
pr_err("tspp: error enabling tsif0 GPIOs\n");
goto free_irq;
}
if (tspp_start_tsif(&pdev->tsif[0]) != 0) {
rc = -EBUSY;
pr_err("tspp: error starting tsif0");
goto free_irq;
}
if (pdev->tsif[0].ref_count == 1) {
val = readl_relaxed(pdev->base + TSPP_CONTROL);
writel_relaxed(val & ~<API key>,
pdev->base + TSPP_CONTROL);
wmb();
}
break;
case TSPP_SOURCE_TSIF1:
if (tspp_config_gpios(pdev, channel->src, 1) != 0) {
rc = -EBUSY;
pr_err("tspp: error enabling tsif1 GPIOs\n");
goto free_irq;
}
if (tspp_start_tsif(&pdev->tsif[1]) != 0) {
rc = -EBUSY;
pr_err("tspp: error starting tsif1");
goto free_irq;
}
if (pdev->tsif[1].ref_count == 1) {
val = readl_relaxed(pdev->base + TSPP_CONTROL);
writel_relaxed(val & ~<API key>,
pdev->base + TSPP_CONTROL);
wmb();
}
break;
case TSPP_SOURCE_MEM:
break;
default:
pr_err("tspp: channel %i invalid source %i",
channel->id, source->source);
return -EBUSY;
}
return 0;
free_irq:
if (req_irqs)
msm_tspp_free_irqs(pdev);
return rc;
}
EXPORT_SYMBOL(tspp_open_stream);
int tspp_close_stream(u32 dev, u32 channel_id)
{
u32 val;
u32 prev_ref_count = 0;
struct tspp_device *pdev;
struct tspp_channel *channel;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_cs: can't find device %i", dev);
return -EBUSY;
}
channel = &pdev->channels[channel_id];
switch (channel->src) {
case TSPP_SOURCE_TSIF0:
prev_ref_count = pdev->tsif[0].ref_count;
tspp_stop_tsif(&pdev->tsif[0]);
if (tspp_config_gpios(pdev, channel->src, 0) != 0)
pr_err("tspp: error disabling tsif0 GPIOs\n");
if (prev_ref_count == 1) {
val = readl_relaxed(pdev->base + TSPP_CONTROL);
writel_relaxed(val | <API key>,
pdev->base + TSPP_CONTROL);
wmb();
}
break;
case TSPP_SOURCE_TSIF1:
prev_ref_count = pdev->tsif[1].ref_count;
tspp_stop_tsif(&pdev->tsif[1]);
if (tspp_config_gpios(pdev, channel->src, 0) != 0)
pr_err("tspp: error disabling tsif0 GPIOs\n");
if (prev_ref_count == 1) {
val = readl_relaxed(pdev->base + TSPP_CONTROL);
writel_relaxed(val | <API key>,
pdev->base + TSPP_CONTROL);
wmb();
}
break;
case TSPP_SOURCE_MEM:
break;
case TSPP_SOURCE_NONE:
break;
}
channel->src = TSPP_SOURCE_NONE;
if ((pdev->tsif[0].ref_count + pdev->tsif[1].ref_count) == 0 &&
prev_ref_count)
msm_tspp_free_irqs(pdev);
return 0;
}
EXPORT_SYMBOL(tspp_close_stream);
static int <API key>(struct tspp_device *dev)
{
int ret;
ret = <API key>(&dev->bam_props, &dev->bam_handle);
if (ret) {
pr_err("tspp: failed to register bam device, err-%d\n", ret);
return ret;
}
ret = sps_device_reset(dev->bam_handle);
if (ret) {
<API key>(dev->bam_handle);
pr_err("tspp: error resetting bam device, err=%d\n", ret);
return ret;
}
return 0;
}
int tspp_open_channel(u32 dev, u32 channel_id)
{
int rc = 0;
struct sps_connect *config;
struct sps_register_event *event;
struct tspp_channel *channel;
struct tspp_device *pdev;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_oc: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
if (channel->used) {
pr_err("tspp channel already in use");
return -EBUSY;
}
config = &channel->config;
event = &channel->event;
if (<API key>(pdev) == 0) {
rc = tspp_clock_start(pdev);
if (rc)
return rc;
if (pdev->bam_handle == <API key>) {
rc = <API key>(pdev);
if (rc) {
pr_err("tspp: failed to init sps device, err=%d\n",
rc);
tspp_clock_stop(pdev);
return rc;
}
}
wake_lock(&pdev->wake_lock);
}
channel->used = 1;
channel->pipe = sps_alloc_endpoint();
if (channel->pipe == 0) {
pr_err("tspp: error allocating endpoint");
rc = -ENOMEM;
goto err_sps_alloc;
}
sps_get_config(channel->pipe, config);
config->source = pdev->bam_handle;
config->destination = SPS_DEV_HANDLE_MEM;
config->mode = SPS_MODE_SRC;
config->options =
SPS_O_AUTO_ENABLE |
SPS_O_STREAMING |
SPS_O_DESC_DONE |
SPS_O_ACK_TRANSFERS |
SPS_O_HYBRID;
config->src_pipe_index = channel->id;
config->desc.size =
<API key> * SPS_DESCRIPTOR_SIZE;
config->desc.base = dma_alloc_coherent(&pdev->pdev->dev,
config->desc.size,
&config->desc.phys_base,
GFP_KERNEL);
if (config->desc.base == 0) {
pr_err("tspp: error allocating sps descriptors");
rc = -ENOMEM;
goto err_desc_alloc;
}
memset(config->desc.base, 0, config->desc.size);
rc = sps_connect(channel->pipe, config);
if (rc) {
pr_err("tspp: error connecting bam");
goto err_connect;
}
event->mode = <API key>;
event->options = SPS_O_DESC_DONE;
event->callback = <API key>;
event->xfer_done = NULL;
event->user = pdev;
rc = sps_register_event(channel->pipe, event);
if (rc) {
pr_err("tspp: error registering event");
goto err_event;
}
init_timer(&channel->expiration_timer);
channel->expiration_timer.function = <API key>;
channel->expiration_timer.data = (unsigned long)pdev;
channel->expiration_timer.expires = 0xffffffffL;
rc = pm_runtime_get(&pdev->pdev->dev);
if (rc < 0) {
dev_err(&pdev->pdev->dev,
"Runtime PM: Unable to wake up tspp device, rc = %d",
rc);
}
return 0;
err_event:
sps_disconnect(channel->pipe);
err_connect:
dma_free_coherent(&pdev->pdev->dev, config->desc.size,
config->desc.base, config->desc.phys_base);
err_desc_alloc:
sps_free_endpoint(channel->pipe);
err_sps_alloc:
channel->used = 0;
return rc;
}
EXPORT_SYMBOL(tspp_open_channel);
int tspp_close_channel(u32 dev, u32 channel_id)
{
int i;
int id;
int table_idx;
u32 val;
unsigned long flags;
struct sps_connect *config;
struct tspp_device *pdev;
struct tspp_channel *channel;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_close: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
if (!channel->used)
return 0;
spin_lock_irqsave(&pdev->spinlock, flags);
channel->used = 0;
channel->waiting = NULL;
<API key>(&pdev->spinlock, flags);
if (channel-><API key>)
del_timer(&channel->expiration_timer);
channel->notifier = NULL;
channel->notify_data = NULL;
channel-><API key> = 0;
config = &channel->config;
pdev = channel->pdev;
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
writel_relaxed(val | channel->id, pdev->base + TSPP_PS_DISABLE);
wmb();
for (table_idx = 0; table_idx < TSPP_FILTER_TABLES; table_idx++) {
for (i = 0; i < TSPP_NUM_PRIORITIES; i++) {
struct tspp_pid_filter *filter =
&pdev->filters[table_idx]->filter[i];
id = <API key>(filter);
if (id == channel->id) {
if (<API key>(filter))
tspp_free_key_entry(
<API key>(filter));
filter->config = 0;
filter->filter = 0;
}
}
}
channel->filter_count = 0;
if (sps_disconnect(channel->pipe) != 0)
pr_warn("tspp: Error freeing sps endpoint (%i)", channel->id);
dma_free_coherent(&pdev->pdev->dev, config->desc.size,
config->desc.base, config->desc.phys_base);
sps_free_endpoint(channel->pipe);
<API key>(channel_id, channel);
if (channel->dma_pool) {
dma_pool_destroy(channel->dma_pool);
channel->dma_pool = NULL;
}
channel->src = TSPP_SOURCE_NONE;
channel->mode = TSPP_MODE_DISABLED;
channel->memfree = NULL;
channel->user_info = NULL;
channel->buffer_count = 0;
channel->data = NULL;
channel->read = NULL;
channel->locked = NULL;
if (<API key>(pdev) == 0) {
<API key>(pdev->bam_handle);
pdev->bam_handle = <API key>;
wake_unlock(&pdev->wake_lock);
tspp_clock_stop(pdev);
}
pm_runtime_put(&pdev->pdev->dev);
return 0;
}
EXPORT_SYMBOL(tspp_close_channel);
int <API key>(u32 dev, enum tspp_source source, u32 *tcr_counter)
{
struct tspp_device *pdev;
struct tspp_tsif_device *tsif_device;
if (!tcr_counter)
return -EINVAL;
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("<API key>: can't find device %i\n", dev);
return -ENODEV;
}
switch (source) {
case TSPP_SOURCE_TSIF0:
tsif_device = &pdev->tsif[0];
break;
case TSPP_SOURCE_TSIF1:
tsif_device = &pdev->tsif[1];
break;
default:
tsif_device = NULL;
break;
}
if (tsif_device && tsif_device->ref_count)
*tcr_counter = ioread32(tsif_device->base + TSIF_CLK_REF_OFF);
else
*tcr_counter = 0;
return 0;
}
EXPORT_SYMBOL(<API key>);
int tspp_add_filter(u32 dev, u32 channel_id,
struct tspp_filter *filter)
{
int i, rc;
int other_channel;
int entry;
u32 val, pid, enabled;
struct tspp_device *pdev;
struct tspp_pid_filter p;
struct tspp_channel *channel;
TSPP_DEBUG("tspp: add filter");
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_add: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
if (filter->source > TSPP_SOURCE_MEM) {
pr_err("tspp invalid source");
return -ENOSR;
}
if (filter->priority >= TSPP_NUM_PRIORITIES) {
pr_err("tspp invalid filter priority");
return -ENOSR;
}
channel->mode = filter->mode;
if ((channel->buffer_count > 0) &&
(!<API key>(channel->buffer_size, channel->mode)))
pr_warn("tspp: buffers allocated with incorrect alignment\n");
if (filter->mode == TSPP_MODE_PES) {
for (i = 0; i < TSPP_NUM_PRIORITIES; i++) {
struct tspp_pid_filter *tspp_filter =
&pdev->filters[channel->src]->filter[i];
pid = FILTER_GET_PIPE_PID((tspp_filter));
enabled = <API key>(tspp_filter);
if (enabled && (pid == filter->pid)) {
other_channel =
<API key>(tspp_filter);
pr_err("tspp: pid 0x%x already in use by channel %i",
filter->pid, other_channel);
return -EBADSLT;
}
}
}
enabled = <API key>(
(&(pdev->filters[channel->src]->filter[filter->priority])));
if (enabled) {
pr_err("tspp: filter priority %i source %i is already enabled\n",
filter->priority, channel->src);
return -ENOSR;
}
if (channel->mode == TSPP_MODE_PES) {
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
writel_relaxed(val | (1 << channel->id),
pdev->base + TSPP_PS_DISABLE);
wmb();
}
p.filter = 0;
p.config = <API key>;
<API key>((&p), filter->mode);
FILTER_SET_PIPE_PID((&p), filter->pid);
FILTER_SET_PID_MASK((&p), filter->mask);
<API key>((&p), channel->id);
<API key>((&p), TSPP_MODE_DISABLED);
if (filter->decrypt) {
entry = tspp_get_key_entry();
if (entry == -1) {
pr_err("tspp: no more keys available!");
} else {
p.config |= FILTER_DECRYPT;
<API key>((&p), entry);
}
}
pdev->filters[channel->src]->
filter[filter->priority].config = p.config;
pdev->filters[channel->src]->
filter[filter->priority].filter = p.filter;
if (channel->buffer_count == 0) {
channel->buffer_size =
<API key>(channel->buffer_size,
channel->mode);
rc = <API key>(dev, channel->id,
channel->max_buffers,
channel->buffer_size,
channel->int_freq, NULL, NULL, NULL);
if (rc != 0) {
pr_err("tspp: <API key> failed\n");
return rc;
}
}
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
writel_relaxed(val & ~(1 << channel->id), pdev->base + TSPP_PS_DISABLE);
wmb();
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
channel->filter_count++;
return 0;
}
EXPORT_SYMBOL(tspp_add_filter);
int tspp_remove_filter(u32 dev, u32 channel_id,
struct tspp_filter *filter)
{
int entry;
u32 val;
struct tspp_device *pdev;
int src;
struct tspp_pid_filter *tspp_filter;
struct tspp_channel *channel;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_remove: can't find device %i", dev);
return -ENODEV;
}
if (filter->priority >= TSPP_NUM_PRIORITIES) {
pr_err("tspp invalid filter priority");
return -ENOSR;
}
channel = &pdev->channels[channel_id];
src = channel->src;
tspp_filter = &(pdev->filters[src]->filter[filter->priority]);
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
writel_relaxed(val | channel->id, pdev->base + TSPP_PS_DISABLE);
wmb();
if (tspp_filter->config & FILTER_DECRYPT) {
entry = <API key>(tspp_filter);
tspp_free_key_entry(entry);
}
tspp_filter->config = 0;
tspp_filter->filter = 0;
channel->filter_count
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
writel_relaxed(val & ~(1 << channel->id),
pdev->base + TSPP_PS_DISABLE);
wmb();
val = readl_relaxed(pdev->base + TSPP_PS_DISABLE);
return 0;
}
EXPORT_SYMBOL(tspp_remove_filter);
int tspp_set_key(u32 dev, u32 channel_id, struct tspp_key *key)
{
int i;
int id;
int key_index;
int data;
struct tspp_channel *channel;
struct tspp_device *pdev;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_set: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
for (i = 0; i < TSPP_NUM_PRIORITIES; i++) {
struct tspp_pid_filter *tspp_filter =
&(pdev->filters[channel->src]->filter[i]);
id = <API key>(tspp_filter);
if (id == channel->id) {
if (<API key>(tspp_filter)) {
key_index = <API key>(tspp_filter);
break;
}
}
}
if (i == TSPP_NUM_PRIORITIES) {
pr_err("tspp: no encryption on this channel");
return -ENOKEY;
}
if (key->parity == <API key>) {
pdev->tspp_key_table->entry[key_index].even_lsb = key->lsb;
pdev->tspp_key_table->entry[key_index].even_msb = key->msb;
} else {
pdev->tspp_key_table->entry[key_index].odd_lsb = key->lsb;
pdev->tspp_key_table->entry[key_index].odd_msb = key->msb;
}
data = readl_relaxed(channel->pdev->base + TSPP_KEY_VALID);
return 0;
}
EXPORT_SYMBOL(tspp_set_key);
int <API key>(u32 dev, u32 channel_id,
tspp_notifier *notify, void *userdata, u32 timer_ms)
{
struct tspp_channel *channel;
struct tspp_device *pdev;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_reg: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
channel->notifier = notify;
channel->notify_data = userdata;
channel-><API key> = timer_ms;
return 0;
}
EXPORT_SYMBOL(<API key>);
int <API key>(u32 dev, u32 channel_id)
{
struct tspp_channel *channel;
struct tspp_device *pdev;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_unreg: can't find device %i", dev);
return -ENODEV;
}
channel = &pdev->channels[channel_id];
channel->notifier = NULL;
channel->notify_data = 0;
return 0;
}
EXPORT_SYMBOL(<API key>);
const struct <API key> *tspp_get_buffer(u32 dev, u32 channel_id)
{
struct tspp_mem_buffer *buffer;
struct tspp_channel *channel;
struct tspp_device *pdev;
unsigned long flags;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return NULL;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp_get: can't find device %i", dev);
return NULL;
}
spin_lock_irqsave(&pdev->spinlock, flags);
channel = &pdev->channels[channel_id];
if (!channel->read) {
<API key>(&pdev->spinlock, flags);
pr_warn("tspp: no buffer to get on channel %i!",
channel->id);
return NULL;
}
buffer = channel->read;
if (buffer->state != TSPP_BUF_STATE_DATA) {
<API key>(&pdev->spinlock, flags);
return NULL;
}
if (buffer->state == TSPP_BUF_STATE_DATA) {
buffer->state = <API key>;
channel->read = channel->read->next;
}
<API key>(&pdev->spinlock, flags);
return &buffer->desc;
}
EXPORT_SYMBOL(tspp_get_buffer);
int tspp_release_buffer(u32 dev, u32 channel_id, u32 descriptor_id)
{
int i, found = 0;
struct tspp_mem_buffer *buffer;
struct tspp_channel *channel;
struct tspp_device *pdev;
unsigned long flags;
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("tspp: channel id out of range");
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("tspp: can't find device %i", dev);
return -ENODEV;
}
spin_lock_irqsave(&pdev->spinlock, flags);
channel = &pdev->channels[channel_id];
if (descriptor_id > channel->buffer_count)
pr_warn("tspp: desc id looks weird 0x%08x", descriptor_id);
buffer = channel->locked;
for (i = 0; i < channel->buffer_count; i++) {
if (buffer->desc.id == descriptor_id) {
found = 1;
break;
}
buffer = buffer->next;
}
channel->locked = channel->locked->next;
if (!found) {
<API key>(&pdev->spinlock, flags);
pr_err("tspp: cant find desc %i", descriptor_id);
return -EINVAL;
}
if (buffer->state != <API key>) {
<API key>(&pdev->spinlock, flags);
pr_err("tspp: buffer %i not locked", descriptor_id);
return -EINVAL;
}
buffer->state = <API key>;
if (tspp_queue_buffer(channel, buffer))
pr_warn("tspp: can't requeue buffer");
<API key>(&pdev->spinlock, flags);
return 0;
}
EXPORT_SYMBOL(tspp_release_buffer);
int <API key>(u32 dev, u32 channel_id, u32 count, u32 size,
u32 int_freq, tspp_allocator *alloc,
tspp_memfree *memfree, void *user)
{
struct tspp_channel *channel;
struct tspp_device *pdev;
struct tspp_mem_buffer *last = NULL;
TSPP_DEBUG("<API key>");
if (channel_id >= TSPP_NUM_CHANNELS) {
pr_err("%s: channel id out of range", __func__);
return -ECHRNG;
}
pdev = tspp_find_by_id(dev);
if (!pdev) {
pr_err("%s: can't find device %i", __func__, dev);
return -ENODEV;
}
if (count < <API key>) {
pr_err("%s: tspp requires a minimum of %i buffers\n",
__func__, <API key>);
return -EINVAL;
}
if (count > TSPP_NUM_BUFFERS) {
pr_err("%s: tspp requires a maximum of %i buffers\n",
__func__, TSPP_NUM_BUFFERS);
return -EINVAL;
}
channel = &pdev->channels[channel_id];
if (channel->buffer_count > 0) {
pr_err("%s: buffers already allocated for channel %u",
__func__, channel_id);
return -EINVAL;
}
channel->max_buffers = count;
if (int_freq > channel->max_buffers) {
int_freq = channel->max_buffers;
pr_warn("%s: setting interrupt frequency to %u\n",
__func__, int_freq);
}
channel->int_freq = int_freq;
channel->buffer_size = size;
channel->memfree = memfree;
channel->user_info = user;
if (TSPP_USE_DMA_POOL(channel->buffer_size)) {
channel->dma_pool = dma_pool_create("tspp",
&pdev->pdev->dev, channel->buffer_size, 0, 0);
if (!channel->dma_pool) {
pr_err("%s: Can't allocate memory pool\n", __func__);
return -ENOMEM;
}
} else {
channel->dma_pool = NULL;
}
for (channel->buffer_count = 0;
channel->buffer_count < channel->max_buffers;
channel->buffer_count++) {
struct tspp_mem_buffer *desc = (struct tspp_mem_buffer *)
kmalloc(sizeof(struct tspp_mem_buffer), GFP_KERNEL);
if (!desc) {
pr_warn("%s: Can't allocate desc %i",
__func__, channel->buffer_count);
break;
}
desc->desc.id = channel->buffer_count;
if (tspp_alloc_buffer(channel_id, &desc->desc,
channel->buffer_size, channel->dma_pool,
alloc, user) != 0) {
kfree(desc);
pr_warn("%s: Can't allocate buffer %i",
__func__, channel->buffer_count);
break;
}
desc->filled = 0;
desc->read_index = 0;
if (!channel->data) {
channel->data = desc;
desc->next = channel->data;
} else {
last->next = desc;
}
last = desc;
desc->next = channel->data;
desc->sps.phys_base = desc->desc.phys_base;
desc->sps.base = desc->desc.virt_base;
desc->sps.size = desc->desc.size;
if (tspp_queue_buffer(channel, desc))
pr_err("%s: can't queue buffer %i",
__func__, desc->desc.id);
}
if (channel->buffer_count < channel->max_buffers) {
<API key>(channel_id, channel);
channel->buffer_count = 0;
if (channel->dma_pool) {
dma_pool_destroy(channel->dma_pool);
channel->dma_pool = NULL;
}
return -ENOMEM;
}
channel->waiting = channel->data;
channel->read = channel->data;
channel->locked = channel->data;
if (channel-><API key>)
mod_timer(&channel->expiration_timer,
jiffies +
MSEC_TO_JIFFIES(
channel-><API key>));
return 0;
}
EXPORT_SYMBOL(<API key>);
static int <API key>(void *data, u64 val)
{
int rc;
int clock_started = 0;
struct tspp_device *pdev;
pdev = tspp_find_by_id(0);
if (!pdev) {
pr_err("%s: can't find device 0\n", __func__);
return 0;
}
if (<API key>(pdev) == 0) {
rc = tspp_clock_start(pdev);
if (rc) {
pr_err("%s: tspp_clock_start failed %d\n",
__func__, rc);
return 0;
}
clock_started = 1;
}
writel_relaxed(val, data);
wmb();
if (clock_started)
tspp_clock_stop(pdev);
return 0;
}
static int <API key>(void *data, u64 *val)
{
int rc;
int clock_started = 0;
struct tspp_device *pdev;
pdev = tspp_find_by_id(0);
if (!pdev) {
pr_err("%s: can't find device 0\n", __func__);
*val = 0;
return 0;
}
if (<API key>(pdev) == 0) {
rc = tspp_clock_start(pdev);
if (rc) {
pr_err("%s: tspp_clock_start failed %d\n",
__func__, rc);
*val = 0;
return 0;
}
clock_started = 1;
}
*val = readl_relaxed(data);
if (clock_started)
tspp_clock_stop(pdev);
return 0;
}
<API key>(fops_iomem_x32, <API key>,
<API key>, "0x%08llx");
static void tsif_debugfs_init(struct tspp_tsif_device *tsif_device,
int instance)
{
char name[10];
snprintf(name, 10, "tsif%i", instance);
tsif_device->dent_tsif = debugfs_create_dir(
name, NULL);
if (tsif_device->dent_tsif) {
int i;
void __iomem *base = tsif_device->base;
for (i = 0; i < ARRAY_SIZE(debugfs_tsif_regs); i++) {
tsif_device->debugfs_tsif_regs[i] =
debugfs_create_file(
debugfs_tsif_regs[i].name,
debugfs_tsif_regs[i].mode,
tsif_device->dent_tsif,
base + debugfs_tsif_regs[i].offset,
&fops_iomem_x32);
}
debugfs_create_u32(
"stat_rx_chunks",
S_IRUGO | S_IWUSR | S_IWGRP,
tsif_device->dent_tsif,
&tsif_device->stat_rx);
debugfs_create_u32(
"stat_overflow",
S_IRUGO | S_IWUSR | S_IWGRP,
tsif_device->dent_tsif,
&tsif_device->stat_overflow);
debugfs_create_u32(
"stat_lost_sync",
S_IRUGO | S_IWUSR | S_IWGRP,
tsif_device->dent_tsif,
&tsif_device->stat_lost_sync);
debugfs_create_u32(
"stat_timeout",
S_IRUGO | S_IWUSR | S_IWGRP,
tsif_device->dent_tsif,
&tsif_device->stat_timeout);
}
}
static void tsif_debugfs_exit(struct tspp_tsif_device *tsif_device)
{
if (tsif_device->dent_tsif) {
int i;
<API key>(tsif_device->dent_tsif);
tsif_device->dent_tsif = NULL;
for (i = 0; i < ARRAY_SIZE(debugfs_tsif_regs); i++)
tsif_device->debugfs_tsif_regs[i] = NULL;
}
}
static void tspp_debugfs_init(struct tspp_device *device, int instance)
{
char name[10];
snprintf(name, 10, "tspp%i", instance);
device->dent = debugfs_create_dir(
name, NULL);
if (device->dent) {
int i;
void __iomem *base = device->base;
for (i = 0; i < ARRAY_SIZE(debugfs_tspp_regs); i++) {
device->debugfs_regs[i] =
debugfs_create_file(
debugfs_tspp_regs[i].name,
debugfs_tspp_regs[i].mode,
device->dent,
base + debugfs_tspp_regs[i].offset,
&fops_iomem_x32);
}
}
}
static void tspp_debugfs_exit(struct tspp_device *device)
{
if (device->dent) {
int i;
<API key>(device->dent);
device->dent = NULL;
for (i = 0; i < ARRAY_SIZE(debugfs_tspp_regs); i++)
device->debugfs_regs[i] = NULL;
}
}
static int msm_tspp_map_irqs(struct platform_device *pdev,
struct tspp_device *device)
{
int rc;
rc = <API key>(pdev, "TSIF_TSPP_IRQ");
if (rc > 0) {
device->tspp_irq = rc;
} else {
dev_err(&pdev->dev, "failed to get TSPP IRQ");
return -EINVAL;
}
rc = <API key>(pdev, "TSIF0_IRQ");
if (rc > 0) {
device->tsif[0].tsif_irq = rc;
} else {
dev_err(&pdev->dev, "failed to get TSIF0 IRQ");
return -EINVAL;
}
rc = <API key>(pdev, "TSIF1_IRQ");
if (rc > 0) {
device->tsif[1].tsif_irq = rc;
} else {
dev_err(&pdev->dev, "failed to get TSIF1 IRQ");
return -EINVAL;
}
rc = <API key>(pdev, "TSIF_BAM_IRQ");
if (rc > 0) {
device->bam_irq = rc;
} else {
dev_err(&pdev->dev, "failed to get TSPP BAM IRQ");
return -EINVAL;
}
return 0;
}
static int msm_tspp_probe(struct platform_device *pdev)
{
int rc = -ENODEV;
u32 version;
u32 i;
struct tspp_device *device;
struct resource *mem_tsif0;
struct resource *mem_tsif1;
struct resource *mem_tspp;
struct resource *mem_bam;
struct msm_bus_scale_pdata *tspp_bus_pdata = NULL;
unsigned long rate;
if (pdev->dev.of_node) {
pdev->id = 0;
tspp_bus_pdata = <API key>(pdev);
} else {
pr_err("tspp: Device tree data not available\n");
rc = -EINVAL;
goto out;
}
device = kzalloc(sizeof(struct tspp_device), GFP_KERNEL);
if (!device) {
pr_err("tspp: Failed to allocate memory for device\n");
rc = -ENOMEM;
goto out;
}
device->pdev = pdev;
<API key>(pdev, device);
rc = tspp_get_pinctrl(device);
if (rc) {
pr_err("tspp: failed to get pin control data, rc=%d\n", rc);
goto err_pinctrl;
}
if (tspp_bus_pdata) {
device->tsif_bus_client =
<API key>(tspp_bus_pdata);
if (!device->tsif_bus_client)
pr_err("tspp: Unable to register bus client\n");
} else {
device->tsif_bus_client = 0;
}
device->tsif_vreg = devm_regulator_get(&pdev->dev, "vdd_cx");
if (IS_ERR(device->tsif_vreg)) {
rc = PTR_ERR(device->tsif_vreg);
device->tsif_vreg = NULL;
if (rc == -ENODEV) {
pr_notice("%s: vdd_cx regulator will not be used\n",
__func__);
} else {
dev_err(&pdev->dev,
"failed to get CX regulator, err=%d\n", rc);
goto err_regulator;
}
} else {
rc = <API key>(device->tsif_vreg,
<API key>,
<API key>);
if (rc) {
dev_err(&pdev->dev, "Unable to set CX voltage.\n");
goto err_regulator;
}
rc = regulator_enable(device->tsif_vreg);
if (rc) {
dev_err(&pdev->dev, "Unable to enable CX regulator.\n");
goto err_regulator;
}
}
device->tsif_pclk = clk_get(&pdev->dev, "iface_clk");
if (IS_ERR(device->tsif_pclk)) {
rc = PTR_ERR(device->tsif_pclk);
device->tsif_pclk = NULL;
goto err_pclock;
}
device->tsif_ref_clk = clk_get(&pdev->dev, "ref_clk");
if (IS_ERR(device->tsif_ref_clk)) {
rc = PTR_ERR(device->tsif_ref_clk);
device->tsif_ref_clk = NULL;
goto err_refclock;
}
rate = clk_round_rate(device->tsif_ref_clk, 1);
rc = clk_set_rate(device->tsif_ref_clk, rate);
if (rc)
goto err_res_tsif0;
mem_tsif0 = <API key>(pdev,
IORESOURCE_MEM, "MSM_TSIF0_PHYS");
if (!mem_tsif0) {
pr_err("tspp: Missing tsif0 MEM resource\n");
rc = -ENXIO;
goto err_res_tsif0;
}
device->tsif[0].base = ioremap(mem_tsif0->start,
resource_size(mem_tsif0));
if (!device->tsif[0].base) {
pr_err("tspp: ioremap failed\n");
goto err_map_tsif0;
}
mem_tsif1 = <API key>(pdev,
IORESOURCE_MEM, "MSM_TSIF1_PHYS");
if (!mem_tsif1) {
dev_err(&pdev->dev, "Missing tsif1 MEM resource\n");
rc = -ENXIO;
goto err_res_tsif1;
}
device->tsif[1].base = ioremap(mem_tsif1->start,
resource_size(mem_tsif1));
if (!device->tsif[1].base) {
dev_err(&pdev->dev, "ioremap failed");
goto err_map_tsif1;
}
mem_tspp = <API key>(pdev,
IORESOURCE_MEM, "MSM_TSPP_PHYS");
if (!mem_tspp) {
dev_err(&pdev->dev, "Missing MEM resource");
rc = -ENXIO;
goto err_res_dev;
}
device->base = ioremap(mem_tspp->start, resource_size(mem_tspp));
if (!device->base) {
dev_err(&pdev->dev, "ioremap failed");
goto err_map_dev;
}
mem_bam = <API key>(pdev,
IORESOURCE_MEM, "MSM_TSPP_BAM_PHYS");
if (!mem_bam) {
pr_err("tspp: Missing bam MEM resource");
rc = -ENXIO;
goto err_res_bam;
}
memset(&device->bam_props, 0, sizeof(device->bam_props));
device->bam_props.phys_addr = mem_bam->start;
device->bam_props.virt_addr = ioremap(mem_bam->start,
resource_size(mem_bam));
if (!device->bam_props.virt_addr) {
dev_err(&pdev->dev, "ioremap failed");
goto err_map_bam;
}
if (msm_tspp_map_irqs(pdev, device))
goto err_irq;
device->req_irqs = false;
<API key>(&pdev->dev);
pm_runtime_enable(&pdev->dev);
tspp_debugfs_init(device, 0);
for (i = 0; i < TSPP_TSIF_INSTANCES; i++)
tsif_debugfs_init(&device->tsif[i], i);
wake_lock_init(&device->wake_lock, WAKE_LOCK_SUSPEND,
dev_name(&pdev->dev));
device->filters[0] = device->base + <API key>;
device->filters[1] = device->base + <API key>;
device->filters[2] = device->base + <API key>;
device->tspp_key_table = device->base + TSPP_DATA_KEY;
device-><API key> =
device->base + <API key>;
device->tspp_pipe_context =
device->base + TSPP_PIPE_CONTEXT;
device-><API key> =
device->base + <API key>;
device->bam_props.summing_threshold = 0x10;
device->bam_props.irq = device->bam_irq;
device->bam_props.manage = SPS_BAM_MGR_LOCAL;
if (tspp_clock_start(device) != 0) {
dev_err(&pdev->dev, "Can't start clocks");
goto err_clock;
}
device->bam_handle = <API key>;
spin_lock_init(&device->spinlock);
mutex_init(&device->mutex);
tasklet_init(&device->tlet, <API key>,
(unsigned long)device);
tspp_global_reset(device);
version = readl_relaxed(device->base + TSPP_VERSION);
if ((version != 0x1) && (((version >> 28) & 0xF) != 0x1))
pr_warn("tspp: unrecognized hw version=%i", version);
for (i = 0; i < TSPP_NUM_CHANNELS; i++)
tspp_channel_init(&(device->channels[i]), device);
tspp_clock_stop(device);
printk("%s:TSPP probe is OK!",__func__);
list_add_tail(&(device->devlist), &tspp_devices);
return 0;
err_clock:
tspp_debugfs_exit(device);
for (i = 0; i < TSPP_TSIF_INSTANCES; i++)
tsif_debugfs_exit(&device->tsif[i]);
err_irq:
iounmap(device->bam_props.virt_addr);
err_map_bam:
err_res_bam:
iounmap(device->base);
err_map_dev:
err_res_dev:
iounmap(device->tsif[1].base);
err_map_tsif1:
err_res_tsif1:
iounmap(device->tsif[0].base);
err_map_tsif0:
err_res_tsif0:
if (device->tsif_ref_clk)
clk_put(device->tsif_ref_clk);
err_refclock:
if (device->tsif_pclk)
clk_put(device->tsif_pclk);
err_pclock:
if (device->tsif_vreg)
regulator_disable(device->tsif_vreg);
err_regulator:
if (device->tsif_bus_client)
<API key>(device->tsif_bus_client);
err_pinctrl:
kfree(device);
out:
return rc;
}
static int msm_tspp_remove(struct platform_device *pdev)
{
struct tspp_channel *channel;
u32 i;
struct tspp_device *device = <API key>(pdev);
for (i = 0; i < TSPP_NUM_CHANNELS; i++) {
channel = &device->channels[i];
tspp_close_channel(device->pdev->id, i);
}
for (i = 0; i < TSPP_TSIF_INSTANCES; i++) {
tsif_debugfs_exit(&device->tsif[i]);
}
mutex_destroy(&device->mutex);
if (device->tsif_bus_client)
<API key>(device->tsif_bus_client);
wake_lock_destroy(&device->wake_lock);
if (device->req_irqs)
msm_tspp_free_irqs(device);
iounmap(device->bam_props.virt_addr);
iounmap(device->base);
for (i = 0; i < TSPP_TSIF_INSTANCES; i++)
iounmap(device->tsif[i].base);
if (device->tsif_ref_clk)
clk_put(device->tsif_ref_clk);
if (device->tsif_pclk)
clk_put(device->tsif_pclk);
if (device->tsif_vreg)
regulator_disable(device->tsif_vreg);
pm_runtime_disable(&pdev->dev);
kfree(device);
return 0;
}
static int <API key>(struct device *dev)
{
dev_dbg(dev, "pm_runtime: suspending...");
return 0;
}
static int tspp_runtime_resume(struct device *dev)
{
dev_dbg(dev, "pm_runtime: resuming...");
return 0;
}
static const struct dev_pm_ops tspp_dev_pm_ops = {
.runtime_suspend = <API key>,
.runtime_resume = tspp_runtime_resume,
};
static struct of_device_id msm_match_table[] = {
{.compatible = "qcom,msm_tspp"},
{}
};
static struct platform_driver msm_tspp_driver = {
.probe = msm_tspp_probe,
.remove = msm_tspp_remove,
.driver = {
.name = "msm_tspp",
.pm = &tspp_dev_pm_ops,
.of_match_table = msm_match_table,
},
};
static int __init mod_init(void)
{
int rc;
rc = <API key>(&msm_tspp_driver);
if (rc)
pr_err("tspp: <API key> failed: %d", rc);
return rc;
}
static void __exit mod_exit(void)
{
<API key>(&msm_tspp_driver);
}
module_init(mod_init);
module_exit(mod_exit);
MODULE_DESCRIPTION("TSPP platform device");
MODULE_LICENSE("GPL v2");
|
/** @file
* @brief Dialog for renaming layers
*/
#ifndef <API key>
#define <API key>
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#if <API key> && <API key>
#include <glibmm/threads.h>
#endif
#include <gtkmm/dialog.h>
#include <gtkmm/entry.h>
#include <gtkmm/label.h>
#if WITH_GTKMM_3_0
#include <gtkmm/grid.h>
#else
#include <gtkmm/table.h>
#endif
#include <gtkmm/combobox.h>
#include <gtkmm/liststore.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/scrolledwindow.h>
#include "layer-fns.h"
#include "ui/widget/layer-selector.h"
class SPDesktop;
namespace Inkscape {
namespace UI {
namespace Dialogs {
class <API key> : public Gtk::Dialog {
public:
<API key>();
virtual ~<API key>();
Glib::ustring getName() const { return "<API key>"; }
static void showRename(SPDesktop *desktop, SPObject *layer) {
_showDialog(Rename::instance(), desktop, layer);
}
static void showCreate(SPDesktop *desktop, SPObject *layer) {
_showDialog(Create::instance(), desktop, layer);
}
static void showMove(SPDesktop *desktop, SPObject *layer) {
_showDialog(Move::instance(), desktop, layer);
}
protected:
struct Strategy {
virtual ~Strategy() {}
virtual void setup(<API key> &)=0;
virtual void perform(<API key> &)=0;
};
struct Rename : public Strategy {
static Rename &instance() { static Rename instance; return instance; }
void setup(<API key> &dialog);
void perform(<API key> &dialog);
};
struct Create : public Strategy {
static Create &instance() { static Create instance; return instance; }
void setup(<API key> &dialog);
void perform(<API key> &dialog);
};
struct Move : public Strategy {
static Move &instance() { static Move instance; return instance; }
void setup(<API key> &dialog);
void perform(<API key> &dialog);
};
friend struct Rename;
friend struct Create;
friend struct Move;
Strategy *_strategy;
SPDesktop *_desktop;
SPObject *_layer;
class <API key> : public Gtk::TreeModel::ColumnRecord {
public:
Gtk::TreeModelColumn<<API key>> position;
Gtk::TreeModelColumn<Glib::ustring> name;
<API key>() {
add(position); add(name);
}
};
Gtk::Label _layer_name_label;
Gtk::Entry _layer_name_entry;
Gtk::Label <API key>;
Gtk::ComboBox <API key>;
#if WITH_GTKMM_3_0
Gtk::Grid _layout_table;
#else
Gtk::Table _layout_table;
#endif
bool _position_visible;
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
public:
ModelColumns()
{
add(_colObject);
add(_colVisible);
add(_colLocked);
add(_colLabel);
}
virtual ~ModelColumns() {}
Gtk::TreeModelColumn<SPObject*> _colObject;
Gtk::TreeModelColumn<Glib::ustring> _colLabel;
Gtk::TreeModelColumn<bool> _colVisible;
Gtk::TreeModelColumn<bool> _colLocked;
};
Gtk::TreeView _tree;
ModelColumns* _model;
Glib::RefPtr<Gtk::TreeStore> _store;
Gtk::ScrolledWindow _scroller;
<API key> _dropdown_columns;
Gtk::CellRendererText _label_renderer;
Glib::RefPtr<Gtk::ListStore> _dropdown_list;
Gtk::Button _close_button;
Gtk::Button _apply_button;
sigc::connection _destroy_connection;
static <API key> &_instance() {
static <API key> instance;
return instance;
}
void _setDesktop(SPDesktop *desktop);
void _setLayer(SPObject *layer);
static void _showDialog(Strategy &strategy, SPDesktop *desktop, SPObject *layer);
void _apply();
void _close();
void <API key>();
void <API key>();
void <API key>(Gtk::TreeModel::const_iterator const &row);
void _addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::Row* parentRow, SPObject* target, int level );
SPObject* _selectedLayer();
bool _handleKeyEvent(GdkEventKey *event);
void _handleButtonEvent(GdkEventButton* event);
private:
<API key>(<API key> const &); // no copy
<API key> &operator=(<API key> const &); // no assign
};
} // namespace
} // namespace
} // namespace
#endif //<API key>
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|
<?php
namespace TYPO3\CMS\Backend\Form;
use TYPO3\CMS\Core\Utility\ArrayUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
/**
* Base class for container and single elements - their abstracts extend from here.
*/
abstract class AbstractNode implements NodeInterface
{
/**
* Main data array to work on, given from parent to child elements
*
* @var array
*/
protected $data = [];
/**
* Set data to data array.
*
* @todo: Should NOT set the nodeFactory instance, this is done by AbstractContainer only,
* @todo: but not done for Element classes: Elements are tree leaves, they MUST
* @todo: not create new nodes again.
* @todo: Currently, AbstractFormElement still does that, but do not rely on the fact that
* @todo: Element classes have an instance of NodeFactory at hand.
*
* @param NodeFactory $nodeFactory
* @param array $data
*/
public function __construct(NodeFactory $nodeFactory, array $data)
{
$this->data = $data;
}
/**
* Handler for single nodes
*
* @return array As defined in <API key>() of AbstractNode
*/
abstract public function render();
/**
* Initialize the array that is returned to parent after calling. This structure
* is identical for *all* nodes. Parent will merge the return of a child with its
* own stuff and in itself return an array of the same structure.
*
* @return array
*/
protected function <API key>()
{
return [
'<API key>' => [],
'<API key>' => [],
'<API key>' => [],
'<API key>' => [],
'stylesheetFiles' => [],
// can hold strings or arrays, string = requireJS module, array = requireJS module + callback e.g. array('TYPO3/Foo/Bar', 'function() {}')
'requireJsModules' => [],
'extJSCODE' => '',
'inlineData' => [],
'html' => '',
];
}
/**
* Merge existing data with a child return array
*
* @param array $existing Currently merged array
* @param array $childReturn Array returned by child
* @return array Result array
*/
protected function <API key>(array $existing, array $childReturn)
{
if (!empty($childReturn['html'])) {
$existing['html'] .= LF . $childReturn['html'];
}
if (!empty($childReturn['extJSCODE'])) {
$existing['extJSCODE'] .= LF . $childReturn['extJSCODE'];
}
foreach ($childReturn['<API key>'] as $value) {
$existing['<API key>'][] = $value;
}
foreach ($childReturn['<API key>'] as $value) {
$existing['<API key>'][] = $value;
}
foreach ($childReturn['<API key>'] as $value) {
$existing['<API key>'][] = $value;
}
foreach ($childReturn['stylesheetFiles'] as $value) {
$existing['stylesheetFiles'][] = $value;
}
if (!empty($childReturn['requireJsModules'])) {
foreach ($childReturn['requireJsModules'] as $module) {
$existing['requireJsModules'][] = $module;
}
}
if (!empty($childReturn['<API key>'])) {
foreach ($childReturn['<API key>'] as $<API key>) {
$existing['<API key>'][] = $<API key>;
}
}
if (!empty($childReturn['inlineData'])) {
$existingInlineData = $existing['inlineData'];
$childInlineData = $childReturn['inlineData'];
ArrayUtility::<API key>($existingInlineData, $childInlineData);
$existing['inlineData'] = $existingInlineData;
}
return $existing;
}
/**
* Build JSON string for validations rules and return it
* as data attribute for HTML elements.
*
* @param array $config
* @return string
*/
protected function <API key>(array $config)
{
return sprintf(' <API key>="%s" ', htmlspecialchars($this-><API key>($config)));
}
/**
* Build JSON string for validations rules.
*
* @param array $config
* @return string
*/
protected function <API key>(array $config)
{
$validationRules = [];
if (!empty($config['eval'])) {
$evalList = GeneralUtility::trimExplode(',', $config['eval'], true);
unset($config['eval']);
foreach ($evalList as $evalType) {
$validationRules[] = [
'type' => $evalType,
'config' => $config
];
}
}
if (!empty($config['range'])) {
$validationRules[] = [
'type' => 'range',
'config' => $config['range']
];
}
if (!empty($config['maxitems']) || !empty($config['minitems'])) {
$minItems = (isset($config['minitems'])) ? (int)$config['minitems'] : 0;
$maxItems = (isset($config['maxitems'])) ? (int)$config['maxitems'] : 10000;
$type = ($config['type']) ?: 'range';
if ($config['type'] === 'select' && $config['renderType'] !== 'selectTree' && $maxItems <= 1 && $minItems > 0) {
$validationRules[] = [
'type' => $type,
'minItems' => 1,
'maxItems' => 100000
];
} else {
$validationRules[] = [
'type' => $type,
'minItems' => $minItems,
'maxItems' => $maxItems
];
}
}
if (!empty($config['required'])) {
$validationRules[] = ['type' => 'required'];
}
return json_encode($validationRules);
}
}
|
#!/bin/sh
. ../../dttools/test/test_runner_common.sh
. ./parrot-test.sh
. ../../chirp/test/chirp-common.sh
c="./hostport.$PPID"
myp() {
parrot --no-chirp-catalog --timeout=5 --work-dir="/chirp/$hostport/" "$@"
}
prepare()
{
chirp_start local
echo "$hostport" > "$c"
return 0
}
run()
{
hostport=$(cat "$c")
set +e
N=10
myp /bin/sh <<EOF1
set -ex
cat > a.py <<EOF2
#!/chirp/$hostport/python
import sys
print(' '.join(sys.argv))
EOF2
cp "$(which python)" "$(which sh)" .
chmod 700 a.py python sh
EOF1
while [ "$N" -gt 0 ]; do
myp -- /bin/sh <<EOF1 &
./a.py
EOF1
N=$(expr $N - 1)
done
rc=0
for pid in $(jobs -p); do
wait "$pid"
result=$?
if [ $result -ne 0 ]; then
echo job $pid failed with exit code $result
rc=1
fi
done
return $rc
}
clean()
{
chirp_clean
rm -f "$c"
}
set -e
dispatch "$@"
# vim: set noexpandtab tabstop=4:
|
/* Make __c6xabi_AEABI_NAME an alias for __GCC_NAME. */
#define RENAME_LIBRARY(GCC_NAME, AEABI_NAME) \
__asm__ (".globl\t__c6xabi_" #AEABI_NAME "\n" \
".set\t__c6xabi_" #AEABI_NAME \
", __gnu_" #GCC_NAME "\n");
/* Rename helper functions to the names specified in the C6000 ELF ABI. */
#ifdef L_divsi3
#define <API key> RENAME_LIBRARY (divsi3, divi)
#endif
#ifdef L_divdi3
#define <API key> RENAME_LIBRARY (divdi3, divlli)
#endif
#ifdef L_udivsi3
#define <API key> RENAME_LIBRARY (udivsi3, divu)
#endif
#ifdef L_udivdi3
#define <API key> RENAME_LIBRARY (udivdi3, divull)
#endif
#ifdef L_udivmoddi4
#define <API key> RENAME_LIBRARY (udivmoddi4, divremull)
#endif
#ifdef L_modsi3
#define <API key> RENAME_LIBRARY (modsi3, remi)
#endif
#ifdef L_moddi3
#define <API key> RENAME_LIBRARY (moddi3, remlli)
#endif
#ifdef L_umodsi3
#define <API key> RENAME_LIBRARY (umodsi3, remu)
#endif
#ifdef L_umoddi3
#define <API key> RENAME_LIBRARY (umoddi3, remull)
#endif
#ifdef L_negdi2
#define <API key> RENAME_LIBRARY (negdi2, negll)
#endif
#ifdef L_muldi3
#define <API key> RENAME_LIBRARY (muldi3, mpyll)
#endif
#ifdef L_ashrdi3
#define <API key> RENAME_LIBRARY (ashrdi3, llshr)
#endif
#ifdef L_lshrdi3
#define <API key> RENAME_LIBRARY (lshrdi3, llshru)
#endif
#ifdef L_ashldi3
#define <API key> RENAME_LIBRARY (ashldi3, llshl)
#endif
/* The following are excluded from softfp due to <API key>,
so we rename them here rather than in sfp-machine.h. */
#ifdef L_fixdfdi
#define <API key> RENAME_LIBRARY (fixdfdi, fixdlli)
#endif
#ifdef L_fixunsdfsi
#define <API key> RENAME_LIBRARY (fixunsdfsi, fixdu)
#endif
#ifdef L_fixunsdfdi
#define <API key> RENAME_LIBRARY (fixunsdfdi, fixdull)
#endif
#ifdef L_fixsfdi
#define <API key> RENAME_LIBRARY (fixsfdi, fixflli)
#endif
#ifdef L_fixunssfsi
#define <API key> RENAME_LIBRARY (fixunssfsi, fixfu)
#endif
#ifdef L_fixunssfdi
#define <API key> RENAME_LIBRARY (fixunssfdi, fixfull)
#endif
#ifdef L_floatdidf
#define <API key> RENAME_LIBRARY (floatdidf, fltllid)
#endif
#ifdef L_floatundidf
#define <API key> RENAME_LIBRARY (floatundidf, fltulld)
#endif
#ifdef L_floatdisf
#define <API key> RENAME_LIBRARY (floatdisf, fltllif)
#endif
#ifdef L_floatundisf
#define <API key> RENAME_LIBRARY (floatundisf, fltullf)
#endif
#define LIBGCC2_GNU_PREFIX
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ohcount: CallbackItem Struct Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="pages.html"><span>Related Pages</span></a></li>
<li class="current"><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div class="tabs">
<ul>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="functions.html"><span>Data Fields</span></a></li>
</ul>
</div>
</div>
<div class="contents">
<h1>CallbackItem Struct Reference</h1><!-- doxytag: class="CallbackItem" -->Holds a series of callbacks for in a queue (linked list).
<a href="#_details">More...</a>
<p>
<code>#include <<a class="el" href="<API key>.html">parser_macros.h</a>></code>
<p>
<table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Data Fields</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">lang</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">entity</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">s</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">e</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">void * </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">udata</a></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">struct <a class="el" href="structCallbackItem.html">CallbackItem</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="structCallbackItem.html#<API key>">next</a></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Holds a series of callbacks for in a queue (linked list). <hr><h2>Field Documentation</h2>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::e" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::e</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The end position of the entity in the buffer.
</div>
</div><p>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::entity" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char* <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::entity</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The name of the entity associated with this callback. Must not be 'free'd.
</div>
</div><p>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::lang" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const char* <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::lang</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The language associated with this callback item. Must not be 'free'd.
</div>
</div><p>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::next" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">struct <a class="el" href="structCallbackItem.html">CallbackItem</a>* <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::next</a><code> [read]</code> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The next callback in the linked list.
</div>
</div><p>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::s" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::s</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
The start position of the entity in the buffer.
</div>
</div><p>
<a class="anchor" name="<API key>"></a><!-- doxytag: member="CallbackItem::udata" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">void* <a class="el" href="structCallbackItem.html#<API key>">CallbackItem::udata</a> </td>
</tr>
</table>
</div>
<div class="memdoc">
<p>
Userdata.
</div>
</div><p>
<hr>The documentation for this struct was generated from the following file:<ul>
<li>/Users/andy/dev/ohcount/src/<a class="el" href="<API key>.html">parser_macros.h</a></ul>
</div>
<hr size="1"><address style="text-align: right;"><small>Generated on Fri Aug 28 15:20:08 2009 for ohcount by
<a href="http:
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>
|
# -*- coding: utf-8 -*-
# Automatically generated - don't edit.
# Use `python setup.py build_ui` to update it.
from PyQt5 import QtCore, QtGui, QtWidgets
class <API key>(object):
def setupUi(self, <API key>):
<API key>.setObjectName("<API key>")
<API key>.resize(539, 705)
self.vboxlayout = QtWidgets.QVBoxLayout(<API key>)
self.vboxlayout.setObjectName("vboxlayout")
self.tag_compatibility = QtWidgets.QGroupBox(<API key>)
self.tag_compatibility.setObjectName("tag_compatibility")
self.vboxlayout1 = QtWidgets.QVBoxLayout(self.tag_compatibility)
self.vboxlayout1.setContentsMargins(-1, 6, -1, 7)
self.vboxlayout1.setSpacing(2)
self.vboxlayout1.setObjectName("vboxlayout1")
self.id3v2_version = QtWidgets.QGroupBox(self.tag_compatibility)
self.id3v2_version.setFlat(False)
self.id3v2_version.setCheckable(False)
self.id3v2_version.setObjectName("id3v2_version")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.id3v2_version)
self.horizontalLayout.setContentsMargins(-1, 6, -1, 7)
self.horizontalLayout.setObjectName("horizontalLayout")
self.write_id3v24 = QtWidgets.QRadioButton(self.id3v2_version)
self.write_id3v24.setChecked(True)
self.write_id3v24.setObjectName("write_id3v24")
self.horizontalLayout.addWidget(self.write_id3v24)
self.write_id3v23 = QtWidgets.QRadioButton(self.id3v2_version)
self.write_id3v23.setChecked(False)
self.write_id3v23.setObjectName("write_id3v23")
self.horizontalLayout.addWidget(self.write_id3v23)
self.label = QtWidgets.QLabel(self.id3v2_version)
self.label.setText("")
self.label.setWordWrap(True)
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.vboxlayout1.addWidget(self.id3v2_version)
self.id3v2_text_encoding = QtWidgets.QGroupBox(self.tag_compatibility)
self.id3v2_text_encoding.setObjectName("id3v2_text_encoding")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.id3v2_text_encoding)
self.horizontalLayout_2.setContentsMargins(-1, 6, -1, 7)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.enc_utf8 = QtWidgets.QRadioButton(self.id3v2_text_encoding)
self.enc_utf8.setObjectName("enc_utf8")
self.horizontalLayout_2.addWidget(self.enc_utf8)
self.enc_utf16 = QtWidgets.QRadioButton(self.id3v2_text_encoding)
self.enc_utf16.setObjectName("enc_utf16")
self.horizontalLayout_2.addWidget(self.enc_utf16)
self.enc_iso88591 = QtWidgets.QRadioButton(self.id3v2_text_encoding)
self.enc_iso88591.setObjectName("enc_iso88591")
self.horizontalLayout_2.addWidget(self.enc_iso88591)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_2.addItem(spacerItem1)
self.label_2 = QtWidgets.QLabel(self.id3v2_text_encoding)
self.label_2.setText("")
self.label_2.setWordWrap(True)
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.vboxlayout1.addWidget(self.id3v2_text_encoding)
self.<API key> = QtWidgets.QHBoxLayout()
self.<API key>.setObjectName("<API key>")
self.<API key> = QtWidgets.QLabel(self.tag_compatibility)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
sizePolicy.<API key>(4)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.<API key>.sizePolicy().hasHeightForWidth())
self.<API key>.setSizePolicy(sizePolicy)
self.<API key>.setObjectName("<API key>")
self.<API key>.addWidget(self.<API key>)
self.id3v23_join_with = QtWidgets.QComboBox(self.tag_compatibility)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
sizePolicy.<API key>(1)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.id3v23_join_with.sizePolicy().hasHeightForWidth())
self.id3v23_join_with.setSizePolicy(sizePolicy)
self.id3v23_join_with.setEditable(True)
self.id3v23_join_with.setObjectName("id3v23_join_with")
self.id3v23_join_with.addItem("")
self.id3v23_join_with.setItemText(0, "/")
self.id3v23_join_with.addItem("")
self.id3v23_join_with.setItemText(1, "; ")
self.id3v23_join_with.addItem("")
self.id3v23_join_with.setItemText(2, " / ")
self.<API key>.addWidget(self.id3v23_join_with)
self.vboxlayout1.addLayout(self.<API key>)
self.<API key> = QtWidgets.QCheckBox(self.tag_compatibility)
self.<API key>.setObjectName("<API key>")
self.vboxlayout1.addWidget(self.<API key>)
self.write_id3v1 = QtWidgets.QCheckBox(self.tag_compatibility)
self.write_id3v1.setObjectName("write_id3v1")
self.vboxlayout1.addWidget(self.write_id3v1)
self.vboxlayout.addWidget(self.tag_compatibility)
spacerItem2 = QtWidgets.QSpacerItem(274, 41, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.vboxlayout.addItem(spacerItem2)
self.retranslateUi(<API key>)
QtCore.QMetaObject.connectSlotsByName(<API key>)
<API key>.setTabOrder(self.write_id3v24, self.write_id3v23)
<API key>.setTabOrder(self.write_id3v23, self.enc_utf8)
<API key>.setTabOrder(self.enc_utf8, self.enc_utf16)
<API key>.setTabOrder(self.enc_utf16, self.enc_iso88591)
<API key>.setTabOrder(self.enc_iso88591, self.id3v23_join_with)
<API key>.setTabOrder(self.id3v23_join_with, self.<API key>)
<API key>.setTabOrder(self.<API key>, self.write_id3v1)
def retranslateUi(self, <API key>):
_translate = QtCore.QCoreApplication.translate
self.tag_compatibility.setTitle(_("ID3"))
self.id3v2_version.setTitle(_("ID3v2 Version"))
self.write_id3v24.setText(_("2.4"))
self.write_id3v23.setText(_("2.3"))
self.id3v2_text_encoding.setTitle(_("ID3v2 text encoding"))
self.enc_utf8.setText(_("UTF-8"))
self.enc_utf16.setText(_("UTF-16"))
self.enc_iso88591.setText(_("ISO-8859-1"))
self.<API key>.setText(_("Join multiple ID3v2.3 tags with:"))
self.id3v23_join_with.setToolTip(_("<html><head/><body><p>Default is \'/\' to maintain compatibility with previous Picard releases.</p><p>New alternatives are \';_\' or \'_/_\' or type your own. </p></body></html>"))
self.<API key>.setText(_("Save iTunes compatible grouping and work"))
self.write_id3v1.setText(_("Also include ID3v1 tags in the files"))
|
(function ($) {
angular.module('<API key>', ['mediaBrowser', 'MediaBrowserField']);
})(jQuery);
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "arm9tdmi.h"
#include "target_type.h"
#include "register.h"
#include "arm_opcodes.h"
#include "arm_semihosting.h"
/*
* NOTE: this holds code that's used with multiple ARM9 processors:
* - ARM9TDMI (ARMv4T) ... in ARM920, ARM922, and ARM940 cores
* - ARM9E-S (ARMv5TE) ... in ARM946, ARM966, and ARM968 cores
* - ARM9EJS (ARMv5TEJ) ... in ARM926 core
*
* In short, the file name is a misnomer ... it is NOT specific to
* that first generation ARM9 processor, or cores using it.
*/
#if 0
#define <API key>
#endif
enum arm9tdmi_vector_bit {
<API key> = 0x01,
<API key> = 0x02,
ARM9TDMI_SWI_VECTOR = 0x04,
<API key> = 0x08,
<API key> = 0x10,
/* BIT(5) reserved -- must be zero */
ARM9TDMI_IRQ_VECTOR = 0x40,
ARM9TDMI_FIQ_VECTOR = 0x80,
};
static const struct arm9tdmi_vector {
const char *name;
uint32_t value;
} arm9tdmi_vectors[] = {
{"reset", <API key>},
{"undef", <API key>},
{"swi", ARM9TDMI_SWI_VECTOR},
{"pabt", <API key>},
{"dabt", <API key>},
{"irq", ARM9TDMI_IRQ_VECTOR},
{"fiq", ARM9TDMI_FIQ_VECTOR},
{0, 0},
};
int <API key>(struct target *target)
{
int retval = ERROR_OK;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
/* only check the debug reason if we don't know it already */
if ((target->debug_reason != DBG_REASON_DBGRQ)
&& (target->debug_reason != <API key>)) {
struct scan_field fields[3];
uint8_t databus[4];
uint8_t instructionbus[4];
uint8_t debug_reason;
fields[0].num_bits = 32;
fields[0].out_value = NULL;
fields[0].in_value = databus;
fields[1].num_bits = 3;
fields[1].out_value = NULL;
fields[1].in_value = &debug_reason;
fields[2].num_bits = 32;
fields[2].out_value = NULL;
fields[2].in_value = instructionbus;
retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(arm7_9->jtag_info.tap, arm7_9->jtag_info.intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
jtag_add_dr_scan(arm7_9->jtag_info.tap, 3, fields, TAP_DRPAUSE);
retval = jtag_execute_queue();
if (retval != ERROR_OK)
return retval;
fields[0].in_value = NULL;
fields[0].out_value = databus;
fields[1].in_value = NULL;
fields[1].out_value = &debug_reason;
fields[2].in_value = NULL;
fields[2].out_value = instructionbus;
jtag_add_dr_scan(arm7_9->jtag_info.tap, 3, fields, TAP_DRPAUSE);
if (debug_reason & 0x4)
if (debug_reason & 0x2)
target->debug_reason = <API key>;
else
target->debug_reason = <API key>;
else
target->debug_reason = <API key>;
}
return ERROR_OK;
}
/* put an instruction in the ARM9TDMI pipeline or write the data bus,
* and optionally read data
*/
int arm9tdmi_clock_out(struct arm_jtag *jtag_info, uint32_t instr,
uint32_t out, uint32_t *in, int sysspeed)
{
int retval = ERROR_OK;
struct scan_field fields[3];
uint8_t out_buf[4];
uint8_t instr_buf[4];
uint8_t sysspeed_buf = 0x0;
/* prepare buffer */
buf_set_u32(out_buf, 0, 32, out);
buf_set_u32(instr_buf, 0, 32, flip_u32(instr, 32));
if (sysspeed)
buf_set_u32(&sysspeed_buf, 2, 1, 1);
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
fields[0].num_bits = 32;
fields[0].out_value = out_buf;
fields[0].in_value = NULL;
fields[1].num_bits = 3;
fields[1].out_value = &sysspeed_buf;
fields[1].in_value = NULL;
fields[2].num_bits = 32;
fields[2].out_value = instr_buf;
fields[2].in_value = NULL;
if (in) {
fields[0].in_value = (uint8_t *)in;
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_DRPAUSE);
jtag_add_callback(arm_le_to_h_u32, (<API key>)in);
} else
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_DRPAUSE);
jtag_add_runtest(0, TAP_DRPAUSE);
#ifdef <API key>
{
retval = jtag_execute_queue();
if (retval != ERROR_OK)
return retval;
if (in)
LOG_DEBUG("instr: 0x%8.8x, out: 0x%8.8x, in: 0x%8.8x", instr, out, *in);
else
LOG_DEBUG("instr: 0x%8.8x, out: 0x%8.8x", instr, out);
}
#endif
return ERROR_OK;
}
/* just read data (instruction and data-out = don't care) */
int <API key>(struct arm_jtag *jtag_info, uint32_t *in)
{
int retval = ERROR_OK;
struct scan_field fields[3];
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
fields[0].num_bits = 32;
fields[0].out_value = NULL;
fields[0].in_value = (uint8_t *)in;
fields[1].num_bits = 3;
fields[1].out_value = NULL;
fields[1].in_value = NULL;
fields[2].num_bits = 32;
fields[2].out_value = NULL;
fields[2].in_value = NULL;
jtag_add_dr_scan(jtag_info->tap, 3, fields, TAP_DRPAUSE);
jtag_add_callback(arm_le_to_h_u32, (<API key>)in);
jtag_add_runtest(0, TAP_DRPAUSE);
#ifdef <API key>
{
retval = jtag_execute_queue();
if (retval != ERROR_OK)
return retval;
if (in)
LOG_DEBUG("in: 0x%8.8x", *in);
else
LOG_ERROR("BUG: called with in == NULL");
}
#endif
return ERROR_OK;
}
/* clock the target, and read the databus
* the *in pointer points to a buffer where elements of 'size' bytes
* are stored in big (be == 1) or little (be == 0) endianness
*/
int <API key>(struct arm_jtag *jtag_info,
void *in, int size, int be)
{
int retval = ERROR_OK;
struct scan_field fields[2];
retval = arm_jtag_scann(jtag_info, 0x1, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_DRPAUSE);
if (retval != ERROR_OK)
return retval;
if (size == 4) {
fields[0].num_bits = 32;
fields[0].out_value = NULL;
fields[0].in_value = in;
fields[1].num_bits = 3 + 32;
fields[1].out_value = NULL;
fields[1].in_value = NULL;
} else {
/* Discard irrelevant bits of the scan, making sure we don't write more
* than size bytes to in */
fields[0].num_bits = size * 8;
fields[0].out_value = NULL;
fields[0].in_value = in;
fields[1].num_bits = 3 + 32 + 32 - size * 8;
fields[1].out_value = NULL;
fields[1].in_value = NULL;
}
jtag_add_dr_scan(jtag_info->tap, 2, fields, TAP_DRPAUSE);
jtag_add_callback4(<API key>,
(<API key>)in,
(<API key>)size,
(<API key>)be,
(<API key>)0);
jtag_add_runtest(0, TAP_DRPAUSE);
#ifdef <API key>
{
retval = jtag_execute_queue();
if (retval != ERROR_OK)
return retval;
if (in)
LOG_DEBUG("in: 0x%8.8x", *(uint32_t *)in);
else
LOG_ERROR("BUG: called with in == NULL");
}
#endif
return ERROR_OK;
}
static void <API key>(struct target *target,
uint32_t *r0, uint32_t *pc)
{
int retval = ERROR_OK;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* save r0 before using it and put system in ARM state
* to allow common handling of ARM and THUMB debugging */
/* fetch STR r0, [r0] */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_STR(0, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* STR r0, [r0] in Memory */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, r0, 0);
/* MOV r0, r15 fetched, STR in Decode */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_MOV(0, 15), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_STR(0, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* nothing fetched, STR r0, [r0] in Memory */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, pc, 0);
/* use pc-relative LDR to clear r0[1:0] (for switch to ARM mode) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_LDR_PCREL(0), 0, NULL, 0);
/* LDR in Decode */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* LDR in Execute */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* LDR in Memory (to account for interlock) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* fetch BX */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_BX(0), 0, NULL, 0);
/* NOP fetched, BX in Decode, MOV in Execute */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* NOP fetched, BX in Execute (1) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
retval = jtag_execute_queue();
if (retval != ERROR_OK)
return;
/* fix program counter:
* MOV r0, r15 was the 5th instruction (+8)
* reading PC in Thumb state gives address of instruction + 4
*/
*pc -= 0xc;
}
void <API key>(struct target *target,
uint32_t mask, uint32_t *core_regs[16])
{
int i;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* STMIA r0-15, [r0] at debug speed
* register values will start to appear on 4th DCLK
*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_STMIA(0, mask & 0xffff, 0, 0), 0, NULL, 0);
/* fetch NOP, STM in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, STM in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
for (i = 0; i <= 15; i++) {
if (mask & (1 << i))
/* nothing fetched, STM in MEMORY (i'th cycle) */
<API key>(jtag_info, core_regs[i]);
}
}
static void <API key>(struct target *target,
uint32_t mask, void *buffer, int size)
{
int i;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
int be = (target->endianness == TARGET_BIG_ENDIAN) ? 1 : 0;
uint32_t *buf_u32 = buffer;
uint16_t *buf_u16 = buffer;
uint8_t *buf_u8 = buffer;
/* STMIA r0-15, [r0] at debug speed
* register values will start to appear on 4th DCLK
*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_STMIA(0, mask & 0xffff, 0, 0), 0, NULL, 0);
/* fetch NOP, STM in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, STM in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
for (i = 0; i <= 15; i++) {
if (mask & (1 << i))
/* nothing fetched, STM in MEMORY (i'th cycle) */
switch (size) {
case 4:
<API key>(jtag_info, buf_u32++, 4, be);
break;
case 2:
<API key>(jtag_info, buf_u16++, 2, be);
break;
case 1:
<API key>(jtag_info, buf_u8++, 1, be);
break;
}
}
}
static void arm9tdmi_read_xpsr(struct target *target, uint32_t *xpsr, int spsr)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* MRS r0, cpsr */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MRS(0, spsr & 1), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* STR r0, [r15] */
arm9tdmi_clock_out(jtag_info, ARMV4_5_STR(0, 15), 0, NULL, 0);
/* fetch NOP, STR in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, STR in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, STR in MEMORY */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, xpsr, 0);
}
static void arm9tdmi_write_xpsr(struct target *target, uint32_t xpsr, int spsr)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
LOG_DEBUG("xpsr: %8.8" PRIx32 ", spsr: %i", xpsr, spsr);
/* MSR1 fetched */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MSR_IM(xpsr & 0xff, 0, 1, spsr), 0, NULL, 0);
/* MSR2 fetched, MSR1 in DECODE */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MSR_IM((xpsr & 0xff00) >> 8, 0xc, 2, spsr), 0, NULL, 0);
/* MSR3 fetched, MSR1 in EXECUTE (1), MSR2 in DECODE */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MSR_IM((xpsr & 0xff0000) >> 16, 0x8, 4, spsr), 0, NULL, 0);
/* nothing fetched, MSR1 in EXECUTE (2) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, MSR1 in EXECUTE (3) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* MSR4 fetched, MSR2 in EXECUTE (1), MSR3 in DECODE */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MSR_IM((xpsr & 0xff000000) >> 24, 0x4, 8, spsr), 0, NULL, 0);
/* nothing fetched, MSR2 in EXECUTE (2) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, MSR2 in EXECUTE (3) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* NOP fetched, MSR3 in EXECUTE (1), MSR4 in DECODE */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, MSR3 in EXECUTE (2) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, MSR3 in EXECUTE (3) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* NOP fetched, MSR4 in EXECUTE (1) */
/* last MSR writes flags, which takes only one cycle */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
}
static void <API key>(struct target *target,
uint8_t xpsr_im, int rot, int spsr)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
LOG_DEBUG("xpsr_im: %2.2x, rot: %i, spsr: %i", xpsr_im, rot, spsr);
/* MSR fetched */
arm9tdmi_clock_out(jtag_info, ARMV4_5_MSR_IM(xpsr_im, rot, 1, spsr), 0, NULL, 0);
/* NOP fetched, MSR in DECODE */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* NOP fetched, MSR in EXECUTE (1) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* rot == 4 writes flags, which takes only one cycle */
if (rot != 4) {
/* nothing fetched, MSR in EXECUTE (2) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, MSR in EXECUTE (3) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
}
}
void <API key>(struct target *target,
uint32_t mask, uint32_t core_regs[16])
{
int i;
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* LDMIA r0-15, [r0] at debug speed
* register values will start to appear on 4th DCLK
*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDMIA(0, mask & 0xffff, 0, 0), 0, NULL, 0);
/* fetch NOP, LDM in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, LDM in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
for (i = 0; i <= 15; i++) {
if (mask & (1 << i))
/* nothing fetched, LDM still in EXECUTE (1 + i cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, core_regs[i], NULL, 0);
}
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
}
void <API key>(struct target *target, uint32_t mask)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed load-multiple into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDMIA(0, mask & 0xffff, 0, 1), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
void <API key>(struct target *target, int num)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed load half-word into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDRH_IP(num, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
void <API key>(struct target *target, int num)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed load byte into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDRB_IP(num, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
void <API key>(struct target *target, uint32_t mask)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed store-multiple into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_STMIA(0, mask, 0, 1), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
void <API key>(struct target *target, int num)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed store half-word into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_STRH_IP(num, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
void <API key>(struct target *target, int num)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* put system-speed store byte into the pipeline */
arm9tdmi_clock_out(jtag_info, ARMV4_5_STRB_IP(num, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
static void arm9tdmi_write_pc(struct target *target, uint32_t pc)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
/* LDMIA r0-15, [r0] at debug speed
* register values will start to appear on 4th DCLK
*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDMIA(0, 0x8000, 0, 0), 0, NULL, 0);
/* fetch NOP, LDM in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, LDM in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, LDM in EXECUTE stage (2nd cycle) (output data) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, pc, NULL, 0);
/* nothing fetched, LDM in EXECUTE stage (3rd cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, LDM in EXECUTE stage (4th cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, LDM in EXECUTE stage (5th cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
}
void <API key>(struct target *target)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
arm9tdmi_clock_out(jtag_info, ARMV4_5_B(0xfffffc, 0), 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
}
static void <API key>(struct target *target)
{
LOG_DEBUG("-");
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct arm *arm = &arm7_9->arm;
struct arm_jtag *jtag_info = &arm7_9->jtag_info;
struct reg *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
/* LDMIA r0-15, [r0] at debug speed
* register values will start to appear on 4th DCLK
*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_LDMIA(0, 0x1, 0, 0), 0, NULL, 0);
/* fetch NOP, LDM in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* fetch NOP, LDM in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* nothing fetched, LDM in EXECUTE stage (2nd cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP,
buf_get_u32(arm->pc->value, 0, 32) | 1, NULL, 0);
/* nothing fetched, LDM in EXECUTE stage (3rd cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* Branch and eXchange */
arm9tdmi_clock_out(jtag_info, ARMV4_5_BX(0), 0, NULL, 0);
<API key>(dbg_stat);
/* fetch NOP, BX in DECODE stage */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
<API key>(dbg_stat);
/* fetch NOP, BX in EXECUTE stage (1st cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 0);
/* target is now in Thumb state */
<API key>(dbg_stat);
/* load r0 value, MOV_IM in Decode*/
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_LDR_PCREL(0), 0, NULL, 0);
/* fetch NOP, LDR in Decode, MOV_IM in Execute */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* fetch NOP, LDR in Execute */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
/* nothing fetched, LDR in EXECUTE stage (2nd cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP,
buf_get_u32(arm->core_cache->reg_list[0].value, 0, 32), NULL, 0);
/* nothing fetched, LDR in EXECUTE stage (3rd cycle) */
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
<API key>(dbg_stat);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_B(0x7f7), 0, NULL, 1);
arm9tdmi_clock_out(jtag_info, ARMV4_5_T_NOP, 0, NULL, 0);
}
void <API key>(struct target *target, uint32_t next_pc)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (arm7_9->has_single_step) {
buf_set_u32(arm7_9->eice_cache->reg_list[EICE_DBG_CTRL].value, 3, 1, 1);
<API key>(&arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]);
} else
<API key>(target, next_pc);
}
void <API key>(struct target *target)
{
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
if (arm7_9->has_single_step) {
buf_set_u32(arm7_9->eice_cache->reg_list[EICE_DBG_CTRL].value, 3, 1, 0);
<API key>(&arm7_9->eice_cache->reg_list[EICE_DBG_CTRL]);
} else
<API key>(target);
}
static void <API key>(struct target *target)
{
struct reg_cache **cache_p = <API key>(&target->reg_cache);
struct arm *arm = target_to_arm(target);
(*cache_p) = arm_build_reg_cache(target, arm);
}
int <API key>(struct command_context *cmd_ctx,
struct target *target)
{
<API key>(target);
<API key>(target);
return ERROR_OK;
}
int <API key>(struct target *target,
struct arm7_9_common *arm7_9, struct jtag_tap *tap)
{
/* prepare JTAG information for the new target */
arm7_9->jtag_info.tap = tap;
arm7_9->jtag_info.scann_size = 5;
/* register arch-specific functions */
arm7_9-><API key> = <API key>;
arm7_9->change_to_arm = <API key>;
arm7_9->read_core_regs = <API key>;
arm7_9-><API key> = <API key>;
arm7_9->read_xpsr = arm9tdmi_read_xpsr;
arm7_9->write_xpsr = arm9tdmi_write_xpsr;
arm7_9->write_xpsr_im8 = <API key>;
arm7_9->write_core_regs = <API key>;
arm7_9->load_word_regs = <API key>;
arm7_9->load_hword_reg = <API key>;
arm7_9->load_byte_reg = <API key>;
arm7_9->store_word_regs = <API key>;
arm7_9->store_hword_reg = <API key>;
arm7_9->store_byte_reg = <API key>;
arm7_9->write_pc = arm9tdmi_write_pc;
arm7_9->branch_resume = <API key>;
arm7_9->branch_resume_thumb = <API key>;
arm7_9->enable_single_step = <API key>;
arm7_9->disable_single_step = <API key>;
arm7_9->write_memory = arm7_9_write_memory;
arm7_9->bulk_write_memory = <API key>;
arm7_9->post_debug_entry = NULL;
arm7_9->pre_restore_context = NULL;
/* initialize arch-specific breakpoint handling */
arm7_9->arm_bkpt = 0xdeeedeee;
arm7_9->thumb_bkpt = 0xdeee;
arm7_9->dbgreq_adjust_pc = 3;
<API key>(target, arm7_9);
/* override use of DBGRQ, this is safe on ARM9TDMI */
arm7_9->use_dbgrq = 1;
/* all ARM9s have the vector catch register */
arm7_9->has_vector_catch = 1;
return ERROR_OK;
}
static int <API key>(struct target *target, Jim_Interp *interp)
{
struct arm7_9_common *arm7_9 = calloc(1, sizeof(struct arm7_9_common));
<API key>(target, arm7_9, target->tap);
arm7_9->arm.is_armv4 = true;
return ERROR_OK;
}
COMMAND_HANDLER(<API key>)
{
struct target *target = get_current_target(CMD_CTX);
struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
struct reg *vector_catch;
uint32_t vector_catch_value;
if (!target_was_examined(target)) {
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
/* it's uncommon, but some ARM7 chips can support this */
if (arm7_9->common_magic != ARM7_9_COMMON_MAGIC
|| !arm7_9->has_vector_catch) {
command_print(CMD_CTX, "target doesn't have EmbeddedICE "
"with vector_catch");
return <API key>;
}
vector_catch = &arm7_9->eice_cache->reg_list[EICE_VEC_CATCH];
/* read the vector catch register if necessary */
if (!vector_catch->valid)
<API key>(vector_catch);
/* get the current setting */
vector_catch_value = buf_get_u32(vector_catch->value, 0, 8);
if (CMD_ARGC > 0) {
vector_catch_value = 0x0;
if (strcmp(CMD_ARGV[0], "all") == 0)
vector_catch_value = 0xdf;
else if (strcmp(CMD_ARGV[0], "none") == 0) {
/* do nothing */
} else {
for (unsigned i = 0; i < CMD_ARGC; i++) {
/* go through list of vectors */
unsigned j;
for (j = 0; arm9tdmi_vectors[j].name; j++) {
if (strcmp(CMD_ARGV[i], arm9tdmi_vectors[j].name) == 0) {
vector_catch_value |= arm9tdmi_vectors[j].value;
break;
}
}
/* complain if vector wasn't found */
if (!arm9tdmi_vectors[j].name) {
command_print(CMD_CTX, "vector '%s' not found, leaving current setting unchanged", CMD_ARGV[i]);
/* reread current setting */
vector_catch_value = buf_get_u32(
vector_catch->value,
0, 8);
break;
}
}
}
/* store new settings */
buf_set_u32(vector_catch->value, 0, 8, vector_catch_value);
<API key>(vector_catch);
}
/* output current settings */
for (unsigned i = 0; arm9tdmi_vectors[i].name; i++) {
command_print(CMD_CTX, "%s: %s", arm9tdmi_vectors[i].name,
(vector_catch_value & arm9tdmi_vectors[i].value)
? "catch" : "don't catch");
}
return ERROR_OK;
}
static const struct <API key> <API key>[] = {
{
.name = "vector_catch",
.handler = <API key>,
.mode = COMMAND_EXEC,
.help = "Display, after optionally updating, configuration "
"of vector catch unit.",
.usage = "[all|none|(reset|undef|swi|pabt|dabt|irq|fiq)*]",
},
<API key>
};
const struct <API key> <API key>[] = {
{
.chain = <API key>,
},
{
.name = "arm9",
.mode = COMMAND_ANY,
.help = "arm9 command group",
.usage = "",
.chain = <API key>,
},
<API key>
};
/** Holds methods for ARM9TDMI targets. */
struct target_type arm9tdmi_target = {
.name = "arm9tdmi",
.poll = arm7_9_poll,
.arch_state = arm_arch_state,
.target_request_data = <API key>,
.halt = arm7_9_halt,
.resume = arm7_9_resume,
.step = arm7_9_step,
.assert_reset = arm7_9_assert_reset,
.deassert_reset = <API key>,
.soft_reset_halt = <API key>,
.get_gdb_arch = arm_get_gdb_arch,
.get_gdb_reg_list = <API key>,
.read_memory = arm7_9_read_memory,
.write_memory = <API key>,
.checksum_memory = arm_checksum_memory,
.blank_check_memory = <API key>,
.run_algorithm = <API key>,
.add_breakpoint = <API key>,
.remove_breakpoint = <API key>,
.add_watchpoint = <API key>,
.remove_watchpoint = <API key>,
.commands = <API key>,
.target_create = <API key>,
.init_target = <API key>,
.examine = arm7_9_examine,
.check_reset = arm7_9_check_reset,
};
|
<?php
if (!defined('NV_IS_FILE_ADMIN')) {
die('Stop!!!');
}
$page_title = $lang_module['content_list'];
$stype = $nv_Request->get_string('stype', 'get', '-');
$sstatus = $nv_Request->get_int('sstatus', 'get', -1);
$catid = $nv_Request->get_int('catid', 'get', 0);
$per_page_old = $nv_Request->get_int('per_page', 'cookie', 50);
$per_page = $nv_Request->get_int('per_page', 'get', $per_page_old);
$num_items = $nv_Request->get_int('num_items', 'get', 0);
if ($per_page < 1 and $per_page > 500) {
$per_page = 50;
}
if ($per_page_old != $per_page) {
$nv_Request->set_Cookie('per_page', $per_page, NV_LIVE_COOKIE_TIME);
}
$q = $nv_Request->get_title('q', 'get', '');
$q = str_replace('+', ' ', $q);
$qhtml = nv_htmlspecialchars($q);
$ordername = $nv_Request->get_string('ordername', 'get', 'publtime');
$order = $nv_Request->get_string('order', 'get') == 'asc' ? 'asc' : 'desc';
$val_cat_content = array();
$val_cat_content[] = array(
'value' => 0,
'selected' => ($catid == 0) ? ' selected="selected"' : '',
'title' => $lang_module['search_cat_all']
);
$array_cat_view = array();
$check_declined = false;
foreach ($global_array_cat as $catid_i => $array_value) {
$lev_i = $array_value['lev'];
$check_cat = false;
if (defined('NV_IS_ADMIN_MODULE')) {
$check_cat = true;
} elseif (isset($array_cat_admin[$admin_id][$catid_i])) {
$_cat_admin_i = $array_cat_admin[$admin_id][$catid_i];
if ($_cat_admin_i['admin'] == 1) {
$check_cat = true;
$check_declined = true;
} elseif ($_cat_admin_i['add_content'] == 1) {
$check_cat = true;
} elseif ($_cat_admin_i['pub_content'] == 1 or $_cat_admin_i['app_content'] == 1) {
$check_cat = true;
$check_declined = true;
} elseif ($_cat_admin_i['edit_content'] == 1) {
$check_cat = true;
} elseif ($_cat_admin_i['del_content'] == 1) {
$check_cat = true;
}
}
if ($check_cat) {
$xtitle_i = '';
if ($lev_i > 0) {
$xtitle_i .= ' |';
for ($i = 1; $i <= $lev_i; ++$i) {
$xtitle_i .= '
}
$xtitle_i .= '> ';
}
$xtitle_i .= $array_value['title'];
$sl = '';
if ($catid_i == $catid) {
$sl = ' selected="selected"';
}
$val_cat_content[] = array(
'value' => $catid_i,
'selected' => $sl,
'title' => $xtitle_i
);
$array_cat_view[] = $catid_i;
}
}
if (!defined('NV_IS_ADMIN_MODULE') and $catid > 0 and !in_array($catid, $array_cat_view)) {
Header('Location: ' . NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=main');
die();
}
$array_search = array(
'-' => '
'title' => $lang_module['search_title'],
'bodytext' => $lang_module['search_bodytext'],
'author' => $lang_module['search_author'],
'admin_id' => $lang_module['search_admin'],
'sourcetext' => $lang_module['sources']
);
$array_in_rows = array(
'title',
'bodytext',
'author',
'sourcetext'
);
$array_in_ordername = array(
'title',
'publtime',
'exptime',
'hitstotal',
'hitscm'
);
$array_status_view = array(
'-' => '
'5' => $lang_module['status_5'],
'1' => $lang_module['status_1'],
'0' => $lang_module['status_0'],
'6' => $lang_module['status_6'],
'4' => $lang_module['status_4'],
'2' => $lang_module['status_2'],
'3' => $lang_module['status_3']
);
$array_status_class = array(
'5' => 'danger',
'1' => '',
'0' => 'warning',
'6' => 'warning',
'4' => 'info',
'2' => 'success',
'3' => 'danger'
);
$_permission_action = array();
$array_list_action = array(
'delete' => $lang_global['delete'],
're-published' => $lang_module['re_published'],
'publtime' => $lang_module['publtime'],
'stop' => $lang_module['status_0'],
'waiting' => $lang_module['status_action_0']
);
// Chuyen sang cho duyet
if (defined('NV_IS_ADMIN_MODULE')) {
$array_list_action['declined'] = $lang_module['declined'];
$array_list_action['block'] = $lang_module['addtoblock'];
$array_list_action['addtotopics'] = $lang_module['addtotopics'];
$array_list_action['move'] = $lang_module['move'];
} elseif ($check_declined) { //Neu co quyen duyet bai thi
$array_list_action['declined'] = $lang_module['declined'];
}
if (!in_array($stype, array_keys($array_search))) {
$stype = '-';
}
if ($sstatus < 0 or $sstatus > 10) {
$sstatus = -1;
}
if (!in_array($ordername, array_keys($array_in_ordername))) {
$ordername = 'id';
}
if ($catid == 0) {
$from = NV_PREFIXLANG . '_' . $module_data . '_rows r';
} else {
$from = NV_PREFIXLANG . '_' . $module_data . '_' . $catid . ' r';
}
$where = '';
$page = $nv_Request->get_int('page', 'get', 1);
$checkss = $nv_Request->get_string('checkss', 'get', '');
if ($checkss == NV_CHECK_SESSION) {
if ($stype == 'bodytext') {
$from .= ' INNER JOIN ' . NV_PREFIXLANG . '_' . $module_data . '_detail c ON (r.id=c.id)';
$where = " c.bodyhtml LIKE '%" . $db_slave->dblikeescape($q) . "%'";
} elseif ($stype == "author" or $stype == "title") {
$where = " r." . $stype . " LIKE '%" . $db_slave->dblikeescape($qhtml) . "%'";
} elseif ($stype == 'sourcetext') {
$qurl = $q;
$url_info = @parse_url($qurl);
if (isset($url_info['scheme']) and isset($url_info['host'])) {
$qurl = $url_info['scheme'] . '://' . $url_info['host'];
}
$where = " r.sourceid IN (SELECT sourceid FROM " . NV_PREFIXLANG . "_" . $module_data . "_sources WHERE title like '%" . $db_slave->dblikeescape($q) . "%' OR link like '%" . $db_slave->dblikeescape($qurl) . "%')";
} elseif ($stype == 'admin_id') {
$where = " (u.username LIKE '%" . $db_slave->dblikeescape($qhtml) . "%' OR u.first_name LIKE '%" . $db_slave->dblikeescape($qhtml) . "%')";
} elseif (!empty($q)) {
$from .= ' INNER JOIN ' . NV_PREFIXLANG . '_' . $module_data . '_detail c ON (r.id=c.id)';
$arr_from = array();
foreach ($array_in_rows as $key => $val) {
$arr_from[] = "(r." . $val . " LIKE '%" . $db_slave->dblikeescape($q) . "%')";
}
$where = " (r.author LIKE '%" . $db_slave->dblikeescape($qhtml) . "%'
OR r.title LIKE '%" . $db_slave->dblikeescape($qhtml) . "%'
OR c.bodyhtml LIKE '%" . $db_slave->dblikeescape($q) . "%'
OR u.username LIKE '%" . $db_slave->dblikeescape($qhtml) . "%'
OR u.first_name LIKE '%" . $db_slave->dblikeescape($qhtml) . "%')";
}
if ($sstatus != -1) {
if ($where == '') {
$where = ' r.status = ' . $sstatus;
} else {
$where .= ' AND r.status = ' . $sstatus;
}
}
if (strpos($where, 'u.username')) {
$from .= ' LEFT JOIN ' . <API key> . ' u ON r.admin_id=u.userid';
}
}
if (!defined('NV_IS_ADMIN_MODULE')) {
$from_catid = array();
foreach ($array_cat_view as $catid_i) {
$from_catid[] = "r.listcatid = '" . $catid_i . "'";
$from_catid[] = "r.listcatid like '" . $catid_i . ",%'";
$from_catid[] = "r.listcatid like '%," . $catid_i . ",%'";
$from_catid[] = "r.listcatid like '%," . $catid_i . "'";
}
$where .= (empty($where)) ? ' (' . implode(' OR ', $from_catid) . ')' : ' AND (' . implode(' OR ', $from_catid) . ')';
}
$link_i = NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=Other';
$global_array_cat[0] = array(
'catid' => 0,
'parentid' => 0,
'title' => 'Other',
'alias' => 'Other',
'link' => $link_i,
'viewcat' => 'viewcat_page_new',
'subcatid' => 0,
'numlinks' => 3,
'description' => '',
'keywords' => ''
);
$search_type = array();
foreach ($array_search as $key => $val) {
$search_type[] = array(
'key' => $key,
'value' => $val,
'selected' => ($key == $stype) ? ' selected="selected"' : ''
);
}
for ($i = 0; $i <= 10; $i++) {
$sl = ($i == $sstatus) ? ' selected="selected"' : '';
$search_status[] = array(
'key' => $i,
'value' => $lang_module['status_' . $i],
'selected' => $sl
);
}
$i = 5;
$search_per_page = array();
while ($i <= 500) {
$search_per_page[] = array(
'page' => $i,
'selected' => ($i == $per_page) ? ' selected="selected"' : ''
);
$i = $i + 5;
}
$order2 = ($order == 'asc') ? 'desc' : 'asc';
$ord_sql = ' r.' . $ordername . ' ' . $order;
$db_slave->sqlreset()
->select('COUNT(*)')
->from($from)
->where($where);
$_sql = $db_slave->sql();
$num_checkss = md5($num_items . NV_CHECK_SESSION . $_sql);
if ($num_checkss != $nv_Request->get_string('num_checkss', 'get', '')) {
$num_items = $db_slave->query($_sql)->fetchColumn();
$num_checkss = md5($num_items . NV_CHECK_SESSION . $_sql);
}
$base_url_mod = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $op . '&per_page=' . $per_page;
if ($catid) {
$base_url_mod .= '&catid=' . $catid;
}
if (!empty($q)) {
$base_url_mod .= '&q=' . $q . '&checkss=' . $checkss;
}
$base_url_mod .= '&stype=' . $stype . '&num_items=' . $num_items . '&num_checkss=' . $num_checkss;
$db_slave->select('r.id, r.catid, r.listcatid, r.admin_id, r.title, r.alias, r.status , r.publtime, r.exptime, r.hitstotal, r.hitscm, r.admin_id')
->order('r.' . $ordername . ' ' . $order)
->limit($per_page)
->offset(($page - 1) * $per_page);
$result = $db_slave->query($db_slave->sql());
$data = $array_ids = $array_userid = array();
while (list ($id, $catid_i, $listcatid, $post_id, $title, $alias, $status, $publtime, $exptime, $hitstotal, $hitscm, $_userid) = $result->fetch(3)) {
$publtime = nv_date('H:i d/m/y', $publtime);
$title = nv_clean60($title);
if ($catid > 0) {
$catid_i = $catid;
}
$<API key> = $<API key> = false;
if (defined('NV_IS_ADMIN_MODULE')) {
$<API key> = $<API key> = true;
} else {
$array_temp = explode(',', $listcatid);
$check_edit = $check_del = 0;
foreach ($array_temp as $catid_i) {
if (isset($array_cat_admin[$admin_id][$catid_i])) {
if ($array_cat_admin[$admin_id][$catid_i]['admin'] == 1) {
++$check_edit;
++$check_del;
$_permission_action['publtime'] = true;
$_permission_action['re-published'] = true;
$_permission_action['exptime'] = true;
$_permission_action['declined'] = true;
} else {
if ($array_cat_admin[$admin_id][$catid_i]['edit_content'] == 1) {
++$check_edit;
if ($status) {
$_permission_action['exptime'] = true;
}
} elseif ($array_cat_admin[$admin_id][$catid_i]['pub_content'] == 1 and $status == 0) {
++$check_edit;
$_permission_action['publtime'] = true;
$_permission_action['re-published'] = true;
} elseif (($status == 0 or $status == 4 or $status == 5) and $post_id == $admin_id) {
++$check_edit;
$_permission_action['waiting'] = true;
}
if ($array_cat_admin[$admin_id][$catid_i]['del_content'] == 1) {
++$check_del;
} elseif (($status == 0 or $status == 4 or $status == 5) and $post_id == $admin_id) {
++$check_del;
$_permission_action['waiting'] = true;
}
}
}
}
if ($check_edit == sizeof($array_temp)) {
$<API key> = true;
}
if ($check_del == sizeof($array_temp)) {
$<API key> = true;
}
}
$admin_funcs = array();
if ($<API key>) {
$admin_funcs[] = nv_link_edit_page($id);
}
if ($<API key>) {
$admin_funcs[] = nv_link_delete_page($id);
$_permission_action['delete'] = true;
}
$data[$id] = array(
'id' => $id,
'link' => NV_BASE_SITEURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=' . $module_name . '&' . NV_OP_VARIABLE . '=' . $global_array_cat[$catid_i]['alias'] . '/' . $alias . '-' . $id . $global_config['rewrite_exturl'],
'title' => $title,
'publtime' => $publtime,
'status_id' => $status,
'status' => $lang_module['status_' . $status],
'class' => $array_status_class[$status],
'userid' => $_userid,
'hitstotal' => number_format($hitstotal, 0, ',', '.'),
'hitscm' => number_format($hitscm, 0, ',', '.'),
'numtags' => 0,
'feature' => implode(' ', $admin_funcs)
);
$array_ids[] = $id;
$array_userid[] = $_userid;
}
// Lay so tags
if (!empty($array_ids)) {
$db_slave->sqlreset()
->select('COUNT(*) AS numtags, id')
->from(NV_PREFIXLANG . '_' . $module_data . '_tags_id')
->where('id IN( ' . implode(',', $array_ids) . ' )')
->group('id');
$result = $db_slave->query($db_slave->sql());
while (list ($numtags, $id) = $result->fetch(3)) {
$data[$id]['numtags'] = $numtags;
}
}
if (!empty($array_userid)) {
$array_userid = array_unique($array_userid);
$db_slave->sqlreset()
->select('userid, username')
->from(<API key>)
->where('userid IN( ' . implode(',', $array_userid) . ' )');
$array_userid = array();
$result = $db_slave->query($db_slave->sql());
while (list ($_userid, $_username) = $result->fetch(3)) {
$array_userid[$_userid] = $_username;
}
}
$base_url_id = $base_url_mod . '&ordername=id&order=' . $order2 . '&page=' . $page;
$base_url_name = $base_url_mod . '&ordername=title&order=' . $order2 . '&page=' . $page;
$base_url_publtime = $base_url_mod . '&ordername=publtime&order=' . $order2 . '&page=' . $page;
$base_url_exptime = $base_url_mod . '&ordername=exptime&order=' . $order2 . '&page=' . $page;
$base_url_hitstotal = $base_url_mod . '&ordername=hitstotal&order=' . $order2 . '&page=' . $page;
$base_url_hitscm = $base_url_mod . '&ordername=hitscm&order=' . $order2 . '&page=' . $page;
$base_url = $base_url_mod . '&sstatus=' . $sstatus . '&ordername=' . $ordername . '&order=' . $order;
$generate_page = nv_generate_page($base_url, $num_items, $per_page, $page);
$xtpl = new XTemplate('main.tpl', NV_ROOTDIR . '/themes/' . $global_config['module_theme'] . '/modules/' . $module_file);
$xtpl->assign('LANG', $lang_module);
$xtpl->assign('GLANG', $lang_global);
$xtpl->assign('NV_BASE_ADMINURL', NV_BASE_ADMINURL);
$xtpl->assign('NV_NAME_VARIABLE', NV_NAME_VARIABLE);
$xtpl->assign('MODULE_NAME', $module_name);
$xtpl->assign('OP', $op);
$xtpl->assign('Q', $qhtml);
$xtpl->assign('base_url_id', $base_url_id);
$xtpl->assign('base_url_name', $base_url_name);
$xtpl->assign('base_url_publtime', $base_url_publtime);
$xtpl->assign('base_url_exptime', $base_url_exptime);
$xtpl->assign('base_url_hitstotal', $base_url_hitstotal);
$xtpl->assign('base_url_hitscm', $base_url_hitscm);
foreach ($val_cat_content as $cat_content) {
$xtpl->assign('CAT_CONTENT', $cat_content);
$xtpl->parse('main.cat_content');
}
foreach ($search_type as $search_t) {
$xtpl->assign('SEARCH_TYPE', $search_t);
$xtpl->parse('main.search_type');
}
foreach ($search_per_page as $s_per_page) {
$xtpl->assign('SEARCH_PER_PAGE', $s_per_page);
$xtpl->parse('main.s_per_page');
}
foreach ($search_status as $status_view) {
$xtpl->assign('SEARCH_STATUS', $status_view);
$xtpl->parse('main.search_status');
}
foreach ($data as $row) {
$is_excdata = 0;
if ($global_config['idsite'] > 0 and isset($site_mods['excdata']) and isset($push_content['module'][$module_name]) and $row['status_id'] == 1) {
$count = $db_slave->query('SELECT COUNT(*) FROM ' . NV_PREFIXLANG . '_' . $site_mods['excdata']['module_data'] . '_sended WHERE id_content=' . $row['id'] . ' AND module=' . $db_slave->quote($module_name))
->fetchColumn();
if ($count == 0) {
$is_excdata = 1;
$row['url_send'] = NV_BASE_ADMINURL . 'index.php?' . NV_LANG_VARIABLE . '=' . NV_LANG_DATA . '&' . NV_NAME_VARIABLE . '=excdata&' . NV_OP_VARIABLE . '=send&module=' . $module_name . '&id=' . $row['id'];
}
}
if ($row['status_id'] == 4 and empty($row['title'])) {
$row['title'] = $lang_module['no_name'];
}
$row['username'] = isset($array_userid[$row['userid']]) ? $array_userid[$row['userid']] : '';
$xtpl->assign('ROW', $row);
if ($is_excdata) {
$xtpl->parse('main.loop.excdata');
}
if ($row['status_id'] == 4) {
$xtpl->parse('main.loop.text');
} else {
$xtpl->parse('main.loop.url');
}
$xtpl->parse('main.loop');
}
while (list ($action_i, $title_i) = each($array_list_action)) {
if (defined('NV_IS_ADMIN_MODULE') || isset($_permission_action[$action_i])) {
$action_assign = array(
'value' => $action_i,
'title' => $title_i
);
$xtpl->assign('ACTION', $action_assign);
$xtpl->parse('main.action');
}
}
if (!empty($generate_page)) {
$xtpl->assign('GENERATE_PAGE', $generate_page);
$xtpl->parse('main.generate_page');
}
$xtpl->parse('main');
$contents = $xtpl->text('main');
include NV_ROOTDIR . '/includes/header.php';
echo nv_admin_theme($contents);
include NV_ROOTDIR . '/includes/footer.php';
|
#include <linux/qcomwlan_pwrif.h>
#define <API key> 230
#define WLAN_RESET_OUT 1
#define WLAN_RESET 0
static const char *id = "WLAN";
int <API key>(int on)
{
static char wlan_on;
static const char *vregs_qwlan_name[] = {
"8058_l20",
"8058_l8",
"8901_s4",
"8901_lvs1",
"8901_l0",
"8058_s2",
"8058_s1",
};
static const int vregs_qwlan_val_min[] = {
1800000,
3050000,
1225000,
0,
1200000,
1300000,
500000,
};
static const int vregs_qwlan_val_max[] = {
1800000,
3050000,
1225000,
0,
1200000,
1300000,
1200000,
};
static const bool <API key>[] = {
0,
0,
0,
0,
1,
1,
0,
};
static struct regulator *vregs_qwlan[ARRAY_SIZE(vregs_qwlan_name)];
static struct msm_xo_voter *wlan_clock;
int ret, i, rc = 0;
/* WLAN RESET and CLK settings */
if (on && !wlan_on) {
/*
* Program U12 GPIO expander pin IO1 to de-assert (drive 0)
* WLAN_EXT_POR_N to put WLAN in reset
*/
rc = gpio_request(<API key>, "WLAN_DEEP_SLEEP_N");
if (rc) {
pr_err("WLAN reset GPIO %d request failed\n",
<API key>);
goto fail;
}
rc = <API key>(<API key>,
WLAN_RESET_OUT);
if (rc < 0) {
pr_err("WLAN reset GPIO %d set output direction failed",
<API key>);
goto fail_gpio_dir_out;
}
/* Configure TCXO to be slave to WLAN_CLK_PWR_REQ */
if (wlan_clock == NULL) {
wlan_clock = msm_xo_get(MSM_XO_TCXO_A0, id);
if (IS_ERR(wlan_clock)) {
pr_err("Failed to get TCXO_A0 voter (%ld)\n",
PTR_ERR(wlan_clock));
goto fail_gpio_dir_out;
}
}
rc = msm_xo_mode_vote(wlan_clock, <API key>);
if (rc < 0) {
pr_err("Configuring TCXO to Pin controllable failed"
"(%d)\n", rc);
goto fail_xo_mode_vote;
}
} else if (!on && wlan_on) {
if (wlan_clock != NULL)
msm_xo_mode_vote(wlan_clock, MSM_XO_MODE_OFF);
<API key>(<API key>, WLAN_RESET);
gpio_free(<API key>);
}
/* WLAN VREG settings */
for (i = 0; i < ARRAY_SIZE(vregs_qwlan_name); i++) {
if (vregs_qwlan[i] == NULL) {
vregs_qwlan[i] = regulator_get(NULL,
vregs_qwlan_name[i]);
if (IS_ERR(vregs_qwlan[i])) {
pr_err("regulator get of %s failed (%ld)\n",
vregs_qwlan_name[i],
PTR_ERR(vregs_qwlan[i]));
rc = PTR_ERR(vregs_qwlan[i]);
goto vreg_get_fail;
}
if (vregs_qwlan_val_min[i] || vregs_qwlan_val_max[i]) {
rc = <API key>(vregs_qwlan[i],
vregs_qwlan_val_min[i],
vregs_qwlan_val_max[i]);
if (rc) {
pr_err("<API key>(%s) failed\n",
vregs_qwlan_name[i]);
goto vreg_fail;
}
}
/* vote for pin control (if needed) */
if (<API key>[i]) {
rc = regulator_set_mode(vregs_qwlan[i],
REGULATOR_MODE_IDLE);
if (rc) {
pr_err("regulator_set_mode(%s) failed\n",
vregs_qwlan_name[i]);
goto vreg_fail;
}
}
}
if (on && !wlan_on) {
rc = regulator_enable(vregs_qwlan[i]);
if (rc < 0) {
pr_err("vreg %s enable failed (%d)\n",
vregs_qwlan_name[i], rc);
goto vreg_fail;
}
} else if (!on && wlan_on) {
rc = regulator_disable(vregs_qwlan[i]);
if (rc < 0) {
pr_err("vreg %s disable failed (%d)\n",
vregs_qwlan_name[i], rc);
goto vreg_fail;
}
}
}
if (on)
wlan_on = true;
else
wlan_on = false;
return 0;
vreg_fail:
regulator_put(vregs_qwlan[i]);
vreg_get_fail:
i
while (i) {
ret = !on ? regulator_enable(vregs_qwlan[i]) :
regulator_disable(vregs_qwlan[i]);
if (ret < 0) {
pr_err("vreg %s %s failed (%d) in err path\n",
vregs_qwlan_name[i],
!on ? "enable" : "disable", ret);
}
regulator_put(vregs_qwlan[i]);
i
}
if (!on)
goto fail;
fail_xo_mode_vote:
msm_xo_put(wlan_clock);
fail_gpio_dir_out:
gpio_free(<API key>);
fail:
return rc;
}
EXPORT_SYMBOL(<API key>);
|
# Written by Gustavo Niemeyer <niemeyer@conectiva.com>
# This file is part of Smart Package Manager.
# Smart Package Manager is free software; you can redistribute it and/or
# your option) any later version.
# Smart Package Manager is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# along with Smart Package Manager; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from smart.const import ENFORCE, OPTIONAL, INSTALL, REMOVE, RECURSIONLIMIT
from smart.cache import PreRequires
from smart import *
import os, sys
MAXSORTERDEPTH = RECURSIONLIMIT-50
class LoopError(Error): pass
class ElementGroup(object):
def __init__(self):
self._relations = {} # (pred, succ) -> True
def getRelations(self):
return self._relations.keys()
def addPredecessor(self, succ, pred):
self._relations[(pred, succ)] = True
def addSuccessor(self, pred, succ):
self._relations[(pred, succ)] = True
class ElementOrGroup(ElementGroup): pass
class ElementAndGroup(ElementGroup): pass
class ElementSorter(object):
def __init__(self):
self._successors = {} # pred -> {(succ, kind): True}
self._predcount = {} # succ -> n
self._groups = {} # (pred, succ, kind) -> [group, ...]
self._disabled = {} # (pred, succ, kind) -> True
def reset(self):
self._successors.clear()
self._groups.clear()
def _getLoop(self, start, end=None):
if end is None:
end = start
successors = self._successors
path = [start]
done = {}
loop = {}
while path:
head = path[-1]
dct = successors.get(head)
if dct:
for succ, kind in dct:
if (head, succ, kind) not in self._disabled:
if succ in loop or succ == end:
loop.update(dict.fromkeys(path, True))
loop[end] = True # If end != start
elif succ not in done:
done[succ] = True
path.append(succ)
break
else:
path.pop()
else:
path.pop()
return loop
def _checkLoop(self, start, end=None):
if end is None:
end = start
successors = self._successors
queue = [start]
done = {}
while queue:
elem = queue.pop()
dct = successors.get(elem)
if dct:
for succ, kind in dct:
if (elem, succ, kind) not in self._disabled:
if succ == end:
return True
elif succ not in done:
done[succ] = True
queue.append(succ)
return False
def getLoops(self):
successors = self._successors
predcount = self._predcount
loops = {}
for elem in successors:
if predcount.get(elem) and elem not in loops:
loop = self._getLoop(elem)
if loop:
loops.update(loop)
return loops
def getLoopPaths(self, loops):
if not loops:
return []
successors = self._successors
paths = []
done = {}
for elem in loops:
if elem not in done:
path = [elem]
while path:
head = path[-1]
dct = successors.get(head)
if dct:
for succ, kind in dct:
if (succ in loops and
(head, succ, kind) not in self._disabled):
done[succ] = True
if succ == elem:
paths.append(path+[elem])
else:
headsucc = (head, succ)
if headsucc not in done:
done[headsucc] = True
path.append(succ)
break
else:
path.pop()
else:
path.pop()
return paths
def _breakLoops(self, elem, loops, rellock, reclock, depth=0):
if depth > MAXSORTERDEPTH:
return False
result = True
dct = self._successors.get(elem)
if dct:
for succ, kind in dct.keys():
# Should we care about this relation?
if succ not in loops:
continue
tup = (elem, succ, kind)
if tup in self._disabled:
continue
# Check if the loop for this specific relation is still alive.
if not self._checkLoop(succ, elem):
continue
# Some upper frame is already checking this. Protect
# from infinite recursion.
if tup in reclock:
result = False
break
# If this relation is locked, our only chance is breaking
# it forward.
if tup in rellock:
reclock[tup] = True
loop = self._getLoop(succ, elem)
broke = self._breakLoops(succ, loop, rellock,
reclock, depth+1)
del reclock[tup]
if not broke:
result = False
continue
# If this relation is optional, break it now.
if kind is OPTIONAL:
self._breakRelation(*tup)
continue
# We have an enforced relation. Let's check if we
# have OR groups that could satisfy it.
groups = self._groups.get(tup)
if groups:
# Any enforced AND groups tell us we can't
# break this relation.
for group in groups:
if type(group) is ElementAndGroup:
groups = None
break
if groups:
# Check if we can remove the relation from all groups.
reenable = {}
for group in groups:
reenable[group] = []
active = 0
for gpred, gsucc in group._relations:
gtup = (gpred, gsucc, kind)
if gtup in self._disabled:
if gtup not in rellock:
reenable[group].append(gtup)
else:
active += 1
if active > 1: break
if active > 1:
del reenable[group]
elif not reenable[group]:
break
else:
# These relations must not be reenabled in
# the loop breaking steps below.
relations = self._breakRelation(*tup)
for rtup in relations:
rellock[rtup] = True
# Reenable the necessary relations, if possible.
# Every group must have at least one active relation
# so that we can disable our own relation.
for group in reenable:
succeeded = False
# Check if some iteration of _breakLoop() below
# already reenabled one relation with success.
for gtup in reenable[group]:
if gtup not in self._disabled:
succeeded = True
break
if succeeded:
continue
# Nope. Let's try to do that here.
for gtup in reenable[group]:
erelations = self._enableRelation(*gtup)
for etup in erelations:
rellock[etup] = True
for epred, esucc, ekind in erelations:
eloop = self._getLoop(esucc, epred)
if (eloop and not
self._breakLoops(esucc, eloop, rellock,
reclock, depth+1)):
break
else:
succeeded = True
for etup in erelations:
del rellock[etup]
if succeeded:
break
self._breakRelation(*gtup)
if not succeeded:
break
else:
# Done!
for rtup in relations:
del rellock[rtup]
continue
# Some OR group failed to exchange the relation,
# so we can't break our own relation.
for rtup in self._enableRelation(*tup):
del rellock[rtup]
# Our last chance is breaking it forward.
reclock[tup] = True
loop = self._getLoop(succ, elem)
broke = self._breakLoops(succ, loop, rellock, reclock, depth+1)
del reclock[tup]
if not broke:
result = False
return result
def _breakRelation(self, pred, succ, kind):
tup = (pred, succ, kind)
self._disabled[tup] = True
relations = {tup: True}
groups = self._groups.get(tup)
if groups:
for group in groups:
if type(group) is ElementAndGroup:
for gpred, gsucc in group._relations:
gtup = (gpred, gsucc, kind)
self._disabled[gtup] = True
relations[gtup] = True
return relations
def _enableRelation(self, pred, succ, kind):
tup = (pred, succ, kind)
del self._disabled[tup]
relations = {tup: True}
groups = self._groups.get(tup)
if groups:
for group in groups:
if type(group) is ElementAndGroup:
for gpred, gsucc in group._relations:
if gpred != pred or gsucc != succ:
gtup = (gpred, gsucc, kind)
del self._disabled[gtup]
relations[gtup] = True
return relations
def getSuccessors(self, elem):
succs = {}
for succ, kind in self._successors[elem]:
if (pred, succ, kind) not in self._disabled:
succs[succ] = True
return succs
def getPredecessors(self, elem):
preds = {}
for pred in self._successors:
for succ, kind in self._successors[pred]:
if succ == elem and (pred, succ, kind) not in self._disabled:
preds[pred] = True
return preds
def getAllSuccessors(self, elem):
succs = {}
queue = [elem]
while queue:
elem = queue.pop()
for succ, kind in self._successors[elem]:
if (succ not in all and
(elem, succ, kind) not in self._disabled):
succs[succ] = True
queue.append(succ)
return succs
def getAllPredecessors(self, elem):
preds = {}
queue = [elem]
while queue:
elem = queue.pop()
for pred in self._successors:
for succ, kind in self._successors[pred]:
if (succ == elem and
(pred, succ, kind) not in self._disabled):
preds[elem] = True
queue.append(elem)
return preds
def breakLoops(self):
successors = self._successors
result = True
loops = self.getLoops()
if loops:
for elem in successors:
if elem in loops:
if not self._breakLoops(elem, loops, {}, {}):
result = False
return result
def addElement(self, elem):
if elem not in self._successors:
self._successors[elem] = ()
def addPredecessor(self, succ, pred, kind=ENFORCE):
self.addSuccessor(pred, succ, kind)
def addSuccessor(self, pred, succ, kind=ENFORCE):
successors = self._successors
predcount = self._predcount
if succ not in successors:
successors[succ] = ()
dct = successors.get(pred)
if not dct:
successors[pred] = {(succ, kind): True}
if succ not in predcount:
predcount[succ] = 1
else:
predcount[succ] += 1
elif (succ, kind) not in dct:
dct[(succ, kind)] = True
if succ not in predcount:
predcount[succ] = 1
else:
predcount[succ] += 1
groups = self._groups.get((pred, succ, kind))
if groups:
group = ElementAndGroup()
group.addPredecessor(succ, pred)
groups.append(group)
def addGroup(self, group, kind=ENFORCE):
if not group._relations:
return
if len(group._relations) == 1:
pred, succ = iter(group._relations).next()
self.addSuccessor(pred, succ, kind)
return
successors = self._successors
predcount = self._predcount
for pred, succ in group._relations:
groups = self._groups.get((pred, succ, kind))
if not groups:
groups = self._groups[(pred, succ, kind)] = []
dct = successors.get(pred)
if dct and (succ, kind) in dct:
group = ElementAndGroup()
group.addSuccessor(pred, succ)
groups.append(group)
groups.append(group)
if succ not in successors:
successors[succ] = ()
dct = successors.get(pred)
if not dct:
successors[pred] = {(succ, kind): True}
if succ not in predcount:
predcount[succ] = 1
else:
predcount[succ] += 1
elif (succ, kind) not in dct:
dct[(succ, kind)] = True
if succ not in predcount:
predcount[succ] = 1
else:
predcount[succ] += 1
def getSorted(self):
successors = self._successors
predcount = self._predcount.copy()
self._profile(1)
brokeall = self.breakLoops()
self._profile(2)
if not brokeall:
raise LoopError, _("Unbreakable loops found while sorting")
for pred, succ, kind in self._disabled:
predcount[succ] -= 1
result = [x for x in successors if not predcount.get(x)]
for elem in result:
dct = successors.get(elem)
if dct:
for succ, kind in dct:
if (elem, succ, kind) in self._disabled:
continue
left = predcount.get(succ)
if left is None:
continue
if left-1 == 0:
del predcount[succ]
result.append(succ)
else:
predcount[succ] -= 1
self._profile(3)
if len(result) != len(successors):
raise Error, _("Internal error: there are still loops (%d != %d)!")\
% (len(result), len(successors))
return result
def _profile(self, id):
if sysconf.get("sorter-profile"):
import time
if id == 1:
successors = self._successors
enforce = 0
optional = 0
ngroups = 0
for pred in self._successors:
for succ, kind in successors[pred]:
groups = self._groups.get((pred, succ, kind))
if groups:
ngroups += len(groups)
if kind is ENFORCE:
enforce += 1
else:
optional += 1
print "Number of elements:", len(successors)
print "Number of relations:", enforce+optional
print "Number of relation groups:", ngroups
print "Number of enforced relations:", enforce
print "Number of optional relations:", optional
self._profile_start = time.clock()
elif id == 2:
print "Number of disabled relations:", len(self._disabled)
print "Break delay: %.2fs" % (time.clock()-self._profile_start)
self._profile_start = time.clock()
elif id == 3:
print "Sort delay: %.2fs" % (time.clock()-self._profile_start)
class ChangeSetSorter(ElementSorter):
def __init__(self, changeset=None):
ElementSorter.__init__(self)
if changeset:
self.setChangeSet(changeset)
def setChangeSet(self, changeset):
self.reset()
for pkg in changeset:
op = changeset[pkg]
elem = (pkg, op)
self.addElement(elem)
# Packages being installed or removed must go in
# before their dependencies are removed, or after
# their dependencies are reinstalled.
for req in pkg.requires:
group = ElementOrGroup()
for prv in req.providedby:
for prvpkg in prv.packages:
if prvpkg is pkg:
continue
if changeset.get(prvpkg) is INSTALL:
group.addSuccessor((prvpkg, INSTALL), elem)
elif prvpkg.installed:
if changeset.get(prvpkg) is not REMOVE:
break
group.addSuccessor(elem, (prvpkg, REMOVE))
else:
continue
break
else:
relations = group.getRelations()
if relations:
# Should Requires of PreRequires become PreRequires
# as well?
if isinstance(req, PreRequires):
kind = ENFORCE
else:
kind = OPTIONAL
self.addGroup(group, kind)
if op is INSTALL:
# Upgraded packages being removed must go in
# before this package's installation. Notice that
# depending on the package manager, these remove
# entries will probably be ripped out and dealt
# by the package manager itself during upgrades.
upgpkgs = [upgpkg for prv in pkg.provides
for upg in prv.upgradedby
for upgpkg in upg.packages]
upgpkgs.extend([prvpkg for upg in pkg.upgrades
for prv in upg.providedby
for prvpkg in prv.packages])
for upgpkg in upgpkgs:
if upgpkg is pkg:
continue
if changeset.get(upgpkg) is REMOVE:
self.addSuccessor((upgpkg, REMOVE), elem, ENFORCE)
# Conflicted packages being removed must go in
# before this package's installation.
cnfpkgs = [prvpkg for cnf in pkg.conflicts
for prv in cnf.providedby
for prvpkg in prv.packages
if prvpkg is not pkg]
cnfpkgs.extend([cnfpkg for prv in pkg.provides
for cnf in prv.conflictedby
for cnfpkg in cnf.packages
if cnfpkg is not pkg])
for cnfpkg in cnfpkgs:
if cnfpkg is pkg:
continue
if changeset.get(cnfpkg) is REMOVE:
self.addSuccessor((cnfpkg, REMOVE), elem, ENFORCE)
assert len(self._successors) == len(changeset)
|
#ifndef MIPS_LINUX_TDEP_H
#define MIPS_LINUX_TDEP_H
/* Copied from <asm/elf.h>. */
#define ELF_NGREG 45
#define ELF_NFPREG 33
typedef unsigned char mips_elf_greg_t[4];
typedef mips_elf_greg_t mips_elf_gregset_t[ELF_NGREG];
typedef unsigned char mips_elf_fpreg_t[8];
typedef mips_elf_fpreg_t mips_elf_fpregset_t[ELF_NFPREG];
/* 0 - 31 are integer registers, 32 - 63 are fp registers. */
#define FPR_BASE 32
#define PC 64
#define CAUSE 65
#define BADVADDR 66
#define MMHI 67
#define MMLO 68
#define FPC_CSR 69
#define FPC_EIR 70
#define DSP_BASE 71
#define DSP_CONTROL 77
#define EF_REG0 6
#define EF_REG31 37
#define EF_LO 38
#define EF_HI 39
#define EF_CP0_EPC 40
#define EF_CP0_BADVADDR 41
#define EF_CP0_STATUS 42
#define EF_CP0_CAUSE 43
#define EF_SIZE 180
void mips_supply_gregset (struct regcache *, const mips_elf_gregset_t *);
void mips_fill_gregset (const struct regcache *, mips_elf_gregset_t *, int);
/* 64-bit support. */
/* Copied from <asm/elf.h>. */
#define MIPS64_ELF_NGREG 45
#define MIPS64_ELF_NFPREG 33
typedef unsigned char mips64_elf_greg_t[8];
typedef mips64_elf_greg_t <API key>[MIPS64_ELF_NGREG];
typedef unsigned char mips64_elf_fpreg_t[8];
typedef mips64_elf_fpreg_t <API key>[MIPS64_ELF_NFPREG];
/* 0 - 31 are integer registers, 32 - 63 are fp registers. */
#define MIPS64_FPR_BASE 32
#define MIPS64_PC 64
#define MIPS64_CAUSE 65
#define MIPS64_BADVADDR 66
#define MIPS64_MMHI 67
#define MIPS64_MMLO 68
#define MIPS64_FPC_CSR 69
#define MIPS64_FPC_EIR 70
#define MIPS64_EF_REG0 0
#define MIPS64_EF_REG31 31
#define MIPS64_EF_LO 32
#define MIPS64_EF_HI 33
#define MIPS64_EF_CP0_EPC 34
#define <API key> 35
#define <API key> 36
#define MIPS64_EF_CP0_CAUSE 37
#define MIPS64_EF_SIZE 304
void <API key> (struct regcache *, const <API key> *);
void mips64_fill_gregset (const struct regcache *,
<API key> *, int);
void <API key> (struct regcache *,
const <API key> *);
void <API key> (const struct regcache *,
<API key> *, int);
enum {
/* The Linux kernel stores an error code from any interrupted
syscall in a "register" (in $0's save slot). */
MIPS_RESTART_REGNUM = 79
};
/* Return 1 if MIPS_RESTART_REGNUM is usable. */
int <API key> (struct gdbarch *gdbarch);
/* Target descriptions. */
extern struct target_desc *tdesc_mips_linux;
extern struct target_desc *tdesc_mips64_linux;
extern struct target_desc *<API key>;
extern struct target_desc *<API key>;
#endif /* MIPS_LINUX_TDEP_H */
|
package com.oracle.chess.protocol;
import java.util.ArrayList;
import java.util.List;
/**
* QueryGamesRsp class.
*
*/
public class QueryGamesRsp extends MessageRsp {
public static class Game {
private String gameId;
private String summary;
private boolean open;
private String whitePlayer;
private String blackPlayer;
private boolean completed;
public String getGameId() {
return gameId;
}
public void setGameId(String gameId) {
this.gameId = gameId;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public boolean isOpen() {
return open;
}
public void setOpen(boolean open) {
this.open = open;
}
public String getWhitePlayer() {
return whitePlayer;
}
public void setWhitePlayer(String whitePlayer) {
this.whitePlayer = whitePlayer;
}
public String getBlackPlayer() {
return blackPlayer;
}
public void setBlackPlayer(String blackPlayer) {
this.blackPlayer = blackPlayer;
}
public boolean isCompleted() {
return completed;
}
public void setCompleted(boolean completed) {
this.completed = completed;
}
};
private List<Game> games = new ArrayList<>();
public QueryGamesRsp() {
}
public QueryGamesRsp(String gameId) {
super(gameId);
}
public void addGame(Game game) {
if (games == null) {
games = new ArrayList<>();
}
games.add(game);
}
public List<Game> getGames() {
return games;
}
public void setGames(List<Game> games) {
this.games = games;
}
@Override
public void processMe(<API key> processor) {
processor.process(this);
}
}
|
/*
* This file contains the system call macros and syscall
* numbers used by the shared library loader.
*/
#define __NR_exit 1
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_getpid 20
#define __NR_getuid 24
#define __NR_getgid 47
#define __NR_geteuid 49
#define __NR_getegid 50
#define __NR_readlink 58
#define __NR_mmap 71
#define __NR_munmap 73
#define __NR_stat 38
#define __NR_mprotect 74
/* We can't use the real errno in ldso, since it has not yet
* been dynamicly linked in yet. */
extern int _dl_errno;
/* Here are the macros which define how this platform makes
* system calls. This particular variant does _not_ set
* errno (note how it is disabled in __syscall_return) since
* these will get called before the errno symbol is dynamicly
* linked. */
#define _syscall0(type,name) \
type name(void) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res)\
: "r" (__g1) \
: "o0", "cc"); \
if (__res < -255 || __res >= 0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall1(type,name,type1,arg1) \
type name(type1 arg1) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res >= 0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall2(type,name,type1,arg1,type2,arg2) \
type name(type1 arg1,type2 arg2) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
register long __o1 __asm__ ("o1") = (long)(arg2); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__o1), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res >= 0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
type name(type1 arg1,type2 arg2,type3 arg3) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
register long __o1 __asm__ ("o1") = (long)(arg2); \
register long __o2 __asm__ ("o2") = (long)(arg3); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res>=0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
register long __o1 __asm__ ("o1") = (long)(arg2); \
register long __o2 __asm__ ("o2") = (long)(arg3); \
register long __o3 __asm__ ("o3") = (long)(arg4); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res>=0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
register long __o1 __asm__ ("o1") = (long)(arg2); \
register long __o2 __asm__ ("o2") = (long)(arg3); \
register long __o3 __asm__ ("o3") = (long)(arg4); \
register long __o4 __asm__ ("o4") = (long)(arg5); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res>=0) \
return (type) __res; \
_dl_errno = -__res; \
return -1; \
}
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
type5,arg5,type6,arg6) \
type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
{ \
long __res; \
register long __g1 __asm__ ("g1") = __NR_##name; \
register long __o0 __asm__ ("o0") = (long)(arg1); \
register long __o1 __asm__ ("o1") = (long)(arg2); \
register long __o2 __asm__ ("o2") = (long)(arg3); \
register long __o3 __asm__ ("o3") = (long)(arg4); \
register long __o4 __asm__ ("o4") = (long)(arg5); \
register long __o5 __asm__ ("o5") = (long)(arg6); \
__asm__ __volatile__ ("t 0x10\n\t" \
"bcc 1f\n\t" \
"mov %%o0, %0\n\t" \
"sub %%g0, %%o0, %0\n\t" \
"1:\n\t" \
: "=r" (__res), "=&r" (__o0) \
: "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__o5), "r" (__g1) \
: "cc"); \
if (__res < -255 || __res>=0) \
return (type) __res; \
/*errno = -__res; */\
return -1; \
}
|
#pragma once
#include "FileItem.h"
#include "addons/kodi-addon-dev-kit/include/kodi/xbmc_pvr_types.h"
#include "interfaces/IAnnouncer.h"
#include "threads/Event.h"
#include "threads/Thread.h"
#include "utils/EventStream.h"
#include "utils/JobManager.h"
#include "utils/Observer.h"
#include "pvr/PVRActionListener.h"
#include "pvr/PVREvent.h"
#include "pvr/PVRSettings.h"
#include "pvr/PVRTypes.h"
#include "pvr/epg/EpgContainer.h"
#include "pvr/recordings/PVRRecording.h"
#include <atomic>
#include <memory>
#include <string>
#include <vector>
class <API key>;
class <API key>;
class CStopWatch;
class CFileItemList;
class CVariant;
namespace PVR
{
class CPVRClient;
class CPVRGUIInfo;
enum <API key>
{
<API key> = 0,
<API key>,
<API key>
};
class CPVRManagerJobQueue
{
public:
CPVRManagerJobQueue();
void Start();
void Stop();
void Clear();
void AppendJob(CJob * job);
void ExecutePendingJobs();
bool WaitForJobs(unsigned int milliSeconds);
private:
CCriticalSection m_critSection;
CEvent m_triggerEvent;
std::vector<CJob *> m_pendingUpdates;
bool m_bStopped;
};
class CPVRManager : private CThread, public Observable, public ANNOUNCEMENT::IAnnouncer
{
public:
/*!
* @brief Create a new CPVRManager instance, which handles all PVR related operations in XBMC.
*/
CPVRManager(void);
/*!
* @brief Stop the PVRManager and destroy all objects it created.
*/
virtual ~CPVRManager(void);
void Announce(ANNOUNCEMENT::AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data) override;
/*!
* @brief Get the channel groups container.
* @return The groups container.
*/
<API key> ChannelGroups(void) const;
/*!
* @brief Get the recordings container.
* @return The recordings container.
*/
CPVRRecordingsPtr Recordings(void) const;
/*!
* @brief Get the timers container.
* @return The timers container.
*/
CPVRTimersPtr Timers(void) const;
/*!
* @brief Get the timers container.
* @return The timers container.
*/
CPVRClientsPtr Clients(void) const;
/*!
* @brief Get access to the pvr gui actions.
* @return The gui actions.
*/
CPVRGUIActionsPtr GUIActions(void) const;
/*!
* @brief Get access to the epg container.
* @return The epg container.
*/
CPVREpgContainer& EpgContainer();
/*!
* @brief Init PVRManager.
*/
void Init(void);
/*!
* @brief Reinit PVRManager.
*/
void Reinit(void);
/*!
* @brief Start the PVRManager, which loads all PVR data and starts some threads to update the PVR data.
*/
void Start();
/*!
* @brief Stop PVRManager.
*/
void Stop(void);
/*!
* @brief Stop PVRManager, unload data.
*/
void Unload();
/*!
* @brief Deinit PVRManager, unload data, unload addons.
*/
void Deinit();
/*!
* @brief Propagate event on system sleep
*/
void OnSleep();
/*!
* @brief Propagate event on system wake
*/
void OnWake();
/*!
* @brief Get the TV database.
* @return The TV database.
*/
CPVRDatabasePtr GetTVDatabase(void) const;
/*!
* @brief Get a GUIInfoManager character string.
* @param dwInfo The string to get.
* @return The requested string or an empty one if it wasn't found.
*/
bool TranslateCharInfo(DWORD dwInfo, std::string &strValue) const;
/*!
* @brief Get a GUIInfoManager integer.
* @param dwInfo The integer to get.
* @return The requested integer or 0 if it wasn't found.
*/
int TranslateIntInfo(DWORD dwInfo) const;
/*!
* @brief Get a GUIInfoManager boolean.
* @param dwInfo The boolean to get.
* @return The requested boolean or false if it wasn't found.
*/
bool TranslateBoolInfo(DWORD dwInfo) const;
/*!
* @brief Show the player info.
* @param iTimeout Hide the player info after iTimeout seconds.
* @todo not really the right place for this :-)
*/
void ShowPlayerInfo(int iTimeout);
/*!
* @brief Check if a TV channel, radio channel or recording is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlaying(void) const;
/*!
* @brief Check if the given channel is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlayingChannel(const CPVRChannelPtr &channel) const;
/*!
* @brief Check if the given recording is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlayingRecording(const CPVRRecordingPtr &recording) const;
/*!
* @return True while the PVRManager is initialising.
*/
inline bool IsInitialising(void) const
{
return GetState() == <API key>;
}
/*!
* @brief Check whether the PVRManager has fully started.
* @return True if started, false otherwise.
*/
inline bool IsStarted(void) const
{
return GetState() == ManagerStateStarted;
}
/*!
* @brief Check whether the PVRManager is stopping
* @return True while the PVRManager is stopping.
*/
inline bool IsStopping(void) const
{
return GetState() == <API key>;
}
/*!
* @brief Check whether the PVRManager has been stopped.
* @return True if stopped, false otherwise.
*/
inline bool IsStopped(void) const
{
return GetState() == ManagerStateStopped;
}
/*!
* @brief Return the channel that is currently playing.
* @return The channel or NULL if none is playing.
*/
CPVRChannelPtr GetCurrentChannel(void) const;
/*!
* @brief Return the recording that is currently playing.
* @return The recording or NULL if none is playing.
*/
CPVRRecordingPtr GetCurrentRecording(void) const;
/*!
* @brief Update the channel displayed in guiinfomanager and application to match the currently playing channel.
*/
void <API key>(void);
/*!
* @brief Return the EPG for the channel that is currently playing.
* @param channel The EPG or NULL if no channel is playing.
* @return The amount of results that was added or -1 if none.
*/
int GetCurrentEpg(CFileItemList &results) const;
/*!
* @brief Check whether EPG tags for channels have been created.
* @return True if EPG tags have been created, false otherwise.
*/
bool EpgsCreated(void) const;
/*!
* @brief Reset the playing EPG tag.
*/
void ResetPlayingTag(void);
/*!
* @brief Switch to the given channel.
* @param channel The channel to switch to.
* @param bPreview True to show a preview, false otherwise.
* @return True if the switch was successful, false otherwise.
*/
bool <API key>(const CPVRChannelPtr &channel, bool bPreview);
/*!
* @brief Close an open PVR stream.
*/
void CloseStream(void);
/*!
* @brief Open a stream from the given channel.
* @param fileItem The file item with the channel to open.
* @return True if the stream was opened, false otherwise.
*/
bool OpenLiveStream(const CFileItem &fileItem);
/*!
* @brief Open a stream from the given recording.
* @param tag The recording to open.
* @return True if the stream was opened, false otherwise.
*/
bool OpenRecordedStream(const CPVRRecordingPtr &tag);
/*!
* @brief Start or stop recording on the channel that is currently being played.
* @param bOnOff True to start recording, false to stop.
*/
void <API key>(bool bOnOff);
/*!
* @brief Check whether there are active recordings.
* @return True if there are active recordings, false otherwise.
*/
bool IsRecording(void) const;
/*!
* @brief Check whether the system Kodi is running on can be powered down
* (shutdown/reboot/suspend/hibernate) without stopping any active
* recordings and/or without preventing the start of recordings
* scheduled for now + pvrpowermanagement.backendidletime.
* @param bAskUser True to informs user in case of potential
* data loss. User can decide to allow powerdown anyway. False to
* not to ask user and to not confirm power down.
* @return True if system can be safely powered down, false otherwise.
*/
bool CanSystemPowerdown(bool bAskUser = true) const;
/*!
* @brief Set the current playing group, used to load the right channel.
* @param group The new group.
*/
void SetPlayingGroup(const CPVRChannelGroupPtr &group);
/*!
* @brief Get the current playing group, used to load the right channel.
* @param bRadio True to get the current radio group, false to get the current TV group.
* @return The current group or the group containing all channels if it's not set.
*/
CPVRChannelGroupPtr GetPlayingGroup(bool bRadio = false);
/*!
* @brief Let the background thread create epg tags for all channels.
*/
void TriggerEpgsCreate(void);
/*!
* @brief Let the background thread update the recordings list.
*/
void <API key>(void);
/*!
* @brief Let the background thread update the timer list.
*/
void TriggerTimersUpdate(void);
/*!
* @brief Let the background thread update the channel list.
*/
void <API key>(void);
/*!
* @brief Let the background thread update the channel groups list.
*/
void <API key>(void);
/*!
* @brief Let the background thread search for missing channel icons.
*/
void <API key>(void);
/*!
* @brief Update the channel that is currently active.
* @param item The new channel.
* @return True if it was updated correctly, false otherwise.
*/
bool UpdateItem(CFileItem& item);
/*!
* @brief Switch to a channel given it's channel id.
* @param iChannelId The channel id to switch to.
* @return True if the channel was switched, false otherwise.
*/
bool ChannelSwitchById(unsigned int iChannelId);
/*!
* @brief Switch to the next channel in this group.
* @param iNewChannelNumber The new channel number after the switch.
* @param bPreview If true, don't do the actual switch but just update channel pointers.
* Used to display event info while doing "fast channel switching"
* @return True if the channel was switched, false otherwise.
*/
bool ChannelUp(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, true); }
/*!
* @brief Switch to the previous channel in this group.
* @param iNewChannelNumber The new channel number after the switch.
* @param bPreview If true, don't do the actual switch but just update channel pointers.
* Used to display event info while doing "fast channel switching"
* @return True if the channel was switched, false otherwise.
*/
bool ChannelDown(unsigned int *iNewChannelNumber, bool bPreview = false) { return ChannelUpDown(iNewChannelNumber, bPreview, false); }
/*!
* @brief Get the total duration of the currently playing LiveTV item.
* @return The total duration in milliseconds or NULL if no channel is playing.
*/
int GetTotalTime(void) const;
/*!
* @brief Get the current position in milliseconds since the start of a LiveTV item.
* @return The position in milliseconds or NULL if no channel is playing.
*/
int GetStartTime(void) const;
/*!
* @brief Update the current playing file in the guiinfomanager and application.
*/
void UpdateCurrentFile(void);
/*!
* @brief Check whether names are still correct after the language settings changed.
*/
void LocalizationChanged(void);
/*!
* @brief Check if a TV channel is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlayingTV(void) const;
/*!
* @brief Check if a radio channel is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlayingRadio(void) const;
/*!
* @brief Check if a recording is playing.
* @return True if it's playing, false otherwise.
*/
bool IsPlayingRecording(void) const;
/*!
* @brief Try to find missing channel icons automatically
*/
void <API key>(void);
/*!
* @brief Check if parental lock is overridden at the given moment.
* @param channel The channel to open.
* @return True if parental lock is overridden, false otherwise.
*/
bool IsParentalLocked(const CPVRChannelPtr &channel);
/*!
* @brief Restart the parental timer.
*/
void <API key>();
/*!
* @brief Create EPG tags for all channels in internal channel groups
* @return True if EPG tags where created successfully, false otherwise
*/
bool CreateChannelEpgs(void);
/*!
* @brief get the name of the channel group of the current playing channel
* @return name of channel if tv channel is playing
*/
std::string <API key>();
/*!
* @brief Signal a connection change of a client
*/
void <API key>(CPVRClient *client, std::string connectString, <API key> state, std::string message);
/*!
* @brief Explicitly set the state of channel preview. This is when channel is displayed on OSD without actually switching
*/
void SetChannelPreview(bool preview);
/*!
* @brief Query the state of channel preview
*/
bool IsChannelPreview() const;
/*!
* @brief Query the events available for CEventStream
*/
CEventStream<PVREvent>& Events() { return m_events; }
/*!
* @brief Publish an event
* @param state the event
*/
void PublishEvent(PVREvent state);
/*!
* @brief Show an extended progress bar dialog.
* @param strTitle the title for the dialog.
* @return the handle that can be used to control the progress dialog.
*/
<API key>* ShowProgressDialog(const std::string &strTitle) const;
protected:
/*!
* @brief PVR update and control thread.
*/
void Process(void) override;
private:
/*!
* @brief Updates the last watched timestamps of the channel and group which are currently playing.
* @param channel The channel which is updated
*/
void UpdateLastWatched(const CPVRChannelPtr &channel);
/*!
* @brief Set the playing group to the first group the channel is in if the given channel is not part of the current playing group
* @param channel The channel
*/
void SetPlayingGroup(const CPVRChannelPtr &channel);
/*!
* @brief Save the currently playing channel as last played channel
*/
void <API key>() const;
/*!
* @brief Executes "pvrpowermanagement.setwakeupcmd"
*/
bool SetWakeupCommand(void);
/*!
* @brief Show or update the progress dialog.
* @param strText The current status.
* @param iProgress The current progress in %.
*/
void ShowProgressDialog(const std::string &strText, int iProgress);
/*!
* @brief Hide the progress dialog if it's visible.
*/
void HideProgressDialog(void);
/*!
* @brief Load at least one client and load all other PVR data after loading the client.
* If some clients failed to load here, the pvrmanager will retry to load them every second.
* @param bShowProgress True, to show a progress dialog for the different load stages.
* @return If at least one client and all pvr data was loaded, false otherwise.
*/
bool Load(bool bShowProgress);
/*!
* @brief Reset all properties.
*/
void ResetProperties(void);
/*!
* @brief Destroy PVRManager's objects.
*/
void Clear(void);
/*!
* @brief Called by ChannelUp() and ChannelDown() to perform a channel switch.
* @param iNewChannelNumber The new channel number after the switch.
* @param bPreview Preview window if true.
* @param bUp Go one channel up if true, one channel down if false.
* @return True if the switch was successful, false otherwise.
*/
bool ChannelUpDown(unsigned int *iNewChannelNumber, bool bPreview, bool bUp);
/*!
* @brief Continue playback on the last played channel.
*/
void <API key>(void);
enum ManagerState
{
ManagerStateError = 0,
ManagerStateStopped,
<API key>,
<API key>,
<API key>,
ManagerStateStarted
};
ManagerState GetState(void) const;
void SetState(ManagerState state);
bool <API key>(CPVRTimerInfoTagPtr& causingEvent) const;
bool <API key>(const CFileItemPtr& item) const;
bool <API key>(void) const;
/** @name containers */
<API key> m_channelGroups; /*!< pointer to the channel groups container */
CPVRRecordingsPtr m_recordings; /*!< pointer to the recordings container */
CPVRTimersPtr m_timers; /*!< pointer to the timers container */
CPVRClientsPtr m_addons; /*!< pointer to the pvr addon container */
std::unique_ptr<CPVRGUIInfo> m_guiInfo; /*!< pointer to the guiinfo data */
CPVRGUIActionsPtr m_guiActions; /*!< pointer to the pvr gui actions */
CPVREpgContainer m_epgContainer; /*!< the epg container */
CPVRManagerJobQueue m_pendingUpdates; /*!< vector of pending pvr updates */
CFileItemPtr m_currentFile; /*!< the PVR file that is currently playing */
CPVRDatabasePtr m_database; /*!< the database for all PVR related data */
CCriticalSection m_critSection; /*!< critical section for all changes to this class, except for changes to triggers */
bool m_bFirstStart; /*!< true when the PVR manager was started first, false otherwise */
bool <API key>; /*!< true while switching channels */
bool m_bEpgsCreated; /*!< true if epg data for channels has been created */
<API key> * m_progressBar; /*!< extended progress dialog instance pointer */
<API key> * m_progressHandle; /*!< progress dialog that is displayed while the pvrmanager is loading */
CCriticalSection m_managerStateMutex;
ManagerState m_managerState;
std::unique_ptr<CStopWatch> m_parentalTimer;
CCriticalSection m_startStopMutex; // mutex for protecting pvr manager's start/restart/stop sequence */
std::atomic_bool m_isChannelPreview;
CEventSource<PVREvent> m_events;
CPVRActionListener m_actionListener;
CPVRSettings m_settings;
};
}
|
// <API key>: GPL-2.0
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/pinctrl/consumer.h>
#include "i2c-at91.h"
unsigned at91_twi_read(struct at91_twi_dev *dev, unsigned reg)
{
return readl_relaxed(dev->base + reg);
}
void at91_twi_write(struct at91_twi_dev *dev, unsigned reg, unsigned val)
{
writel_relaxed(val, dev->base + reg);
}
void <API key>(struct at91_twi_dev *dev)
{
at91_twi_write(dev, AT91_TWI_IDR, AT91_TWI_INT_MASK);
}
void at91_twi_irq_save(struct at91_twi_dev *dev)
{
dev->imr = at91_twi_read(dev, AT91_TWI_IMR) & AT91_TWI_INT_MASK;
<API key>(dev);
}
void <API key>(struct at91_twi_dev *dev)
{
at91_twi_write(dev, AT91_TWI_IER, dev->imr);
}
void at91_init_twi_bus(struct at91_twi_dev *dev)
{
<API key>(dev);
at91_twi_write(dev, AT91_TWI_CR, AT91_TWI_SWRST);
if (dev->slave_detected)
<API key>(dev);
else
<API key>(dev);
}
static struct at91_twi_pdata at91rm9200_config = {
.clk_max_div = 5,
.clk_offset = 3,
.has_unre_flag = true,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata at91sam9261_config = {
.clk_max_div = 5,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata at91sam9260_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata at91sam9g20_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata at91sam9g10_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static const struct platform_device_id at91_twi_devtypes[] = {
{
.name = "i2c-at91rm9200",
.driver_data = (unsigned long) &at91rm9200_config,
}, {
.name = "i2c-at91sam9261",
.driver_data = (unsigned long) &at91sam9261_config,
}, {
.name = "i2c-at91sam9260",
.driver_data = (unsigned long) &at91sam9260_config,
}, {
.name = "i2c-at91sam9g20",
.driver_data = (unsigned long) &at91sam9g20_config,
}, {
.name = "i2c-at91sam9g10",
.driver_data = (unsigned long) &at91sam9g10_config,
}, {
/* sentinel */
}
};
#if defined(CONFIG_OF)
static struct at91_twi_pdata at91sam9x5_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = false,
.has_dig_filtr = false,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata sama5d4_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = false,
.has_alt_cmd = false,
.has_hold_field = true,
.has_dig_filtr = true,
.has_adv_dig_filtr = false,
.has_ana_filtr = false,
};
static struct at91_twi_pdata sama5d2_config = {
.clk_max_div = 7,
.clk_offset = 3,
.has_unre_flag = true,
.has_alt_cmd = true,
.has_hold_field = true,
.has_dig_filtr = true,
.has_adv_dig_filtr = true,
.has_ana_filtr = true,
};
static struct at91_twi_pdata sam9x60_config = {
.clk_max_div = 7,
.clk_offset = 4,
.has_unre_flag = true,
.has_alt_cmd = true,
.has_hold_field = true,
.has_dig_filtr = true,
.has_adv_dig_filtr = true,
.has_ana_filtr = true,
};
static const struct of_device_id atmel_twi_dt_ids[] = {
{
.compatible = "atmel,at91rm9200-i2c",
.data = &at91rm9200_config,
}, {
.compatible = "atmel,at91sam9260-i2c",
.data = &at91sam9260_config,
}, {
.compatible = "atmel,at91sam9261-i2c",
.data = &at91sam9261_config,
}, {
.compatible = "atmel,at91sam9g20-i2c",
.data = &at91sam9g20_config,
}, {
.compatible = "atmel,at91sam9g10-i2c",
.data = &at91sam9g10_config,
}, {
.compatible = "atmel,at91sam9x5-i2c",
.data = &at91sam9x5_config,
}, {
.compatible = "atmel,sama5d4-i2c",
.data = &sama5d4_config,
}, {
.compatible = "atmel,sama5d2-i2c",
.data = &sama5d2_config,
}, {
.compatible = "microchip,sam9x60-i2c",
.data = &sam9x60_config,
}, {
/* sentinel */
}
};
MODULE_DEVICE_TABLE(of, atmel_twi_dt_ids);
#endif
static struct at91_twi_pdata *<API key>(
struct platform_device *pdev)
{
if (pdev->dev.of_node) {
const struct of_device_id *match;
match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node);
if (!match)
return NULL;
return (struct at91_twi_pdata *)match->data;
}
return (struct at91_twi_pdata *) <API key>(pdev)->driver_data;
}
static int at91_twi_probe(struct platform_device *pdev)
{
struct at91_twi_dev *dev;
struct resource *mem;
int rc;
u32 phy_addr;
dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
if (!dev)
return -ENOMEM;
dev->dev = &pdev->dev;
mem = <API key>(pdev, IORESOURCE_MEM, 0);
if (!mem)
return -ENODEV;
phy_addr = mem->start;
dev->pdata = <API key>(pdev);
if (!dev->pdata)
return -ENODEV;
dev->base = <API key>(&pdev->dev, mem);
if (IS_ERR(dev->base))
return PTR_ERR(dev->base);
dev->irq = platform_get_irq(pdev, 0);
if (dev->irq < 0)
return dev->irq;
<API key>(pdev, dev);
dev->clk = devm_clk_get(dev->dev, NULL);
if (IS_ERR(dev->clk)) {
dev_err(dev->dev, "no clock defined\n");
return -ENODEV;
}
clk_prepare_enable(dev->clk);
snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91");
i2c_set_adapdata(&dev->adapter, dev);
dev->adapter.owner = THIS_MODULE;
dev->adapter.class = <API key>;
dev->adapter.dev.parent = dev->dev;
dev->adapter.nr = pdev->id;
dev->adapter.timeout = AT91_I2C_TIMEOUT;
dev->adapter.dev.of_node = pdev->dev.of_node;
dev->slave_detected = <API key>(&pdev->dev);
if (dev->slave_detected)
rc = <API key>(pdev, phy_addr, dev);
else
rc = <API key>(pdev, phy_addr, dev);
if (rc)
return rc;
at91_init_twi_bus(dev);
<API key>(dev->dev, AUTOSUSPEND_TIMEOUT);
<API key>(dev->dev);
<API key>(dev->dev);
pm_runtime_enable(dev->dev);
rc = <API key>(&dev->adapter);
if (rc) {
<API key>(dev->clk);
pm_runtime_disable(dev->dev);
<API key>(dev->dev);
return rc;
}
dev_info(dev->dev, "AT91 i2c bus driver (hw version: %
at91_twi_read(dev, AT91_TWI_VER));
return 0;
}
static int at91_twi_remove(struct platform_device *pdev)
{
struct at91_twi_dev *dev = <API key>(pdev);
i2c_del_adapter(&dev->adapter);
<API key>(dev->clk);
pm_runtime_disable(dev->dev);
<API key>(dev->dev);
return 0;
}
#ifdef CONFIG_PM
static int <API key>(struct device *dev)
{
struct at91_twi_dev *twi_dev = dev_get_drvdata(dev);
<API key>(twi_dev->clk);
<API key>(dev);
return 0;
}
static int <API key>(struct device *dev)
{
struct at91_twi_dev *twi_dev = dev_get_drvdata(dev);
<API key>(dev);
return clk_prepare_enable(twi_dev->clk);
}
static int <API key>(struct device *dev)
{
if (!<API key>(dev))
<API key>(dev);
return 0;
}
static int <API key>(struct device *dev)
{
struct at91_twi_dev *twi_dev = dev_get_drvdata(dev);
int ret;
if (!<API key>(dev)) {
ret = <API key>(dev);
if (ret)
return ret;
}
<API key>(dev);
<API key>(dev);
at91_init_twi_bus(twi_dev);
return 0;
}
static const struct dev_pm_ops at91_twi_pm = {
.suspend_noirq = <API key>,
.resume_noirq = <API key>,
.runtime_suspend = <API key>,
.runtime_resume = <API key>,
};
#define at91_twi_pm_ops (&at91_twi_pm)
#else
#define at91_twi_pm_ops NULL
#endif
static struct platform_driver at91_twi_driver = {
.probe = at91_twi_probe,
.remove = at91_twi_remove,
.id_table = at91_twi_devtypes,
.driver = {
.name = "at91_i2c",
.of_match_table = of_match_ptr(atmel_twi_dt_ids),
.pm = at91_twi_pm_ops,
},
};
static int __init at91_twi_init(void)
{
return <API key>(&at91_twi_driver);
}
static void __exit at91_twi_exit(void)
{
<API key>(&at91_twi_driver);
}
subsys_initcall(at91_twi_init);
module_exit(at91_twi_exit);
MODULE_AUTHOR("Nikolaus Voss <n.voss@weinmann.de>");
MODULE_DESCRIPTION("I2C (TWI) driver for Atmel AT91");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:at91_i2c");
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
#include "stor-layout.h"
#include "print-tree.h"
#include "tree-iterator.h"
#include "cp-tree.h"
#include "flags.h"
#include "tree-inline.h"
#include "debug.h"
#include "convert.h"
#include "cgraph.h"
#include "splay-tree.h"
#include "hash-table.h"
#include "gimple-expr.h"
#include "gimplify.h"
static tree bot_manip (tree *, int *, void *);
static tree bot_replace (tree *, int *, void *);
static int list_hash_eq (const void *, const void *);
static hashval_t list_hash_pieces (tree, tree, tree);
static hashval_t list_hash (const void *);
static tree build_target_expr (tree, tree, tsubst_flags_t);
static tree count_trees_r (tree *, int *, void *);
static tree verify_stmt_tree_r (tree *, int *, void *);
static tree build_local_temp (tree);
static tree <API key> (tree *, tree, tree, int, bool *);
static tree <API key> (tree *, tree, tree, int, bool *);
static tree <API key> (tree *, tree, tree, int, bool *);
static tree <API key> (tree *, tree, tree, int, bool *);
/* If REF is an lvalue, returns the kind of lvalue that REF is.
Otherwise, returns clk_none. */
cp_lvalue_kind
lvalue_kind (const_tree ref)
{
cp_lvalue_kind op1_lvalue_kind = clk_none;
cp_lvalue_kind op2_lvalue_kind = clk_none;
/* Expressions of reference type are sometimes wrapped in
INDIRECT_REFs. INDIRECT_REFs are just internal compiler
representation, not part of the language, so we have to look
through them. */
if (REFERENCE_REF_P (ref))
return lvalue_kind (TREE_OPERAND (ref, 0));
if (TREE_TYPE (ref)
&& TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
{
/* unnamed rvalue references are rvalues */
if (TYPE_REF_IS_RVALUE (TREE_TYPE (ref))
&& TREE_CODE (ref) != PARM_DECL
&& !VAR_P (ref)
&& TREE_CODE (ref) != COMPONENT_REF
/* Functions are always lvalues. */
&& TREE_CODE (TREE_TYPE (TREE_TYPE (ref))) != FUNCTION_TYPE)
return clk_rvalueref;
/* lvalue references and named rvalue references are lvalues. */
return clk_ordinary;
}
if (ref == current_class_ptr)
return clk_none;
switch (TREE_CODE (ref))
{
case SAVE_EXPR:
return clk_none;
/* preincrements and predecrements are valid lvals, provided
what they refer to are valid lvals. */
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case TRY_CATCH_EXPR:
case WITH_CLEANUP_EXPR:
case REALPART_EXPR:
case IMAGPART_EXPR:
return lvalue_kind (TREE_OPERAND (ref, 0));
case MEMBER_REF:
case DOTSTAR_EXPR:
if (TREE_CODE (ref) == MEMBER_REF)
op1_lvalue_kind = clk_ordinary;
else
op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
if (TYPE_PTRMEMFUNC_P (TREE_TYPE (TREE_OPERAND (ref, 1))))
op1_lvalue_kind = clk_none;
return op1_lvalue_kind;
case COMPONENT_REF:
op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
/* Look at the member designator. */
if (!op1_lvalue_kind)
;
else if (is_overloaded_fn (TREE_OPERAND (ref, 1)))
/* The "field" can be a FUNCTION_DECL or an OVERLOAD in some
situations. If we're seeing a COMPONENT_REF, it's a non-static
member, so it isn't an lvalue. */
op1_lvalue_kind = clk_none;
else if (TREE_CODE (TREE_OPERAND (ref, 1)) != FIELD_DECL)
/* This can be IDENTIFIER_NODE in a template. */;
else if (DECL_C_BIT_FIELD (TREE_OPERAND (ref, 1)))
{
/* Clear the ordinary bit. If this object was a class
rvalue we want to preserve that information. */
op1_lvalue_kind &= ~clk_ordinary;
/* The lvalue is for a bitfield. */
op1_lvalue_kind |= clk_bitfield;
}
else if (DECL_PACKED (TREE_OPERAND (ref, 1)))
op1_lvalue_kind |= clk_packed;
return op1_lvalue_kind;
case STRING_CST:
case <API key>:
return clk_ordinary;
case CONST_DECL:
/* CONST_DECL without TREE_STATIC are enumeration values and
thus not lvalues. With TREE_STATIC they are used by ObjC++
in <API key> and need to be considered as
lvalues. */
if (! TREE_STATIC (ref))
return clk_none;
case VAR_DECL:
if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
&& DECL_LANG_SPECIFIC (ref)
&& DECL_IN_AGGR_P (ref))
return clk_none;
case INDIRECT_REF:
case ARROW_EXPR:
case ARRAY_REF:
case ARRAY_NOTATION_REF:
case PARM_DECL:
case RESULT_DECL:
return clk_ordinary;
/* A scope ref in a template, left as SCOPE_REF to support later
access checking. */
case SCOPE_REF:
gcc_assert (!<API key> (CONST_CAST_TREE (ref)));
{
tree op = TREE_OPERAND (ref, 1);
if (TREE_CODE (op) == FIELD_DECL)
return (DECL_C_BIT_FIELD (op) ? clk_bitfield : clk_ordinary);
else
return lvalue_kind (op);
}
case MAX_EXPR:
case MIN_EXPR:
/* Disallow <? and >? as lvalues if either argument side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 0))
|| TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 1)))
return clk_none;
op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 0));
op2_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 1));
break;
case COND_EXPR:
op1_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 1)
? TREE_OPERAND (ref, 1)
: TREE_OPERAND (ref, 0));
op2_lvalue_kind = lvalue_kind (TREE_OPERAND (ref, 2));
break;
case MODIFY_EXPR:
case TYPEID_EXPR:
return clk_ordinary;
case COMPOUND_EXPR:
return lvalue_kind (TREE_OPERAND (ref, 1));
case TARGET_EXPR:
return clk_class;
case VA_ARG_EXPR:
return (CLASS_TYPE_P (TREE_TYPE (ref)) ? clk_class : clk_none);
case CALL_EXPR:
/* We can see calls outside of TARGET_EXPR in templates. */
if (CLASS_TYPE_P (TREE_TYPE (ref)))
return clk_class;
return clk_none;
case FUNCTION_DECL:
/* All functions (except non-static-member functions) are
lvalues. */
return (<API key> (ref)
? clk_none : clk_ordinary);
case BASELINK:
/* We now represent a reference to a single static member function
with a BASELINK. */
/* This CONST_CAST is okay because BASELINK_FUNCTIONS returns
its argument unmodified and we assign it to a const_tree. */
return lvalue_kind (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref)));
case NON_DEPENDENT_EXPR:
/* We just return clk_ordinary for NON_DEPENDENT_EXPR in C++98, but
in C++11 lvalues don't bind to rvalue references, so we need to
work harder to avoid bogus errors (c++/44870). */
if (cxx_dialect < cxx11)
return clk_ordinary;
else
return lvalue_kind (TREE_OPERAND (ref, 0));
default:
if (!TREE_TYPE (ref))
return clk_none;
if (CLASS_TYPE_P (TREE_TYPE (ref)))
return clk_class;
break;
}
/* If one operand is not an lvalue at all, then this expression is
not an lvalue. */
if (!op1_lvalue_kind || !op2_lvalue_kind)
return clk_none;
/* Otherwise, it's an lvalue, and it has all the odd properties
contributed by either operand. */
op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind;
/* It's not an ordinary lvalue if it involves any other kind. */
if ((op1_lvalue_kind & ~clk_ordinary) != clk_none)
op1_lvalue_kind &= ~clk_ordinary;
/* It can't be both a pseudo-lvalue and a non-addressable lvalue.
A COND_EXPR of those should be wrapped in a TARGET_EXPR. */
if ((op1_lvalue_kind & (clk_rvalueref|clk_class))
&& (op1_lvalue_kind & (clk_bitfield|clk_packed)))
op1_lvalue_kind = clk_none;
return op1_lvalue_kind;
}
/* Returns the kind of lvalue that REF is, in the sense of
[basic.lval]. This function should really be named lvalue_p; it
computes the C++ definition of lvalue. */
cp_lvalue_kind
real_lvalue_p (const_tree ref)
{
cp_lvalue_kind kind = lvalue_kind (ref);
if (kind & (clk_rvalueref|clk_class))
return clk_none;
else
return kind;
}
/* This differs from real_lvalue_p in that class rvalues are considered
lvalues. */
bool
lvalue_p (const_tree ref)
{
return (lvalue_kind (ref) != clk_none);
}
/* This differs from real_lvalue_p in that rvalues formed by dereferencing
rvalue references are considered rvalues. */
bool
<API key> (const_tree ref)
{
cp_lvalue_kind kind = lvalue_kind (ref);
if (kind & clk_class)
return false;
else
return (kind != clk_none);
}
/* Returns true if REF is an xvalue, false otherwise. */
bool
xvalue_p (const_tree ref)
{
return (lvalue_kind (ref) == clk_rvalueref);
}
/* Test whether DECL is a builtin that may appear in a
constant-expression. */
bool
<API key> (const_tree decl)
{
/* At present BUILT_IN_CONSTANT_P is the only builtin we're allowing
in <API key>. We may want to add other builtins later. */
return <API key> (decl);
}
/* Build a TARGET_EXPR, initializing the DECL with the VALUE. */
static tree
build_target_expr (tree decl, tree value, tsubst_flags_t complain)
{
tree t;
tree type = TREE_TYPE (decl);
#ifdef ENABLE_CHECKING
gcc_assert (VOID_TYPE_P (TREE_TYPE (value))
|| TREE_TYPE (decl) == TREE_TYPE (value)
/* On ARM ctors return 'this'. */
|| (TYPE_PTR_P (TREE_TYPE (value))
&& TREE_CODE (value) == CALL_EXPR)
|| <API key> (TREE_TYPE (decl),
TREE_TYPE (value)));
#endif
t = <API key> (decl, complain);
if (t == error_mark_node)
return error_mark_node;
t = build4 (TARGET_EXPR, type, decl, value, t, NULL_TREE);
/* We always set TREE_SIDE_EFFECTS so that expand_expr does not
ignore the TARGET_EXPR. If there really turn out to be no
side-effects, then the optimizer should be able to get rid of
whatever code is generated anyhow. */
TREE_SIDE_EFFECTS (t) = 1;
return t;
}
/* Return an undeclared local temporary of type TYPE for use in building a
TARGET_EXPR. */
static tree
build_local_temp (tree type)
{
tree slot = build_decl (input_location,
VAR_DECL, NULL_TREE, type);
DECL_ARTIFICIAL (slot) = 1;
DECL_IGNORED_P (slot) = 1;
DECL_CONTEXT (slot) = <API key>;
layout_decl (slot, 0);
return slot;
}
/* Set various status flags when building an AGGR_INIT_EXPR object T. */
static void
<API key> (tree t)
{
bool side_effects;
side_effects = TREE_SIDE_EFFECTS (t);
if (!side_effects)
{
int i, n;
n = TREE_OPERAND_LENGTH (t);
for (i = 1; i < n; i++)
{
tree op = TREE_OPERAND (t, i);
if (op && TREE_SIDE_EFFECTS (op))
{
side_effects = 1;
break;
}
}
}
TREE_SIDE_EFFECTS (t) = side_effects;
}
/* Build an AGGR_INIT_EXPR of class tcc_vl_exp with the indicated RETURN_TYPE,
FN, and SLOT. NARGS is the number of call arguments which are specified
as a tree array ARGS. */
static tree
<API key> (tree return_type, tree fn, tree slot, int nargs,
tree *args)
{
tree t;
int i;
t = build_vl_exp (AGGR_INIT_EXPR, nargs + 3);
TREE_TYPE (t) = return_type;
AGGR_INIT_EXPR_FN (t) = fn;
AGGR_INIT_EXPR_SLOT (t) = slot;
for (i = 0; i < nargs; i++)
AGGR_INIT_EXPR_ARG (t, i) = args[i];
<API key> (t);
return t;
}
/* INIT is a CALL_EXPR or AGGR_INIT_EXPR which needs info about its
target. TYPE is the type to be initialized.
Build an AGGR_INIT_EXPR to represent the initialization. This function
differs from build_cplus_new in that an AGGR_INIT_EXPR can only be used
to initialize another object, whereas a TARGET_EXPR can either
initialize another object or create its own temporary object, and as a
result building up a TARGET_EXPR requires that the type's destructor be
callable. */
tree
<API key> (tree type, tree init)
{
tree fn;
tree slot;
tree rval;
int is_ctor;
/* Don't build AGGR_INIT_EXPR in a template. */
if (<API key>)
return init;
if (TREE_CODE (init) == CALL_EXPR)
fn = CALL_EXPR_FN (init);
else if (TREE_CODE (init) == AGGR_INIT_EXPR)
fn = AGGR_INIT_EXPR_FN (init);
else
return convert (type, init);
is_ctor = (TREE_CODE (fn) == ADDR_EXPR
&& TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL
&& DECL_CONSTRUCTOR_P (TREE_OPERAND (fn, 0)));
/* We split the CALL_EXPR into its function and its arguments here.
Then, in expand_expr, we put them back together. The reason for
this is that this expression might be a default argument
expression. In that case, we need a new temporary every time the
expression is used. That's what <API key> does; it
replaces every AGGR_INIT_EXPR with a copy that uses a fresh
temporary slot. Then, expand_expr builds up a call-expression
using the new slot. */
/* If we don't need to use a constructor to create an object of this
type, don't mess with AGGR_INIT_EXPR. */
if (is_ctor || TREE_ADDRESSABLE (type))
{
slot = build_local_temp (type);
if (TREE_CODE(init) == CALL_EXPR)
rval = <API key> (void_type_node, fn, slot,
call_expr_nargs (init),
CALL_EXPR_ARGP (init));
else
rval = <API key> (void_type_node, fn, slot,
<API key> (init),
AGGR_INIT_EXPR_ARGP (init));
TREE_SIDE_EFFECTS (rval) = 1;
<API key> (rval) = is_ctor;
TREE_NOTHROW (rval) = TREE_NOTHROW (init);
<API key> (rval) = <API key> (init);
}
else
rval = init;
return rval;
}
/* INIT is a CALL_EXPR or AGGR_INIT_EXPR which needs info about its
target. TYPE is the type that this initialization should appear to
have.
Build an encapsulation of the initialization to perform
and return it so that it can be processed by <API key>
and language-specific expression expanders. */
tree
build_cplus_new (tree type, tree init, tsubst_flags_t complain)
{
tree rval = <API key> (type, init);
tree slot;
if (!<API key> (type, init, complain))
return error_mark_node;
/* Make sure that we're not trying to create an instance of an
abstract class. */
if (<API key> (NULL_TREE, type, complain))
return error_mark_node;
if (TREE_CODE (rval) == AGGR_INIT_EXPR)
slot = AGGR_INIT_EXPR_SLOT (rval);
else if (TREE_CODE (rval) == CALL_EXPR
|| TREE_CODE (rval) == CONSTRUCTOR)
slot = build_local_temp (type);
else
return rval;
rval = build_target_expr (slot, rval, complain);
if (rval != error_mark_node)
<API key> (rval) = 1;
return rval;
}
/* Subroutine of build_vec_init_expr: Build up a single element
intialization as a proxy for the full array initialization to get things
marked as used and any appropriate diagnostics.
Since we're deferring building the actual constructor calls until
gimplification time, we need to build one now and throw it away so
that the relevant constructor gets mark_used before cgraph decides
what functions are needed. Here we assume that init is either
NULL_TREE, void_type_node (indicating <API key>), or
another array to copy. */
static tree
build_vec_init_elt (tree type, tree init, tsubst_flags_t complain)
{
tree inner_type = strip_array_types (type);
vec<tree, va_gc> *argvec;
if (integer_zerop (<API key> (type))
|| !CLASS_TYPE_P (inner_type))
/* No interesting initialization to do. */
return integer_zero_node;
else if (init == void_type_node)
return build_value_init (inner_type, complain);
gcc_assert (init == NULL_TREE
|| (<API key>
(type, TREE_TYPE (init))));
argvec = make_tree_vector ();
if (init)
{
tree init_type = strip_array_types (TREE_TYPE (init));
tree dummy = build_dummy_object (init_type);
if (!real_lvalue_p (init))
dummy = move (dummy);
argvec->quick_push (dummy);
}
init = <API key> (NULL_TREE, <API key>,
&argvec, inner_type, LOOKUP_NORMAL,
complain);
release_tree_vector (argvec);
/* For a trivial constructor, build_over_call creates a TARGET_EXPR. But
we don't want one here because we aren't creating a temporary. */
if (TREE_CODE (init) == TARGET_EXPR)
init = TARGET_EXPR_INITIAL (init);
return init;
}
/* Return a TARGET_EXPR which expresses the initialization of an array to
be named later, either <API key> or copy-initialization
from another array of the same type. */
tree
build_vec_init_expr (tree type, tree init, tsubst_flags_t complain)
{
tree slot;
bool value_init = false;
tree elt_init = build_vec_init_elt (type, init, complain);
if (init == void_type_node)
{
value_init = true;
init = NULL_TREE;
}
slot = build_local_temp (type);
init = build2 (VEC_INIT_EXPR, type, slot, init);
TREE_SIDE_EFFECTS (init) = true;
SET_EXPR_LOCATION (init, input_location);
if (cxx_dialect >= cxx11
&& <API key> (elt_init))
<API key> (init) = true;
<API key> (init) = value_init;
return init;
}
/* Give a helpful diagnostic for a non-constexpr VEC_INIT_EXPR in a context
that requires a constant expression. */
void
<API key> (tree expr)
{
tree type = TREE_TYPE (VEC_INIT_EXPR_SLOT (expr));
tree init, elt_init;
if (<API key> (expr))
init = void_type_node;
else
init = VEC_INIT_EXPR_INIT (expr);
elt_init = build_vec_init_elt (type, init, tf_warning_or_error);
<API key> (elt_init);
}
tree
build_array_copy (tree init)
{
return build_vec_init_expr (TREE_TYPE (init), init, tf_warning_or_error);
}
/* Build a TARGET_EXPR using INIT to initialize a new temporary of the
indicated TYPE. */
tree
<API key> (tree init, tree type, tsubst_flags_t complain)
{
gcc_assert (!VOID_TYPE_P (type));
if (TREE_CODE (init) == TARGET_EXPR
|| init == error_mark_node)
return init;
else if (CLASS_TYPE_P (type) && <API key> (type)
&& !VOID_TYPE_P (TREE_TYPE (init))
&& TREE_CODE (init) != COND_EXPR
&& TREE_CODE (init) != CONSTRUCTOR
&& TREE_CODE (init) != VA_ARG_EXPR)
/* We need to build up a copy constructor call. A void initializer
means we're being called from bot_manip. COND_EXPR is a special
case because we already have copies on the arms and we don't want
another one here. A CONSTRUCTOR is aggregate initialization, which
is handled separately. A VA_ARG_EXPR is magic creation of an
aggregate; there's no additional work to be done. */
return force_rvalue (init, complain);
return force_target_expr (type, init, complain);
}
/* Like the above function, but without the checking. This function should
only be used by code which is deliberately trying to subvert the type
system, such as call_builtin_trap. Or build_over_call, to avoid
infinite recursion. */
tree
force_target_expr (tree type, tree init, tsubst_flags_t complain)
{
tree slot;
gcc_assert (!VOID_TYPE_P (type));
slot = build_local_temp (type);
return build_target_expr (slot, init, complain);
}
/* Like <API key>, but use the type of INIT. */
tree
<API key> (tree init, tsubst_flags_t complain)
{
if (TREE_CODE (init) == AGGR_INIT_EXPR)
return build_target_expr (AGGR_INIT_EXPR_SLOT (init), init, complain);
else if (TREE_CODE (init) == VEC_INIT_EXPR)
return build_target_expr (VEC_INIT_EXPR_SLOT (init), init, complain);
else
return <API key> (init, TREE_TYPE (init), complain);
}
tree
get_target_expr (tree init)
{
return <API key> (init, tf_warning_or_error);
}
/* If EXPR is a bitfield reference, convert it to the declared type of
the bitfield, and return the resulting expression. Otherwise,
return EXPR itself. */
tree
<API key> (tree expr)
{
tree bitfield_type;
bitfield_type = <API key> (expr);
if (bitfield_type)
expr = convert_to_integer (TYPE_MAIN_VARIANT (bitfield_type),
expr);
return expr;
}
/* EXPR is being used in an rvalue context. Return a version of EXPR
that is marked as an rvalue. */
tree
rvalue (tree expr)
{
tree type;
if (error_operand_p (expr))
return expr;
expr = mark_rvalue_use (expr);
/* [basic.lval]
Non-class rvalues always have cv-unqualified types. */
type = TREE_TYPE (expr);
if (!CLASS_TYPE_P (type) && cv_qualified_p (type))
type = cv_unqualified (type);
/* We need to do this for rvalue refs as well to get the right answer
from decltype; see c++/36628. */
if (!<API key> && <API key> (expr))
expr = build1 (NON_LVALUE_EXPR, type, expr);
else if (type != TREE_TYPE (expr))
expr = build_nop (type, expr);
return expr;
}
/* Hash an ARRAY_TYPE. K is really of type `tree'. */
static hashval_t
cplus_array_hash (const void* k)
{
hashval_t hash;
const_tree const t = (const_tree) k;
hash = TYPE_UID (TREE_TYPE (t));
if (TYPE_DOMAIN (t))
hash ^= TYPE_UID (TYPE_DOMAIN (t));
return hash;
}
typedef struct cplus_array_info {
tree type;
tree domain;
} cplus_array_info;
/* Compare two ARRAY_TYPEs. K1 is really of type `tree', K2 is really
of type `cplus_array_info*'. */
static int
cplus_array_compare (const void * k1, const void * k2)
{
const_tree const t1 = (const_tree) k1;
const cplus_array_info *const t2 = (const cplus_array_info*) k2;
return (TREE_TYPE (t1) == t2->type && TYPE_DOMAIN (t1) == t2->domain);
}
/* Hash table containing dependent array types, which are unsuitable for
the <API key> type hash table. */
static GTY ((param_is (union tree_node))) htab_t cplus_array_htab;
/* Like build_array_type, but handle special C++ semantics. */
tree
<API key> (tree elt_type, tree index_type)
{
tree t;
if (elt_type == error_mark_node || index_type == error_mark_node)
return error_mark_node;
if (<API key>
&& (dependent_type_p (elt_type)
|| (index_type && !TREE_CONSTANT (TYPE_MAX_VALUE (index_type)))))
{
void **e;
cplus_array_info cai;
hashval_t hash;
if (cplus_array_htab == NULL)
cplus_array_htab = htab_create_ggc (61, &cplus_array_hash,
&cplus_array_compare, NULL);
hash = TYPE_UID (elt_type);
if (index_type)
hash ^= TYPE_UID (index_type);
cai.type = elt_type;
cai.domain = index_type;
e = <API key> (cplus_array_htab, &cai, hash, INSERT);
if (*e)
/* We have found the type: we're done. */
return (tree) *e;
else
{
/* Build a new array type. */
t = cxx_make_type (ARRAY_TYPE);
TREE_TYPE (t) = elt_type;
TYPE_DOMAIN (t) = index_type;
/* Store it in the hash table. */
*e = t;
/* Set the canonical type for this new node. */
if (<API key> (elt_type)
|| (index_type && <API key> (index_type)))
<API key> (t);
else if (TYPE_CANONICAL (elt_type) != elt_type
|| (index_type
&& TYPE_CANONICAL (index_type) != index_type))
TYPE_CANONICAL (t)
= <API key>
(TYPE_CANONICAL (elt_type),
index_type ? TYPE_CANONICAL (index_type) : index_type);
else
TYPE_CANONICAL (t) = t;
}
}
else
{
if (!<API key> (elt_type)
&& !(index_type && <API key> (index_type))
&& (TYPE_CANONICAL (elt_type) != elt_type
|| (index_type && TYPE_CANONICAL (index_type) != index_type)))
/* Make sure that the canonical type is on the appropriate
variants list. */
<API key>
(TYPE_CANONICAL (elt_type),
index_type ? TYPE_CANONICAL (index_type) : index_type);
t = build_array_type (elt_type, index_type);
}
/* Push these needs up so that initialization takes place
more easily. */
bool needs_ctor
= <API key> (TYPE_MAIN_VARIANT (elt_type));
<API key> (t) = needs_ctor;
bool needs_dtor
= <API key> (TYPE_MAIN_VARIANT (elt_type));
<API key> (t) = needs_dtor;
/* We want TYPE_MAIN_VARIANT of an array to strip cv-quals from the
element type as well, so fix it up if needed. */
if (elt_type != TYPE_MAIN_VARIANT (elt_type))
{
tree m = <API key> (TYPE_MAIN_VARIANT (elt_type),
index_type);
if (TYPE_MAIN_VARIANT (t) != m)
{
if (COMPLETE_TYPE_P (TREE_TYPE (t)) && !COMPLETE_TYPE_P (m))
{
/* m was built before the element type was complete, so we
also need to copy the layout info from t. We might
end up doing this multiple times if t is an array of
unknown bound. */
tree size = TYPE_SIZE (t);
tree size_unit = TYPE_SIZE_UNIT (t);
unsigned int align = TYPE_ALIGN (t);
unsigned int user_align = TYPE_USER_ALIGN (t);
enum machine_mode mode = TYPE_MODE (t);
for (tree var = m; var; var = TYPE_NEXT_VARIANT (var))
{
TYPE_SIZE (var) = size;
TYPE_SIZE_UNIT (var) = size_unit;
TYPE_ALIGN (var) = align;
TYPE_USER_ALIGN (var) = user_align;
SET_TYPE_MODE (var, mode);
<API key> (var) = needs_ctor;
<API key> (var) = needs_dtor;
}
}
TYPE_MAIN_VARIANT (t) = m;
TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
TYPE_NEXT_VARIANT (m) = t;
}
}
/* Avoid spurious warnings with VLAs (c++/54583). */
if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
TREE_NO_WARNING (TYPE_SIZE (t)) = 1;
return t;
}
/* Return an ARRAY_TYPE with element type ELT and length N. */
tree
<API key> (tree elt, int n)
{
return <API key> (elt, build_index_type (size_int (n - 1)));
}
/* True iff T is a C++1y array of runtime bound (VLA). */
bool
<API key> (tree t)
{
if (!t || TREE_CODE (t) != ARRAY_TYPE)
return false;
tree dom = TYPE_DOMAIN (t);
if (!dom)
return false;
tree max = TYPE_MAX_VALUE (dom);
return (!<API key> (max)
|| (!<API key> (max) && !TREE_CONSTANT (max)));
}
/* Return a reference type node referring to TO_TYPE. If RVAL is
true, return an rvalue reference type, otherwise return an lvalue
reference type. If a type node exists, reuse it, otherwise create
a new one. */
tree
<API key> (tree to_type, bool rval)
{
tree lvalue_ref, t;
lvalue_ref = <API key> (to_type);
if (!rval)
return lvalue_ref;
/* This code to create rvalue reference types is based on and tied
to the code creating lvalue reference types in the middle-end
functions <API key> and <API key>.
It works by putting the rvalue reference type nodes after the
lvalue reference nodes in the TYPE_NEXT_REF_TO linked list, so
they will effectively be ignored by the middle end. */
for (t = lvalue_ref; (t = TYPE_NEXT_REF_TO (t)); )
if (TYPE_REF_IS_RVALUE (t))
return t;
t = <API key> (lvalue_ref);
TYPE_REF_IS_RVALUE (t) = true;
TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (lvalue_ref);
TYPE_NEXT_REF_TO (lvalue_ref) = t;
if (<API key> (to_type))
<API key> (t);
else if (TYPE_CANONICAL (to_type) != to_type)
TYPE_CANONICAL (t)
= <API key> (TYPE_CANONICAL (to_type), rval);
else
TYPE_CANONICAL (t) = t;
layout_type (t);
return t;
}
/* Returns EXPR cast to rvalue reference type, like std::move. */
tree
move (tree expr)
{
tree type = TREE_TYPE (expr);
gcc_assert (TREE_CODE (type) != REFERENCE_TYPE);
type = <API key> (type, /*rval*/true);
return build_static_cast (type, expr, tf_warning_or_error);
}
/* Used by the C++ front end to build qualified array types. However,
the C version of this function does not properly maintain canonical
types (which are not used in C). */
tree
<API key> (tree type, int type_quals)
{
return <API key> (type, type_quals);
}
/* Make a variant of TYPE, qualified with the TYPE_QUALS. Handles
arrays correctly. In particular, if TYPE is an array of T's, and
TYPE_QUALS is non-empty, returns an array of qualified T's.
FLAGS determines how to deal with ill-formed qualifications. If
tf_ignore_bad_quals is set, then bad qualifications are dropped
(this is permitted if TYPE was introduced via a typedef or template
type parameter). If bad qualifications are dropped and tf_warning
is set, then a warning is issued for non-const qualifications. If
tf_ignore_bad_quals is not set and tf_error is not set, we
return error_mark_node. Otherwise, we issue an error, and ignore
the qualifications.
Qualification of a reference type is valid when the reference came
via a typedef or template type argument. [dcl.ref] No such
dispensation is provided for qualifying a function type. [dcl.fct]
DR 295 queries this and the proposed resolution brings it into line
with qualifying a reference. We implement the DR. We also behave
in a similar manner for restricting non-pointer types. */
tree
<API key> (tree type,
int type_quals,
tsubst_flags_t complain)
{
tree result;
int bad_quals = TYPE_UNQUALIFIED;
if (type == error_mark_node)
return type;
if (type_quals == cp_type_quals (type))
return type;
if (TREE_CODE (type) == ARRAY_TYPE)
{
/* In C++, the qualification really applies to the array element
type. Obtain the appropriately qualified element type. */
tree t;
tree element_type
= <API key> (TREE_TYPE (type),
type_quals,
complain);
if (element_type == error_mark_node)
return error_mark_node;
/* See if we already have an identically qualified type. Tests
should be equivalent to those in <API key>. */
for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
if (TREE_TYPE (t) == element_type
&& TYPE_NAME (t) == TYPE_NAME (type)
&& TYPE_CONTEXT (t) == TYPE_CONTEXT (type)
&& <API key> (TYPE_ATTRIBUTES (t),
TYPE_ATTRIBUTES (type)))
break;
if (!t)
{
t = <API key> (element_type, TYPE_DOMAIN (type));
/* Keep the typedef name. */
if (TYPE_NAME (t) != TYPE_NAME (type))
{
t = <API key> (t);
TYPE_NAME (t) = TYPE_NAME (type);
}
}
/* Even if we already had this variant, we update
<API key> and <API key> in case
they changed since the variant was originally created.
This seems hokey; if there is some way to use a previous
variant *without* coming through here,
<API key> will never be updated. */
<API key> (t)
= <API key> (TYPE_MAIN_VARIANT (element_type));
<API key> (t)
= <API key> (TYPE_MAIN_VARIANT (element_type));
return t;
}
else if (TYPE_PTRMEMFUNC_P (type))
{
/* For a pointer-to-member type, we can't just return a
cv-qualified version of the RECORD_TYPE. If we do, we
haven't changed the field that contains the actual pointer to
a method, and so <API key> will be wrong. */
tree t;
t = <API key> (type);
t = <API key> (t, type_quals, complain);
return <API key> (t);
}
else if (TREE_CODE (type) == TYPE_PACK_EXPANSION)
{
tree t = <API key> (type);
t = <API key> (t, type_quals, complain);
return make_pack_expansion (t);
}
/* A reference or method type shall not be cv-qualified.
[dcl.ref], [dcl.fct]. This used to be an error, but as of DR 295
(in CD1) we always ignore extra cv-quals on functions. */
if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE)
&& (TREE_CODE (type) == REFERENCE_TYPE
|| TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == METHOD_TYPE))
{
if (TREE_CODE (type) == REFERENCE_TYPE)
bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE);
}
/* But preserve any function-cv-quals on a FUNCTION_TYPE. */
if (TREE_CODE (type) == FUNCTION_TYPE)
type_quals |= type_memfn_quals (type);
/* A restrict-qualified type must be a pointer (or reference)
to object or incomplete type. */
if ((type_quals & TYPE_QUAL_RESTRICT)
&& TREE_CODE (type) != TEMPLATE_TYPE_PARM
&& TREE_CODE (type) != TYPENAME_TYPE
&& !POINTER_TYPE_P (type))
{
bad_quals |= TYPE_QUAL_RESTRICT;
type_quals &= ~TYPE_QUAL_RESTRICT;
}
if (bad_quals == TYPE_UNQUALIFIED
|| (complain & tf_ignore_bad_quals))
;
else if (!(complain & tf_error))
return error_mark_node;
else
{
tree bad_type = <API key> (ptr_type_node, bad_quals);
error ("%qV qualifiers cannot be applied to %qT",
bad_type, type);
}
/* Retrieve (or create) the appropriately qualified variant. */
result = <API key> (type, type_quals);
/* Preserve exception specs and ref-qualifier since <API key>
doesn't know about them. */
if (TREE_CODE (result) == FUNCTION_TYPE
|| TREE_CODE (result) == METHOD_TYPE)
{
result = <API key> (result, <API key> (type));
result = <API key> (result, type_memfn_rqual (type));
}
/* If this was a pointer-to-method type, and we just made a copy,
then we need to unshare the record that holds the cached
<API key> type, because these will be distinct
between the unqualified and qualified types. */
if (result != type
&& TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
&& TYPE_LANG_SPECIFIC (result) == TYPE_LANG_SPECIFIC (type))
TYPE_LANG_SPECIFIC (result) = NULL;
/* We may also have ended up building a new copy of the canonical
type of a pointer-to-method type, which could have the same
sharing problem described above. */
if (TYPE_CANONICAL (result) != TYPE_CANONICAL (type)
&& TYPE_PTR_P (type)
&& TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
&& (TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result))
== TYPE_LANG_SPECIFIC (TYPE_CANONICAL (type))))
TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result)) = NULL;
return result;
}
/* Return TYPE with const and volatile removed. */
tree
cv_unqualified (tree type)
{
int quals;
if (type == error_mark_node)
return type;
quals = cp_type_quals (type);
quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE);
return <API key> (type, quals);
}
/* Builds a qualified variant of T that is not a typedef variant.
E.g. consider the following declarations:
typedef const int ConstInt;
typedef ConstInt* PtrConstInt;
If T is PtrConstInt, this function returns a type representing
const int*.
In other words, if T is a typedef, the function returns the underlying type.
The cv-qualification and attributes of the type returned match the
input type.
They will always be compatible types.
The returned type is built so that all of its subtypes
recursively have their typedefs stripped as well.
This is different from just returning TYPE_CANONICAL (T)
Because of several reasons:
* If T is a type that needs structural equality
its TYPE_CANONICAL (T) will be NULL.
* TYPE_CANONICAL (T) desn't carry type attributes
and loses template parameter names. */
tree
strip_typedefs (tree t)
{
tree result = NULL, type = NULL, t0 = NULL;
if (!t || t == error_mark_node || t == TYPE_CANONICAL (t))
return t;
gcc_assert (TYPE_P (t));
switch (TREE_CODE (t))
{
case POINTER_TYPE:
type = strip_typedefs (TREE_TYPE (t));
result = build_pointer_type (type);
break;
case REFERENCE_TYPE:
type = strip_typedefs (TREE_TYPE (t));
result = <API key> (type, TYPE_REF_IS_RVALUE (t));
break;
case OFFSET_TYPE:
t0 = strip_typedefs (<API key> (t));
type = strip_typedefs (TREE_TYPE (t));
result = build_offset_type (t0, type);
break;
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (t))
{
t0 = strip_typedefs (<API key> (t));
result = <API key> (t0);
}
break;
case ARRAY_TYPE:
type = strip_typedefs (TREE_TYPE (t));
t0 = strip_typedefs (TYPE_DOMAIN (t));;
result = <API key> (type, t0);
break;
case FUNCTION_TYPE:
case METHOD_TYPE:
{
tree arg_types = NULL, arg_node, arg_type;
for (arg_node = TYPE_ARG_TYPES (t);
arg_node;
arg_node = TREE_CHAIN (arg_node))
{
if (arg_node == void_list_node)
break;
arg_type = strip_typedefs (TREE_VALUE (arg_node));
gcc_assert (arg_type);
arg_types =
tree_cons (TREE_PURPOSE (arg_node), arg_type, arg_types);
}
if (arg_types)
arg_types = nreverse (arg_types);
/* A list of parameters not ending with an ellipsis
must end with void_list_node. */
if (arg_node)
arg_types = chainon (arg_types, void_list_node);
type = strip_typedefs (TREE_TYPE (t));
if (TREE_CODE (t) == METHOD_TYPE)
{
tree class_type = TREE_TYPE (TREE_VALUE (arg_types));
gcc_assert (class_type);
result =
<API key> (class_type, type,
TREE_CHAIN (arg_types));
result
= <API key> (result, type_memfn_rqual (t));
}
else
{
result = build_function_type (type,
arg_types);
result = apply_memfn_quals (result,
type_memfn_quals (t),
type_memfn_rqual (t));
}
if (<API key> (t))
result = <API key> (result,
<API key> (t));
}
break;
case TYPENAME_TYPE:
{
tree fullname = <API key> (t);
if (TREE_CODE (fullname) == TEMPLATE_ID_EXPR
&& TREE_OPERAND (fullname, 1))
{
tree args = TREE_OPERAND (fullname, 1);
tree new_args = copy_node (args);
bool changed = false;
for (int i = 0; i < TREE_VEC_LENGTH (args); ++i)
{
tree arg = TREE_VEC_ELT (args, i);
tree strip_arg;
if (TYPE_P (arg))
strip_arg = strip_typedefs (arg);
else
strip_arg = strip_typedefs_expr (arg);
TREE_VEC_ELT (new_args, i) = strip_arg;
if (strip_arg != arg)
changed = true;
}
if (changed)
{
<API key> (new_args)
= <API key> (args);
fullname
= <API key> (TREE_OPERAND (fullname, 0),
new_args);
}
else
ggc_free (new_args);
}
result = make_typename_type (strip_typedefs (TYPE_CONTEXT (t)),
fullname, typename_type, tf_none);
}
break;
case DECLTYPE_TYPE:
result = strip_typedefs_expr (DECLTYPE_TYPE_EXPR (t));
if (result == DECLTYPE_TYPE_EXPR (t))
return t;
else
result = (<API key>
(result,
<API key> (t),
tf_none));
break;
default:
break;
}
if (!result)
result = TYPE_MAIN_VARIANT (t);
if (TYPE_USER_ALIGN (t) != TYPE_USER_ALIGN (result)
|| TYPE_ALIGN (t) != TYPE_ALIGN (result))
{
gcc_assert (TYPE_USER_ALIGN (t));
if (TYPE_ALIGN (t) == TYPE_ALIGN (result))
result = <API key> (result);
else
result = build_aligned_type (result, TYPE_ALIGN (t));
TYPE_USER_ALIGN (result) = true;
}
if (TYPE_ATTRIBUTES (t))
result = <API key> (result, TYPE_ATTRIBUTES (t));
return <API key> (result, cp_type_quals (t));
}
/* Like strip_typedefs above, but works on expressions, so that in
template<class T> struct A
{
typedef T TT;
B<sizeof(TT)> b;
};
sizeof(TT) is replaced by sizeof(T). */
tree
strip_typedefs_expr (tree t)
{
unsigned i,n;
tree r, type, *ops;
enum tree_code code;
if (t == NULL_TREE || t == error_mark_node)
return t;
if (DECL_P (t) || CONSTANT_CLASS_P (t))
return t;
/* Some expressions have type operands, so let's handle types here rather
than check TYPE_P in multiple places below. */
if (TYPE_P (t))
return strip_typedefs (t);
code = TREE_CODE (t);
switch (code)
{
case IDENTIFIER_NODE:
case TEMPLATE_PARM_INDEX:
case OVERLOAD:
case BASELINK:
case <API key>:
return t;
case TRAIT_EXPR:
{
tree type1 = strip_typedefs (TRAIT_EXPR_TYPE1 (t));
tree type2 = strip_typedefs (TRAIT_EXPR_TYPE2 (t));
if (type1 == TRAIT_EXPR_TYPE1 (t)
&& type2 == TRAIT_EXPR_TYPE2 (t))
return t;
r = copy_node (t);
TRAIT_EXPR_TYPE1 (t) = type1;
TRAIT_EXPR_TYPE2 (t) = type2;
return r;
}
case TREE_LIST:
{
vec<tree, va_gc> *vec = make_tree_vector ();
bool changed = false;
tree it;
for (it = t; it; it = TREE_CHAIN (it))
{
tree val = strip_typedefs_expr (TREE_VALUE (t));
vec_safe_push (vec, val);
if (val != TREE_VALUE (t))
changed = true;
gcc_assert (TREE_PURPOSE (it) == NULL_TREE);
}
if (changed)
{
r = NULL_TREE;
<API key> (*vec, i, it)
r = tree_cons (NULL_TREE, it, r);
}
else
r = t;
release_tree_vector (vec);
return r;
}
case TREE_VEC:
{
bool changed = false;
vec<tree, va_gc> *vec = make_tree_vector ();
n = TREE_VEC_LENGTH (t);
vec_safe_reserve (vec, n);
for (i = 0; i < n; ++i)
{
tree op = strip_typedefs_expr (TREE_VEC_ELT (t, i));
vec->quick_push (op);
if (op != TREE_VEC_ELT (t, i))
changed = true;
}
if (changed)
{
r = copy_node (t);
for (i = 0; i < n; ++i)
TREE_VEC_ELT (r, i) = (*vec)[i];
<API key> (r)
= <API key> (t);
}
else
r = t;
release_tree_vector (vec);
return r;
}
case CONSTRUCTOR:
{
bool changed = false;
vec<constructor_elt, va_gc> *vec
= vec_safe_copy (CONSTRUCTOR_ELTS (t));
n = CONSTRUCTOR_NELTS (t);
type = strip_typedefs (TREE_TYPE (t));
for (i = 0; i < n; ++i)
{
constructor_elt *e = &(*vec)[i];
tree op = strip_typedefs_expr (e->value);
if (op != e->value)
{
changed = true;
e->value = op;
}
gcc_checking_assert (e->index == strip_typedefs_expr (e->index));
}
if (!changed && type == TREE_TYPE (t))
{
vec_free (vec);
return t;
}
else
{
r = copy_node (t);
TREE_TYPE (r) = type;
CONSTRUCTOR_ELTS (r) = vec;
return r;
}
}
case LAMBDA_EXPR:
error ("lambda-expression in a constant expression");
return error_mark_node;
default:
break;
}
gcc_assert (EXPR_P (t));
n = TREE_OPERAND_LENGTH (t);
ops = XALLOCAVEC (tree, n);
type = TREE_TYPE (t);
switch (code)
{
CASE_CONVERT:
case IMPLICIT_CONV_EXPR:
case DYNAMIC_CAST_EXPR:
case STATIC_CAST_EXPR:
case CONST_CAST_EXPR:
case <API key>:
case CAST_EXPR:
case NEW_EXPR:
type = strip_typedefs (type);
/* fallthrough */
default:
for (i = 0; i < n; ++i)
ops[i] = strip_typedefs_expr (TREE_OPERAND (t, i));
break;
}
/* If nothing changed, return t. */
for (i = 0; i < n; ++i)
if (ops[i] != TREE_OPERAND (t, i))
break;
if (i == n && type == TREE_TYPE (t))
return t;
r = copy_node (t);
TREE_TYPE (r) = type;
for (i = 0; i < n; ++i)
TREE_OPERAND (r, i) = ops[i];
return r;
}
/* Makes a copy of BINFO and TYPE, which is to be inherited into a
graph dominated by T. If BINFO is NULL, TYPE is a dependent base,
and we do a shallow copy. If BINFO is non-NULL, we do a deep copy.
VIRT indicates whether TYPE is inherited virtually or not.
IGO_PREV points at the previous binfo of the inheritance graph
order chain. The newly copied binfo's TREE_CHAIN forms this
ordering.
The <API key> vector of T is constructed in the
correct order. That is in the order the bases themselves should be
constructed in.
The BINFO_INHERITANCE of a virtual base class points to the binfo
of the most derived type. ??? We could probably change this so that
BINFO_INHERITANCE becomes synonymous with BINFO_PRIMARY, and hence
remove a field. They currently can only differ for primary virtual
virtual bases. */
tree
copy_binfo (tree binfo, tree type, tree t, tree *igo_prev, int virt)
{
tree new_binfo;
if (virt)
{
/* See if we've already made this virtual base. */
new_binfo = binfo_for_vbase (type, t);
if (new_binfo)
return new_binfo;
}
new_binfo = make_tree_binfo (binfo ? BINFO_N_BASE_BINFOS (binfo) : 0);
BINFO_TYPE (new_binfo) = type;
/* Chain it into the inheritance graph. */
TREE_CHAIN (*igo_prev) = new_binfo;
*igo_prev = new_binfo;
if (binfo && !<API key> (binfo))
{
int ix;
tree base_binfo;
gcc_assert (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), type));
BINFO_OFFSET (new_binfo) = BINFO_OFFSET (binfo);
BINFO_VIRTUALS (new_binfo) = BINFO_VIRTUALS (binfo);
/* We do not need to copy the accesses, as they are read only. */
BINFO_BASE_ACCESSES (new_binfo) = BINFO_BASE_ACCESSES (binfo);
/* Recursively copy base binfos of BINFO. */
for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
{
tree new_base_binfo;
new_base_binfo = copy_binfo (base_binfo, BINFO_TYPE (base_binfo),
t, igo_prev,
BINFO_VIRTUAL_P (base_binfo));
if (!<API key> (new_base_binfo))
<API key> (new_base_binfo) = new_binfo;
BINFO_BASE_APPEND (new_binfo, new_base_binfo);
}
}
else
<API key> (new_binfo) = 1;
if (virt)
{
/* Push it onto the list after any virtual bases it contains
will have been pushed. */
<API key> (t)->quick_push (new_binfo);
BINFO_VIRTUAL_P (new_binfo) = 1;
<API key> (new_binfo) = TYPE_BINFO (t);
}
return new_binfo;
}
/* Hashing of lists so that we don't make duplicates.
The entry point is `list_hash_canon'. */
/* Now here is the hash table. When recording a list, it is added
to the slot whose index is the hash code mod the table size.
Note that the hash table is used for several kinds of lists.
While all these live in the same table, they are completely independent,
and the hash code is computed differently for each of these. */
static GTY ((param_is (union tree_node))) htab_t list_hash_table;
struct list_proxy
{
tree purpose;
tree value;
tree chain;
};
/* Compare ENTRY (an entry in the hash table) with DATA (a list_proxy
for a node we are thinking about adding). */
static int
list_hash_eq (const void* entry, const void* data)
{
const_tree const t = (const_tree) entry;
const struct list_proxy *const proxy = (const struct list_proxy *) data;
return (TREE_VALUE (t) == proxy->value
&& TREE_PURPOSE (t) == proxy->purpose
&& TREE_CHAIN (t) == proxy->chain);
}
/* Compute a hash code for a list (chain of TREE_LIST nodes
with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
TREE_COMMON slots), by adding the hash codes of the individual entries. */
static hashval_t
list_hash_pieces (tree purpose, tree value, tree chain)
{
hashval_t hashcode = 0;
if (chain)
hashcode += TREE_HASH (chain);
if (value)
hashcode += TREE_HASH (value);
else
hashcode += 1007;
if (purpose)
hashcode += TREE_HASH (purpose);
else
hashcode += 1009;
return hashcode;
}
/* Hash an already existing TREE_LIST. */
static hashval_t
list_hash (const void* p)
{
const_tree const t = (const_tree) p;
return list_hash_pieces (TREE_PURPOSE (t),
TREE_VALUE (t),
TREE_CHAIN (t));
}
/* Given list components PURPOSE, VALUE, AND CHAIN, return the canonical
object for an identical list if one already exists. Otherwise, build a
new one, and record it as the canonical object. */
tree
hash_tree_cons (tree purpose, tree value, tree chain)
{
int hashcode = 0;
void **slot;
struct list_proxy proxy;
/* Hash the list node. */
hashcode = list_hash_pieces (purpose, value, chain);
/* Create a proxy for the TREE_LIST we would like to create. We
don't actually create it so as to avoid creating garbage. */
proxy.purpose = purpose;
proxy.value = value;
proxy.chain = chain;
/* See if it is already in the table. */
slot = <API key> (list_hash_table, &proxy, hashcode,
INSERT);
/* If not, create a new node. */
if (!*slot)
*slot = tree_cons (purpose, value, chain);
return (tree) *slot;
}
/* Constructor for hashed lists. */
tree
hash_tree_chain (tree value, tree chain)
{
return hash_tree_cons (NULL_TREE, value, chain);
}
void
debug_binfo (tree elem)
{
HOST_WIDE_INT n;
tree virtuals;
fprintf (stderr, "type \"%s\", offset = " <API key>
"\nvtable type:\n",
TYPE_NAME_STRING (BINFO_TYPE (elem)),
TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
debug_tree (BINFO_TYPE (elem));
if (BINFO_VTABLE (elem))
fprintf (stderr, "vtable decl \"%s\"\n",
IDENTIFIER_POINTER (DECL_NAME (<API key> (elem))));
else
fprintf (stderr, "no vtable decl yet\n");
fprintf (stderr, "virtuals:\n");
virtuals = BINFO_VIRTUALS (elem);
n = 0;
while (virtuals)
{
tree fndecl = TREE_VALUE (virtuals);
fprintf (stderr, "%s [%ld =? %ld]\n",
IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)),
(long) n, (long) TREE_INT_CST_LOW (DECL_VINDEX (fndecl)));
++n;
virtuals = TREE_CHAIN (virtuals);
}
}
/* Build a representation for the qualified name SCOPE::NAME. TYPE is
the type of the result expression, if known, or NULL_TREE if the
resulting expression is type-dependent. If TEMPLATE_P is true,
NAME is known to be a template because the user explicitly used the
"template" keyword after the "::".
All SCOPE_REFs should be built by use of this function. */
tree
<API key> (tree type, tree scope, tree name, bool template_p)
{
tree t;
if (type == error_mark_node
|| scope == error_mark_node
|| name == error_mark_node)
return error_mark_node;
t = build2 (SCOPE_REF, type, scope, name);
<API key> (t) = template_p;
PTRMEM_OK_P (t) = true;
if (type)
t = <API key> (t);
return t;
}
/* Like <API key>, but also check ref-qualifier and exception
specification. */
static bool
<API key> (const_tree cand, const_tree base, int type_quals,
cp_ref_qualifier rqual, tree raises)
{
return (<API key> (cand, base, type_quals)
&& comp_except_specs (raises, <API key> (cand),
ce_exact)
&& type_memfn_rqual (cand) == rqual);
}
/* Build the FUNCTION_TYPE or METHOD_TYPE with the ref-qualifier RQUAL. */
tree
<API key> (tree type, cp_ref_qualifier rqual)
{
tree t;
if (rqual == type_memfn_rqual (type))
return type;
int type_quals = TYPE_QUALS (type);
tree raises = <API key> (type);
for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t))
if (<API key> (t, type, type_quals, rqual, raises))
return t;
t = <API key> (type);
switch (rqual)
{
case REF_QUAL_RVALUE:
<API key> (t) = 1;
<API key> (t) = 1;
break;
case REF_QUAL_LVALUE:
<API key> (t) = 0;
<API key> (t) = 1;
break;
default:
<API key> (t) = 0;
break;
}
if (<API key> (type))
/* Propagate structural equality. */
<API key> (t);
else if (TYPE_CANONICAL (type) != type)
/* Build the underlying canonical type, since it is different
from TYPE. */
TYPE_CANONICAL (t) = <API key> (TYPE_CANONICAL (type),
rqual);
else
/* T is its own canonical type. */
TYPE_CANONICAL (t) = t;
return t;
}
/* Returns nonzero if X is an expression for a (possibly overloaded)
function. If "f" is a function or function template, "f", "c->f",
"c.f", "C::f", and "f<int>" will all be considered possibly
overloaded functions. Returns 2 if the function is actually
overloaded, i.e., if it is impossible to know the type of the
function without performing overload resolution. */
int
is_overloaded_fn (tree x)
{
/* A baselink is also considered an overloaded function. */
if (TREE_CODE (x) == OFFSET_REF
|| TREE_CODE (x) == COMPONENT_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
x = BASELINK_FUNCTIONS (x);
if (TREE_CODE (x) == TEMPLATE_ID_EXPR)
x = TREE_OPERAND (x, 0);
if (<API key> (OVL_CURRENT (x))
|| (TREE_CODE (x) == OVERLOAD && OVL_CHAIN (x)))
return 2;
return (TREE_CODE (x) == FUNCTION_DECL
|| TREE_CODE (x) == OVERLOAD);
}
/* X is the CALL_EXPR_FN of a CALL_EXPR. If X represents a dependent name
(14.6.2), return the IDENTIFIER_NODE for that name. Otherwise, return
NULL_TREE. */
tree
dependent_name (tree x)
{
if (identifier_p (x))
return x;
if (TREE_CODE (x) != COMPONENT_REF
&& TREE_CODE (x) != OFFSET_REF
&& TREE_CODE (x) != BASELINK
&& is_overloaded_fn (x))
return DECL_NAME (get_first_fn (x));
return NULL_TREE;
}
/* Returns true iff X is an expression for an overloaded function
whose type cannot be known without performing overload
resolution. */
bool
<API key> (tree x)
{
return is_overloaded_fn (x) == 2;
}
tree
get_fns (tree from)
{
gcc_assert (is_overloaded_fn (from));
/* A baselink is also considered an overloaded function. */
if (TREE_CODE (from) == OFFSET_REF
|| TREE_CODE (from) == COMPONENT_REF)
from = TREE_OPERAND (from, 1);
if (BASELINK_P (from))
from = BASELINK_FUNCTIONS (from);
if (TREE_CODE (from) == TEMPLATE_ID_EXPR)
from = TREE_OPERAND (from, 0);
return from;
}
tree
get_first_fn (tree from)
{
return OVL_CURRENT (get_fns (from));
}
/* Return a new OVL node, concatenating it with the old one. */
tree
ovl_cons (tree decl, tree chain)
{
tree result = make_node (OVERLOAD);
TREE_TYPE (result) = unknown_type_node;
OVL_FUNCTION (result) = decl;
TREE_CHAIN (result) = chain;
return result;
}
/* Build a new overloaded function. If this is the first one,
just return it; otherwise, ovl_cons the _DECLs */
tree
build_overload (tree decl, tree chain)
{
if (! chain && TREE_CODE (decl) != TEMPLATE_DECL)
return decl;
return ovl_cons (decl, chain);
}
/* Return the scope where the overloaded functions OVL were found. */
tree
ovl_scope (tree ovl)
{
if (TREE_CODE (ovl) == OFFSET_REF
|| TREE_CODE (ovl) == COMPONENT_REF)
ovl = TREE_OPERAND (ovl, 1);
if (TREE_CODE (ovl) == BASELINK)
return BINFO_TYPE (BASELINK_BINFO (ovl));
if (TREE_CODE (ovl) == TEMPLATE_ID_EXPR)
ovl = TREE_OPERAND (ovl, 0);
/* Skip using-declarations. */
while (TREE_CODE (ovl) == OVERLOAD && OVL_USED (ovl) && OVL_CHAIN (ovl))
ovl = OVL_CHAIN (ovl);
return CP_DECL_CONTEXT (OVL_CURRENT (ovl));
}
/* Return TRUE if FN is a non-static member function, FALSE otherwise.
This function looks into BASELINK and OVERLOAD nodes. */
bool
<API key> (tree fn)
{
if (fn == NULL_TREE)
return false;
if (is_overloaded_fn (fn))
fn = get_first_fn (fn);
return (DECL_P (fn)
&& <API key> (fn));
}
#define PRINT_RING_SIZE 4
static const char *
<API key> (tree decl, int v, bool translate)
{
static unsigned int uid_ring[PRINT_RING_SIZE];
static char *print_ring[PRINT_RING_SIZE];
static bool trans_ring[PRINT_RING_SIZE];
static int ring_counter;
int i;
/* Only cache functions. */
if (v < 2
|| TREE_CODE (decl) != FUNCTION_DECL
|| DECL_LANG_SPECIFIC (decl) == 0)
return lang_decl_name (decl, v, translate);
/* See if this print name is lying around. */
for (i = 0; i < PRINT_RING_SIZE; i++)
if (uid_ring[i] == DECL_UID (decl) && translate == trans_ring[i])
/* yes, so return it. */
return print_ring[i];
if (++ring_counter == PRINT_RING_SIZE)
ring_counter = 0;
if (<API key> != NULL_TREE)
{
/* There may be both translated and untranslated versions of the
name cached. */
for (i = 0; i < 2; i++)
{
if (uid_ring[ring_counter] == DECL_UID (<API key>))
ring_counter += 1;
if (ring_counter == PRINT_RING_SIZE)
ring_counter = 0;
}
gcc_assert (uid_ring[ring_counter] != DECL_UID (<API key>));
}
free (print_ring[ring_counter]);
print_ring[ring_counter] = xstrdup (lang_decl_name (decl, v, translate));
uid_ring[ring_counter] = DECL_UID (decl);
trans_ring[ring_counter] = translate;
return print_ring[ring_counter];
}
const char *
cxx_printable_name (tree decl, int v)
{
return <API key> (decl, v, false);
}
const char *
<API key> (tree decl, int v)
{
return <API key> (decl, v, true);
}
/* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
listed in RAISES. */
tree
<API key> (tree type, tree raises)
{
tree v;
int type_quals;
if (comp_except_specs (raises, <API key> (type), ce_exact))
return type;
type_quals = TYPE_QUALS (type);
cp_ref_qualifier rqual = type_memfn_rqual (type);
for (v = TYPE_MAIN_VARIANT (type); v; v = TYPE_NEXT_VARIANT (v))
if (<API key> (v, type, type_quals, rqual, raises))
return v;
/* Need to build a new variant. */
v = <API key> (type);
<API key> (v) = raises;
return v;
}
/* Given a <API key> node T, create a new
<API key> bound with NEWARGS as its template
arguments. */
tree
<API key> (tree t, tree newargs)
{
tree decl = TYPE_NAME (t);
tree t2;
t2 = cxx_make_type (<API key>);
decl = build_decl (input_location,
TYPE_DECL, DECL_NAME (decl), NULL_TREE);
/* These nodes have to be created to reflect new TYPE_DECL and template
arguments. */
<API key> (t2) = copy_node (<API key> (t));
TEMPLATE_PARM_DECL (<API key> (t2)) = decl;
<API key> (t2)
= build_template_info (<API key> (t), newargs);
TREE_TYPE (decl) = t2;
TYPE_NAME (t2) = decl;
TYPE_STUB_DECL (t2) = decl;
TYPE_SIZE (t2) = 0;
<API key> (t2);
return t2;
}
/* Called from count_trees via walk_tree. */
static tree
count_trees_r (tree *tp, int *walk_subtrees, void *data)
{
++*((int *) data);
if (TYPE_P (*tp))
*walk_subtrees = 0;
return NULL_TREE;
}
/* Debugging function for measuring the rough complexity of a tree
representation. */
int
count_trees (tree t)
{
int n_trees = 0;
<API key> (&t, count_trees_r, &n_trees);
return n_trees;
}
/* Called from verify_stmt_tree via walk_tree. */
static tree
verify_stmt_tree_r (tree* tp, int * /*walk_subtrees*/, void* data)
{
tree t = *tp;
hash_table <pointer_hash <tree_node> > *statements
= static_cast <hash_table <pointer_hash <tree_node> > *> (data);
tree_node **slot;
if (!STATEMENT_CODE_P (TREE_CODE (t)))
return NULL_TREE;
/* If this statement is already present in the hash table, then
there is a circularity in the statement tree. */
gcc_assert (!statements->find (t));
slot = statements->find_slot (t, INSERT);
*slot = t;
return NULL_TREE;
}
/* Debugging function to check that the statement T has not been
corrupted. For now, this function simply checks that T contains no
circularities. */
void
verify_stmt_tree (tree t)
{
hash_table <pointer_hash <tree_node> > statements;
statements.create (37);
cp_walk_tree (&t, verify_stmt_tree_r, &statements, NULL);
statements.dispose ();
}
/* Check if the type T depends on a type with no linkage and if so, return
it. If RELAXED_P then do not consider a class type declared within
a vague-linkage function to have no linkage. */
tree
no_linkage_check (tree t, bool relaxed_p)
{
tree r;
/* There's no point in checking linkage on template functions; we
can't know their complete types. */
if (<API key>)
return NULL_TREE;
switch (TREE_CODE (t))
{
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (t))
goto ptrmem;
/* Lambda types that don't have mangling scope have no linkage. We
check <API key> for error_mark_node because
when we get here from pushtag none of the lambda information is
set up yet, so we want to assume that the lambda has linkage and
fix it up later if not. */
if (<API key> (t)
&& <API key> (t) != error_mark_node
&& <API key> (t) == NULL_TREE)
return t;
/* Fall through. */
case UNION_TYPE:
if (!CLASS_TYPE_P (t))
return NULL_TREE;
/* Fall through. */
case ENUMERAL_TYPE:
/* Only treat anonymous types as having no linkage if they're at
namespace scope. This is core issue 966. */
if (TYPE_ANONYMOUS_P (t) && <API key> (t))
return t;
for (r = CP_TYPE_CONTEXT (t); ; )
{
/* If we're a nested type of a !TREE_PUBLIC class, we might not
have linkage, or we might just be in an anonymous namespace.
If we're in a TREE_PUBLIC class, we have linkage. */
if (TYPE_P (r) && !TREE_PUBLIC (TYPE_NAME (r)))
return no_linkage_check (TYPE_CONTEXT (t), relaxed_p);
else if (TREE_CODE (r) == FUNCTION_DECL)
{
if (!relaxed_p || !vague_linkage_p (r))
return t;
else
r = CP_DECL_CONTEXT (r);
}
else
break;
}
return NULL_TREE;
case ARRAY_TYPE:
case POINTER_TYPE:
case REFERENCE_TYPE:
case VECTOR_TYPE:
return no_linkage_check (TREE_TYPE (t), relaxed_p);
case OFFSET_TYPE:
ptrmem:
r = no_linkage_check (<API key> (t),
relaxed_p);
if (r)
return r;
return no_linkage_check (<API key> (t), relaxed_p);
case METHOD_TYPE:
case FUNCTION_TYPE:
{
tree parm = TYPE_ARG_TYPES (t);
if (TREE_CODE (t) == METHOD_TYPE)
/* The 'this' pointer isn't interesting; a method has the same
linkage (or lack thereof) as its enclosing class. */
parm = TREE_CHAIN (parm);
for (;
parm && parm != void_list_node;
parm = TREE_CHAIN (parm))
{
r = no_linkage_check (TREE_VALUE (parm), relaxed_p);
if (r)
return r;
}
return no_linkage_check (TREE_TYPE (t), relaxed_p);
}
default:
return NULL_TREE;
}
}
extern int depth_reached;
void
<API key> (void)
{
<API key> ();
<API key> ();
<API key> ();
if (GATHER_STATISTICS)
fprintf (stderr, "maximum template instantiation depth reached: %d\n",
depth_reached);
}
/* Return, as an INTEGER_CST node, the number of elements for TYPE
(which is an ARRAY_TYPE). This counts only elements of the top
array. */
tree
<API key> (tree type)
{
return fold_build2_loc (input_location,
PLUS_EXPR, sizetype,
array_type_nelts (type),
size_one_node);
}
/* Return, as an INTEGER_CST node, the number of elements for TYPE
(which is an ARRAY_TYPE). This one is a recursive count of all
ARRAY_TYPEs that are clumped together. */
tree
<API key> (tree type)
{
tree sz = <API key> (type);
type = TREE_TYPE (type);
while (TREE_CODE (type) == ARRAY_TYPE)
{
tree n = <API key> (type);
sz = fold_build2_loc (input_location,
MULT_EXPR, sizetype, sz, n);
type = TREE_TYPE (type);
}
return sz;
}
/* Called from <API key> via mapcar. */
static tree
bot_manip (tree* tp, int* walk_subtrees, void* data)
{
splay_tree target_remap = ((splay_tree) data);
tree t = *tp;
if (!TYPE_P (t) && TREE_CONSTANT (t) && !TREE_SIDE_EFFECTS (t))
{
/* There can't be any TARGET_EXPRs or their slot variables below this
point. But we must make a copy, in case subsequent processing
alters any part of it. For example, during gimplification a cast
of the form (T) &X::f (where "f" is a member function) will lead
to replacing the PTRMEM_CST for &X::f with a VAR_DECL. */
*walk_subtrees = 0;
*tp = unshare_expr (t);
return NULL_TREE;
}
if (TREE_CODE (t) == TARGET_EXPR)
{
tree u;
if (TREE_CODE (TREE_OPERAND (t, 1)) == AGGR_INIT_EXPR)
{
u = build_cplus_new (TREE_TYPE (t), TREE_OPERAND (t, 1),
tf_warning_or_error);
if (<API key> (TREE_OPERAND (t, 1)))
<API key> (TREE_OPERAND (u, 1)) = true;
}
else
u = <API key> (TREE_OPERAND (t, 1), TREE_TYPE (t),
tf_warning_or_error);
<API key> (u) = <API key> (t);
<API key> (u) = <API key> (t);
<API key> (u) = <API key> (t);
/* Map the old variable to the new one. */
splay_tree_insert (target_remap,
(splay_tree_key) TREE_OPERAND (t, 0),
(splay_tree_value) TREE_OPERAND (u, 0));
TREE_OPERAND (u, 1) = <API key> (TREE_OPERAND (u, 1));
/* Replace the old expression with the new version. */
*tp = u;
/* We don't have to go below this point; the recursive call to
<API key> will have handled anything below this
point. */
*walk_subtrees = 0;
return NULL_TREE;
}
if (TREE_CODE (*tp) == SAVE_EXPR)
{
t = *tp;
splay_tree_node n = splay_tree_lookup (target_remap,
(splay_tree_key) t);
if (n)
{
*tp = (tree)n->value;
*walk_subtrees = 0;
}
else
{
copy_tree_r (tp, walk_subtrees, NULL);
splay_tree_insert (target_remap,
(splay_tree_key)t,
(splay_tree_value)*tp);
/* Make sure we don't remap an already-remapped SAVE_EXPR. */
splay_tree_insert (target_remap,
(splay_tree_key)*tp,
(splay_tree_value)*tp);
}
return NULL_TREE;
}
/* Make a copy of this node. */
t = copy_tree_r (tp, walk_subtrees, NULL);
if (TREE_CODE (*tp) == CALL_EXPR)
{
<API key> (*tp);
/* builtin_LINE and builtin_FILE get the location where the default
argument is expanded, not where the call was written. */
tree callee = get_callee_fndecl (*tp);
if (callee && DECL_BUILT_IN (callee))
switch (DECL_FUNCTION_CODE (callee))
{
case BUILT_IN_FILE:
case BUILT_IN_LINE:
SET_EXPR_LOCATION (*tp, input_location);
}
}
return t;
}
/* Replace all remapped VAR_DECLs in T with their new equivalents.
DATA is really a splay-tree mapping old variables to new
variables. */
static tree
bot_replace (tree* t, int* /*walk_subtrees*/, void* data)
{
splay_tree target_remap = ((splay_tree) data);
if (VAR_P (*t))
{
splay_tree_node n = splay_tree_lookup (target_remap,
(splay_tree_key) *t);
if (n)
*t = (tree) n->value;
}
else if (TREE_CODE (*t) == PARM_DECL
&& DECL_NAME (*t) == this_identifier)
{
/* In an NSDMI we need to replace the 'this' parameter we used for
parsing with the real one for this function. */
*t = current_class_ptr;
}
else if (TREE_CODE (*t) == CONVERT_EXPR
&& <API key> (*t))
{
/* In an NSDMI build_base_path defers building conversions to virtual
bases, and we handle it here. */
tree basetype = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (*t)));
vec<tree, va_gc> *vbases = <API key> (current_class_type);
int i; tree binfo;
<API key> (vbases, i, binfo)
if (BINFO_TYPE (binfo) == basetype)
break;
*t = build_base_path (PLUS_EXPR, TREE_OPERAND (*t, 0), binfo, true,
tf_warning_or_error);
}
return NULL_TREE;
}
/* When we parse a default argument expression, we may create
temporary variables via TARGET_EXPRs. When we actually use the
default-argument expression, we make a copy of the expression
and replace the temporaries with appropriate local versions. */
tree
<API key> (tree t)
{
static int target_remap_count;
static splay_tree target_remap;
if (!target_remap_count++)
target_remap = splay_tree_new (<API key>,
/*<API key>=*/NULL,
/*<API key>=*/NULL);
cp_walk_tree (&t, bot_manip, target_remap, NULL);
cp_walk_tree (&t, bot_replace, target_remap, NULL);
if (!--target_remap_count)
{
splay_tree_delete (target_remap);
target_remap = NULL;
}
return t;
}
/* Similar to `build_nt', but for template definitions of dependent
expressions */
tree
build_min_nt_loc (location_t loc, enum tree_code code, ...)
{
tree t;
int length;
int i;
va_list p;
gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
va_start (p, code);
t = make_node (code);
SET_EXPR_LOCATION (t, loc);
length = TREE_CODE_LENGTH (code);
for (i = 0; i < length; i++)
{
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
}
va_end (p);
return t;
}
/* Similar to `build', but for template definitions. */
tree
build_min (enum tree_code code, tree tt, ...)
{
tree t;
int length;
int i;
va_list p;
gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
va_start (p, tt);
t = make_node (code);
length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = tt;
for (i = 0; i < length; i++)
{
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
if (x && !TYPE_P (x) && TREE_SIDE_EFFECTS (x))
TREE_SIDE_EFFECTS (t) = 1;
}
va_end (p);
return t;
}
/* Similar to `build', but for template definitions of non-dependent
expressions. NON_DEP is the non-dependent expression that has been
built. */
tree
build_min_non_dep (enum tree_code code, tree non_dep, ...)
{
tree t;
int length;
int i;
va_list p;
gcc_assert (TREE_CODE_CLASS (code) != tcc_vl_exp);
va_start (p, non_dep);
if (REFERENCE_REF_P (non_dep))
non_dep = TREE_OPERAND (non_dep, 0);
t = make_node (code);
length = TREE_CODE_LENGTH (code);
TREE_TYPE (t) = TREE_TYPE (non_dep);
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
for (i = 0; i < length; i++)
{
tree x = va_arg (p, tree);
TREE_OPERAND (t, i) = x;
}
if (code == COMPOUND_EXPR && TREE_CODE (non_dep) != COMPOUND_EXPR)
/* This should not be considered a COMPOUND_EXPR, because it
resolves to an overload. */
<API key> (t) = 1;
va_end (p);
return <API key> (t);
}
/* Similar to `build_nt_call_vec', but for template definitions of
non-dependent expressions. NON_DEP is the non-dependent expression
that has been built. */
tree
<API key> (tree non_dep, tree fn, vec<tree, va_gc> *argvec)
{
tree t = build_nt_call_vec (fn, argvec);
if (REFERENCE_REF_P (non_dep))
non_dep = TREE_OPERAND (non_dep, 0);
TREE_TYPE (t) = TREE_TYPE (non_dep);
TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (non_dep);
return <API key> (t);
}
tree
get_type_decl (tree t)
{
if (TREE_CODE (t) == TYPE_DECL)
return t;
if (TYPE_P (t))
return TYPE_STUB_DECL (t);
gcc_assert (t == error_mark_node);
return t;
}
/* Returns the namespace that contains DECL, whether directly or
indirectly. */
tree
<API key> (tree decl)
{
while (1)
{
if (TREE_CODE (decl) == NAMESPACE_DECL)
return decl;
else if (TYPE_P (decl))
decl = CP_DECL_CONTEXT (TYPE_MAIN_DECL (decl));
else
decl = CP_DECL_CONTEXT (decl);
}
}
/* Returns true if decl is within an anonymous namespace, however deeply
nested, or false otherwise. */
bool
decl_anon_ns_mem_p (const_tree decl)
{
while (1)
{
if (decl == NULL_TREE || decl == error_mark_node)
return false;
if (TREE_CODE (decl) == NAMESPACE_DECL
&& DECL_NAME (decl) == NULL_TREE)
return true;
/* Classes and namespaces inside anonymous namespaces have
TREE_PUBLIC == 0, so we can shortcut the search. */
else if (TYPE_P (decl))
return (TREE_PUBLIC (TYPE_MAIN_DECL (decl)) == 0);
else if (TREE_CODE (decl) == NAMESPACE_DECL)
return (TREE_PUBLIC (decl) == 0);
else
decl = DECL_CONTEXT (decl);
}
}
/* Subroutine of cp_tree_equal: t1 and t2 are the CALL_EXPR_FNs of two
CALL_EXPRS. Return whether they are equivalent. */
static bool
called_fns_equal (tree t1, tree t2)
{
/* Core 1321: dependent names are equivalent even if the overload sets
are different. But do compare explicit template arguments. */
tree name1 = dependent_name (t1);
tree name2 = dependent_name (t2);
if (name1 || name2)
{
tree targs1 = NULL_TREE, targs2 = NULL_TREE;
if (name1 != name2)
return false;
if (TREE_CODE (t1) == TEMPLATE_ID_EXPR)
targs1 = TREE_OPERAND (t1, 1);
if (TREE_CODE (t2) == TEMPLATE_ID_EXPR)
targs2 = TREE_OPERAND (t2, 1);
return cp_tree_equal (targs1, targs2);
}
else
return cp_tree_equal (t1, t2);
}
/* Return truthvalue of whether T1 is the same tree structure as T2.
Return 1 if they are the same. Return 0 if they are different. */
bool
cp_tree_equal (tree t1, tree t2)
{
enum tree_code code1, code2;
if (t1 == t2)
return true;
if (!t1 || !t2)
return false;
for (code1 = TREE_CODE (t1);
CONVERT_EXPR_CODE_P (code1)
|| code1 == NON_LVALUE_EXPR;
code1 = TREE_CODE (t1))
t1 = TREE_OPERAND (t1, 0);
for (code2 = TREE_CODE (t2);
CONVERT_EXPR_CODE_P (code2)
|| code2 == NON_LVALUE_EXPR;
code2 = TREE_CODE (t2))
t2 = TREE_OPERAND (t2, 0);
/* They might have become equal now. */
if (t1 == t2)
return true;
if (code1 != code2)
return false;
switch (code1)
{
case INTEGER_CST:
return TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
&& TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2);
case REAL_CST:
return REAL_VALUES_EQUAL (TREE_REAL_CST (t1), TREE_REAL_CST (t2));
case STRING_CST:
return TREE_STRING_LENGTH (t1) == TREE_STRING_LENGTH (t2)
&& !memcmp (TREE_STRING_POINTER (t1), TREE_STRING_POINTER (t2),
TREE_STRING_LENGTH (t1));
case FIXED_CST:
return <API key> (TREE_FIXED_CST (t1),
TREE_FIXED_CST (t2));
case COMPLEX_CST:
return cp_tree_equal (TREE_REALPART (t1), TREE_REALPART (t2))
&& cp_tree_equal (TREE_IMAGPART (t1), TREE_IMAGPART (t2));
case VECTOR_CST:
return operand_equal_p (t1, t2, OEP_ONLY_CONST);
case CONSTRUCTOR:
/* We need to do this when determining whether or not two
non-type pointer to member function template arguments
are the same. */
if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
|| CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2))
return false;
{
tree field, value;
unsigned int i;
<API key> (CONSTRUCTOR_ELTS (t1), i, field, value)
{
constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i);
if (!cp_tree_equal (field, elt2->index)
|| !cp_tree_equal (value, elt2->value))
return false;
}
}
return true;
case TREE_LIST:
if (!cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2)))
return false;
if (!cp_tree_equal (TREE_VALUE (t1), TREE_VALUE (t2)))
return false;
return cp_tree_equal (TREE_CHAIN (t1), TREE_CHAIN (t2));
case SAVE_EXPR:
return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
case CALL_EXPR:
{
tree arg1, arg2;
<API key> iter1, iter2;
if (!called_fns_equal (CALL_EXPR_FN (t1), CALL_EXPR_FN (t2)))
return false;
for (arg1 = first_call_expr_arg (t1, &iter1),
arg2 = first_call_expr_arg (t2, &iter2);
arg1 && arg2;
arg1 = next_call_expr_arg (&iter1),
arg2 = next_call_expr_arg (&iter2))
if (!cp_tree_equal (arg1, arg2))
return false;
if (arg1 || arg2)
return false;
return true;
}
case TARGET_EXPR:
{
tree o1 = TREE_OPERAND (t1, 0);
tree o2 = TREE_OPERAND (t2, 0);
/* Special case: if either target is an unallocated VAR_DECL,
it means that it's going to be unified with whatever the
TARGET_EXPR is really supposed to initialize, so treat it
as being equivalent to anything. */
if (VAR_P (o1) && DECL_NAME (o1) == NULL_TREE
&& !DECL_RTL_SET_P (o1))
/*Nop*/;
else if (VAR_P (o2) && DECL_NAME (o2) == NULL_TREE
&& !DECL_RTL_SET_P (o2))
/*Nop*/;
else if (!cp_tree_equal (o1, o2))
return false;
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1));
}
case WITH_CLEANUP_EXPR:
if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
return false;
return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t1, 1));
case COMPONENT_REF:
if (TREE_OPERAND (t1, 1) != TREE_OPERAND (t2, 1))
return false;
return cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0));
case PARM_DECL:
/* For comparing uses of parameters in late-specified return types
with an out-of-class definition of the function, but can also come
up for expressions that involve 'this' in a member function
template. */
if (<API key>)
/* When comparing hash table entries, only an exact match is
good enough; we don't want to replace 'this' with the
version from another function. */
return false;
if (same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
{
if (DECL_ARTIFICIAL (t1) ^ DECL_ARTIFICIAL (t2))
return false;
if (DECL_ARTIFICIAL (t1)
|| (DECL_PARM_LEVEL (t1) == DECL_PARM_LEVEL (t2)
&& DECL_PARM_INDEX (t1) == DECL_PARM_INDEX (t2)))
return true;
}
return false;
case VAR_DECL:
case CONST_DECL:
case FIELD_DECL:
case FUNCTION_DECL:
case TEMPLATE_DECL:
case IDENTIFIER_NODE:
case SSA_NAME:
return false;
case BASELINK:
return (BASELINK_BINFO (t1) == BASELINK_BINFO (t2)
&& <API key> (t1) == <API key> (t2)
&& <API key> (t1) == <API key> (t2)
&& cp_tree_equal (BASELINK_FUNCTIONS (t1),
BASELINK_FUNCTIONS (t2)));
case TEMPLATE_PARM_INDEX:
return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2)
&& TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2)
&& (<API key> (t1)
== <API key> (t2))
&& same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)),
TREE_TYPE (TEMPLATE_PARM_DECL (t2))));
case TEMPLATE_ID_EXPR:
return (cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0))
&& cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)));
case TREE_VEC:
{
unsigned ix;
if (TREE_VEC_LENGTH (t1) != TREE_VEC_LENGTH (t2))
return false;
for (ix = TREE_VEC_LENGTH (t1); ix
if (!cp_tree_equal (TREE_VEC_ELT (t1, ix),
TREE_VEC_ELT (t2, ix)))
return false;
return true;
}
case SIZEOF_EXPR:
case ALIGNOF_EXPR:
{
tree o1 = TREE_OPERAND (t1, 0);
tree o2 = TREE_OPERAND (t2, 0);
if (code1 == SIZEOF_EXPR)
{
if (SIZEOF_EXPR_TYPE_P (t1))
o1 = TREE_TYPE (o1);
if (SIZEOF_EXPR_TYPE_P (t2))
o2 = TREE_TYPE (o2);
}
if (TREE_CODE (o1) != TREE_CODE (o2))
return false;
if (TYPE_P (o1))
return same_type_p (o1, o2);
else
return cp_tree_equal (o1, o2);
}
case MODOP_EXPR:
{
tree t1_op1, t2_op1;
if (!cp_tree_equal (TREE_OPERAND (t1, 0), TREE_OPERAND (t2, 0)))
return false;
t1_op1 = TREE_OPERAND (t1, 1);
t2_op1 = TREE_OPERAND (t2, 1);
if (TREE_CODE (t1_op1) != TREE_CODE (t2_op1))
return false;
return cp_tree_equal (TREE_OPERAND (t1, 2), TREE_OPERAND (t2, 2));
}
case PTRMEM_CST:
/* Two pointer-to-members are the same if they point to the same
field or function in the same class. */
if (PTRMEM_CST_MEMBER (t1) != PTRMEM_CST_MEMBER (t2))
return false;
return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2));
case OVERLOAD:
if (OVL_FUNCTION (t1) != OVL_FUNCTION (t2))
return false;
return cp_tree_equal (OVL_CHAIN (t1), OVL_CHAIN (t2));
case TRAIT_EXPR:
if (TRAIT_EXPR_KIND (t1) != TRAIT_EXPR_KIND (t2))
return false;
return same_type_p (TRAIT_EXPR_TYPE1 (t1), TRAIT_EXPR_TYPE1 (t2))
&& same_type_p (TRAIT_EXPR_TYPE2 (t1), TRAIT_EXPR_TYPE2 (t2));
case CAST_EXPR:
case STATIC_CAST_EXPR:
case <API key>:
case CONST_CAST_EXPR:
case DYNAMIC_CAST_EXPR:
case IMPLICIT_CONV_EXPR:
case NEW_EXPR:
if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)))
return false;
/* Now compare operands as usual. */
break;
case DEFERRED_NOEXCEPT:
return (cp_tree_equal (<API key> (t1),
<API key> (t2))
&& comp_template_args (<API key> (t1),
<API key> (t2)));
break;
default:
break;
}
switch (TREE_CODE_CLASS (code1))
{
case tcc_unary:
case tcc_binary:
case tcc_comparison:
case tcc_expression:
case tcc_vl_exp:
case tcc_reference:
case tcc_statement:
{
int i, n;
n = <API key> (t1);
if (TREE_CODE_CLASS (code1) == tcc_vl_exp
&& n != TREE_OPERAND_LENGTH (t2))
return false;
for (i = 0; i < n; ++i)
if (!cp_tree_equal (TREE_OPERAND (t1, i), TREE_OPERAND (t2, i)))
return false;
return true;
}
case tcc_type:
return same_type_p (t1, t2);
default:
gcc_unreachable ();
}
/* We can get here with --disable-checking. */
return false;
}
/* The type of ARG when used as an lvalue. */
tree
lvalue_type (tree arg)
{
tree type = TREE_TYPE (arg);
return type;
}
/* The type of ARG for printing error messages; denote lvalues with
reference types. */
tree
error_type (tree arg)
{
tree type = TREE_TYPE (arg);
if (TREE_CODE (type) == ARRAY_TYPE)
;
else if (TREE_CODE (type) == ERROR_MARK)
;
else if (real_lvalue_p (arg))
type = <API key> (lvalue_type (arg));
else if (MAYBE_CLASS_TYPE_P (type))
type = lvalue_type (arg);
return type;
}
/* Does FUNCTION use a variable-length argument list? */
int
varargs_function_p (const_tree function)
{
return stdarg_p (TREE_TYPE (function));
}
/* Returns 1 if decl is a member of a class. */
int
member_p (const_tree decl)
{
const_tree const ctx = DECL_CONTEXT (decl);
return (ctx && TYPE_P (ctx));
}
/* Create a placeholder for member access where we don't actually have an
object that the access is against. */
tree
build_dummy_object (tree type)
{
tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_zero_node);
return <API key> (decl, RO_NULL, tf_warning_or_error);
}
/* We've gotten a reference to a member of TYPE. Return *this if appropriate,
or a dummy object otherwise. If BINFOP is non-0, it is filled with the
binfo path from current_class_type to TYPE, or 0. */
tree
maybe_dummy_object (tree type, tree* binfop)
{
tree decl, context;
tree binfo;
tree current = <API key> ();
if (current
&& (binfo = lookup_base (current, type, ba_any, NULL,
tf_warning_or_error)))
context = current;
else
{
/* Reference from a nested class member function. */
context = type;
binfo = TYPE_BINFO (type);
}
if (binfop)
*binfop = binfo;
if (current_class_ref
/* current_class_ref might not correspond to current_class_type if
we're in <API key> or a lambda-declarator; in either
case, we want to use current_class_ref if it matches CONTEXT. */
&& (<API key>
(TREE_TYPE (current_class_ref), context)))
decl = current_class_ref;
else
decl = build_dummy_object (context);
return decl;
}
/* Returns 1 if OB is a placeholder object, or a pointer to one. */
int
is_dummy_object (const_tree ob)
{
if (INDIRECT_REF_P (ob))
ob = TREE_OPERAND (ob, 0);
return (TREE_CODE (ob) == NOP_EXPR
&& TREE_OPERAND (ob, 0) == void_zero_node);
}
/* Returns 1 iff type T is something we want to treat as a scalar type for
the purpose of deciding whether it is trivial/POD/standard-layout. */
bool
scalarish_type_p (const_tree t)
{
if (t == error_mark_node)
return 1;
return (SCALAR_TYPE_P (t)
|| TREE_CODE (t) == VECTOR_TYPE);
}
/* Returns true iff T requires non-trivial default initialization. */
bool
<API key> (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return <API key> (t);
else
return 0;
}
/* Returns true iff copying an object of type T (including via move
constructor) is non-trivial. That is, T has no non-trivial copy
constructors and no non-trivial move constructors. */
bool
<API key> (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
{
gcc_assert (COMPLETE_TYPE_P (t));
return ((TYPE_HAS_COPY_CTOR (t)
&& <API key> (t))
|| <API key> (t));
}
else
return 0;
}
/* Returns 1 iff type T is a trivially copyable type, as defined in
[basic.types] and [class]. */
bool
<API key> (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return ((!TYPE_HAS_COPY_CTOR (t)
|| !<API key> (t))
&& !<API key> (t)
&& (!<API key> (t)
|| !<API key> (t))
&& !<API key> (t)
&& <API key> (t));
else
return scalarish_type_p (t);
}
/* Returns 1 iff type T is a trivial type, as defined in [basic.types] and
[class]. */
bool
trivial_type_p (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return (<API key> (t)
&& <API key> (t));
else
return scalarish_type_p (t);
}
/* Returns 1 iff type T is a POD type, as defined in [basic.types]. */
bool
pod_type_p (const_tree t)
{
/* This CONST_CAST is okay because strip_array_types returns its
argument unmodified and we assign it to a const_tree. */
t = strip_array_types (CONST_CAST_TREE(t));
if (!CLASS_TYPE_P (t))
return scalarish_type_p (t);
else if (cxx_dialect > cxx98)
/* [class]/10: A POD struct is a class that is both a trivial class and a
standard-layout class, and has no non-static data members of type
non-POD struct, non-POD union (or array of such types).
We don't need to check individual members because if a member is
non-std-layout or non-trivial, the class will be too. */
return (std_layout_type_p (t) && trivial_type_p (t));
else
/* The C++98 definition of POD is different. */
return !<API key> (t);
}
/* Returns true iff T is POD for the purpose of layout, as defined in the
C++ ABI. */
bool
layout_pod_type_p (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return !<API key> (t);
else
return scalarish_type_p (t);
}
/* Returns true iff T is a standard-layout type, as defined in
[basic.types]. */
bool
std_layout_type_p (const_tree t)
{
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return !<API key> (t);
else
return scalarish_type_p (t);
}
/* Nonzero iff type T is a class template implicit specialization. */
bool
<API key> (const_tree t)
{
return CLASS_TYPE_P (t) && <API key> (t);
}
/* Returns 1 iff zero initialization of type T means actually storing
zeros in it. */
int
zero_init_p (const_tree t)
{
/* This CONST_CAST is okay because strip_array_types returns its
argument unmodified and we assign it to a const_tree. */
t = strip_array_types (CONST_CAST_TREE(t));
if (t == error_mark_node)
return 1;
/* NULL pointers to data members are initialized with -1. */
if (TYPE_PTRDATAMEM_P (t))
return 0;
/* Classes that contain types that can't be zero-initialized, cannot
be zero-initialized themselves. */
if (CLASS_TYPE_P (t) && <API key> (t))
return 0;
return 1;
}
/* Table of valid C++ attributes. */
const struct attribute_spec cxx_attribute_table[] =
{
/* { name, min_len, max_len, decl_req, type_req, fn_type_req, handler,
<API key> } */
{ "java_interface", 0, 0, false, false, false,
<API key>, false },
{ "com_interface", 0, 0, false, false, false,
<API key>, false },
{ "init_priority", 1, 1, true, false, false,
<API key>, false },
{ "abi_tag", 1, -1, false, false, false,
<API key>, true },
{ NULL, 0, 0, false, false, false, NULL, false }
};
/* Handle a "java_interface" attribute; arguments as in
struct attribute_spec.handler. */
static tree
<API key> (tree* node,
tree name,
tree /*args*/,
int flags,
bool* no_add_attrs)
{
if (DECL_P (*node)
|| !CLASS_TYPE_P (*node)
|| !TYPE_FOR_JAVA (*node))
{
error ("%qE attribute can only be applied to Java class definitions",
name);
*no_add_attrs = true;
return NULL_TREE;
}
if (!(flags & (int) <API key>))
*node = <API key> (*node);
TYPE_JAVA_INTERFACE (*node) = 1;
return NULL_TREE;
}
/* Handle a "com_interface" attribute; arguments as in
struct attribute_spec.handler. */
static tree
<API key> (tree* node,
tree name,
tree /*args*/,
int /*flags*/,
bool* no_add_attrs)
{
static int warned;
*no_add_attrs = true;
if (DECL_P (*node)
|| !CLASS_TYPE_P (*node)
|| *node != TYPE_MAIN_VARIANT (*node))
{
warning (OPT_Wattributes, "%qE attribute can only be applied "
"to class definitions", name);
return NULL_TREE;
}
if (!warned++)
warning (0, "%qE is obsolete; g++ vtables are now COM-compatible by default",
name);
return NULL_TREE;
}
/* Handle an "init_priority" attribute; arguments as in
struct attribute_spec.handler. */
static tree
<API key> (tree* node,
tree name,
tree args,
int /*flags*/,
bool* no_add_attrs)
{
tree initp_expr = TREE_VALUE (args);
tree decl = *node;
tree type = TREE_TYPE (decl);
int pri;
STRIP_NOPS (initp_expr);
initp_expr = default_conversion (initp_expr);
if (!initp_expr || TREE_CODE (initp_expr) != INTEGER_CST)
{
error ("requested init_priority is not an integer constant");
*no_add_attrs = true;
return NULL_TREE;
}
pri = TREE_INT_CST_LOW (initp_expr);
type = strip_array_types (type);
if (decl == NULL_TREE
|| !VAR_P (decl)
|| !TREE_STATIC (decl)
|| DECL_EXTERNAL (decl)
|| (TREE_CODE (type) != RECORD_TYPE
&& TREE_CODE (type) != UNION_TYPE)
/* Static objects in functions are initialized the
first time control passes through that
function. This is not precise enough to pin down an
init_priority value, so don't allow it. */
|| <API key>)
{
error ("can only use %qE attribute on file-scope definitions "
"of objects of class type", name);
*no_add_attrs = true;
return NULL_TREE;
}
if (pri > MAX_INIT_PRIORITY || pri <= 0)
{
error ("requested init_priority is out of range");
*no_add_attrs = true;
return NULL_TREE;
}
/* Check for init_priorities that are reserved for
language and runtime support implementations.*/
if (pri <= <API key>)
{
warning
(0, "requested init_priority is reserved for internal use");
}
if (<API key>)
{
<API key> (decl, pri);
<API key> (decl) = 1;
return NULL_TREE;
}
else
{
error ("%qE attribute is not supported on this platform", name);
*no_add_attrs = true;
return NULL_TREE;
}
}
/* DECL is being redeclared; the old declaration had the abi tags in OLD,
and the new one has the tags in NEW_. Give an error if there are tags
in NEW_ that weren't in OLD. */
bool
<API key> (const_tree decl, const_tree old, const_tree new_)
{
if (old && TREE_CODE (TREE_VALUE (old)) == TREE_LIST)
old = TREE_VALUE (old);
if (new_ && TREE_CODE (TREE_VALUE (new_)) == TREE_LIST)
new_ = TREE_VALUE (new_);
bool err = false;
for (const_tree t = new_; t; t = TREE_CHAIN (t))
{
tree str = TREE_VALUE (t);
for (const_tree in = old; in; in = TREE_CHAIN (in))
{
tree ostr = TREE_VALUE (in);
if (cp_tree_equal (str, ostr))
goto found;
}
error ("redeclaration of %qD adds abi tag %E", decl, str);
err = true;
found:;
}
if (err)
{
inform (<API key> (decl), "previous declaration here");
return false;
}
return true;
}
/* Handle an "abi_tag" attribute; arguments as in
struct attribute_spec.handler. */
static tree
<API key> (tree* node, tree name, tree args,
int flags, bool* no_add_attrs)
{
if (TYPE_P (*node))
{
if (!OVERLOAD_TYPE_P (*node))
{
error ("%qE attribute applied to non-class, non-enum type %qT",
name, *node);
goto fail;
}
else if (!(flags & (int)<API key>))
{
error ("%qE attribute applied to %qT after its definition",
name, *node);
goto fail;
}
else if (CLASS_TYPE_P (*node)
&& <API key> (*node))
{
warning (OPT_Wattributes, "ignoring %qE attribute applied to "
"template instantiation %qT", name, *node);
goto fail;
}
else if (CLASS_TYPE_P (*node)
&& <API key> (*node))
{
warning (OPT_Wattributes, "ignoring %qE attribute applied to "
"template specialization %qT", name, *node);
goto fail;
}
tree attributes = TYPE_ATTRIBUTES (*node);
tree decl = TYPE_NAME (*node);
/* Make sure all declarations have the same abi tags. */
if (<API key> (decl) != input_location)
{
if (!<API key> (decl,
lookup_attribute ("abi_tag",
attributes),
args))
goto fail;
}
}
else
{
if (TREE_CODE (*node) != FUNCTION_DECL)
{
error ("%qE attribute applied to non-function %qD", name, *node);
goto fail;
}
else if (DECL_LANGUAGE (*node) == lang_c)
{
error ("%qE attribute applied to extern \"C\" function %qD",
name, *node);
goto fail;
}
}
return NULL_TREE;
fail:
*no_add_attrs = true;
return NULL_TREE;
}
/* Return a new PTRMEM_CST of the indicated TYPE. The MEMBER is the
thing pointed to by the constant. */
tree
make_ptrmem_cst (tree type, tree member)
{
tree ptrmem_cst = make_node (PTRMEM_CST);
TREE_TYPE (ptrmem_cst) = type;
PTRMEM_CST_MEMBER (ptrmem_cst) = member;
return ptrmem_cst;
}
/* Build a variant of TYPE that has the indicated ATTRIBUTES. May
return an existing type if an appropriate type already exists. */
tree
<API key> (tree type, tree attributes)
{
tree new_type;
new_type = <API key> (type, attributes);
if (TREE_CODE (new_type) == FUNCTION_TYPE
|| TREE_CODE (new_type) == METHOD_TYPE)
{
new_type = <API key> (new_type,
<API key> (type));
new_type = <API key> (new_type,
type_memfn_rqual (type));
}
/* Making a new main variant of a class type is broken. */
gcc_assert (!CLASS_TYPE_P (type) || new_type == type);
return new_type;
}
/* Return TRUE if TYPE1 and TYPE2 are identical for type hashing purposes.
Called only after doing all language independent checks. Only
to check <API key> for FUNCTION_TYPE, the rest is already
compared in type_hash_eq. */
bool
cxx_type_hash_eq (const_tree typea, const_tree typeb)
{
gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE
|| TREE_CODE (typea) == METHOD_TYPE);
return comp_except_specs (<API key> (typea),
<API key> (typeb), ce_exact);
}
/* Apply FUNC to all language-specific sub-trees of TP in a pre-order
traversal. Called from walk_tree. */
tree
cp_walk_subtrees (tree *tp, int *walk_subtrees_p, walk_tree_fn func,
void *data, struct pointer_set_t *pset)
{
enum tree_code code = TREE_CODE (*tp);
tree result;
#define WALK_SUBTREE(NODE) \
do \
{ \
result = cp_walk_tree (&(NODE), func, data, pset); \
if (result) goto out; \
} \
while (0)
/* Not one of the easy cases. We must explicitly go through the
children. */
result = NULL_TREE;
switch (code)
{
case DEFAULT_ARG:
case <API key>:
case <API key>:
case <API key>:
case TEMPLATE_PARM_INDEX:
case TEMPLATE_TYPE_PARM:
case TYPENAME_TYPE:
case TYPEOF_TYPE:
case UNDERLYING_TYPE:
/* None of these have subtrees other than those already walked
above. */
*walk_subtrees_p = 0;
break;
case BASELINK:
WALK_SUBTREE (BASELINK_FUNCTIONS (*tp));
*walk_subtrees_p = 0;
break;
case PTRMEM_CST:
WALK_SUBTREE (TREE_TYPE (*tp));
*walk_subtrees_p = 0;
break;
case TREE_LIST:
WALK_SUBTREE (TREE_PURPOSE (*tp));
break;
case OVERLOAD:
WALK_SUBTREE (OVL_FUNCTION (*tp));
WALK_SUBTREE (OVL_CHAIN (*tp));
*walk_subtrees_p = 0;
break;
case USING_DECL:
WALK_SUBTREE (DECL_NAME (*tp));
WALK_SUBTREE (USING_DECL_SCOPE (*tp));
WALK_SUBTREE (USING_DECL_DECLS (*tp));
*walk_subtrees_p = 0;
break;
case RECORD_TYPE:
if (TYPE_PTRMEMFUNC_P (*tp))
WALK_SUBTREE (<API key> (*tp));
break;
case TYPE_ARGUMENT_PACK:
case <API key>:
{
tree args = ARGUMENT_PACK_ARGS (*tp);
int i, len = TREE_VEC_LENGTH (args);
for (i = 0; i < len; i++)
WALK_SUBTREE (TREE_VEC_ELT (args, i));
}
break;
case TYPE_PACK_EXPANSION:
WALK_SUBTREE (TREE_TYPE (*tp));
WALK_SUBTREE (<API key> (*tp));
*walk_subtrees_p = 0;
break;
case EXPR_PACK_EXPANSION:
WALK_SUBTREE (TREE_OPERAND (*tp, 0));
WALK_SUBTREE (<API key> (*tp));
*walk_subtrees_p = 0;
break;
case CAST_EXPR:
case <API key>:
case STATIC_CAST_EXPR:
case CONST_CAST_EXPR:
case DYNAMIC_CAST_EXPR:
case IMPLICIT_CONV_EXPR:
if (TREE_TYPE (*tp))
WALK_SUBTREE (TREE_TYPE (*tp));
{
int i;
for (i = 0; i < TREE_CODE_LENGTH (TREE_CODE (*tp)); ++i)
WALK_SUBTREE (TREE_OPERAND (*tp, i));
}
*walk_subtrees_p = 0;
break;
case TRAIT_EXPR:
WALK_SUBTREE (TRAIT_EXPR_TYPE1 (*tp));
WALK_SUBTREE (TRAIT_EXPR_TYPE2 (*tp));
*walk_subtrees_p = 0;
break;
case DECLTYPE_TYPE:
WALK_SUBTREE (DECLTYPE_TYPE_EXPR (*tp));
*walk_subtrees_p = 0;
break;
default:
return NULL_TREE;
}
/* We didn't find what we were looking for. */
out:
return result;
#undef WALK_SUBTREE
}
/* Like save_expr, but for C++. */
tree
cp_save_expr (tree expr)
{
/* There is no reason to create a SAVE_EXPR within a template; if
needed, we can create the SAVE_EXPR when instantiating the
template. Furthermore, the middle-end cannot handle C++-specific
tree codes. */
if (<API key>)
return expr;
return save_expr (expr);
}
/* Initialize tree.c. */
void
init_tree (void)
{
list_hash_table = htab_create_ggc (31, list_hash, list_hash_eq, NULL);
}
/* Returns the kind of special function that DECL (a FUNCTION_DECL)
is. Note that sfk_none is zero, so this function can be used as a
predicate to test whether or not DECL is a special function. */
<API key>
special_function_p (const_tree decl)
{
/* Rather than doing all this stuff with magic names, we should
probably have a field of type `<API key>' in
DECL_LANG_SPECIFIC. */
if (<API key> (decl))
return <API key>;
if (<API key> (decl))
return <API key>;
if (<API key> (decl))
return <API key>;
if (DECL_CONSTRUCTOR_P (decl))
return sfk_constructor;
if (<API key> (decl) == NOP_EXPR)
{
if (copy_fn_p (decl))
return sfk_copy_assignment;
if (move_fn_p (decl))
return sfk_move_assignment;
}
if (<API key> (decl))
return sfk_destructor;
if (<API key> (decl))
return <API key>;
if (<API key> (decl))
return sfk_base_destructor;
if (<API key> (decl))
return <API key>;
if (DECL_CONV_FN_P (decl))
return sfk_conversion;
return sfk_none;
}
/* Returns nonzero if TYPE is a character type, including wchar_t. */
int
char_type_p (tree type)
{
return (same_type_p (type, char_type_node)
|| same_type_p (type, <API key>)
|| same_type_p (type, <API key>)
|| same_type_p (type, char16_type_node)
|| same_type_p (type, char32_type_node)
|| same_type_p (type, wchar_type_node));
}
/* Returns the kind of linkage associated with the indicated DECL. Th
value returned is as specified by the language standard; it is
independent of implementation details regarding template
instantiation, etc. For example, it is possible that a declaration
to which this function assigns external linkage would not show up
as a global symbol when you run `nm' on the resulting object file. */
linkage_kind
decl_linkage (tree decl)
{
/* This function doesn't attempt to calculate the linkage from first
principles as given in [basic.link]. Instead, it makes use of
the fact that we have already set TREE_PUBLIC appropriately, and
then handles a few special cases. Ideally, we would calculate
linkage first, and then transform that into a concrete
implementation. */
/* Things that don't have names have no linkage. */
if (!DECL_NAME (decl))
return lk_none;
/* Fields have no linkage. */
if (TREE_CODE (decl) == FIELD_DECL)
return lk_none;
/* Things that are TREE_PUBLIC have external linkage. */
if (TREE_PUBLIC (decl))
return lk_external;
if (TREE_CODE (decl) == NAMESPACE_DECL)
return lk_external;
/* Linkage of a CONST_DECL depends on the linkage of the enumeration
type. */
if (TREE_CODE (decl) == CONST_DECL)
return decl_linkage (TYPE_NAME (DECL_CONTEXT (decl)));
/* Some things that are not TREE_PUBLIC have external linkage, too.
For example, on targets that don't have weak symbols, we make all
template instantiations have internal linkage (in the object
file), but the symbols should still be treated as having external
linkage from the point of view of the language. */
if (<API key> (decl)
&& DECL_COMDAT (decl))
return lk_external;
/* Things in local scope do not have linkage, if they don't have
TREE_PUBLIC set. */
if (<API key> (decl))
return lk_none;
/* Members of the anonymous namespace also have TREE_PUBLIC unset, but
are considered to have external linkage for language purposes. DECLs
really meant to have internal linkage have DECL_THIS_STATIC set. */
if (TREE_CODE (decl) == TYPE_DECL)
return lk_external;
if (<API key> (decl))
{
if (!DECL_THIS_STATIC (decl))
return lk_external;
/* Static data members and static member functions from classes
in anonymous namespace also don't have TREE_PUBLIC set. */
if (DECL_CLASS_CONTEXT (decl))
return lk_external;
}
/* Everything else has internal linkage. */
return lk_internal;
}
/* Returns the storage duration of the object or reference associated with
the indicated DECL, which should be a VAR_DECL or PARM_DECL. */
duration_kind
<API key> (tree decl)
{
if (TREE_CODE (decl) == PARM_DECL)
return dk_auto;
if (TREE_CODE (decl) == FUNCTION_DECL)
return dk_static;
gcc_assert (VAR_P (decl));
if (!TREE_STATIC (decl)
&& !DECL_EXTERNAL (decl))
return dk_auto;
if (DECL_THREAD_LOCAL_P (decl))
return dk_thread;
return dk_static;
}
/* EXP is an expression that we want to pre-evaluate. Returns (in
*INITP) an expression that will perform the pre-evaluation. The
value returned by this function is a side-effect free expression
equivalent to the pre-evaluated expression. Callers must ensure
that *INITP is evaluated before EXP. */
tree
stabilize_expr (tree exp, tree* initp)
{
tree init_expr;
if (!TREE_SIDE_EFFECTS (exp))
init_expr = NULL_TREE;
else if (VOID_TYPE_P (TREE_TYPE (exp)))
{
init_expr = exp;
exp = void_zero_node;
}
/* There are no expressions with REFERENCE_TYPE, but there can be call
arguments with such a type; just treat it as a pointer. */
else if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE
|| SCALAR_TYPE_P (TREE_TYPE (exp))
|| !<API key> (exp))
{
init_expr = get_target_expr (exp);
exp = TARGET_EXPR_SLOT (init_expr);
if (CLASS_TYPE_P (TREE_TYPE (exp)))
exp = move (exp);
else
exp = rvalue (exp);
}
else
{
bool xval = !real_lvalue_p (exp);
exp = cp_build_addr_expr (exp, tf_warning_or_error);
init_expr = get_target_expr (exp);
exp = TARGET_EXPR_SLOT (init_expr);
exp = <API key> (exp, RO_NULL, tf_warning_or_error);
if (xval)
exp = move (exp);
}
*initp = init_expr;
gcc_assert (!TREE_SIDE_EFFECTS (exp));
return exp;
}
/* Add NEW_EXPR, an expression whose value we don't care about, after the
similar expression ORIG. */
tree
<API key> (tree orig, tree new_expr)
{
if (!new_expr || !TREE_SIDE_EFFECTS (new_expr))
return orig;
if (!orig || !TREE_SIDE_EFFECTS (orig))
return new_expr;
return build2 (COMPOUND_EXPR, void_type_node, orig, new_expr);
}
/* Like stabilize_expr, but for a call whose arguments we want to
pre-evaluate. CALL is modified in place to use the pre-evaluated
arguments, while, upon return, *INITP contains an expression to
compute the arguments. */
void
stabilize_call (tree call, tree *initp)
{
tree inits = NULL_TREE;
int i;
int nargs = call_expr_nargs (call);
if (call == error_mark_node || <API key>)
{
*initp = NULL_TREE;
return;
}
gcc_assert (TREE_CODE (call) == CALL_EXPR);
for (i = 0; i < nargs; i++)
{
tree init;
CALL_EXPR_ARG (call, i) =
stabilize_expr (CALL_EXPR_ARG (call, i), &init);
inits = <API key> (inits, init);
}
*initp = inits;
}
/* Like stabilize_expr, but for an AGGR_INIT_EXPR whose arguments we want
to pre-evaluate. CALL is modified in place to use the pre-evaluated
arguments, while, upon return, *INITP contains an expression to
compute the arguments. */
static void
stabilize_aggr_init (tree call, tree *initp)
{
tree inits = NULL_TREE;
int i;
int nargs = <API key> (call);
if (call == error_mark_node)
return;
gcc_assert (TREE_CODE (call) == AGGR_INIT_EXPR);
for (i = 0; i < nargs; i++)
{
tree init;
AGGR_INIT_EXPR_ARG (call, i) =
stabilize_expr (AGGR_INIT_EXPR_ARG (call, i), &init);
inits = <API key> (inits, init);
}
*initp = inits;
}
/* Like stabilize_expr, but for an initialization.
If the initialization is for an object of class type, this function
takes care not to introduce additional temporaries.
Returns TRUE iff the expression was successfully pre-evaluated,
i.e., if INIT is now side-effect free, except for, possibly, a
single call to a constructor. */
bool
stabilize_init (tree init, tree *initp)
{
tree t = init;
*initp = NULL_TREE;
if (t == error_mark_node || <API key>)
return true;
if (TREE_CODE (t) == INIT_EXPR)
t = TREE_OPERAND (t, 1);
if (TREE_CODE (t) == TARGET_EXPR)
t = TARGET_EXPR_INITIAL (t);
/* If the RHS can be stabilized without breaking copy elision, stabilize
it. We specifically don't stabilize class prvalues here because that
would mean an extra copy, but they might be stabilized below. */
if (TREE_CODE (init) == INIT_EXPR
&& TREE_CODE (t) != CONSTRUCTOR
&& TREE_CODE (t) != AGGR_INIT_EXPR
&& (SCALAR_TYPE_P (TREE_TYPE (t))
|| <API key> (t)))
{
TREE_OPERAND (init, 1) = stabilize_expr (t, initp);
return true;
}
if (TREE_CODE (t) == COMPOUND_EXPR
&& TREE_CODE (init) == INIT_EXPR)
{
tree last = expr_last (t);
/* Handle stabilizing the EMPTY_CLASS_EXPR pattern. */
if (!TREE_SIDE_EFFECTS (last))
{
*initp = t;
TREE_OPERAND (init, 1) = last;
return true;
}
}
if (TREE_CODE (t) == CONSTRUCTOR)
{
/* Aggregate initialization: stabilize each of the field
initializers. */
unsigned i;
constructor_elt *ce;
bool good = true;
vec<constructor_elt, va_gc> *v = CONSTRUCTOR_ELTS (t);
for (i = 0; vec_safe_iterate (v, i, &ce); ++i)
{
tree type = TREE_TYPE (ce->value);
tree subinit;
if (TREE_CODE (type) == REFERENCE_TYPE
|| SCALAR_TYPE_P (type))
ce->value = stabilize_expr (ce->value, &subinit);
else if (!stabilize_init (ce->value, &subinit))
good = false;
*initp = <API key> (*initp, subinit);
}
return good;
}
if (TREE_CODE (t) == CALL_EXPR)
{
stabilize_call (t, initp);
return true;
}
if (TREE_CODE (t) == AGGR_INIT_EXPR)
{
stabilize_aggr_init (t, initp);
return true;
}
/* The initialization is being performed via a bitwise copy -- and
the item copied may have side effects. */
return !TREE_SIDE_EFFECTS (init);
}
/* Like "fold", but should be used whenever we might be processing the
body of a template. */
tree
<API key> (tree expr)
{
/* In the body of a template, there is never any need to call
"fold". We will call fold later when actually instantiating the
template. Integral constant expressions in templates will be
evaluated via <API key>, as necessary. */
if (<API key>)
return expr;
/* Fold C++ front-end specific tree codes. */
if (TREE_CODE (expr) == UNARY_PLUS_EXPR)
return fold_convert (TREE_TYPE (expr), TREE_OPERAND (expr, 0));
return fold (expr);
}
/* Returns true if a cast to TYPE may appear in an integral constant
expression. */
bool
<API key> (tree type)
{
return (<API key> (type)
|| cxx_dialect >= cxx11
|| dependent_type_p (type)
|| type == error_mark_node);
}
/* Return true if we need to fix linkage information of DECL. */
static bool
<API key> (tree decl)
{
/* Skip if DECL is not externally visible. */
if (!TREE_PUBLIC (decl))
return false;
/* We need to fix DECL if it a appears to be exported but with no
function body. Thunks do not have CFGs and we may need to
handle them specially later. */
if (!gimple_has_body_p (decl)
&& !DECL_THUNK_P (decl)
&& !DECL_EXTERNAL (decl))
{
struct cgraph_node *node = cgraph_get_node (decl);
/* Don't fix same_body aliases. Although they don't have their own
CFG, they share it with what they alias to. */
if (!node || !node->alias
|| !vec_safe_length (node->ref_list.references))
return true;
}
return false;
}
/* Clean the C++ specific parts of the tree T. */
void
cp_free_lang_data (tree t)
{
if (TREE_CODE (t) == METHOD_TYPE
|| TREE_CODE (t) == FUNCTION_TYPE)
{
/* Default args are not interesting anymore. */
tree argtypes = TYPE_ARG_TYPES (t);
while (argtypes)
{
TREE_PURPOSE (argtypes) = 0;
argtypes = TREE_CHAIN (argtypes);
}
}
else if (TREE_CODE (t) == FUNCTION_DECL
&& <API key> (t))
{
/* If T is used in this translation unit at all, the definition
must exist somewhere else since we have decided to not emit it
in this TU. So make it an external reference. */
DECL_EXTERNAL (t) = 1;
TREE_STATIC (t) = 0;
}
if (TREE_CODE (t) == NAMESPACE_DECL)
{
/* The list of users of a namespace isn't useful for the middle-end
or debug generators. */
<API key> (t) = NULL_TREE;
/* Neither do we need the leftover chaining of namespaces
from the binding level. */
DECL_CHAIN (t) = NULL_TREE;
}
}
/* Stub for c-common. Please keep in sync with c-decl.c.
FIXME: If address space support is target specific, then this
should be a C target hook. But currently this is not possible,
because this function is called via <API key>. */
void
<API key> (const char * /*word*/, addr_space_t /*as*/)
{
}
/* Return the number of operands in T that we care about for things like
mangling. */
int
<API key> (const_tree t)
{
enum tree_code code = TREE_CODE (t);
switch (code)
{
case PREINCREMENT_EXPR:
case PREDECREMENT_EXPR:
case POSTINCREMENT_EXPR:
case POSTDECREMENT_EXPR:
return 1;
case ARRAY_REF:
return 2;
case EXPR_PACK_EXPANSION:
return 1;
default:
return TREE_OPERAND_LENGTH (t);
}
}
/* Implement -<API key>. Return true if the
conditions for the warning hold, false otherwise. */
bool
<API key> (tree expr, location_t loc)
{
if (<API key> == 0
&& !NULLPTR_TYPE_P (TREE_TYPE (expr)))
{
warning_at (loc, <API key>,
"zero as null pointer constant");
return true;
}
return false;
}
#if defined <API key> && (GCC_VERSION >= 2007)
/* Complain that some language-specific thing hanging off a tree
node has been accessed improperly. */
void
lang_check_failed (const char* file, int line, const char* function)
{
internal_error ("lang_* check: failed in %s, at %s:%d",
function, trim_filename (file), line);
}
#endif /* <API key> */
#include "gt-cp-tree.h"
|
ALTER TABLE db_version CHANGE COLUMN <API key> <API key> bit;
DELETE FROM `<API key>` WHERE `spell` IN (20154, 20271, 21084);
DELETE FROM `npc_trainer` WHERE `spell` IN (20154, 20271, 21084);
|
#ifndef __HTTPC_H__
#define __HTTPC_H__
#include <rtthread.h>
#include <lwip/sockets.h>
#include <lwip/netdb.h>
struct http_session
{
char* user_agent;
int socket;
/* size of http file */
rt_size_t size;
rt_off_t position;
};
struct http_session* http_session_open(const char* url);
rt_size_t http_session_read(struct http_session* session, rt_uint8_t *buffer, rt_size_t length);
rt_off_t http_session_seek(struct http_session* session, rt_off_t offset, int mode);
int http_session_close(struct http_session* session);
int <API key>(struct sockaddr_in *server, const char * url, char *host_addr, char** request);
int <API key>(char *mime_buf);
int http_read_line( int socket, char * buffer, int size );
#endif
|
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/pm.h>
#include <linux/pcieport_if.h>
#include "portdrv.h"
extern int pcie_mch_quirk; /* MSI-quirk Indicator */
static int <API key>(struct device *dev)
{
struct pcie_device *pciedev;
struct <API key> *driver;
int status = -ENODEV;
if (!dev || !dev->driver)
return status;
driver = to_service_driver(dev->driver);
if (!driver || !driver->probe)
return status;
pciedev = to_pcie_device(dev);
status = driver->probe(pciedev, driver->id_table);
if (!status) {
printk(KERN_DEBUG "Load service driver %s on pcie device %s\n",
driver->name, dev->bus_id);
get_device(dev);
}
return status;
}
static int <API key>(struct device *dev)
{
struct pcie_device *pciedev;
struct <API key> *driver;
if (!dev || !dev->driver)
return 0;
pciedev = to_pcie_device(dev);
driver = to_service_driver(dev->driver);
if (driver && driver->remove) {
printk(KERN_DEBUG "Unload service driver %s on pcie device %s\n",
driver->name, dev->bus_id);
driver->remove(pciedev);
put_device(dev);
}
return 0;
}
static void <API key>(struct device *dev) {}
static int <API key>(struct device *dev, pm_message_t state, u32 level)
{
struct pcie_device *pciedev;
struct <API key> *driver;
if (!dev || !dev->driver)
return 0;
pciedev = to_pcie_device(dev);
driver = to_service_driver(dev->driver);
if (driver && driver->suspend)
driver->suspend(pciedev, state);
return 0;
}
static int <API key>(struct device *dev, u32 level)
{
struct pcie_device *pciedev;
struct <API key> *driver;
if (!dev || !dev->driver)
return 0;
pciedev = to_pcie_device(dev);
driver = to_service_driver(dev->driver);
if (driver && driver->resume)
driver->resume(pciedev);
return 0;
}
/*
* release_pcie_device
*
* Being invoked automatically when device is being removed
* in response to device_unregister(dev) call.
* Release all resources being claimed.
*/
static void release_pcie_device(struct device *dev)
{
printk(KERN_DEBUG "Free Port Service[%s]\n", dev->bus_id);
kfree(to_pcie_device(dev));
}
static int is_msi_quirked(struct pci_dev *dev)
{
int port_type, quirk = 0;
u16 reg16;
<API key>(dev,
pci_find_capability(dev, PCI_CAP_ID_EXP) +
<API key>, ®16);
port_type = (reg16 >> 4) & PORT_TYPE_MASK;
switch(port_type) {
case PCIE_RC_PORT:
if (pcie_mch_quirk == 1)
quirk = 1;
break;
case <API key>:
case <API key>:
default:
break;
}
return quirk;
}
static int <API key>(struct pci_dev *dev, int *vectors, int mask)
{
int i, pos, nvec, status = -EINVAL;
int interrupt_mode = PCIE_PORT_INTx_MODE;
/* Set INTx as default */
for (i = 0, nvec = 0; i < <API key>; i++) {
if (mask & (1 << i))
nvec++;
vectors[i] = dev->irq;
}
/* Check MSI quirk */
if (is_msi_quirked(dev))
return interrupt_mode;
/* Select MSI-X over MSI if supported */
pos = pci_find_capability(dev, PCI_CAP_ID_MSIX);
if (pos) {
struct msix_entry msix_entries[<API key>] =
{{0, 0}, {0, 1}, {0, 2}, {0, 3}};
printk("%s Found MSIX capability\n", __FUNCTION__);
status = pci_enable_msix(dev, msix_entries, nvec);
if (!status) {
int j = 0;
interrupt_mode = PCIE_PORT_MSIX_MODE;
for (i = 0; i < <API key>; i++) {
if (mask & (1 << i))
vectors[i] = msix_entries[j++].vector;
}
}
}
if (status) {
pos = pci_find_capability(dev, PCI_CAP_ID_MSI);
if (pos) {
printk("%s Found MSI capability\n", __FUNCTION__);
status = pci_enable_msi(dev);
if (!status) {
interrupt_mode = PCIE_PORT_MSI_MODE;
for (i = 0;i < <API key>;i++)
vectors[i] = dev->irq;
}
}
}
return interrupt_mode;
}
static int <API key>(struct pci_dev *dev)
{
int services = 0, pos;
u16 reg16;
u32 reg32;
pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
<API key>(dev, pos + <API key>, ®16);
/* Hot-Plug Capable */
if (reg16 & PORT_TO_SLOT_MASK) {
<API key>(dev,
pos + <API key>, ®32);
if (reg32 & <API key>)
services |= <API key>;
}
/* PME Capable */
pos = pci_find_capability(dev, PCI_CAP_ID_PME);
if (pos)
services |= <API key>;
pos = PCI_CFG_SPACE_SIZE;
while (pos) {
<API key>(dev, pos, ®32);
switch (reg32 & 0xffff) {
case PCI_EXT_CAP_ID_ERR:
services |= <API key>;
pos = reg32 >> 20;
break;
case PCI_EXT_CAP_ID_VC:
services |= <API key>;
pos = reg32 >> 20;
break;
default:
pos = 0;
break;
}
}
return services;
}
static void pcie_device_init(struct pci_dev *parent, struct pcie_device *dev,
int port_type, int service_type, int irq, int irq_mode)
{
struct device *device;
dev->port = parent;
dev->interrupt_mode = irq_mode;
dev->irq = irq;
dev->id.vendor = parent->vendor;
dev->id.device = parent->device;
dev->id.port_type = port_type;
dev->id.service_type = (1 << service_type);
/* Initialize generic device interface */
device = &dev->device;
memset(device, 0, sizeof(struct device));
INIT_LIST_HEAD(&device->node);
INIT_LIST_HEAD(&device->children);
INIT_LIST_HEAD(&device->bus_list);
device->bus = &pcie_port_bus_type;
device->driver = NULL;
device->driver_data = NULL;
device->release = release_pcie_device; /* callback to free pcie dev */
sprintf(&device->bus_id[0], "pcie%02x",
get_descriptor_id(port_type, service_type));
device->parent = &parent->dev;
}
static struct pcie_device* alloc_pcie_device(struct pci_dev *parent,
int port_type, int service_type, int irq, int irq_mode)
{
struct pcie_device *device;
device = kmalloc(sizeof(struct pcie_device), GFP_KERNEL);
if (!device)
return NULL;
memset(device, 0, sizeof(struct pcie_device));
pcie_device_init(parent, device, port_type, service_type, irq,irq_mode);
printk(KERN_DEBUG "Allocate Port Service[%s]\n", device->device.bus_id);
return device;
}
int <API key>(struct pci_dev *dev)
{
int pos, type;
u16 reg;
if (!(pos = pci_find_capability(dev, PCI_CAP_ID_EXP)))
return -ENODEV;
<API key>(dev, pos + <API key>, ®);
type = (reg >> 4) & PORT_TYPE_MASK;
if ( type == PCIE_RC_PORT || type == <API key> ||
type == <API key> )
return 0;
return -ENODEV;
}
int <API key>(struct pci_dev *dev)
{
int status, type, capabilities, irq_mode, i;
int vectors[<API key>];
u16 reg16;
/* Get port type */
<API key>(dev,
pci_find_capability(dev, PCI_CAP_ID_EXP) +
<API key>, ®16);
type = (reg16 >> 4) & PORT_TYPE_MASK;
/* Now get port services */
capabilities = <API key>(dev);
irq_mode = <API key>(dev, vectors, capabilities);
/* Allocate child services if any */
for (i = 0; i < <API key>; i++) {
struct pcie_device *child;
if (capabilities & (1 << i)) {
child = alloc_pcie_device(
dev, /* parent */
type, /* port type */
i, /* service type */
vectors[i], /* irq */
irq_mode /* interrupt mode */);
if (child) {
status = device_register(&child->device);
if (status) {
kfree(child);
continue;
}
get_device(&child->device);
}
}
}
return 0;
}
#ifdef CONFIG_PM
int <API key>(struct pci_dev *dev, pm_message_t state)
{
struct list_head *head, *tmp;
struct device *parent, *child;
struct device_driver *driver;
struct <API key> *service_driver;
parent = &dev->dev;
head = &parent->children;
tmp = head->next;
while (head != tmp) {
child = container_of(tmp, struct device, node);
tmp = tmp->next;
if (child->bus != &pcie_port_bus_type)
continue;
driver = child->driver;
if (!driver)
continue;
service_driver = to_service_driver(driver);
if (service_driver->suspend)
service_driver->suspend(to_pcie_device(child), state);
}
return 0;
}
int <API key>(struct pci_dev *dev)
{
struct list_head *head, *tmp;
struct device *parent, *child;
struct device_driver *driver;
struct <API key> *service_driver;
parent = &dev->dev;
head = &parent->children;
tmp = head->next;
while (head != tmp) {
child = container_of(tmp, struct device, node);
tmp = tmp->next;
if (child->bus != &pcie_port_bus_type)
continue;
driver = child->driver;
if (!driver)
continue;
service_driver = to_service_driver(driver);
if (service_driver->resume)
service_driver->resume(to_pcie_device(child));
}
return 0;
}
#endif
void <API key>(struct pci_dev *dev)
{
struct list_head *head, *tmp;
struct device *parent, *child;
struct device_driver *driver;
struct <API key> *service_driver;
int interrupt_mode = PCIE_PORT_INTx_MODE;
parent = &dev->dev;
head = &parent->children;
tmp = head->next;
while (head != tmp) {
child = container_of(tmp, struct device, node);
tmp = tmp->next;
if (child->bus != &pcie_port_bus_type)
continue;
driver = child->driver;
if (driver) {
service_driver = to_service_driver(driver);
if (service_driver->remove)
service_driver->remove(to_pcie_device(child));
}
interrupt_mode = (to_pcie_device(child))->interrupt_mode;
put_device(child);
device_unregister(child);
}
/* Switch to INTx by default if MSI enabled */
if (interrupt_mode == PCIE_PORT_MSIX_MODE)
pci_disable_msix(dev);
else if (interrupt_mode == PCIE_PORT_MSI_MODE)
pci_disable_msi(dev);
}
void <API key>(void)
{
bus_register(&pcie_port_bus_type);
}
void <API key>(void)
{
bus_unregister(&pcie_port_bus_type);
}
int <API key>(struct <API key> *new)
{
new->driver.name = (char *)new->name;
new->driver.bus = &pcie_port_bus_type;
new->driver.probe = <API key>;
new->driver.remove = <API key>;
new->driver.shutdown = <API key>;
new->driver.suspend = <API key>;
new->driver.resume = <API key>;
return driver_register(&new->driver);
}
void <API key>(struct <API key> *new)
{
driver_unregister(&new->driver);
}
EXPORT_SYMBOL(<API key>);
EXPORT_SYMBOL(<API key>);
|
.<API key> .block,
.<API key> .block {
overflow:hidden;
}
.<API key> .block:before,
.<API key> .block:before {
content:"";
position:absolute;
top:0;
right:0;
border-width:0 16px 16px 0;
border-style:solid;
-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
-moz-box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
box-shadow:0 1px 1px rgba(0,0,0,0.3), -1px 1px 1px rgba(0,0,0,0.2);
display:block; width:0; /* Firefox 3.0 damage limitation */
}
|
#include "sysconfig.h"
#include "sysdeps.h"
#include "include/uae.h"
#include "include/options.h"
#include "gensound.h"
#include "audio.h"
#include "uae/fs.h"
int have_sound = 0;
static float <API key>;
static int obtainedfreq;
static float <API key> = 1.0;
/* Originally from sampler.cpp (not used in FS-UAE) */
float sampler_evtime;
static int (*g_audio_callback)(int type, int16_t *buffer, int size) = NULL;
static int g_audio_buffer_size = 512 * 2 * 2;
struct sound_data
{
#if 0
int waiting_for_buffer;
int deactive;
int devicetype;
#endif
int obtainedfreq;
#if 0
int paused;
int mute;
int channels;
int freq;
int samplesize;
int sndbufsize;
int sndbufframes;
int softvolume;
struct sound_dp *data;
#endif
};
static struct sound_data sdpaula;
static struct sound_data *sdp = &sdpaula;
static uae_u8 *extrasndbuf;
static int extrasndbufsize;
static int extrasndbuffered;
int <API key>(audio_callback func)
{
g_audio_callback = func;
return 1;
}
int <API key>(int size)
{
g_audio_buffer_size = size;
return 1;
}
int <API key>(int frequency)
{
if (frequency == 0) {
/* Some code divides by frequency, so 0 is not a good idea */
write_log("WARNING: <API key> 0, set to 44100\n");
frequency = 44100;
}
char freq[13];
snprintf(freq, 13, "%d", frequency);
amiga_set_option("sound_frequency", freq);
write_log("<API key>: %d\n", frequency);
sdp->obtainedfreq = frequency;
//changed_prefs.sound_freq = frequency;
//write_log("changed_prefs: %p\n", &changed_prefs);
//config_changed = 1;
return 1;
}
void update_sound (double clk)
{
if (!have_sound)
return;
<API key> = clk * CYCLE_UNIT * <API key> / sdp->obtainedfreq;
<API key> = <API key>;
sampler_evtime = clk * CYCLE_UNIT * <API key>;
}
#if 0
void update_sound (double freq, int longframe, int linetoggle) {
static int lastfreq;
double lines = 0;
double hpos;
if (freq < 0)
freq = lastfreq;
lastfreq = freq;
if (!have_sound)
return;
if (linetoggle) {
hpos = maxhpos_short + 0.5;
lines += 0.5;
} else {
if (longframe < 0)
lines += 0.5;
else if (longframe > 0)
lines += 1.0;
hpos = maxhpos_short;
}
lines += maxvpos_nom;
<API key> = hpos * lines * freq * CYCLE_UNIT / (double) obtainedfreq;
#ifdef SAMPLER
sampler_evtime = hpos * lines * freq * CYCLE_UNIT;
#endif
}
#endif
#include "audio.h"
#include "uae/memory.h"
#include "events.h"
#include "custom.h"
#include "gui.h"
#include "gensound.h"
#include "driveclick.h"
#include "sounddep/sound.h"
#include "threaddep/thread.h"
//#include <SDL_audio.h>
uae_u16 paula_sndbuffer[44100];
uae_u16 *paula_sndbufpt;
int paula_sndbufsize;
static void clearbuffer (void)
{
memset (paula_sndbuffer, 0, sizeof (paula_sndbuffer));
}
static void channelswap (uae_s16 *sndbuffer, int len)
{
int i;
for (i = 0; i < len; i += 2) {
uae_s16 t;
t = sndbuffer[i];
sndbuffer[i] = sndbuffer[i + 1];
sndbuffer[i + 1] = t;
}
}
static void channelswap6 (uae_s16 *sndbuffer, int len)
{
int i;
for (i = 0; i < len; i += 6) {
uae_s16 t;
t = sndbuffer[i + 0];
sndbuffer[i + 0] = sndbuffer[i + 1];
sndbuffer[i + 1] = t;
t = sndbuffer[i + 4];
sndbuffer[i + 4] = sndbuffer[i + 5];
sndbuffer[i + 5] = t;
}
}
static void send_sound (struct sound_data *sd, uae_u16 *sndbuffer)
{
#if 0
if (savestate_state)
return;
if (sd->paused)
return;
if (sd->softvolume >= 0) {
uae_s16 *p = (uae_s16*)sndbuffer;
for (int i = 0; i < sd->sndbufsize / 2; i++) {
p[i] = p[i] * sd->softvolume / 32768;
}
}
#endif
if (g_audio_callback) {
g_audio_callback(0, (int16_t *) paula_sndbuffer, paula_sndbufsize);
}
}
void finish_sound_buffer (void)
{
static unsigned long tframe;
int bufsize = (uae_u8*)paula_sndbufpt - (uae_u8*)paula_sndbuffer;
if (currprefs.turbo_emulation) {
paula_sndbufpt = paula_sndbuffer;
return;
}
if (currprefs.<API key>) {
if (<API key> (currprefs.sound_stereo) == 2 || <API key> (currprefs.sound_stereo) == 4)
channelswap((uae_s16*)paula_sndbuffer, bufsize / 2);
else if (<API key> (currprefs.sound_stereo) == 6)
channelswap6((uae_s16*)paula_sndbuffer, bufsize / 2);
}
#ifdef DRIVESOUND
driveclick_mix ((uae_s16*)paula_sndbuffer, paula_sndbufsize / 2, currprefs.dfxclickchannelmask);
#endif
// must be after driveclick_mix
paula_sndbufpt = paula_sndbuffer;
#ifdef AVIOUTPUT
if (avioutput_enabled && avioutput_audio) {
<API key>((uae_u8*)paula_sndbuffer, bufsize);
if (<API key>)
sound_setadjust(0);
}
if (avioutput_enabled && (!<API key> || <API key>))
return;
#endif
if (!have_sound)
return;
#if 0
// we got buffer that was not full (recording active). Need special handling.
if (bufsize < sdp->sndbufsize && !extrasndbuf) {
extrasndbufsize = sdp->sndbufsize;
extrasndbuf = xcalloc(uae_u8, sdp->sndbufsize);
extrasndbuffered = 0;
}
#endif
static int statuscnt;
if (statuscnt > 0 && tframe != timeframes) {
tframe = timeframes;
statuscnt
if (statuscnt == 0)
gui_data.sndbuf_status = 0;
}
if (gui_data.sndbuf_status == 3)
gui_data.sndbuf_status = 0;
if (extrasndbuf) {
int size = extrasndbuffered + bufsize;
int copied = 0;
if (size > extrasndbufsize) {
copied = extrasndbufsize - extrasndbuffered;
memcpy(extrasndbuf + extrasndbuffered, paula_sndbuffer, copied);
send_sound(sdp, (uae_u16*)extrasndbuf);
extrasndbuffered = 0;
}
memcpy(extrasndbuf + extrasndbuffered, (uae_u8*)paula_sndbuffer + copied, bufsize - copied);
extrasndbuffered += bufsize - copied;
} else {
send_sound(sdp, paula_sndbuffer);
}
}
/* Try to determine whether sound is available. */
int setup_sound (void)
{
sound_available = 1;
return 1;
}
static int open_sound (void)
{
if (!currprefs.produce_sound) {
return 0;
}
config_changed = 1;
clearbuffer();
currprefs.sound_stereo = 1;
//currprefs.sound_freq = <API key>();
//changed_prefs.sound_freq = sdp->obtainedfreq;
//init_sound_table16 ();
sample_handler = currprefs.sound_stereo ? sample16s_handler : sample16_handler;
//obtainedfreq = currprefs.sound_freq;
obtainedfreq = sdp->obtainedfreq;
have_sound = 1;
sound_available = 1;
paula_sndbufsize = g_audio_buffer_size;
paula_sndbufpt = paula_sndbuffer;
#ifdef DRIVESOUND
driveclick_init();
#endif
write_log("open_sound returning 1\n");
return 1;
}
void close_sound (void)
{
config_changed = 1;
gui_data.sndbuf = 0;
gui_data.sndbuf_status = 3;
if (!have_sound)
return;
// SDL_PauseAudio (1);
clearbuffer();
have_sound = 0;
}
int init_sound (void)
{
write_log("init_sound\n");
gui_data.sndbuf_status = 3;
gui_data.sndbuf = 0;
if (!sound_available)
return 0;
if (currprefs.produce_sound <= 1)
return 0;
if (have_sound)
return 1;
if (!open_sound ())
return 0;
//sdp->paused = 1;
#ifdef DRIVESOUND
driveclick_reset ();
#endif
//reset_sound ();
//resume_sound ();
return 1;
}
void pause_sound (void)
{
write_log("STUB: pause_sound\n");
if (!have_sound)
return;
#if 0
SDL_PauseAudio (1);
#endif
}
void resume_sound (void)
{
write_log("STUB: resume_sound\n");
if (!have_sound)
return;
clearbuffer();
#if 0
SDL_PauseAudio (0);
#endif
}
void reset_sound (void)
{
clearbuffer();
return;
}
void sound_volume (int dir)
{
}
void pause_sound_buffer (void)
{
if (g_audio_callback) {
g_audio_callback(1, NULL, 0);
}
}
void <API key>(void)
{
if (g_audio_callback) {
g_audio_callback(2, NULL, 0);
}
}
void master_sound_volume (int dir)
{
STUB("");
#if 0
int vol, mute, r;
r = get_master_volume (&vol, &mute);
if (!r)
return;
if (dir == 0)
mute = mute ? 0 : 1;
vol += dir * (65536 / 10);
if (vol < 0)
vol = 0;
if (vol > 65535)
vol = 65535;
aset_master_volume (vol, mute);
config_changed = 1;
#endif
}
void sound_mute(int newmute)
{
write_log("STUB: sound_mute\n");
}
|
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/ioport.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/interrupt.h>
#include <linux/dma-mapping.h>
#include <linux/dmaengine.h>
#include <linux/highmem.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/completion.h>
#include <linux/mmc/host.h>
#include <linux/mmc/mmc.h>
#include <linux/mmc/sdio.h>
#include <linux/gpio.h>
#include <linux/regulator/consumer.h>
#include <linux/module.h>
#include <mach/mxs.h>
#include <mach/common.h>
#include <mach/dma.h>
#include <mach/mmc.h>
#define DRIVER_NAME "mxs-mmc"
/* card detect polling timeout */
#define <API key> (HZ/2)
#define SSP_VERSION_LATEST 4
#define ssp_is_old() (host->version < SSP_VERSION_LATEST)
/* SSP registers */
#define HW_SSP_CTRL0 0x000
#define BM_SSP_CTRL0_RUN (1 << 29)
#define <API key> (1 << 28)
#define <API key> (1 << 26)
#define BM_SSP_CTRL0_READ (1 << 25)
#define <API key> (1 << 24)
#define <API key> (22)
#define <API key> (0x3 << 22)
#define <API key> (1 << 21)
#define <API key> (1 << 19)
#define <API key> (1 << 17)
#define BM_SSP_CTRL0_ENABLE (1 << 16)
#define <API key> (0)
#define <API key> (0xffff)
#define HW_SSP_CMD0 0x010
#define <API key> (1 << 25)
#define <API key> (1 << 22)
#define <API key> (1 << 21)
#define <API key> (1 << 20)
#define <API key> (16)
#define <API key> (0xf << 16)
#define <API key> (8)
#define <API key> (0xff << 8)
#define BP_SSP_CMD0_CMD (0)
#define BM_SSP_CMD0_CMD (0xff)
#define HW_SSP_CMD1 0x020
#define HW_SSP_XFER_SIZE 0x030
#define HW_SSP_BLOCK_SIZE 0x040
#define <API key> (4)
#define <API key> (0xffffff << 4)
#define <API key> (0)
#define <API key> (0xf)
#define HW_SSP_TIMING (ssp_is_old() ? 0x050 : 0x070)
#define <API key> (16)
#define <API key> (0xffff << 16)
#define <API key> (8)
#define <API key> (0xff << 8)
#define <API key> (0)
#define <API key> (0xff)
#define HW_SSP_CTRL1 (ssp_is_old() ? 0x060 : 0x080)
#define <API key> (1 << 31)
#define <API key> (1 << 30)
#define <API key> (1 << 29)
#define <API key> (1 << 28)
#define <API key> (1 << 27)
#define <API key> (1 << 26)
#define <API key> (1 << 25)
#define <API key> (1 << 24)
#define <API key> (1 << 23)
#define <API key> (1 << 22)
#define <API key> (1 << 21)
#define <API key> (1 << 20)
#define <API key> (1 << 17)
#define <API key> (1 << 16)
#define <API key> (1 << 15)
#define <API key> (1 << 14)
#define <API key> (1 << 13)
#define <API key> (1 << 9)
#define <API key> (4)
#define <API key> (0xf << 4)
#define <API key> (0)
#define <API key> (0xf)
#define HW_SSP_SDRESP0 (ssp_is_old() ? 0x080 : 0x0a0)
#define HW_SSP_SDRESP1 (ssp_is_old() ? 0x090 : 0x0b0)
#define HW_SSP_SDRESP2 (ssp_is_old() ? 0x0a0 : 0x0c0)
#define HW_SSP_SDRESP3 (ssp_is_old() ? 0x0b0 : 0x0d0)
#define HW_SSP_STATUS (ssp_is_old() ? 0x0c0 : 0x100)
#define <API key> (1 << 28)
#define <API key> (1 << 17)
#define HW_SSP_VERSION (cpu_is_mx23() ? 0x110 : 0x130)
#define <API key> (24)
#define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field)
#define MXS_MMC_IRQ_BITS (<API key> | \
<API key> | \
<API key> | \
<API key> | \
<API key> | \
<API key> | \
<API key> | \
<API key>)
#define SSP_PIO_NUM 3
struct mxs_mmc_host {
struct mmc_host *mmc;
struct mmc_request *mrq;
struct mmc_command *cmd;
struct mmc_data *data;
void __iomem *base;
int irq;
struct resource *res;
struct resource *dma_res;
struct clk *clk;
unsigned int clk_rate;
struct dma_chan *dmach;
struct mxs_dma_data dma_data;
unsigned int dma_dir;
u32 ssp_pio_words[SSP_PIO_NUM];
unsigned int version;
unsigned char bus_width;
spinlock_t lock;
int sdio_irq_en;
};
static int mxs_mmc_get_ro(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
struct <API key> *pdata =
mmc_dev(host->mmc)->platform_data;
if (!pdata)
return -EFAULT;
if (!gpio_is_valid(pdata->wp_gpio))
return -EINVAL;
return gpio_get_value(pdata->wp_gpio);
}
static int mxs_mmc_get_cd(struct mmc_host *mmc)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
return !(readl(host->base + HW_SSP_STATUS) &
<API key>);
}
static void mxs_mmc_reset(struct mxs_mmc_host *host)
{
u32 ctrl0, ctrl1;
mxs_reset_block(host->base);
ctrl0 = <API key>;
ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
BF_SSP(0x7, CTRL1_WORD_LENGTH) |
<API key> |
<API key> |
<API key> |
<API key> |
<API key> |
<API key> |
<API key>;
writel(BF_SSP(0xffff, TIMING_TIMEOUT) |
BF_SSP(2, TIMING_CLOCK_DIVIDE) |
BF_SSP(0, TIMING_CLOCK_RATE),
host->base + HW_SSP_TIMING);
if (host->sdio_irq_en) {
ctrl0 |= <API key>;
ctrl1 |= <API key>;
}
writel(ctrl0, host->base + HW_SSP_CTRL0);
writel(ctrl1, host->base + HW_SSP_CTRL1);
}
static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
struct mmc_command *cmd);
static void <API key>(struct mxs_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
struct mmc_request *mrq = host->mrq;
if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
if (mmc_resp_type(cmd) & MMC_RSP_136) {
cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0);
cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1);
cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2);
cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3);
} else {
cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0);
}
}
if (data) {
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, host->dma_dir);
/*
* If there was an error on any block, we mark all
* data blocks as being in error.
*/
if (!data->error)
data->bytes_xfered = data->blocks * data->blksz;
else
data->bytes_xfered = 0;
host->data = NULL;
if (mrq->stop) {
mxs_mmc_start_cmd(host, mrq->stop);
return;
}
}
host->mrq = NULL;
mmc_request_done(host->mmc, mrq);
}
static void <API key>(void *param)
{
struct mxs_mmc_host *host = param;
<API key>(host);
}
static irqreturn_t mxs_mmc_irq_handler(int irq, void *dev_id)
{
struct mxs_mmc_host *host = dev_id;
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
u32 stat;
spin_lock(&host->lock);
stat = readl(host->base + HW_SSP_CTRL1);
writel(stat & MXS_MMC_IRQ_BITS,
host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
if ((stat & <API key>) && (stat & <API key>))
mmc_signal_sdio_irq(host->mmc);
spin_unlock(&host->lock);
if (stat & <API key>)
cmd->error = -ETIMEDOUT;
else if (stat & <API key>)
cmd->error = -EIO;
if (data) {
if (stat & (<API key> |
<API key>))
data->error = -ETIMEDOUT;
else if (stat & <API key>)
data->error = -EILSEQ;
else if (stat & (<API key> |
<API key>))
data->error = -EIO;
}
return IRQ_HANDLED;
}
static struct <API key> *mxs_mmc_prep_dma(
struct mxs_mmc_host *host, unsigned int append)
{
struct <API key> *desc;
struct mmc_data *data = host->data;
struct scatterlist * sgl;
unsigned int sg_len;
if (data) {
/* data */
dma_map_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, host->dma_dir);
sgl = data->sg;
sg_len = data->sg_len;
} else {
/* pio */
sgl = (struct scatterlist *) host->ssp_pio_words;
sg_len = SSP_PIO_NUM;
}
desc = host->dmach->device-><API key>(host->dmach,
sgl, sg_len, host->dma_dir, append);
if (desc) {
desc->callback = <API key>;
desc->callback_param = host;
} else {
if (data)
dma_unmap_sg(mmc_dev(host->mmc), data->sg,
data->sg_len, host->dma_dir);
}
return desc;
}
static void mxs_mmc_bc(struct mxs_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct <API key> *desc;
u32 ctrl0, cmd0, cmd1;
ctrl0 = BM_SSP_CTRL0_ENABLE | <API key>;
cmd0 = BF_SSP(cmd->opcode, CMD0_CMD) | <API key>;
cmd1 = cmd->arg;
if (host->sdio_irq_en) {
ctrl0 |= <API key>;
cmd0 |= <API key> | <API key>;
}
host->ssp_pio_words[0] = ctrl0;
host->ssp_pio_words[1] = cmd0;
host->ssp_pio_words[2] = cmd1;
host->dma_dir = DMA_NONE;
desc = mxs_mmc_prep_dma(host, 0);
if (!desc)
goto out;
dmaengine_submit(desc);
return;
out:
dev_warn(mmc_dev(host->mmc),
"%s: failed to prep dma\n", __func__);
}
static void mxs_mmc_ac(struct mxs_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct <API key> *desc;
u32 ignore_crc, get_resp, long_resp;
u32 ctrl0, cmd0, cmd1;
ignore_crc = (mmc_resp_type(cmd) & MMC_RSP_CRC) ?
0 : <API key>;
get_resp = (mmc_resp_type(cmd) & MMC_RSP_PRESENT) ?
<API key> : 0;
long_resp = (mmc_resp_type(cmd) & MMC_RSP_136) ?
<API key> : 0;
ctrl0 = BM_SSP_CTRL0_ENABLE | ignore_crc | get_resp | long_resp;
cmd0 = BF_SSP(cmd->opcode, CMD0_CMD);
cmd1 = cmd->arg;
if (host->sdio_irq_en) {
ctrl0 |= <API key>;
cmd0 |= <API key> | <API key>;
}
host->ssp_pio_words[0] = ctrl0;
host->ssp_pio_words[1] = cmd0;
host->ssp_pio_words[2] = cmd1;
host->dma_dir = DMA_NONE;
desc = mxs_mmc_prep_dma(host, 0);
if (!desc)
goto out;
dmaengine_submit(desc);
return;
out:
dev_warn(mmc_dev(host->mmc),
"%s: failed to prep dma\n", __func__);
}
static unsigned short mxs_ns_to_ssp_ticks(unsigned clock_rate, unsigned ns)
{
const unsigned int ssp_timeout_mul = 4096;
/*
* Calculate ticks in ms since ns are large numbers
* and might overflow
*/
const unsigned int clock_per_ms = clock_rate / 1000;
const unsigned int ms = ns / 1000;
const unsigned int ticks = ms * clock_per_ms;
const unsigned int ssp_ticks = ticks / ssp_timeout_mul;
WARN_ON(ssp_ticks == 0);
return ssp_ticks;
}
static void mxs_mmc_adtc(struct mxs_mmc_host *host)
{
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = cmd->data;
struct <API key> *desc;
struct scatterlist *sgl = data->sg, *sg;
unsigned int sg_len = data->sg_len;
int i;
unsigned short dma_data_dir, timeout;
unsigned int data_size = 0, log2_blksz;
unsigned int blocks = data->blocks;
u32 ignore_crc, get_resp, long_resp, read;
u32 ctrl0, cmd0, cmd1, val;
ignore_crc = (mmc_resp_type(cmd) & MMC_RSP_CRC) ?
0 : <API key>;
get_resp = (mmc_resp_type(cmd) & MMC_RSP_PRESENT) ?
<API key> : 0;
long_resp = (mmc_resp_type(cmd) & MMC_RSP_136) ?
<API key> : 0;
if (data->flags & MMC_DATA_WRITE) {
dma_data_dir = DMA_TO_DEVICE;
read = 0;
} else {
dma_data_dir = DMA_FROM_DEVICE;
read = BM_SSP_CTRL0_READ;
}
ctrl0 = BF_SSP(host->bus_width, CTRL0_BUS_WIDTH) |
ignore_crc | get_resp | long_resp |
<API key> | read |
<API key> |
BM_SSP_CTRL0_ENABLE;
cmd0 = BF_SSP(cmd->opcode, CMD0_CMD);
/* get logarithm to base 2 of block size for setting register */
log2_blksz = ilog2(data->blksz);
/*
* take special care of the case that data size from data->sg
* is not equal to blocks x blksz
*/
for_each_sg(sgl, sg, sg_len, i)
data_size += sg->length;
if (data_size != data->blocks * data->blksz)
blocks = 1;
/* xfer count, block size and count need to be set differently */
if (ssp_is_old()) {
ctrl0 |= BF_SSP(data_size, CTRL0_XFER_COUNT);
cmd0 |= BF_SSP(log2_blksz, CMD0_BLOCK_SIZE) |
BF_SSP(blocks - 1, CMD0_BLOCK_COUNT);
} else {
writel(data_size, host->base + HW_SSP_XFER_SIZE);
writel(BF_SSP(log2_blksz, <API key>) |
BF_SSP(blocks - 1, <API key>),
host->base + HW_SSP_BLOCK_SIZE);
}
if ((cmd->opcode == <API key>) ||
(cmd->opcode == SD_IO_RW_EXTENDED))
cmd0 |= <API key>;
cmd1 = cmd->arg;
if (host->sdio_irq_en) {
ctrl0 |= <API key>;
cmd0 |= <API key> | <API key>;
}
/* set the timeout count */
timeout = mxs_ns_to_ssp_ticks(host->clk_rate, data->timeout_ns);
val = readl(host->base + HW_SSP_TIMING);
val &= ~(<API key>);
val |= BF_SSP(timeout, TIMING_TIMEOUT);
writel(val, host->base + HW_SSP_TIMING);
/* pio */
host->ssp_pio_words[0] = ctrl0;
host->ssp_pio_words[1] = cmd0;
host->ssp_pio_words[2] = cmd1;
host->dma_dir = DMA_NONE;
desc = mxs_mmc_prep_dma(host, 0);
if (!desc)
goto out;
/* append data sg */
WARN_ON(host->data != NULL);
host->data = data;
host->dma_dir = dma_data_dir;
desc = mxs_mmc_prep_dma(host, 1);
if (!desc)
goto out;
dmaengine_submit(desc);
return;
out:
dev_warn(mmc_dev(host->mmc),
"%s: failed to prep dma\n", __func__);
}
static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
struct mmc_command *cmd)
{
host->cmd = cmd;
switch (mmc_cmd_type(cmd)) {
case MMC_CMD_BC:
mxs_mmc_bc(host);
break;
case MMC_CMD_BCR:
mxs_mmc_ac(host);
break;
case MMC_CMD_AC:
mxs_mmc_ac(host);
break;
case MMC_CMD_ADTC:
mxs_mmc_adtc(host);
break;
default:
dev_warn(mmc_dev(host->mmc),
"%s: unknown MMC command\n", __func__);
break;
}
}
static void mxs_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
WARN_ON(host->mrq != NULL);
host->mrq = mrq;
mxs_mmc_start_cmd(host, mrq->cmd);
}
static void <API key>(struct mxs_mmc_host *host, unsigned int rate)
{
unsigned int ssp_clk, ssp_sck;
u32 clock_divide, clock_rate;
u32 val;
ssp_clk = clk_get_rate(host->clk);
for (clock_divide = 2; clock_divide <= 254; clock_divide += 2) {
clock_rate = DIV_ROUND_UP(ssp_clk, rate * clock_divide);
clock_rate = (clock_rate > 0) ? clock_rate - 1 : 0;
if (clock_rate <= 255)
break;
}
if (clock_divide > 254) {
dev_err(mmc_dev(host->mmc),
"%s: cannot set clock to %d\n", __func__, rate);
return;
}
ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
val = readl(host->base + HW_SSP_TIMING);
val &= ~(<API key> | <API key>);
val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
writel(val, host->base + HW_SSP_TIMING);
host->clk_rate = ssp_sck;
dev_dbg(mmc_dev(host->mmc),
"%s: clock_divide %d, clock_rate %d, ssp_clk %d, rate_actual %d, rate_requested %d\n",
__func__, clock_divide, clock_rate, ssp_clk, ssp_sck, rate);
}
static void mxs_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
if (ios->bus_width == MMC_BUS_WIDTH_8)
host->bus_width = 2;
else if (ios->bus_width == MMC_BUS_WIDTH_4)
host->bus_width = 1;
else
host->bus_width = 0;
if (ios->clock)
<API key>(host, ios->clock);
}
static void <API key>(struct mmc_host *mmc, int enable)
{
struct mxs_mmc_host *host = mmc_priv(mmc);
unsigned long flags;
spin_lock_irqsave(&host->lock, flags);
host->sdio_irq_en = enable;
if (enable) {
writel(<API key>,
host->base + HW_SSP_CTRL0 + MXS_SET_ADDR);
writel(<API key>,
host->base + HW_SSP_CTRL1 + MXS_SET_ADDR);
if (readl(host->base + HW_SSP_STATUS) & <API key>)
mmc_signal_sdio_irq(host->mmc);
} else {
writel(<API key>,
host->base + HW_SSP_CTRL0 + MXS_CLR_ADDR);
writel(<API key>,
host->base + HW_SSP_CTRL1 + MXS_CLR_ADDR);
}
<API key>(&host->lock, flags);
}
static const struct mmc_host_ops mxs_mmc_ops = {
.request = mxs_mmc_request,
.get_ro = mxs_mmc_get_ro,
.get_cd = mxs_mmc_get_cd,
.set_ios = mxs_mmc_set_ios,
.enable_sdio_irq = <API key>,
};
static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
{
struct mxs_mmc_host *host = param;
if (!mxs_dma_is_apbh(chan))
return false;
if (chan->chan_id != host->dma_res->start)
return false;
chan->private = &host->dma_data;
return true;
}
static int mxs_mmc_probe(struct platform_device *pdev)
{
struct mxs_mmc_host *host;
struct mmc_host *mmc;
struct resource *iores, *dmares, *r;
struct <API key> *pdata;
int ret = 0, irq_err, irq_dma;
dma_cap_mask_t mask;
iores = <API key>(pdev, IORESOURCE_MEM, 0);
dmares = <API key>(pdev, IORESOURCE_DMA, 0);
irq_err = platform_get_irq(pdev, 0);
irq_dma = platform_get_irq(pdev, 1);
if (!iores || !dmares || irq_err < 0 || irq_dma < 0)
return -EINVAL;
r = request_mem_region(iores->start, resource_size(iores), pdev->name);
if (!r)
return -EBUSY;
mmc = mmc_alloc_host(sizeof(struct mxs_mmc_host), &pdev->dev);
if (!mmc) {
ret = -ENOMEM;
goto out_release_mem;
}
host = mmc_priv(mmc);
host->base = ioremap(r->start, resource_size(r));
if (!host->base) {
ret = -ENOMEM;
goto out_mmc_free;
}
/* only major verion does matter */
host->version = readl(host->base + HW_SSP_VERSION) >>
<API key>;
host->mmc = mmc;
host->res = r;
host->dma_res = dmares;
host->irq = irq_err;
host->sdio_irq_en = 0;
host->clk = clk_get(&pdev->dev, NULL);
if (IS_ERR(host->clk)) {
ret = PTR_ERR(host->clk);
goto out_iounmap;
}
clk_prepare_enable(host->clk);
mxs_mmc_reset(host);
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
host->dma_data.chan_irq = irq_dma;
host->dmach = dma_request_channel(mask, mxs_mmc_dma_filter, host);
if (!host->dmach) {
dev_err(mmc_dev(host->mmc),
"%s: failed to request dma\n", __func__);
goto out_clk_put;
}
/* set mmc core parameters */
mmc->ops = &mxs_mmc_ops;
mmc->caps = <API key> | <API key> |
MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL;
pdata = mmc_dev(host->mmc)->platform_data;
if (pdata) {
if (pdata->flags & SLOTF_8_BIT_CAPABLE)
mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA;
if (pdata->flags & SLOTF_4_BIT_CAPABLE)
mmc->caps |= MMC_CAP_4_BIT_DATA;
}
mmc->f_min = 400000;
mmc->f_max = 288000000;
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
mmc->max_segs = 52;
mmc->max_blk_size = 1 << 0xf;
mmc->max_blk_count = (ssp_is_old()) ? 0xff : 0xffffff;
mmc->max_req_size = (ssp_is_old()) ? 0xffff : 0xffffffff;
mmc->max_seg_size = <API key>(host->dmach->device->dev);
<API key>(pdev, mmc);
ret = request_irq(host->irq, mxs_mmc_irq_handler, 0, DRIVER_NAME, host);
if (ret)
goto out_free_dma;
spin_lock_init(&host->lock);
ret = mmc_add_host(mmc);
if (ret)
goto out_free_irq;
dev_info(mmc_dev(host->mmc), "initialized\n");
return 0;
out_free_irq:
free_irq(host->irq, host);
out_free_dma:
if (host->dmach)
dma_release_channel(host->dmach);
out_clk_put:
<API key>(host->clk);
clk_put(host->clk);
out_iounmap:
iounmap(host->base);
out_mmc_free:
mmc_free_host(mmc);
out_release_mem:
release_mem_region(iores->start, resource_size(iores));
return ret;
}
static int mxs_mmc_remove(struct platform_device *pdev)
{
struct mmc_host *mmc = <API key>(pdev);
struct mxs_mmc_host *host = mmc_priv(mmc);
struct resource *res = host->res;
mmc_remove_host(mmc);
free_irq(host->irq, host);
<API key>(pdev, NULL);
if (host->dmach)
dma_release_channel(host->dmach);
<API key>(host->clk);
clk_put(host->clk);
iounmap(host->base);
mmc_free_host(mmc);
release_mem_region(res->start, resource_size(res));
return 0;
}
#ifdef CONFIG_PM
static int mxs_mmc_suspend(struct device *dev)
{
struct mmc_host *mmc = dev_get_drvdata(dev);
struct mxs_mmc_host *host = mmc_priv(mmc);
int ret = 0;
ret = mmc_suspend_host(mmc);
<API key>(host->clk);
return ret;
}
static int mxs_mmc_resume(struct device *dev)
{
struct mmc_host *mmc = dev_get_drvdata(dev);
struct mxs_mmc_host *host = mmc_priv(mmc);
int ret = 0;
clk_prepare_enable(host->clk);
ret = mmc_resume_host(mmc);
return ret;
}
static const struct dev_pm_ops mxs_mmc_pm_ops = {
.suspend = mxs_mmc_suspend,
.resume = mxs_mmc_resume,
};
#endif
static struct platform_driver mxs_mmc_driver = {
.probe = mxs_mmc_probe,
.remove = mxs_mmc_remove,
.driver = {
.name = DRIVER_NAME,
.owner = THIS_MODULE,
#ifdef CONFIG_PM
.pm = &mxs_mmc_pm_ops,
#endif
},
};
static int __init mxs_mmc_init(void)
{
return <API key>(&mxs_mmc_driver);
}
static void __exit mxs_mmc_exit(void)
{
<API key>(&mxs_mmc_driver);
}
module_init(mxs_mmc_init);
module_exit(mxs_mmc_exit);
MODULE_DESCRIPTION("FREESCALE MXS MMC peripheral");
MODULE_AUTHOR("Freescale Semiconductor");
MODULE_LICENSE("GPL");
|
"""\
minidom.py -- a lightweight DOM implementation based on SAX.
parse( "foo.xml" )
parseString( "<foo><bar/></foo>" )
Todo:
==
* convenience methods for getting elements and text.
* more testing
* bring some of the writer and linearizer code into conformance with this
interface
* SAX 2 namespaces
"""
import pulldom
import string
from StringIO import StringIO
import types
class Node:
ELEMENT_NODE = 1
ATTRIBUTE_NODE = 2
TEXT_NODE = 3
CDATA_SECTION_NODE = 4
<API key> = 5
ENTITY_NODE = 6
<API key> = 7
COMMENT_NODE = 8
DOCUMENT_NODE = 9
DOCUMENT_TYPE_NODE = 10
<API key> = 11
NOTATION_NODE = 12
allnodes = {}
_debug = 0
_makeParentNodes = 1
debug = None
def __init__(self):
self.childNodes = []
if Node._debug:
index = repr(id(self)) + repr(self.__class__)
Node.allnodes[index] = repr(self.__dict__)
if Node.debug is None:
Node.debug = StringIO()
#open( "debug4.out", "w" )
Node.debug.write("create %s\n" % index)
def __getattr__(self, key):
if key[0:2] == "__":
raise AttributeError
# getattr should never call getattr!
if self.__dict__.has_key("inGetAttr"):
del self.inGetAttr
raise AttributeError, key
prefix, attrname = key[:5], key[5:]
if prefix == "_get_":
self.inGetAttr = 1
if hasattr(self, attrname):
del self.inGetAttr
return (lambda self=self, attrname=attrname:
getattr(self, attrname))
else:
del self.inGetAttr
raise AttributeError, key
else:
self.inGetAttr = 1
try:
func = getattr(self, "_get_" + key)
except AttributeError:
raise AttributeError, key
del self.inGetAttr
return func()
def __nonzero__(self):
return 1
def toxml(self):
writer = StringIO()
self.writexml(writer)
return writer.getvalue()
def hasChildNodes(self):
if self.childNodes:
return 1
else:
return 0
def _get_firstChild(self):
return self.childNodes[0]
def _get_lastChild(self):
return self.childNodes[-1]
def insertBefore(self, newChild, refChild):
index = self.childNodes.index(refChild)
self.childNodes.insert(index, newChild)
if self._makeParentNodes:
newChild.parentNode = self
def appendChild(self, node):
if self.childNodes:
last = self.lastChild
node.previousSibling = last
last.nextSibling = node
else:
node.previousSibling = None
node.nextSibling = None
self.childNodes.append(node)
return node
def replaceChild(self, newChild, oldChild):
index = self.childNodes.index(oldChild)
self.childNodes[index] = oldChild
def removeChild(self, oldChild):
index = self.childNodes.index(oldChild)
del self.childNodes[index]
def cloneNode(self, deep):
import new
clone = new.instance(self.__class__, self.__dict__)
clone.attributes = self.attributes.copy()
if not deep:
clone.childNodes = []
else:
clone.childNodes = map(lambda x: x.cloneNode, self.childNodes)
return clone
def unlink(self):
self.parentNode = None
while self.childNodes:
self.childNodes[-1].unlink()
del self.childNodes[-1] # probably not most efficient!
self.childNodes = None
self.previousSibling = None
self.nextSibling = None
if self.attributes:
for attr in self._attrs.values():
self.removeAttributeNode(attr)
assert not len(self._attrs)
assert not len(self._attrsNS)
if Node._debug:
index = repr(id(self)) + repr(self.__class__)
self.debug.write("Deleting: %s\n" % index)
del Node.allnodes[index]
def _write_data(writer, data):
"Writes datachars to writer."
data = string.replace(data, "&", "&")
data = string.replace(data, "<", "<")
data = string.replace(data, "\"", """)
data = string.replace(data, ">", ">")
writer.write(data)
def <API key>(parent, name, rc):
for node in parent.childNodes:
if node.nodeType == Node.ELEMENT_NODE and \
(name == "*" or node.tagName == name):
rc.append(node)
<API key>(node, name, rc)
return rc
def <API key>(parent, nsURI, localName, rc):
for node in parent.childNodes:
if node.nodeType == Node.ELEMENT_NODE:
if ((localName == "*" or node.tagName == localName) and
(nsURI == "*" or node.namespaceURI == nsURI)):
rc.append(node)
<API key>(node, name, rc)
class Attr(Node):
nodeType = Node.ATTRIBUTE_NODE
def __init__(self, qName, namespaceURI="", localName=None, prefix=None):
# skip setattr for performance
self.__dict__["localName"] = localName or qName
self.__dict__["nodeName"] = self.__dict__["name"] = qName
self.__dict__["namespaceURI"] = namespaceURI
self.__dict__["prefix"] = prefix
self.attributes = None
Node.__init__(self)
# nodeValue and value are set elsewhere
def __setattr__(self, name, value):
if name in ("value", "nodeValue"):
self.__dict__["value"] = self.__dict__["nodeValue"] = value
else:
self.__dict__[name] = value
class AttributeList:
"""the attribute list is a transient interface to the underlying
dictionaries. mutations here will change the underlying element's
dictionary"""
def __init__(self, attrs, attrsNS):
self._attrs = attrs
self._attrsNS = attrsNS
self.length = len(self._attrs.keys())
def item(self, index):
try:
return self[self.keys()[index]]
except IndexError:
return None
def items(self):
return map(lambda node: (node.tagName, node.value),
self._attrs.values())
def itemsNS(self):
return map(lambda node: ((node.URI, node.localName), node.value),
self._attrs.values())
def keys(self):
return self._attrs.keys()
def keysNS(self):
return self._attrsNS.keys()
def values(self):
return self._attrs.values()
def __len__(self):
return self.length
def __cmp__(self, other):
if self._attrs is getattr(other, "_attrs", None):
return 0
else:
return cmp(id(self), id(other))
#FIXME: is it appropriate to return .value?
def __getitem__(self, attname_or_tuple):
if type(attname_or_tuple) is types.TupleType:
return self._attrsNS[attname_or_tuple]
else:
return self._attrs[attname_or_tuple]
# same as set
def __setitem__(self, attname, value):
if type(value) is types.StringType:
node = Attr(attname)
node.value=value
else:
assert isinstance(value, Attr) or type(value) is types.StringType
node = value
old = self._attrs.get(attname, None)
if old:
old.unlink()
self._attrs[node.name] = node
self._attrsNS[(node.namespaceURI, node.localName)] = node
def __delitem__(self, attname_or_tuple):
node = self[attname_or_tuple]
node.unlink()
del self._attrs[node.name]
del self._attrsNS[(node.namespaceURI, node.localName)]
class Element(Node):
nodeType = Node.ELEMENT_NODE
def __init__(self, tagName, namespaceURI="", prefix="",
localName=None):
Node.__init__(self)
self.tagName = self.nodeName = tagName
self.localName = localName or tagName
self.prefix = prefix
self.namespaceURI = namespaceURI
self.nodeValue = None
self._attrs={} # attributes are double-indexed:
self._attrsNS={}# tagName -> Attribute
# URI,localName -> Attribute
# in the future: consider lazy generation of attribute objects
# this is too tricky for now because of headaches
# with namespaces.
def getAttribute(self, attname):
return self._attrs[attname].value
def getAttributeNS(self, namespaceURI, localName):
return self._attrsNS[(namespaceURI, localName)].value
def setAttribute(self, attname, value):
attr = Attr(attname)
# for performance
attr.__dict__["value"] = attr.__dict__["nodeValue"] = value
self.setAttributeNode(attr)
def setAttributeNS(self, namespaceURI, qualifiedName, value):
prefix, localname = _nssplit(qualifiedName)
# for performance
attr = Attr(qualifiedName, namespaceURI, localname, prefix)
attr.__dict__["value"] = attr.__dict__["nodeValue"] = value
self.setAttributeNode(attr)
# FIXME: return original node if something changed.
def getAttributeNode(self, attrname):
return self._attrs.get(attrname)
def getAttributeNodeNS(self, namespaceURI, localName):
return self._attrsNS[(namespaceURI, localName)]
def setAttributeNode(self, attr):
old = self._attrs.get(attr.name, None)
if old:
old.unlink()
self._attrs[attr.name] = attr
self._attrsNS[(attr.namespaceURI, attr.localName)] = attr
# FIXME: return old value if something changed
def removeAttribute(self, name):
attr = self._attrs[name]
self.removeAttributeNode(attr)
def removeAttributeNS(self, namespaceURI, localName):
attr = self._attrsNS[(namespaceURI, localName)]
self.removeAttributeNode(attr)
def removeAttributeNode(self, node):
node.unlink()
del self._attrs[node.name]
del self._attrsNS[(node.namespaceURI, node.localName)]
def <API key>(self, name):
return <API key>(self, name, [])
def <API key>(self, namespaceURI, localName):
<API key>(self, namespaceURI, localName, [])
def __repr__(self):
return "<DOM Element: %s at %s>" % (self.tagName, id(self))
# undocumented
def writexml(self, writer):
writer.write("<" + self.tagName)
a_names = self._get_attributes().keys()
a_names.sort()
for a_name in a_names:
writer.write(" %s=\"" % a_name)
_write_data(writer, self._get_attributes()[a_name].value)
writer.write("\"")
if self.childNodes:
writer.write(">")
for node in self.childNodes:
node.writexml(writer)
writer.write("</%s>" % self.tagName)
else:
writer.write("/>")
def _get_attributes(self):
return AttributeList(self._attrs, self._attrsNS)
class Comment(Node):
nodeType = Node.COMMENT_NODE
def __init__(self, data):
Node.__init__(self)
self.data = self.nodeValue = data
self.nodeName = "#comment"
self.attributes = None
def writexml(self, writer):
writer.write("" % self.data)
class <API key>(Node):
nodeType = Node.<API key>
def __init__(self, target, data):
Node.__init__(self)
self.target = self.nodeName = target
self.data = self.nodeValue = data
self.attributes = None
def writexml(self, writer):
writer.write("<?%s %s?>" % (self.target, self.data))
class Text(Node):
nodeType = Node.TEXT_NODE
nodeName = "#text"
def __init__(self, data):
Node.__init__(self)
self.data = self.nodeValue = data
self.attributes = None
def __repr__(self):
if len(self.data) > 10:
dotdotdot = "..."
else:
dotdotdot = ""
return "<DOM Text node \"%s%s\">" % (self.data[0:10], dotdotdot)
def writexml(self, writer):
_write_data(writer, self.data)
def _nssplit(qualifiedName):
import string
fields = string.split(qualifiedName,':', 1)
if len(fields) == 2:
return fields
elif len(fields) == 1:
return ('', fields[0])
class Document(Node):
nodeType = Node.DOCUMENT_NODE
documentElement = None
def __init__(self):
Node.__init__(self)
self.attributes = None
self.nodeName = "#document"
self.nodeValue = None
def appendChild(self, node):
if node.nodeType == Node.ELEMENT_NODE:
if self.documentElement:
raise TypeError, "Two document elements disallowed"
else:
self.documentElement = node
Node.appendChild(self, node)
return node
createElement = Element
createTextNode = Text
createComment = Comment
<API key> = <API key>
createAttribute = Attr
def createElementNS(self, namespaceURI, qualifiedName):
prefix,localName = _nssplit(qualifiedName)
return Element(qualifiedName, namespaceURI, prefix, localName)
def createAttributeNS(self, namespaceURI, qualifiedName):
prefix,localName = _nssplit(qualifiedName)
return Attr(qualifiedName, namespaceURI, localName, prefix)
def <API key>(self, namespaceURI, localName):
<API key>(self, namespaceURI, localName)
def unlink(self):
self.documentElement = None
Node.unlink(self)
def <API key>(self, name):
rc = []
<API key>(self, name, rc)
return rc
def writexml(self, writer):
for node in self.childNodes:
node.writexml(writer)
def _doparse(func, args, kwargs):
events = apply(func, args, kwargs)
toktype, rootNode = events.getEvent()
events.expandNode(rootNode)
return rootNode
def parse(*args, **kwargs):
"Parse a file into a DOM by filename or file object"
return _doparse(pulldom.parse, args, kwargs)
def parseString(*args, **kwargs):
"Parse a file into a DOM from a string"
return _doparse(pulldom.parseString, args, kwargs)
|
#include <linux/init.h>
#include <linux/types.h>
#include <linux/mm.h>
#include <linux/interrupt.h>
#include <linux/spinlock.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/clk.h>
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <asm/irq.h>
#include <mach/dma.h>
#include <mach/hardware.h>
#include "dmaengine.h"
#define <API key> 16
#define IMX_DMA_CHANNELS 16
#define IMX_DMA_2D_SLOTS 2
#define IMX_DMA_2D_SLOT_A 0
#define IMX_DMA_2D_SLOT_B 1
#define IMX_DMA_LENGTH_LOOP ((unsigned int)-1)
#define IMX_DMA_MEMSIZE_32 (0 << 4)
#define IMX_DMA_MEMSIZE_8 (1 << 4)
#define IMX_DMA_MEMSIZE_16 (2 << 4)
#define IMX_DMA_TYPE_LINEAR (0 << 10)
#define IMX_DMA_TYPE_2D (1 << 10)
#define IMX_DMA_TYPE_FIFO (2 << 10)
#define IMX_DMA_ERR_BURST (1 << 0)
#define IMX_DMA_ERR_REQUEST (1 << 1)
#define <API key> (1 << 2)
#define IMX_DMA_ERR_BUFFER (1 << 3)
#define IMX_DMA_ERR_TIMEOUT (1 << 4)
#define DMA_DCR 0x00 /* Control Register */
#define DMA_DISR 0x04 /* Interrupt status Register */
#define DMA_DIMR 0x08 /* Interrupt mask Register */
#define DMA_DBTOSR 0x0c /* Burst timeout status Register */
#define DMA_DRTOSR 0x10 /* Request timeout Register */
#define DMA_DSESR 0x14 /* Transfer Error Status Register */
#define DMA_DBOSR 0x18 /* Buffer overflow status Register */
#define DMA_DBTOCR 0x1c /* Burst timeout control Register */
#define DMA_WSRA 0x40 /* W-Size Register A */
#define DMA_XSRA 0x44 /* X-Size Register A */
#define DMA_YSRA 0x48 /* Y-Size Register A */
#define DMA_WSRB 0x4c /* W-Size Register B */
#define DMA_XSRB 0x50 /* X-Size Register B */
#define DMA_YSRB 0x54 /* Y-Size Register B */
#define DMA_SAR(x) (0x80 + ((x) << 6)) /* Source Address Registers */
#define DMA_DAR(x) (0x84 + ((x) << 6)) /* Destination Address Registers */
#define DMA_CNTR(x) (0x88 + ((x) << 6)) /* Count Registers */
#define DMA_CCR(x) (0x8c + ((x) << 6)) /* Control Registers */
#define DMA_RSSR(x) (0x90 + ((x) << 6)) /* Request source select Registers */
#define DMA_BLR(x) (0x94 + ((x) << 6)) /* Burst length Registers */
#define DMA_RTOR(x) (0x98 + ((x) << 6)) /* Request timeout Registers */
#define DMA_BUCR(x) (0x98 + ((x) << 6)) /* Bus Utilization Registers */
#define DMA_CCNR(x) (0x9C + ((x) << 6)) /* Channel counter Registers */
#define DCR_DRST (1<<1)
#define DCR_DEN (1<<0)
#define DBTOCR_EN (1<<15)
#define DBTOCR_CNT(x) ((x) & 0x7fff)
#define CNTR_CNT(x) ((x) & 0xffffff)
#define CCR_ACRPT (1<<14)
#define CCR_DMOD_LINEAR (0x0 << 12)
#define CCR_DMOD_2D (0x1 << 12)
#define CCR_DMOD_FIFO (0x2 << 12)
#define CCR_DMOD_EOBFIFO (0x3 << 12)
#define CCR_SMOD_LINEAR (0x0 << 10)
#define CCR_SMOD_2D (0x1 << 10)
#define CCR_SMOD_FIFO (0x2 << 10)
#define CCR_SMOD_EOBFIFO (0x3 << 10)
#define CCR_MDIR_DEC (1<<9)
#define CCR_MSEL_B (1<<8)
#define CCR_DSIZ_32 (0x0 << 6)
#define CCR_DSIZ_8 (0x1 << 6)
#define CCR_DSIZ_16 (0x2 << 6)
#define CCR_SSIZ_32 (0x0 << 4)
#define CCR_SSIZ_8 (0x1 << 4)
#define CCR_SSIZ_16 (0x2 << 4)
#define CCR_REN (1<<3)
#define CCR_RPT (1<<2)
#define CCR_FRC (1<<1)
#define CCR_CEN (1<<0)
#define RTOR_EN (1<<15)
#define RTOR_CLK (1<<14)
#define RTOR_PSC (1<<13)
enum imxdma_prep_type {
IMXDMA_DESC_MEMCPY,
<API key>,
<API key>,
IMXDMA_DESC_CYCLIC,
};
struct imx_dma_2d_config {
u16 xsr;
u16 ysr;
u16 wsr;
int count;
};
struct imxdma_desc {
struct list_head node;
struct <API key> desc;
enum dma_status status;
dma_addr_t src;
dma_addr_t dest;
size_t len;
enum <API key> direction;
enum imxdma_prep_type type;
/* For memcpy and interleaved */
unsigned int config_port;
unsigned int config_mem;
/* For interleaved transfers */
unsigned int x;
unsigned int y;
unsigned int w;
/* For slave sg and cyclic */
struct scatterlist *sg;
unsigned int sgcount;
};
struct imxdma_channel {
int hw_chaining;
struct timer_list watchdog;
struct imxdma_engine *imxdma;
unsigned int channel;
struct tasklet_struct dma_tasklet;
struct list_head ld_free;
struct list_head ld_queue;
struct list_head ld_active;
int descs_allocated;
enum dma_slave_buswidth word_size;
dma_addr_t per_address;
u32 watermark_level;
struct dma_chan chan;
struct <API key> desc;
enum dma_status status;
int dma_request;
struct scatterlist *sg_list;
u32 ccr_from_device;
u32 ccr_to_device;
bool enabled_2d;
int slot_2d;
};
struct imxdma_engine {
struct device *dev;
struct <API key> dma_parms;
struct dma_device dma_device;
void __iomem *base;
struct clk *dma_ahb;
struct clk *dma_ipg;
spinlock_t lock;
struct imx_dma_2d_config slots_2d[IMX_DMA_2D_SLOTS];
struct imxdma_channel channel[IMX_DMA_CHANNELS];
};
static struct imxdma_channel *to_imxdma_chan(struct dma_chan *chan)
{
return container_of(chan, struct imxdma_channel, chan);
}
static inline bool <API key>(struct imxdma_channel *imxdmac)
{
struct imxdma_desc *desc;
if (!list_empty(&imxdmac->ld_active)) {
desc = list_first_entry(&imxdmac->ld_active, struct imxdma_desc,
node);
if (desc->type == IMXDMA_DESC_CYCLIC)
return true;
}
return false;
}
static void imx_dmav1_writel(struct imxdma_engine *imxdma, unsigned val,
unsigned offset)
{
__raw_writel(val, imxdma->base + offset);
}
static unsigned imx_dmav1_readl(struct imxdma_engine *imxdma, unsigned offset)
{
return __raw_readl(imxdma->base + offset);
}
static int imxdma_hw_chain(struct imxdma_channel *imxdmac)
{
if (cpu_is_mx27())
return imxdmac->hw_chaining;
else
return 0;
}
/*
* imxdma_sg_next - prepare next chunk for scatter-gather DMA emulation
*/
static inline int imxdma_sg_next(struct imxdma_desc *d)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(d->desc.chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct scatterlist *sg = d->sg;
unsigned long now;
now = min(d->len, sg->length);
if (d->len != IMX_DMA_LENGTH_LOOP)
d->len -= now;
if (d->direction == DMA_DEV_TO_MEM)
imx_dmav1_writel(imxdma, sg->dma_address,
DMA_DAR(imxdmac->channel));
else
imx_dmav1_writel(imxdma, sg->dma_address,
DMA_SAR(imxdmac->channel));
imx_dmav1_writel(imxdma, now, DMA_CNTR(imxdmac->channel));
dev_dbg(imxdma->dev, " %s channel: %d dst 0x%08x, src 0x%08x, "
"size 0x%08x\n", __func__, imxdmac->channel,
imx_dmav1_readl(imxdma, DMA_DAR(imxdmac->channel)),
imx_dmav1_readl(imxdma, DMA_SAR(imxdmac->channel)),
imx_dmav1_readl(imxdma, DMA_CNTR(imxdmac->channel)));
return now;
}
static void imxdma_enable_hw(struct imxdma_desc *d)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(d->desc.chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
int channel = imxdmac->channel;
unsigned long flags;
dev_dbg(imxdma->dev, "%s channel %d\n", __func__, channel);
local_irq_save(flags);
imx_dmav1_writel(imxdma, 1 << channel, DMA_DISR);
imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_DIMR) &
~(1 << channel), DMA_DIMR);
imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) |
CCR_CEN | CCR_ACRPT, DMA_CCR(channel));
if ((cpu_is_mx21() || cpu_is_mx27()) &&
d->sg && imxdma_hw_chain(imxdmac)) {
d->sg = sg_next(d->sg);
if (d->sg) {
u32 tmp;
imxdma_sg_next(d);
tmp = imx_dmav1_readl(imxdma, DMA_CCR(channel));
imx_dmav1_writel(imxdma, tmp | CCR_RPT | CCR_ACRPT,
DMA_CCR(channel));
}
}
local_irq_restore(flags);
}
static void imxdma_disable_hw(struct imxdma_channel *imxdmac)
{
struct imxdma_engine *imxdma = imxdmac->imxdma;
int channel = imxdmac->channel;
unsigned long flags;
dev_dbg(imxdma->dev, "%s channel %d\n", __func__, channel);
if (imxdma_hw_chain(imxdmac))
del_timer(&imxdmac->watchdog);
local_irq_save(flags);
imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_DIMR) |
(1 << channel), DMA_DIMR);
imx_dmav1_writel(imxdma, imx_dmav1_readl(imxdma, DMA_CCR(channel)) &
~CCR_CEN, DMA_CCR(channel));
imx_dmav1_writel(imxdma, 1 << channel, DMA_DISR);
local_irq_restore(flags);
}
static void imxdma_watchdog(unsigned long data)
{
struct imxdma_channel *imxdmac = (struct imxdma_channel *)data;
struct imxdma_engine *imxdma = imxdmac->imxdma;
int channel = imxdmac->channel;
imx_dmav1_writel(imxdma, 0, DMA_CCR(channel));
/* Tasklet watchdog error handler */
tasklet_schedule(&imxdmac->dma_tasklet);
dev_dbg(imxdma->dev, "channel %d: watchdog timeout!\n",
imxdmac->channel);
}
static irqreturn_t imxdma_err_handler(int irq, void *dev_id)
{
struct imxdma_engine *imxdma = dev_id;
unsigned int err_mask;
int i, disr;
int errcode;
disr = imx_dmav1_readl(imxdma, DMA_DISR);
err_mask = imx_dmav1_readl(imxdma, DMA_DBTOSR) |
imx_dmav1_readl(imxdma, DMA_DRTOSR) |
imx_dmav1_readl(imxdma, DMA_DSESR) |
imx_dmav1_readl(imxdma, DMA_DBOSR);
if (!err_mask)
return IRQ_HANDLED;
imx_dmav1_writel(imxdma, disr & err_mask, DMA_DISR);
for (i = 0; i < IMX_DMA_CHANNELS; i++) {
if (!(err_mask & (1 << i)))
continue;
errcode = 0;
if (imx_dmav1_readl(imxdma, DMA_DBTOSR) & (1 << i)) {
imx_dmav1_writel(imxdma, 1 << i, DMA_DBTOSR);
errcode |= IMX_DMA_ERR_BURST;
}
if (imx_dmav1_readl(imxdma, DMA_DRTOSR) & (1 << i)) {
imx_dmav1_writel(imxdma, 1 << i, DMA_DRTOSR);
errcode |= IMX_DMA_ERR_REQUEST;
}
if (imx_dmav1_readl(imxdma, DMA_DSESR) & (1 << i)) {
imx_dmav1_writel(imxdma, 1 << i, DMA_DSESR);
errcode |= <API key>;
}
if (imx_dmav1_readl(imxdma, DMA_DBOSR) & (1 << i)) {
imx_dmav1_writel(imxdma, 1 << i, DMA_DBOSR);
errcode |= IMX_DMA_ERR_BUFFER;
}
/* Tasklet error handler */
tasklet_schedule(&imxdma->channel[i].dma_tasklet);
printk(KERN_WARNING
"DMA timeout on channel %d -%s%s%s%s\n", i,
errcode & IMX_DMA_ERR_BURST ? " burst" : "",
errcode & IMX_DMA_ERR_REQUEST ? " request" : "",
errcode & <API key> ? " transfer" : "",
errcode & IMX_DMA_ERR_BUFFER ? " buffer" : "");
}
return IRQ_HANDLED;
}
static void <API key>(struct imxdma_channel *imxdmac)
{
struct imxdma_engine *imxdma = imxdmac->imxdma;
int chno = imxdmac->channel;
struct imxdma_desc *desc;
unsigned long flags;
spin_lock_irqsave(&imxdma->lock, flags);
if (list_empty(&imxdmac->ld_active)) {
<API key>(&imxdma->lock, flags);
goto out;
}
desc = list_first_entry(&imxdmac->ld_active,
struct imxdma_desc,
node);
<API key>(&imxdma->lock, flags);
if (desc->sg) {
u32 tmp;
desc->sg = sg_next(desc->sg);
if (desc->sg) {
imxdma_sg_next(desc);
tmp = imx_dmav1_readl(imxdma, DMA_CCR(chno));
if (imxdma_hw_chain(imxdmac)) {
/* FIXME: The timeout should probably be
* configurable
*/
mod_timer(&imxdmac->watchdog,
jiffies + msecs_to_jiffies(500));
tmp |= CCR_CEN | CCR_RPT | CCR_ACRPT;
imx_dmav1_writel(imxdma, tmp, DMA_CCR(chno));
} else {
imx_dmav1_writel(imxdma, tmp & ~CCR_CEN,
DMA_CCR(chno));
tmp |= CCR_CEN;
}
imx_dmav1_writel(imxdma, tmp, DMA_CCR(chno));
if (<API key>(imxdmac))
/* Tasklet progression */
tasklet_schedule(&imxdmac->dma_tasklet);
return;
}
if (imxdma_hw_chain(imxdmac)) {
del_timer(&imxdmac->watchdog);
return;
}
}
out:
imx_dmav1_writel(imxdma, 0, DMA_CCR(chno));
/* Tasklet irq */
tasklet_schedule(&imxdmac->dma_tasklet);
}
static irqreturn_t dma_irq_handler(int irq, void *dev_id)
{
struct imxdma_engine *imxdma = dev_id;
int i, disr;
if (cpu_is_mx21() || cpu_is_mx27())
imxdma_err_handler(irq, dev_id);
disr = imx_dmav1_readl(imxdma, DMA_DISR);
dev_dbg(imxdma->dev, "%s called, disr=0x%08x\n", __func__, disr);
imx_dmav1_writel(imxdma, disr, DMA_DISR);
for (i = 0; i < IMX_DMA_CHANNELS; i++) {
if (disr & (1 << i))
<API key>(&imxdma->channel[i]);
}
return IRQ_HANDLED;
}
static int imxdma_xfer_desc(struct imxdma_desc *d)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(d->desc.chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
int slot = -1;
int i;
/* Configure and enable */
switch (d->type) {
case <API key>:
/* Try to get a free 2D slot */
for (i = 0; i < IMX_DMA_2D_SLOTS; i++) {
if ((imxdma->slots_2d[i].count > 0) &&
((imxdma->slots_2d[i].xsr != d->x) ||
(imxdma->slots_2d[i].ysr != d->y) ||
(imxdma->slots_2d[i].wsr != d->w)))
continue;
slot = i;
break;
}
if (slot < 0)
return -EBUSY;
imxdma->slots_2d[slot].xsr = d->x;
imxdma->slots_2d[slot].ysr = d->y;
imxdma->slots_2d[slot].wsr = d->w;
imxdma->slots_2d[slot].count++;
imxdmac->slot_2d = slot;
imxdmac->enabled_2d = true;
if (slot == IMX_DMA_2D_SLOT_A) {
d->config_mem &= ~CCR_MSEL_B;
d->config_port &= ~CCR_MSEL_B;
imx_dmav1_writel(imxdma, d->x, DMA_XSRA);
imx_dmav1_writel(imxdma, d->y, DMA_YSRA);
imx_dmav1_writel(imxdma, d->w, DMA_WSRA);
} else {
d->config_mem |= CCR_MSEL_B;
d->config_port |= CCR_MSEL_B;
imx_dmav1_writel(imxdma, d->x, DMA_XSRB);
imx_dmav1_writel(imxdma, d->y, DMA_YSRB);
imx_dmav1_writel(imxdma, d->w, DMA_WSRB);
}
/*
* We fall-through here intentionally, since a 2D transfer is
* similar to MEMCPY just adding the 2D slot configuration.
*/
case IMXDMA_DESC_MEMCPY:
imx_dmav1_writel(imxdma, d->src, DMA_SAR(imxdmac->channel));
imx_dmav1_writel(imxdma, d->dest, DMA_DAR(imxdmac->channel));
imx_dmav1_writel(imxdma, d->config_mem | (d->config_port << 2),
DMA_CCR(imxdmac->channel));
imx_dmav1_writel(imxdma, d->len, DMA_CNTR(imxdmac->channel));
dev_dbg(imxdma->dev, "%s channel: %d dest=0x%08x src=0x%08x "
"dma_length=%d\n", __func__, imxdmac->channel,
d->dest, d->src, d->len);
break;
/* Cyclic transfer is the same as slave_sg with special sg configuration. */
case IMXDMA_DESC_CYCLIC:
case <API key>:
if (d->direction == DMA_DEV_TO_MEM) {
imx_dmav1_writel(imxdma, imxdmac->per_address,
DMA_SAR(imxdmac->channel));
imx_dmav1_writel(imxdma, imxdmac->ccr_from_device,
DMA_CCR(imxdmac->channel));
dev_dbg(imxdma->dev, "%s channel: %d sg=%p sgcount=%d "
"total length=%d dev_addr=0x%08x (dev2mem)\n",
__func__, imxdmac->channel, d->sg, d->sgcount,
d->len, imxdmac->per_address);
} else if (d->direction == DMA_MEM_TO_DEV) {
imx_dmav1_writel(imxdma, imxdmac->per_address,
DMA_DAR(imxdmac->channel));
imx_dmav1_writel(imxdma, imxdmac->ccr_to_device,
DMA_CCR(imxdmac->channel));
dev_dbg(imxdma->dev, "%s channel: %d sg=%p sgcount=%d "
"total length=%d dev_addr=0x%08x (mem2dev)\n",
__func__, imxdmac->channel, d->sg, d->sgcount,
d->len, imxdmac->per_address);
} else {
dev_err(imxdma->dev, "%s channel: %d bad dma mode\n",
__func__, imxdmac->channel);
return -EINVAL;
}
imxdma_sg_next(d);
break;
default:
return -EINVAL;
}
imxdma_enable_hw(d);
return 0;
}
static void imxdma_tasklet(unsigned long data)
{
struct imxdma_channel *imxdmac = (void *)data;
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc;
unsigned long flags;
spin_lock_irqsave(&imxdma->lock, flags);
if (list_empty(&imxdmac->ld_active)) {
/* Someone might have called terminate all */
<API key>(&imxdma->lock, flags);
return;
}
desc = list_first_entry(&imxdmac->ld_active, struct imxdma_desc, node);
/* If we are dealing with a cyclic descriptor keep it on ld_active
* and dont mark the descripor as complete.
* Only in non-cyclic cases it would be marked as complete
*/
if (<API key>(imxdmac))
goto out;
else
dma_cookie_complete(&desc->desc);
/* Free 2D slot if it was an interleaved transfer */
if (imxdmac->enabled_2d) {
imxdma->slots_2d[imxdmac->slot_2d].count
imxdmac->enabled_2d = false;
}
list_move_tail(imxdmac->ld_active.next, &imxdmac->ld_free);
if (!list_empty(&imxdmac->ld_queue)) {
desc = list_first_entry(&imxdmac->ld_queue, struct imxdma_desc,
node);
list_move_tail(imxdmac->ld_queue.next, &imxdmac->ld_active);
if (imxdma_xfer_desc(desc) < 0)
dev_warn(imxdma->dev, "%s: channel: %d couldn't xfer desc\n",
__func__, imxdmac->channel);
}
out:
<API key>(&imxdma->lock, flags);
if (desc->desc.callback)
desc->desc.callback(desc->desc.callback_param);
}
static int imxdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
unsigned long arg)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct dma_slave_config *dmaengine_cfg = (void *)arg;
struct imxdma_engine *imxdma = imxdmac->imxdma;
unsigned long flags;
unsigned int mode = 0;
switch (cmd) {
case DMA_TERMINATE_ALL:
imxdma_disable_hw(imxdmac);
spin_lock_irqsave(&imxdma->lock, flags);
<API key>(&imxdmac->ld_active, &imxdmac->ld_free);
<API key>(&imxdmac->ld_queue, &imxdmac->ld_free);
<API key>(&imxdma->lock, flags);
return 0;
case DMA_SLAVE_CONFIG:
if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
imxdmac->per_address = dmaengine_cfg->src_addr;
imxdmac->watermark_level = dmaengine_cfg->src_maxburst;
imxdmac->word_size = dmaengine_cfg->src_addr_width;
} else {
imxdmac->per_address = dmaengine_cfg->dst_addr;
imxdmac->watermark_level = dmaengine_cfg->dst_maxburst;
imxdmac->word_size = dmaengine_cfg->dst_addr_width;
}
switch (imxdmac->word_size) {
case <API key>:
mode = IMX_DMA_MEMSIZE_8;
break;
case <API key>:
mode = IMX_DMA_MEMSIZE_16;
break;
default:
case <API key>:
mode = IMX_DMA_MEMSIZE_32;
break;
}
imxdmac->hw_chaining = 1;
if (!imxdma_hw_chain(imxdmac))
return -EINVAL;
imxdmac->ccr_from_device = (mode | IMX_DMA_TYPE_FIFO) |
((IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR) << 2) |
CCR_REN;
imxdmac->ccr_to_device =
(IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR) |
((mode | IMX_DMA_TYPE_FIFO) << 2) | CCR_REN;
imx_dmav1_writel(imxdma, imxdmac->dma_request,
DMA_RSSR(imxdmac->channel));
/* Set burst length */
imx_dmav1_writel(imxdma, imxdmac->watermark_level *
imxdmac->word_size, DMA_BLR(imxdmac->channel));
return 0;
default:
return -ENOSYS;
}
return -EINVAL;
}
static enum dma_status imxdma_tx_status(struct dma_chan *chan,
dma_cookie_t cookie,
struct dma_tx_state *txstate)
{
return dma_cookie_status(chan, cookie, txstate);
}
static dma_cookie_t imxdma_tx_submit(struct <API key> *tx)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(tx->chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
dma_cookie_t cookie;
unsigned long flags;
spin_lock_irqsave(&imxdma->lock, flags);
list_move_tail(imxdmac->ld_free.next, &imxdmac->ld_queue);
cookie = dma_cookie_assign(tx);
<API key>(&imxdma->lock, flags);
return cookie;
}
static int <API key>(struct dma_chan *chan)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imx_dma_data *data = chan->private;
if (data != NULL)
imxdmac->dma_request = data->dma_request;
while (imxdmac->descs_allocated < <API key>) {
struct imxdma_desc *desc;
desc = kzalloc(sizeof(*desc), GFP_KERNEL);
if (!desc)
break;
__memzero(&desc->desc, sizeof(struct <API key>));
<API key>(&desc->desc, chan);
desc->desc.tx_submit = imxdma_tx_submit;
/* txd.flags will be overwritten in prep funcs */
desc->desc.flags = DMA_CTRL_ACK;
desc->status = DMA_SUCCESS;
list_add_tail(&desc->node, &imxdmac->ld_free);
imxdmac->descs_allocated++;
}
if (!imxdmac->descs_allocated)
return -ENOMEM;
return imxdmac->descs_allocated;
}
static void <API key>(struct dma_chan *chan)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc, *_desc;
unsigned long flags;
spin_lock_irqsave(&imxdma->lock, flags);
imxdma_disable_hw(imxdmac);
<API key>(&imxdmac->ld_active, &imxdmac->ld_free);
<API key>(&imxdmac->ld_queue, &imxdmac->ld_free);
<API key>(&imxdma->lock, flags);
<API key>(desc, _desc, &imxdmac->ld_free, node) {
kfree(desc);
imxdmac->descs_allocated
}
INIT_LIST_HEAD(&imxdmac->ld_free);
if (imxdmac->sg_list) {
kfree(imxdmac->sg_list);
imxdmac->sg_list = NULL;
}
}
static struct <API key> *<API key>(
struct dma_chan *chan, struct scatterlist *sgl,
unsigned int sg_len, enum <API key> direction,
unsigned long flags, void *context)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct scatterlist *sg;
int i, dma_length = 0;
struct imxdma_desc *desc;
if (list_empty(&imxdmac->ld_free) ||
<API key>(imxdmac))
return NULL;
desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
for_each_sg(sgl, sg, sg_len, i) {
dma_length += sg->length;
}
switch (imxdmac->word_size) {
case <API key>:
if (sgl->length & 3 || sgl->dma_address & 3)
return NULL;
break;
case <API key>:
if (sgl->length & 1 || sgl->dma_address & 1)
return NULL;
break;
case <API key>:
break;
default:
return NULL;
}
desc->type = <API key>;
desc->sg = sgl;
desc->sgcount = sg_len;
desc->len = dma_length;
desc->direction = direction;
if (direction == DMA_DEV_TO_MEM) {
desc->src = imxdmac->per_address;
} else {
desc->dest = imxdmac->per_address;
}
desc->desc.callback = NULL;
desc->desc.callback_param = NULL;
return &desc->desc;
}
static struct <API key> *<API key>(
struct dma_chan *chan, dma_addr_t dma_addr, size_t buf_len,
size_t period_len, enum <API key> direction,
void *context)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc;
int i;
unsigned int periods = buf_len / period_len;
dev_dbg(imxdma->dev, "%s channel: %d buf_len=%d period_len=%d\n",
__func__, imxdmac->channel, buf_len, period_len);
if (list_empty(&imxdmac->ld_free) ||
<API key>(imxdmac))
return NULL;
desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
if (imxdmac->sg_list)
kfree(imxdmac->sg_list);
imxdmac->sg_list = kcalloc(periods + 1,
sizeof(struct scatterlist), GFP_ATOMIC);
if (!imxdmac->sg_list)
return NULL;
sg_init_table(imxdmac->sg_list, periods);
for (i = 0; i < periods; i++) {
imxdmac->sg_list[i].page_link = 0;
imxdmac->sg_list[i].offset = 0;
imxdmac->sg_list[i].dma_address = dma_addr;
imxdmac->sg_list[i].length = period_len;
dma_addr += period_len;
}
/* close the loop */
imxdmac->sg_list[periods].offset = 0;
imxdmac->sg_list[periods].length = 0;
imxdmac->sg_list[periods].page_link =
((unsigned long)imxdmac->sg_list | 0x01) & ~0x02;
desc->type = IMXDMA_DESC_CYCLIC;
desc->sg = imxdmac->sg_list;
desc->sgcount = periods;
desc->len = IMX_DMA_LENGTH_LOOP;
desc->direction = direction;
if (direction == DMA_DEV_TO_MEM) {
desc->src = imxdmac->per_address;
} else {
desc->dest = imxdmac->per_address;
}
desc->desc.callback = NULL;
desc->desc.callback_param = NULL;
return &desc->desc;
}
static struct <API key> *<API key>(
struct dma_chan *chan, dma_addr_t dest,
dma_addr_t src, size_t len, unsigned long flags)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc;
dev_dbg(imxdma->dev, "%s channel: %d src=0x%x dst=0x%x len=%d\n",
__func__, imxdmac->channel, src, dest, len);
if (list_empty(&imxdmac->ld_free) ||
<API key>(imxdmac))
return NULL;
desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
desc->type = IMXDMA_DESC_MEMCPY;
desc->src = src;
desc->dest = dest;
desc->len = len;
desc->direction = DMA_MEM_TO_MEM;
desc->config_port = IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR;
desc->config_mem = IMX_DMA_MEMSIZE_32 | IMX_DMA_TYPE_LINEAR;
desc->desc.callback = NULL;
desc->desc.callback_param = NULL;
return &desc->desc;
}
static struct <API key> *<API key>(
struct dma_chan *chan, struct <API key> *xt,
unsigned long flags)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc;
dev_dbg(imxdma->dev, "%s channel: %d src_start=0x%x dst_start=0x%x\n"
" src_sgl=%s dst_sgl=%s numf=%d frame_size=%d\n", __func__,
imxdmac->channel, xt->src_start, xt->dst_start,
xt->src_sgl ? "true" : "false", xt->dst_sgl ? "true" : "false",
xt->numf, xt->frame_size);
if (list_empty(&imxdmac->ld_free) ||
<API key>(imxdmac))
return NULL;
if (xt->frame_size != 1 || xt->numf <= 0 || xt->dir != DMA_MEM_TO_MEM)
return NULL;
desc = list_first_entry(&imxdmac->ld_free, struct imxdma_desc, node);
desc->type = <API key>;
desc->src = xt->src_start;
desc->dest = xt->dst_start;
desc->x = xt->sgl[0].size;
desc->y = xt->numf;
desc->w = xt->sgl[0].icg + desc->x;
desc->len = desc->x * desc->y;
desc->direction = DMA_MEM_TO_MEM;
desc->config_port = IMX_DMA_MEMSIZE_32;
desc->config_mem = IMX_DMA_MEMSIZE_32;
if (xt->src_sgl)
desc->config_mem |= IMX_DMA_TYPE_2D;
if (xt->dst_sgl)
desc->config_port |= IMX_DMA_TYPE_2D;
desc->desc.callback = NULL;
desc->desc.callback_param = NULL;
return &desc->desc;
}
static void <API key>(struct dma_chan *chan)
{
struct imxdma_channel *imxdmac = to_imxdma_chan(chan);
struct imxdma_engine *imxdma = imxdmac->imxdma;
struct imxdma_desc *desc;
unsigned long flags;
spin_lock_irqsave(&imxdma->lock, flags);
if (list_empty(&imxdmac->ld_active) &&
!list_empty(&imxdmac->ld_queue)) {
desc = list_first_entry(&imxdmac->ld_queue,
struct imxdma_desc, node);
if (imxdma_xfer_desc(desc) < 0) {
dev_warn(imxdma->dev,
"%s: channel: %d couldn't issue DMA xfer\n",
__func__, imxdmac->channel);
} else {
list_move_tail(imxdmac->ld_queue.next,
&imxdmac->ld_active);
}
}
<API key>(&imxdma->lock, flags);
}
static int __init imxdma_probe(struct platform_device *pdev)
{
struct imxdma_engine *imxdma;
int ret, i;
imxdma = kzalloc(sizeof(*imxdma), GFP_KERNEL);
if (!imxdma)
return -ENOMEM;
if (cpu_is_mx1()) {
imxdma->base = MX1_IO_ADDRESS(MX1_DMA_BASE_ADDR);
} else if (cpu_is_mx21()) {
imxdma->base = MX21_IO_ADDRESS(MX21_DMA_BASE_ADDR);
} else if (cpu_is_mx27()) {
imxdma->base = MX27_IO_ADDRESS(MX27_DMA_BASE_ADDR);
} else {
kfree(imxdma);
return 0;
}
imxdma->dma_ipg = devm_clk_get(&pdev->dev, "ipg");
if (IS_ERR(imxdma->dma_ipg)) {
ret = PTR_ERR(imxdma->dma_ipg);
goto err_clk;
}
imxdma->dma_ahb = devm_clk_get(&pdev->dev, "ahb");
if (IS_ERR(imxdma->dma_ahb)) {
ret = PTR_ERR(imxdma->dma_ahb);
goto err_clk;
}
clk_prepare_enable(imxdma->dma_ipg);
clk_prepare_enable(imxdma->dma_ahb);
/* reset DMA module */
imx_dmav1_writel(imxdma, DCR_DRST, DMA_DCR);
if (cpu_is_mx1()) {
ret = request_irq(MX1_DMA_INT, dma_irq_handler, 0, "DMA", imxdma);
if (ret) {
dev_warn(imxdma->dev, "Can't register IRQ for DMA\n");
goto err_enable;
}
ret = request_irq(MX1_DMA_ERR, imxdma_err_handler, 0, "DMA", imxdma);
if (ret) {
dev_warn(imxdma->dev, "Can't register ERRIRQ for DMA\n");
free_irq(MX1_DMA_INT, NULL);
goto err_enable;
}
}
/* enable DMA module */
imx_dmav1_writel(imxdma, DCR_DEN, DMA_DCR);
/* clear all interrupts */
imx_dmav1_writel(imxdma, (1 << IMX_DMA_CHANNELS) - 1, DMA_DISR);
/* disable interrupts */
imx_dmav1_writel(imxdma, (1 << IMX_DMA_CHANNELS) - 1, DMA_DIMR);
INIT_LIST_HEAD(&imxdma->dma_device.channels);
dma_cap_set(DMA_SLAVE, imxdma->dma_device.cap_mask);
dma_cap_set(DMA_CYCLIC, imxdma->dma_device.cap_mask);
dma_cap_set(DMA_MEMCPY, imxdma->dma_device.cap_mask);
dma_cap_set(DMA_INTERLEAVE, imxdma->dma_device.cap_mask);
/* Initialize 2D global parameters */
for (i = 0; i < IMX_DMA_2D_SLOTS; i++)
imxdma->slots_2d[i].count = 0;
spin_lock_init(&imxdma->lock);
/* Initialize channel parameters */
for (i = 0; i < IMX_DMA_CHANNELS; i++) {
struct imxdma_channel *imxdmac = &imxdma->channel[i];
if (cpu_is_mx21() || cpu_is_mx27()) {
ret = request_irq(MX2x_INT_DMACH0 + i,
dma_irq_handler, 0, "DMA", imxdma);
if (ret) {
dev_warn(imxdma->dev, "Can't register IRQ %d "
"for DMA channel %d\n",
MX2x_INT_DMACH0 + i, i);
goto err_init;
}
init_timer(&imxdmac->watchdog);
imxdmac->watchdog.function = &imxdma_watchdog;
imxdmac->watchdog.data = (unsigned long)imxdmac;
}
imxdmac->imxdma = imxdma;
INIT_LIST_HEAD(&imxdmac->ld_queue);
INIT_LIST_HEAD(&imxdmac->ld_free);
INIT_LIST_HEAD(&imxdmac->ld_active);
tasklet_init(&imxdmac->dma_tasklet, imxdma_tasklet,
(unsigned long)imxdmac);
imxdmac->chan.device = &imxdma->dma_device;
dma_cookie_init(&imxdmac->chan);
imxdmac->channel = i;
/* Add the channel to the DMAC list */
list_add_tail(&imxdmac->chan.device_node,
&imxdma->dma_device.channels);
}
imxdma->dev = &pdev->dev;
imxdma->dma_device.dev = &pdev->dev;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.device_tx_status = imxdma_tx_status;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.<API key> = <API key>;
imxdma->dma_device.device_control = imxdma_control;
imxdma->dma_device.<API key> = <API key>;
<API key>(pdev, imxdma);
imxdma->dma_device.copy_align = 2; /* 2^2 = 4 bytes alignment */
imxdma->dma_device.dev->dma_parms = &imxdma->dma_parms;
<API key>(imxdma->dma_device.dev, 0xffffff);
ret = <API key>(&imxdma->dma_device);
if (ret) {
dev_err(&pdev->dev, "unable to register\n");
goto err_init;
}
return 0;
err_init:
if (cpu_is_mx21() || cpu_is_mx27()) {
while (--i >= 0)
free_irq(MX2x_INT_DMACH0 + i, NULL);
} else if cpu_is_mx1() {
free_irq(MX1_DMA_INT, NULL);
free_irq(MX1_DMA_ERR, NULL);
}
err_enable:
<API key>(imxdma->dma_ipg);
<API key>(imxdma->dma_ahb);
err_clk:
kfree(imxdma);
return ret;
}
static int __exit imxdma_remove(struct platform_device *pdev)
{
struct imxdma_engine *imxdma = <API key>(pdev);
int i;
<API key>(&imxdma->dma_device);
if (cpu_is_mx21() || cpu_is_mx27()) {
for (i = 0; i < IMX_DMA_CHANNELS; i++)
free_irq(MX2x_INT_DMACH0 + i, NULL);
} else if cpu_is_mx1() {
free_irq(MX1_DMA_INT, NULL);
free_irq(MX1_DMA_ERR, NULL);
}
<API key>(imxdma->dma_ipg);
<API key>(imxdma->dma_ahb);
kfree(imxdma);
return 0;
}
static struct platform_driver imxdma_driver = {
.driver = {
.name = "imx-dma",
},
.remove = __exit_p(imxdma_remove),
};
static int __init imxdma_module_init(void)
{
return <API key>(&imxdma_driver, imxdma_probe);
}
subsys_initcall(imxdma_module_init);
MODULE_AUTHOR("Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>");
MODULE_DESCRIPTION("i.MX dma driver");
MODULE_LICENSE("GPL");
|
#ifndef QGSGRASSUTILS_H
#define QGSGRASSUTILS_H
#include <QObject>
class QDialog;
class QLineEdit;
class QLabel;
class QPushButton;
class QgisInterface;
/*! \class QgsGrassUtils
* \brief Various utilities.
*/
class QgsGrassUtils
{
public:
//! Constructor
QgsGrassUtils();
//! Destructor
~QgsGrassUtils();
public:
// Create vector name from map name, layer name and number of layers
static QString vectorLayerName( QString map, QString layer, int nLayers );
// Add all vector layers to QGIS view
static void addVectorLayers( QgisInterface *iface,
QString gisbase, QString location, QString mapset, QString map );
// Check if element exists in current mapset
static bool itemExists( QString element, QString item );
//! Get path to custom HTML browser starter executable
static QString htmlBrowserPath();
};
/*! \class <API key>
* \brief Get name for new element
*/
class <API key>: public QObject
{
Q_OBJECT
public:
//! Constructor
<API key>( QWidget *parent );
//! Destructor
~<API key>();
public:
//! Get a name for new GRASS element (map)
// \param source local source
QString getItem( QString element,
QString title, QString label,
QString text, QString source = 0,
bool * ok = 0 );
public slots:
void textChanged();
private:
QString mElement;
QString mSource;
QDialog *mDialog;
QLineEdit *mLineEdit;
QLabel *mLabel;
QLabel *mErrorLabel;
QPushButton *mOkButton;
QPushButton *mCancelButton;
QWidget *mParent;
};
#endif // QGSGRASSUTILS_H
|
<?php
/**
* Include error handling
*/
//require_once 'PEAR.php';
/**
* Which user interface class is being used.
* @var string class name
*/
$GLOBALS['<API key>'] = 'PEAR_Frontend_CLI';
/**
* Instance of $<API key>.
* @var object
*/
$GLOBALS['<API key>'] = null;
class PEAR_Frontend extends PEAR
{
/**
* Retrieve the frontend object
* @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk
* @static
*/
function &singleton($type = null)
{
if ($type === null) {
if (!isset($GLOBALS['<API key>'])) {
$a = false;
return $a;
}
return $GLOBALS['<API key>'];
}
$a = PEAR_Frontend::setFrontendClass($type);
return $a;
}
/**
* Set the frontend class that will be used by calls to {@link singleton()}
*
* Frontends are expected to conform to the PEAR naming standard of
* _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php)
* @param string $uiclass full class name
* @return PEAR_Frontend
* @static
*/
function &setFrontendClass($uiclass)
{
if (is_object($GLOBALS['<API key>']) &&
is_a($GLOBALS['<API key>'], $uiclass)) {
return $GLOBALS['<API key>'];
}
if (!class_exists($uiclass)) {
$file = str_replace('_', '/', $uiclass) . '.php';
if (PEAR_Frontend::isIncludeable($file)) {
include_once $file;
}
}
if (class_exists($uiclass)) {
$obj = new $uiclass;
// quick test to see if this class implements a few of the most
// important frontend methods
if (is_a($obj, 'PEAR_Frontend')) {
$GLOBALS['<API key>'] = &$obj;
$GLOBALS['<API key>'] = $uiclass;
return $obj;
}
$err = PEAR::raiseError("not a frontend class: $uiclass");
return $err;
}
$err = PEAR::raiseError("no such class: $uiclass");
return $err;
}
/**
* Set the frontend class that will be used by calls to {@link singleton()}
*
* Frontends are expected to be a descendant of PEAR_Frontend
* @param PEAR_Frontend
* @return PEAR_Frontend
* @static
*/
function &setFrontendObject($uiobject)
{
if (is_object($GLOBALS['<API key>']) &&
is_a($GLOBALS['<API key>'], get_class($uiobject))) {
return $GLOBALS['<API key>'];
}
if (!is_a($uiobject, 'PEAR_Frontend')) {
$err = PEAR::raiseError('not a valid frontend class: (' .
get_class($uiobject) . ')');
return $err;
}
$GLOBALS['<API key>'] = &$uiobject;
$GLOBALS['<API key>'] = get_class($uiobject);
return $uiobject;
}
/**
* @param string $path relative or absolute include path
* @return boolean
* @static
*/
function isIncludeable($path)
{
if (file_exists($path) && is_readable($path)) {
return true;
}
$fp = @fopen($path, 'r', true);
if ($fp) {
fclose($fp);
return true;
}
return false;
}
/**
* @param PEAR_Config
*/
function setConfig(&$config)
{
}
/**
* This can be overridden to allow session-based temporary file management
*
* By default, all files are deleted at the end of a session. The web installer
* needs to be able to sustain a list over many sessions in order to support
* user interaction with install scripts
*/
function addTempFile($file)
{
$GLOBALS['<API key>'][] = $file;
}
/**
* Log an action
*
* @param string $msg the message to log
* @param boolean $append_crlf
* @return boolean true
* @abstract
*/
function log($msg, $append_crlf = true)
{
}
/**
* Run a post-installation script
*
* @param array $scripts array of post-install scripts
* @abstract
*/
function <API key>(&$scripts)
{
}
/**
* Display human-friendly output formatted depending on the
* $command parameter.
*
* This should be able to handle basic output data with no command
* @param mixed $data data structure containing the information to display
* @param string $command command from which this method was called
* @abstract
*/
function outputData($data, $command = '_default')
{
}
/**
* Display a modal form dialog and return the given input
*
* A frontend that requires multiple requests to retrieve and process
* data must take these needs into account, and implement the request
* handling code.
* @param string $command command from which this method was called
* @param array $prompts associative array. keys are the input field names
* and values are the description
* @param array $types array of input field types (text, password,
* etc.) keys have to be the same like in $prompts
* @param array $defaults array of default values. again keys have
* to be the same like in $prompts. Do not depend
* on a default value being set.
* @return array input sent by the user
* @abstract
*/
function userDialog($command, $prompts, $types = array(), $defaults = array())
{
}
}
|
// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
// <API key>
#ifndef HEADER
#define HEADER
void foo() {}
template <class T, int N>
T tmain(T argc) {
T b = argc, c, d, e, f, g;
static T a;
// CHECK: static T a;
#pragma omp parallel
#pragma omp sections private(argc, b), firstprivate(c, d), lastprivate(d, f) reduction(- : g) nowait
{
foo();
}
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(c,d) lastprivate(d,f) reduction(-: g) nowait
// CHECK-NEXT: {
// CHECK-NEXT: foo();
// CHECK-NEXT: }
return T();
}
int main(int argc, char **argv) {
// CHECK: int main(int argc, char **argv) {
int b = argc, c, d, e, f, g;
static int a;
// CHECK: static int a;
#pragma omp parallel
#pragma omp sections private(argc, b), firstprivate(argv, c), lastprivate(d, f) reduction(+ : g) nowait
{
#pragma omp section
foo();
#pragma omp section
foo();
}
// CHECK-NEXT: #pragma omp parallel
// CHECK-NEXT: #pragma omp sections private(argc,b) firstprivate(argv,c) lastprivate(d,f) reduction(+: g) nowait
// CHECK-NEXT: {
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: #pragma omp section
// CHECK-NEXT: foo();
// CHECK-NEXT: }
return (tmain<int, 5>(argc) + tmain<char, 1>(argv[0][0]));
}
#endif
|
#include "rar.hpp"
static int SleepTime=0;
void InitSystemOptions(int SleepTime)
{
::SleepTime=SleepTime;
}
#if !defined(SFX_MODULE)
void SetPriority(int Priority)
{
#ifdef _WIN_ALL
uint PriorityClass;
int PriorityLevel;
if (Priority<1 || Priority>15)
return;
if (Priority==1)
{
PriorityClass=IDLE_PRIORITY_CLASS;
PriorityLevel=<API key>;
// Background mode for Vista, can be slow for many small files.
// if (WinNT()>=WNT_VISTA)
// SetPriorityClass(GetCurrentProcess(),<API key>);
}
else
if (Priority<7)
{
PriorityClass=IDLE_PRIORITY_CLASS;
PriorityLevel=Priority-4;
}
else
if (Priority==7)
{
PriorityClass=<API key>;
PriorityLevel=<API key>;
}
else
if (Priority<10)
{
PriorityClass=<API key>;
PriorityLevel=Priority-7;
}
else
if (Priority==10)
{
PriorityClass=<API key>;
PriorityLevel=<API key>;
}
else
{
PriorityClass=HIGH_PRIORITY_CLASS;
PriorityLevel=Priority-13;
}
SetPriorityClass(GetCurrentProcess(),PriorityClass);
SetThreadPriority(GetCurrentThread(),PriorityLevel);
#ifdef RAR_SMP
ThreadPool::SetPriority(PriorityLevel);
#endif
#endif
}
#endif
// Monotonic clock. Like clock(), returns time passed in CLOCKS_PER_SEC items.
// In Android 5+ and Unix usual clock() returns time spent by all threads
// together, so we cannot use it to measure time intervals anymore.
clock_t MonoClock()
{
return clock();
}
void Wait()
{
if (ErrHandler.UserBreak)
ErrHandler.Exit(RARX_USERBREAK);
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
if (SleepTime!=0)
{
static clock_t LastTime=MonoClock();
if (MonoClock()-LastTime>10*CLOCKS_PER_SEC/1000)
{
Sleep(SleepTime);
LastTime=MonoClock();
}
}
#endif
#if defined(_WIN_ALL)
// Reset system sleep timer to prevent system going sleep.
<API key>(ES_SYSTEM_REQUIRED);
#endif
}
#if defined(_WIN_ALL) && !defined(SFX_MODULE)
void Shutdown(POWER_MODE Mode)
{
HANDLE hToken;
TOKEN_PRIVILEGES tkp;
if (OpenProcessToken(GetCurrentProcess(),<API key>|TOKEN_QUERY,&hToken))
{
<API key>(NULL,SE_SHUTDOWN_NAME,&tkp.Privileges[0].Luid);
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Attributes = <API key>;
<API key>(hToken,FALSE,&tkp,0,(PTOKEN_PRIVILEGES)NULL,0);
}
if (Mode==POWERMODE_OFF)
ExitWindowsEx(EWX_SHUTDOWN|EWX_FORCE,<API key>);
if (Mode==POWERMODE_SLEEP)
SetSuspendState(FALSE,FALSE,FALSE);
if (Mode==POWERMODE_HIBERNATE)
SetSuspendState(TRUE,FALSE,FALSE);
if (Mode==POWERMODE_RESTART)
ExitWindowsEx(EWX_REBOOT|EWX_FORCE,<API key>);
}
bool <API key>(bool Open)
{
const wchar *EventName=L"rar -ioff";
static HANDLE hEvent=NULL;
bool Result=false; // Return false if no other RAR -ioff are running.
if (Open) // Create or open the event.
hEvent=CreateEvent(NULL,FALSE,FALSE,EventName);
else
{
if (hEvent!=NULL)
CloseHandle(hEvent); // Close our event.
// Check if other copies still own the event. While race conditions
// are possible, they are improbable and their harm is minimal.
hEvent=CreateEvent(NULL,FALSE,FALSE,EventName);
Result=GetLastError()==<API key>;
if (hEvent!=NULL)
CloseHandle(hEvent);
}
return Result;
}
#endif
#if defined(_WIN_ALL)
// Load library from Windows System32 folder. Use this function to prevent
// loading a malicious code from current folder or same folder as exe.
HMODULE WINAPI LoadSysLibrary(const wchar *Name)
{
wchar SysDir[NM];
if (GetSystemDirectory(SysDir,ASIZE(SysDir))==0)
return NULL;
MakeName(SysDir,Name,SysDir,ASIZE(SysDir));
return LoadLibrary(SysDir);
}
bool IsUserAdmin()
{
<API key> NtAuthority = <API key>;
PSID AdministratorsGroup;
BOOL b = <API key>(&NtAuthority,2,<API key>,
<API key>, 0, 0, 0, 0, 0, 0, &AdministratorsGroup);
if (b)
{
if (!<API key>( NULL, AdministratorsGroup, &b))
b = FALSE;
FreeSid(AdministratorsGroup);
}
return b!=FALSE;
}
#endif
#ifdef USE_SSE
SSE_VERSION _SSE_Version=GetSSEVersion();
SSE_VERSION GetSSEVersion()
{
int CPUInfo[4];
__cpuid(CPUInfo, 7);
if ((CPUInfo[1] & 0x20)!=0)
return SSE_AVX2;
__cpuid(CPUInfo, 1);
if ((CPUInfo[2] & 0x80000)!=0)
return SSE_SSE41;
if ((CPUInfo[2] & 0x200)!=0)
return SSE_SSSE3;
if ((CPUInfo[3] & 0x4000000)!=0)
return SSE_SSE2;
if ((CPUInfo[3] & 0x2000000)!=0)
return SSE_SSE;
return SSE_NONE;
}
#endif
|
int main(void)
{
int i = 0;
i++, i = (i == 0) ? 42 : 89;
return 0;
}
|
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// (at your option) any later version.
// Parity is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
import marked from 'marked';
import React, { Component, PropTypes } from 'react';
import styles from './Markdown.css';
export default class Marked extends Component {
state = {}
render () {
let { parsed } = this.state;
if (!parsed) {
return null;
}
return <div className={ styles.container } style={ this.props.style } <API key>={ { __html: parsed } } />;
}
componentWillMount () {
this.setState({ parsed: this.parse(this.props.val) });
}
<API key> (newProps) {
if (newProps.val === this.props.val) {
return;
}
this.setState({ parsed: this.parse(newProps.val) });
}
parse (val) {
try {
val = marked(val);
} catch (err) {
console.error(`Marked error when parsing ${val}: ${err}`);
}
return val;
}
static propTypes = {
val: PropTypes.any,
style: PropTypes.object
}
}
|
#ifndef <API key>
#define <API key>
#include "PyPlasma.h"
PY_WRAP_PLASMA(<API key>, class <API key>);
#endif
|
"""Predicted Electoral Vote Count"""
import re
from madcow.util.http import getsoup
from madcow.util.color import ColorLib
from madcow.util import Module, strip_html
class Main(Module):
pattern = re.compile(r'^\s*(election|ev)\s*$', re.I)
help = u'ev - current election 2008 vote prediction'
baseurl = u'http:
def init(self):
if self.madcow is None:
self.colorlib = ColorLib('ansi')
else:
self.colorlib = self.madcow.colorlib
def colorize(self, color, key, val):
return u'%s: %s' % (key, val)
def render(self, node):
pass
def response(self, nick, args, kwargs):
soup = getsoup(self.baseurl)
out = []
for box in soup.find('div', 'score-box').findAll('div', 'box'):
score = []
for key in 'name', 'score':
val = strip_html(box.find('span', key).renderContents()).replace(u'\xa0', u'').strip()
if key == 'name':
if val == u'Obama':
color = 'blue'
elif val == 'Romney':
color = 'red'
else:
color = None
if color:
val = self.colorlib.get_color(color, text=val)
if val:
score.append(val)
if score:
out.append(u'%s: %s' % tuple(score))
return u'%s: %s' % (nick, u', '.join(out))
#from IPython.Shell import IPShellEmbed as S; #S()()
|
/*global rJS, RSVP, initGadgetMixin, loopEventListener, $ */
(function(window, rJS, RSVP, initGadgetMixin, loopEventListener, $) {
"use strict";
function saveSpreadsheet(evt) {
var gadget = this, editor_data, editor_gadget;
return new RSVP.Queue().push(function() {
// Prevent double click
if (evt) {
evt.target.<API key>("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
}).push(function(tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
}).push(function(data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body) {
var data = JSON.parse(body);
// create a property within input
// with name the provided at render time
data.input[gadget.props.name] = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
if (evt) {
evt.target.<API key>("ui-btn")[0].disabled = false;
}
});
}
function waitForSave(gadget) {
return loopEventListener(gadget.props.element.<API key>("save_form")[0], "submit", false, saveSpreadsheet.bind(gadget));
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.<API key>("aq_getAttachment", "jio_getAttachment").<API key>("aq_putAttachment", "jio_putAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key;
// view_
gadget.props.name = options.action.substr(5, options.action.length);
// Use input_id from action definition
if (options.action_definition.configuration.input_id) {
gadget.props.name = options.action_definition.configuration.input_id;
}
return new RSVP.Queue().push(function() {
return RSVP.all([ gadget.aq_getAttachment({
_id: jio_key,
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
var content, result = JSON.parse(result_list[0]), <API key> = {
minSpareRows: 1,
onChange: function() {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(saveSpreadsheet.bind(gadget), 100);
}
};
// if there are previously stored data in input for this sprSheet
if (result.input[gadget.props.name]) {
content = result.input[gadget.props.name];
} else {
content = options.action_definition.configuration.columns;
}
$.extend(<API key>, options.action_definition.configuration.<API key> || {});
return result_list[1].render(JSON.stringify(content), <API key>);
});
}).declareMethod("startService", function() {
var gadget = this;
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return RSVP.all([ tableeditor.startService(), waitForSave(gadget) ]);
});
});
})(window, rJS, RSVP, initGadgetMixin, loopEventListener, $);
|
==================
[[\yii\httpclient\Client]]
[[\yii\httpclient\Client]] [[\yii\base\Component]] [[\yii\di\Container]]
php
return [
'components' => [
'phpNetHttp' => [
'class' => 'yii\httpclient\Client',
'baseUrl' => 'http://uk.php.net',
],
],
];
echo Yii::$app->phpNetHttp->get('docs.php')->send()->content;
[[\yii\httpclient\Client]]
php
use yii\httpclient\Client;
class MyRestApi extends Client
{
public $baseUrl = 'http://my.rest.api/';
public function addUser(array $data)
{
$response = $this->post('users', $data)->send();
if (!$response->isOk) {
throw new \Exception('Unable to add user.');
}
return $response->data['id'];
}
}
[[\yii\httpclient\Client]]
php
use yii\base\Component;
use yii\httpclient\Client;
class MyRestApi extends Component
{
public $baseUrl = 'http://my.rest.api/';
private $_httpClient;
public function getHttpClient()
{
if (!is_object($this->_httpClient)) {
$this->_httpClient = Yii::createObject([
'class' => Client::className(),
'baseUrl' => $this->baseUrl,
]);
}
return $this->_httpClient;
}
public function addUser(array $data)
{
$response = $this->getHttpClient()->post('users', $data)->send();
if (!$response->isOk) {
throw new \Exception('Unable to add user.');
}
return $response->data['id'];
}
}
|
package com.google.clearsilver.jsilver.syntax.node;
import com.google.clearsilver.jsilver.syntax.analysis.*;
@SuppressWarnings("nls")
public final class ANameVariable extends PVariable
{
private TWord _word_;
public ANameVariable()
{
// Constructor
}
public ANameVariable(
@SuppressWarnings("hiding") TWord _word_)
{
// Constructor
setWord(_word_);
}
@Override
public Object clone()
{
return new ANameVariable(
cloneNode(this._word_));
}
public void apply(Switch sw)
{
((Analysis) sw).caseANameVariable(this);
}
public TWord getWord()
{
return this._word_;
}
public void setWord(TWord node)
{
if(this._word_ != null)
{
this._word_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._word_ = node;
}
@Override
public String toString()
{
return ""
+ toString(this._word_);
}
@Override
void removeChild(@SuppressWarnings("unused") Node child)
{
// Remove child
if(this._word_ == child)
{
this._word_ = null;
return;
}
throw new RuntimeException("Not a child.");
}
@Override
void replaceChild(@SuppressWarnings("unused") Node oldChild, @SuppressWarnings("unused") Node newChild)
{
// Replace child
if(this._word_ == oldChild)
{
setWord((TWord) newChild);
return;
}
throw new RuntimeException("Not a child.");
}
}
|
#include <stdint.h>
#include <stdbool.h>
#include <avr/io.h>
#include <util/delay.h>
#include "print.h"
#include "debug.h"
#include "util.h"
#include "matrix.h"
#include "eeconfig.h"
#include "action_layer.h"
#include "backlight.h"
#ifndef DEBOUNCE
# define DEBOUNCE 0
#endif
static uint8_t debouncing = DEBOUNCE;
static matrix_row_t matrix[MATRIX_ROWS];
static matrix_row_t matrix_debouncing[MATRIX_ROWS];
static uint8_t read_rows(void);
static uint8_t read_fwkey(void);
static void init_rows(void);
static void unselect_cols(void);
static void select_col(uint8_t col);
inline
uint8_t matrix_rows(void)
{
return MATRIX_ROWS;
}
inline
uint8_t matrix_cols(void)
{
return MATRIX_COLS;
}
void misc_init(void) {
}
void matrix_init(void)
{
<API key>();
unselect_cols();
init_rows();
for (uint8_t i=0; i < MATRIX_ROWS; i++) {
matrix[i] = 0;
matrix_debouncing[i] = 0;
}
}
uint8_t matrix_scan(void)
{
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
select_col(col);
_delay_us(3);
uint8_t rows = read_rows();
// Use the otherwise unused col: 0 row: 0 for firmware key
if(col == 0) {
rows |= read_fwkey();
}
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<<col);
bool curr_bit = rows & (1<<row);
if (prev_bit != curr_bit) {
matrix_debouncing[row] ^= ((matrix_row_t)1<<col);
if (debouncing) {
dprint("bounce!: "); dprintf("%02X", debouncing); dprintln();
}
debouncing = DEBOUNCE;
}
}
unselect_cols();
}
if (debouncing) {
if (--debouncing) {
_delay_ms(1);
} else {
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
matrix[i] = matrix_debouncing[i];
}
}
}
return 1;
}
bool matrix_is_modified(void)
{
if (debouncing) return false;
return true;
}
inline
bool matrix_is_on(uint8_t row, uint8_t col)
{
return (matrix[row] & ((matrix_row_t)1<<col));
}
inline
matrix_row_t matrix_get_row(uint8_t row)
{
return matrix[row];
}
void matrix_print(void)
{
print("\nr/c 0123456789ABCDEF\n");
for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
xprintf("%02X: %032lb\n", row, bitrev32(matrix_get_row(row)));
}
}
uint8_t matrix_key_count(void)
{
uint8_t count = 0;
for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
count += bitpop32(matrix[i]);
}
return count;
}
/* Row configuration
*
* row: 0 1 2 3 4 5
* pin: PD0 PD1 PD2 PD3 PD5 PB7
*
* Firmware uses pin PE2
*/
static void init_rows(void)
{
DDRD &= ~0b00101111;
PORTD |= 0b00101111;
DDRB &= ~0b10000000;
PORTB |= 0b10000000;
DDRE &= ~0b00000100;
PORTE |= 0b00000100;
}
static uint8_t read_rows(void)
{
return (PIND&(1<<0) ? (1<<0) : 0) |
(PIND&(1<<1) ? (1<<1) : 0) |
(PIND&(1<<2) ? (1<<2) : 0) |
(PIND&(1<<3) ? (1<<3) : 0) |
(PIND&(1<<5) ? (1<<4) : 0) |
(PINB&(1<<7) ? (1<<5) : 0);
}
static uint8_t read_fwkey(void)
{
return PINE&(1<<2) ? 0 : (1<<0);
}
/* Column configuration
*
* col: 0 1 2 3
* pin: PF0 PF1 PC7 PC6
*/
static void unselect_cols(void)
{
DDRF |= 0b00000011;
PORTF &= ~0b00000011;
DDRC |= 0b11000000;
PORTC &= ~0b11000000;
}
static void select_col(uint8_t col)
{
switch (col) {
case 0:
PORTF |= (1<<0);
break;
case 1:
PORTF |= (1<<1);
break;
case 2:
PORTC |= (1<<7);
break;
case 3:
PORTC |= (1<<6);
break;
}
}
|
from chill import *
source('mm.c')
procedure('mm')
#format: rose
loop(0)
known('ambn > 0')
known('an > 0')
known('bm > 0')
permute([3,1,2])
print_code()
|
# This file is part of ycmd.
# ycmd is free software: you can redistribute it and/or modify
# (at your option) any later version.
# ycmd is distributed in the hope that it will be useful,
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
from ycmd.utils import re, SplitLines
C_STYLE_COMMENT = '/\\*(?:\n|.)*?\\*/'
CPP_STYLE_COMMENT = '
<API key> = '
# Anything inside single quotes, '...', but mind:
# 1. that the starting single quote is not escaped
# 2. the escaped slash (\\)
# 3. the escaped single quote inside the string
SINGLE_QUOTE_STRING = r"(?<!\\)'(?:\\\\|\\'|.)*?'"
# Anything inside double quotes, "...", but mind:
# 1. that the starting double quote is not escaped
# 2. the escaped slash (\\)
# 3. the escaped double quote inside the string
DOUBLE_QUOTE_STRING = r'(?<!\\)"(?:\\\\|\\"|.)*?"'
# Anything inside back quotes, `...`, but mind:
# 1. that the starting back quote is not escaped
# 2. the escaped slash (\\)
# 3. the escaped back quote inside the string
BACK_QUOTE_STRING = r'(?<!\\)`(?:\\\\|\\`|.)*?`'
# Python-style multiline single-quote string
<API key> = ""
# Python-style multiline double-quote string
<API key> = ''
<API key> = re.compile( "|".join( [
C_STYLE_COMMENT,
CPP_STYLE_COMMENT,
<API key>,
<API key>,
<API key>,
SINGLE_QUOTE_STRING,
DOUBLE_QUOTE_STRING ] ), re.MULTILINE )
<API key> = {
# Spec:
'cpp': re.compile( "|".join( [ C_STYLE_COMMENT,
CPP_STYLE_COMMENT,
SINGLE_QUOTE_STRING,
DOUBLE_QUOTE_STRING ] ), re.MULTILINE ),
# Spec:
'go': re.compile( "|".join( [ C_STYLE_COMMENT,
CPP_STYLE_COMMENT,
SINGLE_QUOTE_STRING,
DOUBLE_QUOTE_STRING,
BACK_QUOTE_STRING ] ), re.MULTILINE ),
# Spec:
'python': re.compile( "|".join( [ <API key>,
<API key>,
<API key>,
SINGLE_QUOTE_STRING,
DOUBLE_QUOTE_STRING ] ), re.MULTILINE ),
# Spec:
'rust': re.compile( "|".join( [ CPP_STYLE_COMMENT,
SINGLE_QUOTE_STRING,
DOUBLE_QUOTE_STRING ] ), re.MULTILINE )
}
for filetype in [ 'c', 'cuda', 'objc', 'objcpp', 'javascript', 'typescript' ]:
<API key>[ filetype ] = (
<API key>[ 'cpp' ] )
# At least c++ and javascript support unicode identifiers, and identifiers may
# starting with an 'alpha' character or underscore. i.e. not starting with a
# 'digit'. The following regex will match:
# - A character which is alpha or _. That is a character which is NOT:
# - a digit (\d)
# - non-alphanumeric
# - not an underscore
# (The latter two come from \W which is the negation of \w)
# - Followed by any alphanumeric or _ characters
<API key> = re.compile( r"[^\W\d]\w*", re.UNICODE )
<API key> = {
# Spec:
# Default identifier plus the dollar sign.
'javascript': re.compile( r"(?:[^\W\d]|\$)[\w$]*", re.UNICODE ),
'css': re.compile( r"-?[^\W\d][\w-]*", re.UNICODE ),
# But not quite since not everything we want to pull out is a tag name. We
# also want attribute names (and probably unquoted attribute values).
# And we also want to ignore common template chars like `}` and `{`.
'html': re.compile( r"[a-zA-Z][^\s/>='\"}{\.]*", re.UNICODE ),
# Section 10.3.2.
# Can be any sequence of '.', '_' and alphanum BUT can't start with:
# - '.' followed by digit
# - digit
'r': re.compile( r"(?!(?:\.\d|\d|_))[\.\w]+", re.UNICODE ),
# Section: Symbols
'clojure': re.compile(
r"[-\*\+!_\?:\.a-zA-Z][-\*\+!_\?:\.\w]*/?[-\*\+!_\?:\.\w]*",
re.UNICODE ),
# Section 2.4
'haskell': re.compile( r"[_a-zA-Z][\w']+", re.UNICODE ),
# Spec: ?
# Colons are often used in labels (e.g. \label{fig:foobar}) so we accept
# them in the middle of an identifier but not at its extremities. We also
# accept dashes for compound words.
'tex': re.compile( r"[^\W\d](?:[\w:-]*\w)?", re.UNICODE ),
'perl6': re.compile( r"[_a-zA-Z](?:\w|[-'](?=[_a-zA-Z]))*", re.UNICODE ),
'scheme': re.compile( r"\+|\-|\.\.\.|"
r"(?:->|(:?\\x[0-9A-Fa-f]+;|[!$%&*/:<=>?~^]|[^\W\d]))"
r"(?:\\x[0-9A-Fa-f]+;|[-+.@!$%&*/:<=>?~^\w])*",
re.UNICODE ),
}
<API key>[ 'typescript' ] = (
<API key>[ 'javascript' ] )
<API key>[ 'scss' ] = <API key>[ 'css' ]
<API key>[ 'sass' ] = <API key>[ 'css' ]
<API key>[ 'less' ] = <API key>[ 'css' ]
<API key>[ 'elisp' ] = (
<API key>[ 'clojure' ] )
<API key>[ 'lisp' ] = (
<API key>[ 'clojure' ] )
def <API key>( filetype ):
return <API key>.get(
filetype, <API key> )
def <API key>( filetype ):
return <API key>.get( filetype, <API key> )
def <API key>( regex_match ):
return '\n' * ( len( SplitLines( regex_match.group( 0 ) ) ) - 1 )
def <API key>( text, filetype = None ):
return <API key>( filetype ).sub(
<API key>, text )
def <API key>( text, filetype = None ):
return re.findall( <API key>( filetype ), text )
def IsIdentifier( text, filetype = None ):
if not text:
return False
regex = <API key>( filetype )
match = regex.match( text )
return match and match.end() == len( text )
# index is 0-based and EXCLUSIVE, so ("foo.", 3) -> 0
# Works with both unicode and str objects.
# Returns the index on bad input.
def <API key>( text, index, filetype = None ):
if not text or index < 1 or index > len( text ):
return index
for i in range( index ):
if IsIdentifier( text[ i : index ], filetype ):
return i
return index
# If the index is not on a valid identifier, it searches forward until a valid
# identifier is found. Returns the identifier.
def IdentifierAtIndex( text, index, filetype = None ):
if index > len( text ):
return ''
for match in <API key>( filetype ).finditer( text ):
if match.end() > index:
return match.group()
return ''
|
#include <r_anal.h>
#include <r_lib.h>
#include <capstone/capstone.h>
#include <capstone/arm.h>
#include "esil.h"
/* arm64 */
#define IMM64(x) insn->detail->arm64.operands[x].imm
/* arm32 */
#define REG(x) cs_reg_name (*handle, insn->detail->arm.operands[x].reg)
#define REG64(x) cs_reg_name (*handle, insn->detail->arm64.operands[x].reg)
#define REGID(x) insn->detail->arm.operands[x].reg
#define IMM(x) insn->detail->arm.operands[x].imm
#define IMM64(x) insn->detail->arm64.operands[x].imm
#define MEMBASE(x) cs_reg_name(*handle, insn->detail->arm.operands[x].mem.base)
#define MEMBASE64(x) cs_reg_name(*handle, insn->detail->arm64.operands[x].mem.base)
#define REGBASE(x) insn->detail->arm.operands[x].mem.base
#define REGBASE64(x) insn->detail->arm64.operands[x].mem.base
#define MEMINDEX(x) insn->detail->arm.operands[x].mem.index
#define MEMINDEX64(x) insn->detail->arm64.operands[x].mem.index
#define MEMDISP(x) insn->detail->arm.operands[x].mem.disp
#define MEMDISP64(x) insn->detail->arm64.operands[x].mem.disp
#define ISREG(x) insn->detail->arm.operands[x].type == ARM_OP_REG
#define ISREG64(x) insn->detail->arm64.operands[x].type == ARM64_OP_REG
// TODO scale and disp
/* arm64 */
static const char *arg(RAnal *a, csh *handle, cs_insn *insn, char *buf, int n) {
buf[0] = 0;
switch (insn->detail->arm.operands[n].type) {
case ARM_OP_REG:
sprintf (buf, "%s",
cs_reg_name (*handle,
insn->detail->arm.operands[n].reg));
break;
case ARM_OP_IMM:
if (a->bits == 64) {
// 64bit only
sprintf (buf, "%"PFMT64d, (ut64)
insn->detail->arm.operands[n].imm);
} else {
// 32bit only
sprintf (buf, "%"PFMT64d, (ut64)(ut32)
insn->detail->arm.operands[n].imm);
}
break;
case ARM_OP_MEM:
break;
case ARM_OP_FP:
sprintf (buf, "%lf", insn->detail->arm.operands[n].fp);
break;
default:
break;
}
return buf;
}
#define ARG(x) arg(a, handle, insn, str[x], x)
#define OPCALL(opchar) arm64math(a, op, addr, buf, len, handle, insn, opchar)
static void arm64math(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn, const char *opchar) {
const char *r0 = REG64(0);
const char *r1 = REG64(1);
if (ISREG64(2)) {
const char *r2 = REG64(2);
if (r0 == r1) {
r_strbuf_setf (&op->esil, "%s,%s,%s=", r2, r0, opchar);
} else {
r_strbuf_setf (&op->esil, "%s,%s,%s,%s,=", r2, r1, opchar, r0);
}
} else {
ut64 i2 = IMM64(2);
if (r0 == r1) {
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,%s=", i2, r0, opchar);
} else {
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,%s,%s,=", i2, r1, opchar, r0);
}
}
}
static int analop64_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn) {
r_strbuf_init (&op->esil);
r_strbuf_set (&op->esil, "");
switch (insn->id) {
case ARM64_INS_REV: {
const char *r0 = REG64(0);
const char *r1 = REG64(1);
r_strbuf_setf (&op->esil,
"24,0xff,%s,&,<<,%s,=,"
"16,0xff,8,%s,>>,&,<<,%s,|=,"
"8,0xff,16,%s,>>,&,<<,%s,|=,"
"0xff,24,%s,>>,&,%s,|=,",
r1, r0, r1, r0, r1, r0, r1, r0);
} break;
case ARM64_INS_ADR:
// TODO: must be 21bit signed
r_strbuf_setf (&op->esil,
"pc,%d,+,%s,=",IMM64(1), REG64(0));
break;
case ARM64_INS_MADD:
r_strbuf_setf (&op->esil,
"%s,%s,*,%s,+,%s,=",REG64(2),REG64(1),REG64(3), REG64(0));
break;
case ARM64_INS_ADD: OPCALL("+"); break;
case ARM64_INS_SUB: OPCALL("-"); break;
case ARM64_INS_MUL: OPCALL("*"); break;
case ARM64_INS_AND: OPCALL("&"); break;
case ARM64_INS_ORR: OPCALL("|"); break;
case ARM64_INS_STURB: // sturb wzr, [x9, 0xffffffffffffffff]
// TODO
break;
case ARM64_INS_EOR:
r_strbuf_setf (&op->esil, "%s,%s,%s,^,=",
REG64(2), REG64(1), REG64(0));
break;
case ARM64_INS_NOP:
r_strbuf_setf (&op->esil, "");
break;
case ARM64_INS_FDIV:
case ARM64_INS_SDIV:
case ARM64_INS_UDIV:
/* TODO: support WZR XZR to specify 32, 64bit op */
r_strbuf_setf (&op->esil, "%s,%s,/=", REG64 (1), REG64 (0));
break;
case ARM64_INS_B:
r_strbuf_setf (&op->esil, "%"PFMT64d",pc,=", (ut64)addr + IMM64 (0));
break;
case ARM64_INS_BL:
r_strbuf_setf (&op->esil, "pc,lr,=,%"PFMT64d",pc,=", addr + IMM64 (0));
break;
case ARM64_INS_BLR:
// XXX
r_strbuf_setf (&op->esil, "pc,lr,=,%d,pc,=", IMM64 (0));
break;
case ARM64_INS_LDUR: // ldr x6, [x6,0xf90]
case ARM64_INS_LDR: // ldr x6, [x6,0xf90]
r_strbuf_setf (&op->esil, "%s,%d,+,[],%s,=",
MEMBASE64(1), MEMDISP64(1), REG64(0));
break;
case ARM64_INS_LDRSB:
case ARM64_INS_LDRB: // ldr x6, [x6,0xf90]
r_strbuf_setf (&op->esil, "%s,%d,+,[1],%s,=",
MEMBASE64(1), MEMDISP64(1), REG64(0));
break;
case ARM64_INS_TST: // cmp w8, 0xd
case ARM64_INS_CMP: // cmp w8, 0xd
// update esil, cpu flags
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,==,$z,=",
IMM64(1), REG64(0));
break;
case ARM64_INS_FCSEL:
case ARM64_INS_CSEL: // CSEL w8, w13, w14, eq
// TODO: w8 = eq? w13: w14
// COND64(4) { ARM64_CC_EQ, NE, HS, ...
r_strbuf_setf (&op->esil, "$z,?{,%s,}{,%s,},%s,=",
REG64(1), REG64(2), REG64(0));
break;
case ARM64_INS_STRB:
r_strbuf_setf (&op->esil, "%s,%s,%"PFMT64d",+,=[1]",
REG64(0), MEMBASE64(1), MEMDISP64(1));
case ARM64_INS_STUR:
case ARM64_INS_STR: // str x6, [x6,0xf90]
case ARM64_INS_STRH:
r_strbuf_setf (&op->esil, "%s,%s,%"PFMT64d",+,=[]",
REG64(0), MEMBASE64(1), MEMDISP64(1));
break;
case ARM64_INS_CBZ:
r_strbuf_setf (&op->esil, "%s,?{,%"PFMT64d",pc,=,}",
REG64(0), IMM64(1));
break;
case ARM64_INS_CBNZ:
r_strbuf_setf (&op->esil, "%s,!,?{,%"PFMT64d",pc,=,}",
REG64(0), IMM64(1));
break;
case ARM64_INS_TBZ:
// tbnz x0, 4, label
// if ((1<<4) & x0) goto label;
r_strbuf_setf (&op->esil, "%d,1,<<=,%s,&,!,?{,%"PFMT64d",pc,=,}",
IMM64(1), REG64(0), IMM64(2));
break;
case ARM64_INS_TBNZ:
// tbnz x0, 4, label
// if ((1<<4) & x0) goto label;
r_strbuf_setf (&op->esil, "%d,1,<<=,%s,&,?{,%"PFMT64d",pc,=,}",
IMM64(1), REG64(0), IMM64(2));
break;
case ARM64_INS_STP: // str x6, x7, [x6,0xf90]
{
int disp = (int)MEMDISP64(2);
char sign = disp>=0?'+':'-';
ut64 abs = disp>=0? MEMDISP64(2): -MEMDISP64(2);
r_strbuf_setf (&op->esil,
"%s,%s,%"PFMT64d",%c,=[],"
"%s,%s,%"PFMT64d",%c,%d,+,=[]",
REG64(0), MEMBASE64(2), abs, sign,
REG64(1), MEMBASE64(2), abs, sign, 8);
}
break;
case ARM64_INS_LDP: // ldp x29, x30, [sp], 0x10
{
int disp = (int)MEMDISP64(2);
char sign = disp>=0?'+':'-';
ut64 abs = disp>=0? MEMDISP64(2): -MEMDISP64(2);
r_strbuf_setf (&op->esil,
"%s,%s,%"PFMT64d",%c,=[],"
"%s,%s,%"PFMT64d",%c,%d,+,=[]",
REG64(0), MEMBASE64(2), abs, sign,
REG64(1), MEMBASE64(2), abs, sign, 8);
}
break;
case ARM64_INS_ADRP:
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,=", IMM64 (1), REG64 (0));
break;
case ARM64_INS_MOV:
r_strbuf_setf (&op->esil, "%s,%s,=", REG64 (1), REG64 (0));
break;
case ARM64_INS_MOVK: // movk w8, 0x1290
// XXX: wrongly implemented
r_strbuf_setf (&op->esil, "%"PFMT64d",%s,=", IMM64 (1), REG64 (0));
break;
case ARM64_INS_MOVZ:
// XXX: wrongly implemented
r_strbuf_setf (&op->esil, "%d,%s,=", IMM64 (1), REG64 (0));
break;
case ARM64_INS_RET:
r_strbuf_setf (&op->esil, "lr,pc,=");
break;
}
return 0;
}
static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len, csh *handle, cs_insn *insn) {
int i;
char str[32][32];
r_strbuf_init (&op->esil);
r_strbuf_set (&op->esil, "");
switch (insn->detail->arm.cc) {
case ARM_CC_AL:
// no condition
break;
case ARM_CC_EQ:
r_strbuf_setf (&op->esil, "zf,0,?,");
break;
case ARM_CC_NE:
r_strbuf_setf (&op->esil, "zf,!,0,?,");
break;
case ARM_CC_GT:
case ARM_CC_LE:
break;
default:
break;
}
// TODO: PREFIX CONDITIONAL
switch (insn->id) {
case ARM_INS_PUSH:
#if 0
PUSH { r4, r5, r6, r7, lr }
4,sp,-=,lr,sp,=[4],
4,sp,-=,r7,sp,=[4],
4,sp,-=,r6,sp,=[4],
4,sp,-=,r5,sp,=[4],
4,sp,-=,r4,sp,=[4]
20,sp,-=,r4,r5,r6,r7,lr,5,sp,=[*]
#endif
r_strbuf_setf (&op->esil, "%d,sp,-=,",
4 * insn->detail->arm.op_count);
for (i=0; i<insn->detail->arm.op_count; i++) {
r_strbuf_appendf (&op->esil, "%s,", REG (i));
}
r_strbuf_appendf (&op->esil, "%d,sp,=[*]",
insn->detail->arm.op_count);
break;
case ARM_INS_STM:
r_strbuf_setf (&op->esil, "");
for (i=1; i<insn->detail->arm.op_count; i++) {
r_strbuf_appendf (&op->esil, "%s,%s,%d,+,=[4],",
REG (i), ARG (0), i*4);
}
break;
case ARM_INS_POP:
#if 0
POP { r4,r5, r6}
r4,r5,r6,3,sp,[*],12,sp,+=
#endif
r_strbuf_setf (&op->esil, "");
for (i=0; i<insn->detail->arm.op_count; i++) {
r_strbuf_appendf (&op->esil, "%s,", REG (i));
}
r_strbuf_appendf (&op->esil, "%d,sp,[*],",
insn->detail->arm.op_count);
r_strbuf_appendf (&op->esil, "%d,sp,+=",
4 * insn->detail->arm.op_count);
break;
case ARM_INS_LDM:
for (i=1; i<insn->detail->arm.op_count; i++) {
r_strbuf_appendf (&op->esil, "%s,%d,+,[4],%s,=",
ARG (0), i*4, REG (i));
}
break;
case ARM_INS_CMP:
r_strbuf_appendf (&op->esil, "%s,%s,==", ARG(1), ARG(0));
break;
case ARM_INS_LSL:
// suffix 'S' forces conditional flag to be updated
r_strbuf_appendf (&op->esil, "%s,%s,<<=", ARG(1), ARG(0));
break;
case ARM_INS_LSR:
// suffix 'S' forces conditional flag to be updated
r_strbuf_appendf (&op->esil, "%s,%s,>>=", ARG(1), ARG(0));
break;
case ARM_INS_B:
r_strbuf_appendf (&op->esil, "%s,pc,=", ARG(0));
break;
case ARM_INS_BL:
case ARM_INS_BLX:
r_strbuf_appendf (&op->esil, "4,pc,+,lr,=,%s,pc,=", ARG(0));
break;
case ARM_INS_MOVT:
r_strbuf_appendf (&op->esil, "16,%s,<<,%s,|=", ARG(1), REG(0));
break;
case ARM_INS_MOV:
case ARM_INS_VMOV:
case ARM_INS_MOVW:
r_strbuf_appendf (&op->esil, "%s,%s,=", ARG(1), REG(0));
break;
case ARM_INS_SSUB16:
case ARM_INS_SSUB8:
case ARM_INS_SUB:
if (!strcmp (ARG(2), "")) {
if (!strcmp (ARG(0), ARG(1))) {
r_strbuf_appendf (&op->esil, "0,%s,=", ARG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%s,-=",
ARG(1), ARG(0));
}
} else {
if (!strcmp (ARG(0), ARG(1))) {
r_strbuf_appendf (&op->esil, "%s,%s,-=", ARG(2), ARG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%s,-,%s,=",
ARG(2), ARG(1), ARG(0));
}
}
break;
case ARM_INS_SADD16:
case ARM_INS_SADD8:
case ARM_INS_ADD:
if (!strcmp (ARG(2), "")) {
if (!strcmp (ARG(1), "pc")) {
// that 2>>2<< is for & 0xfffffffc
// (the address of the current instruction + 4) AND &FFFFFFFC.
// to clear 2 lower bits
r_strbuf_appendf (&op->esil,
"4,%"PFMT64d",+,%s,+=", op->addr, ARG(0));
//"2,2,4,%s,+,>>,<<,%s,+=", ARG(1), ARG(0));
//"2,2,4,%"PFMT64d",+,>>,<<,%s,+=", op->addr, ARG(0));
//"4,%s,+,0xfffffffc,&,%s,+=", ARG(1), ARG(0));
} else {
// THUMB
if (!strcmp (ARG(0), ARG(1))) {
r_strbuf_appendf (&op->esil, "2,%s,*=", ARG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%s,+=", ARG(1), ARG(0));
}
}
} else {
if (!strcmp (ARG(0),ARG(1))) {
r_strbuf_appendf (&op->esil, "%s,%s,+=", ARG(2), ARG(0));
} else if (!strcmp (ARG(2),"0")) {
r_strbuf_appendf (&op->esil, "%s,%s,=", ARG(1), ARG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%s,+,%s,=", ARG(2), ARG(1), ARG(0));
}
}
break;
case ARM_INS_STR:
r_strbuf_appendf (&op->esil, "%s,%s,%d,+,=[4]",
REG(0), MEMBASE(1), MEMDISP(1));
break;
case ARM_INS_STRB:
r_strbuf_appendf (&op->esil, "%s,%s,%d,+,=[1]",
REG(0), MEMBASE(1), MEMDISP(1));
break;
case ARM_INS_LDR:
addr &= ~3LL;
if (MEMDISP(1)<0) {
if (REGBASE(1) == ARM_REG_PC) {
int pcdelta = 8;
switch (a->bits) {
case 32:
op->ptr = addr + 8 - MEMDISP(1);
break;
case 16:
pcdelta = op->size;
op->refptr = 4;
op->ptr = addr + pcdelta - MEMDISP(1);
break;
}
r_strbuf_appendf (&op->esil, "%d,%s,+,%d,-,[4],%s,=",
pcdelta, MEMBASE(1), -MEMDISP(1), REG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%d,-,[4],%s,=",
MEMBASE(1), -MEMDISP(1), REG(0));
}
} else {
if (REGBASE(1) == ARM_REG_PC) {
int pcdelta = 8;
switch (a->bits) {
case 16:
pcdelta = op->size * 2;
op->refptr = 4;
op->ptr = addr + pcdelta + MEMDISP(1);
break;
case 32:
pcdelta = 8;
op->ptr = addr + 8 + MEMDISP(1);
op->refptr = 4;
break;
}
r_strbuf_appendf (&op->esil, "%d,%s,+,%d,+,[4],%s,=",
pcdelta, MEMBASE(1), MEMDISP(1), REG(0));
} else {
r_strbuf_appendf (&op->esil, "%s,%d,+,[4],%s,=",
MEMBASE(1), MEMDISP(1), REG(0));
}
op->refptr = 4;
}
break;
case ARM_INS_LDRD:
case ARM_INS_LDRB:
r_strbuf_appendf (&op->esil, "%s,%d,+,[1],%s,=",
MEMBASE(1), MEMDISP(1), REG(0));
break;
default:
break;
}
return 0;
}
static void anop64 (RAnalOp *op, cs_insn *insn) {
ut64 addr = op->addr;
switch (insn->id) {
case ARM64_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
break;
case ARM64_INS_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
break;
case ARM64_INS_ADD:
op->type = R_ANAL_OP_TYPE_ADD;
break;
case ARM64_INS_CSEL:
case ARM64_INS_FCSEL:
op->type = R_ANAL_OP_TYPE_CMOV;
break;
case ARM64_INS_MOV:
case ARM64_INS_MOVI:
case ARM64_INS_MOVK:
case ARM64_INS_MOVN:
case ARM64_INS_SMOV:
case ARM64_INS_UMOV:
case ARM64_INS_FMOV:
op->type = R_ANAL_OP_TYPE_MOV;
break;
case ARM64_INS_MOVZ:
op->type = R_ANAL_OP_TYPE_MOV;
op->ptr = 0LL;
op->ptrsize = 8;
break;
case ARM64_INS_UXTB:
op->type = R_ANAL_OP_TYPE_MOV;
op->ptr = 0LL;
op->ptrsize = 4;
break;
case ARM64_INS_UXTH:
op->type = R_ANAL_OP_TYPE_MOV;
op->ptr = 0LL;
op->ptrsize = 2;
break;
case ARM64_INS_CCMP:
case ARM64_INS_CCMN:
case ARM64_INS_CMP:
case ARM64_INS_TST:
op->type = R_ANAL_OP_TYPE_CMP;
break;
case ARM64_INS_ROR:
op->type = R_ANAL_OP_TYPE_ROR;
break;
case ARM64_INS_ORR:
case ARM64_INS_ORN:
op->type = R_ANAL_OP_TYPE_OR;
break;
case ARM64_INS_EOR:
op->type = R_ANAL_OP_TYPE_XOR;
break;
case ARM64_INS_LSL:
op->type = R_ANAL_OP_TYPE_SHL;
break;
case ARM64_INS_ASR:
case ARM64_INS_LSR:
op->type = R_ANAL_OP_TYPE_SHR;
break;
case ARM64_INS_STRB:
case ARM64_INS_STR:
op->type = <API key>;
if (REGBASE64(1) == ARM64_REG_X29) {
op->stackop = R_ANAL_STACK_SET;
op->stackptr = 0;
op->ptr = -MEMDISP64(1);
}
break;
case ARM64_INS_LDR:
case ARM64_INS_LDRB:
op->type = R_ANAL_OP_TYPE_LOAD;
if (REGBASE64(1) == ARM64_REG_X29) {
op->stackop = R_ANAL_STACK_GET;
op->stackptr = 0;
op->ptr = MEMDISP64(1);
}
break;
case ARM64_INS_RET:
op->type = R_ANAL_OP_TYPE_RET;
break;
case ARM64_INS_BL: // bl 0x89480
op->type = R_ANAL_OP_TYPE_CALL;
op->jump = IMM64(0);
break;
case ARM64_INS_BLR: // blr x0
op->type = <API key>;
//op->jump = IMM64(0);
break;
case ARM64_INS_CBZ:
case ARM64_INS_CBNZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = IMM64(1);
op->fail = addr+op->size;
break;
case ARM64_INS_TBZ:
case ARM64_INS_TBNZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = IMM64(2);
op->fail = addr+op->size;
break;
case ARM64_INS_BR:
op->type = R_ANAL_OP_TYPE_UJMP;
op->eob = 1;
break;
case ARM64_INS_B:
// BX LR == RET
if (insn->detail->arm64.operands[0].reg == ARM64_REG_LR) {
op->type = R_ANAL_OP_TYPE_RET;
} else if (insn->detail->arm64.cc) {
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = IMM64(0);
op->fail = addr+op->size;
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->jump = IMM64(0);
}
break;
default:
break;
}
}
static void anop32 (RAnalOp *op, cs_insn *insn) {
ut64 addr = op->addr;
int i;
switch (insn->id) {
#if 0
If PC is specified for Rn, the value used is the address of the instruction plus 4.
These instructions cause a PC-relative forward branch using a table of single byte offsets (TBB) or halfword offsets (TBH). Rn provides a pointer to the table, and Rm supplies an index into the table. The branch length is twice the value of the byte (TBB) or the halfword (TBH) returned from the table. The target of the branch table must be in the same execution state.
jmp $$ + 4 + ( [delta] * 2 )
#endif
case ARM_INS_TBH: // half word table
case ARM_INS_TBB: // byte table
op->type = R_ANAL_OP_TYPE_UJMP;
// TABLE JUMP used for switch statements
break;
case ARM_INS_IT:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = addr + insn->size;
op->fail = addr + insn->size + 2;
// XXX what if instruction is 4
break;
case ARM_INS_NOP:
op->type = R_ANAL_OP_TYPE_NOP;
break;
case ARM_INS_POP:
case ARM_INS_FLDMDBX:
case ARM_INS_FLDMIAX:
case ARM_INS_LDMDA:
case ARM_INS_LDMDB:
case ARM_INS_LDMIB:
case ARM_INS_LDM:
op->type = R_ANAL_OP_TYPE_POP;
for (i = 0; i < insn->detail->arm.op_count; i++) {
if (insn->detail->arm.operands[i].type == ARM_OP_REG &&
insn->detail->arm.operands[i].reg == ARM_REG_PC) {
if (insn->detail->arm.cc == ARM_CC_AL)
op->type = R_ANAL_OP_TYPE_RET;
else
op->type = R_ANAL_OP_TYPE_CRET;
break;
}
}
break;
case ARM_INS_SUB:
op->type = R_ANAL_OP_TYPE_SUB;
if (ISREG(0)) {
if (REGID(0) == ARM_REG_SP) {
// 0x00008254 10d04de2 sub sp, sp, 0x10
op->stackop = R_ANAL_STACK_INC;
op->stackptr = IMM (2);
}
}
break;
case ARM_INS_ADD:
op->type = R_ANAL_OP_TYPE_ADD;
if (REGID(1) == ARM_REG_PC) {
op->ptr = addr + 8 + IMM(2);
op->refptr = 0;
}
break;
case ARM_INS_VMOV:
op->type = R_ANAL_OP_TYPE_MOV;
op->family = <API key>;
break;
case ARM_INS_MOV:
case ARM_INS_MOVT:
case ARM_INS_MOVW:
case ARM_INS_VMOVL:
case ARM_INS_VMOVN:
case ARM_INS_VQMOVUN:
case ARM_INS_VQMOVN:
op->type = R_ANAL_OP_TYPE_MOV;
break;
case ARM_INS_UDF:
op->type = R_ANAL_OP_TYPE_TRAP;
break;
case ARM_INS_SVC:
op->type = R_ANAL_OP_TYPE_SWI;
break;
case ARM_INS_AND:
op->type = R_ANAL_OP_TYPE_AND;
break;
case ARM_INS_CMP:
case ARM_INS_TST:
op->type = R_ANAL_OP_TYPE_CMP;
break;
case ARM_INS_ROR:
case ARM_INS_ORN:
case ARM_INS_LSL:
case ARM_INS_LSR:
break;
//case ARM_INS_POP:
case ARM_INS_PUSH:
case ARM_INS_STR:
op->type = <API key>;
// 0x00008160 04202de5 str r2, [sp, -4]!
// 0x000082a0 28000be5 str r0, [fp, -0x28]
if (REGBASE(1) == ARM_REG_FP) {
op->stackop = R_ANAL_STACK_SET;
op->stackptr = 0;
op->ptr = MEMDISP(1);
}
break;
case ARM_INS_LDR:
case ARM_INS_LDRD:
case ARM_INS_LDRB:
case ARM_INS_LDRBT:
case ARM_INS_LDREX:
case ARM_INS_LDREXB:
case ARM_INS_LDREXD:
case ARM_INS_LDREXH:
case ARM_INS_LDRH:
case ARM_INS_LDRHT:
case ARM_INS_LDRSB:
case ARM_INS_LDRSBT:
case ARM_INS_LDRSH:
case ARM_INS_LDRSHT:
case ARM_INS_LDRT:
// 0x000082a8 28301be5 ldr r3, [fp, -0x28]
if (insn->detail->arm.operands[0].reg == ARM_REG_PC) {
op->type = R_ANAL_OP_TYPE_UJMP;
} else {
op->type = R_ANAL_OP_TYPE_LOAD;
}
if (REGBASE(1) == ARM_REG_FP) {
op->stackop = R_ANAL_STACK_GET;
op->stackptr = 0;
op->ptr = MEMDISP(1);
}
break;
case ARM_INS_BL:
case ARM_INS_BLX:
op->type = R_ANAL_OP_TYPE_CALL;
op->jump = IMM(0);
break;
case ARM_INS_CBZ:
case ARM_INS_CBNZ:
op->type = R_ANAL_OP_TYPE_CJMP;
op->jump = IMM(1);
op->fail = addr+op->size;
break;
case ARM_INS_B:
case ARM_INS_BX:
case ARM_INS_BXJ:
// BX LR == RET
if (insn->detail->arm.operands[0].reg == ARM_REG_LR) {
op->type = R_ANAL_OP_TYPE_RET;
} else if (insn->detail->arm.cc) {
if (insn->detail->arm.cc == ARM_CC_INVALID) {
op->type = R_ANAL_OP_TYPE_ILL;
} else if (insn->detail->arm.cc == ARM_CC_AL) {
op->type = R_ANAL_OP_TYPE_JMP;
} else {
op->type = R_ANAL_OP_TYPE_CJMP;
}
if (REGID(1)==ARM_REG_PC) {
op->jump = addr+op->size;
} else {
op->jump = (ut64) (ut32)IMM(0);
// op->jump = addr+op->size;
}
op->fail = addr+op->size;
if (op->jump == op->fail) {
op->type = R_ANAL_OP_TYPE_JMP;
op->fail = UT64_MAX;
}
} else {
op->type = R_ANAL_OP_TYPE_JMP;
op->jump = IMM(0);
}
break;
default:
break;
}
}
static int analop(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf, int len) {
static csh handle = 0;
static int omode = -1;
static int obits = 32;
cs_insn *insn = NULL;
int mode = (a->bits==16)? CS_MODE_THUMB: CS_MODE_ARM;
int n, ret;
mode |= (a->big_endian)? CS_MODE_BIG_ENDIAN: <API key>;
if (mode != omode || a->bits != obits) {
cs_close (&handle);
handle = 0; // unnecessary
omode = mode;
obits = a->bits;
}
op->type = R_ANAL_OP_TYPE_NULL;
op->size = (a->bits==16)? 2: 4;
op->stackop = R_ANAL_STACK_NULL;
op->delay = 0;
op->jump = op->fail = -1;
op->addr = addr;
op->ptr = op->val = -1;
op->refptr = 0;
r_strbuf_init (&op->esil);
if (handle == 0) {
ret = (a->bits==64)?
cs_open (CS_ARCH_ARM64, mode, &handle):
cs_open (CS_ARCH_ARM, mode, &handle);
cs_option (handle, CS_OPT_DETAIL, CS_OPT_ON);
if (ret != CS_ERR_OK) {
return -1;
}
}
n = cs_disasm (handle, (ut8*)buf, len, addr, 1, &insn);
if (n<1) {
op->type = R_ANAL_OP_TYPE_ILL;
} else {
op->size = insn->size;
if (a->bits == 64) {
anop64 (op, insn);
if (a->decode) {
analop64_esil (a, op, addr, buf, len, &handle, insn);
}
} else {
anop32 (op, insn);
if (a->decode) {
analop_esil (a, op, addr, buf, len, &handle, insn);
}
}
cs_free (insn, n);
}
// cs_close (&handle);
return op->size;
}
static int set_reg_profile(RAnal *anal) {
const char *p;
if (anal->bits == 64) {
p = \
"=pc pc\n"
"=sp sp\n"
"=bp x29\n"
"=a0 x0\n"
"=a1 x1\n"
"=a2 x2\n"
"=a3 x3\n"
"=zf zf\n"
"=sf nf\n"
"=of vf\n"
"=cf cf\n"
"=sn ox0\n"
/* 32bit sub-registers */
"gpr w0 .32 0 0\n"
"gpr w1 .32 8 0\n"
"gpr w2 .32 16 0\n"
"gpr w3 .32 24 0\n"
"gpr w4 .32 32 0\n"
"gpr w5 .32 40 0\n"
"gpr w6 .32 48 0\n"
"gpr w7 .32 56 0\n"
"gpr w8 .32 64 0\n"
"gpr w9 .32 72 0\n"
"gpr w10 .32 80 0\n"
"gpr w11 .32 88 0\n"
"gpr w12 .32 96 0\n"
"gpr w13 .32 104 0\n"
"gpr w14 .32 112 0\n"
"gpr w15 .32 120 0\n"
"gpr w16 .32 128 0\n"
"gpr w17 .32 136 0\n"
"gpr w18 .32 144 0\n"
"gpr w19 .32 152 0\n"
"gpr w20 .32 160 0\n"
"gpr w21 .32 168 0\n"
"gpr w22 .32 176 0\n"
"gpr w23 .32 184 0\n"
"gpr w24 .32 192 0\n"
"gpr w25 .32 200 0\n"
"gpr w26 .32 208 0\n"
"gpr w27 .32 216 0\n"
"gpr w28 .32 224 0\n"
"gpr w29 .32 232 0\n"
"gpr w30 .32 240 0\n"
/* 64bit */
"gpr x0 .64 0 0\n"
"gpr x1 .64 8 0\n"
"gpr x2 .64 16 0\n"
"gpr x3 .64 24 0\n"
"gpr x4 .64 32 0\n"
"gpr x5 .64 40 0\n"
"gpr x6 .64 48 0\n"
"gpr x7 .64 56 0\n"
"gpr x8 .64 64 0\n"
"gpr x9 .64 72 0\n"
"gpr x10 .64 80 0\n"
"gpr x11 .64 88 0\n"
"gpr x12 .64 96 0\n"
"gpr x13 .64 104 0\n"
"gpr x14 .64 112 0\n"
"gpr x15 .64 120 0\n"
"gpr x16 .64 128 0\n"
"gpr x17 .64 136 0\n"
"gpr x18 .64 144 0\n"
"gpr x19 .64 152 0\n"
"gpr x20 .64 160 0\n"
"gpr x21 .64 168 0\n"
"gpr x22 .64 176 0\n"
"gpr x23 .64 184 0\n"
"gpr x24 .64 192 0\n"
"gpr x25 .64 200 0\n"
"gpr x26 .64 208 0\n"
"gpr x27 .64 216 0\n"
"gpr x28 .64 224 0\n"
"gpr x29 .64 232 0\n"
"gpr fp .64 232 0\n" // fp = x29
"gpr x30 .64 240 0\n"
"gpr lr .64 240 0\n" // lr = x30
"gpr sp .64 248 0\n"
"gpr zr .64 248 0\n" // zr = sp (x31)
"gpr cpsr .64 256 0\n"
"gpr pc .64 272 0\n"
// probably wrong
"gpr nf .1 .256 0 sign\n" // msb bit of last op
"gpr zf .1 .257 0 zero\n" // set if last op is 0
"gpr cf .1 .258 0 carry\n" // set if last op carries
"gpr vf .1 .515 0 overflow\n"; // set if overflows
} else {
p = \
"=pc r15\n"
"=sp r14\n" // XXX
"=bp fp\n" // XXX
"=a0 r0\n"
"=a1 r1\n"
"=a2 r2\n"
"=a3 r3\n"
"gpr sl .32 40 0\n" // rl0
"gpr fp .32 44 0\n" // r11
"gpr ip .32 48 0\n" // r12
"gpr sp .32 52 0\n" // r13
"gpr lr .32 56 0\n" // r14
"gpr pc .32 60 0\n" // r15
"gpr r0 .32 0 0\n"
"gpr r1 .32 4 0\n"
"gpr r2 .32 8 0\n"
"gpr r3 .32 12 0\n"
"gpr r4 .32 16 0\n"
"gpr r5 .32 20 0\n"
"gpr r6 .32 24 0\n"
"gpr r7 .32 28 0\n"
"gpr r8 .32 32 0\n"
"gpr r9 .32 36 0\n"
"gpr r10 .32 40 0\n"
"gpr r11 .32 44 0\n"
"gpr r12 .32 48 0\n"
"gpr r13 .32 52 0\n"
"gpr r14 .32 56 0\n"
"gpr r15 .32 60 0\n"
"gpr r16 .32 64 0\n"
"gpr r17 .32 68 0\n"
"gpr cpsr .32 72 0\n";
}
return <API key> (anal->reg, p);
}
RAnalPlugin <API key> = {
.name = "arm",
.desc = "Capstone ARM analyzer",
.license = "BSD",
.esil = true,
.arch = R_SYS_ARCH_ARM,
.set_reg_profile = set_reg_profile,
.bits = 16 | 32 | 64,
.op = &analop,
};
#ifndef CORELIB
struct r_lib_struct_t radare_plugin = {
.type = R_LIB_TYPE_ANAL,
.data = &<API key>,
.version = R2_VERSION
};
#endif
|
//: generics/CreatorGeneric.java
abstract class GenericWithCreate<T> {
final T element;
GenericWithCreate() { element = create(); }
abstract T create();
}
class X {}
class Creator extends GenericWithCreate<X> {
X create() { return new X(); }
void f() {
System.out.println(element.getClass().getSimpleName());
}
}
public class CreatorGeneric {
public static void main(String[] args) {
Creator c = new Creator();
c.f();
}
} /* Output:
X
*///:~
|
#include <stdbool.h>
#include <stdint.h>
#include "platform.h"
#ifdef USE_MAX7456
#include "common/utils.h"
#include "drivers/display.h"
#include "drivers/max7456.h"
#include "fc/config.h"
#include "io/displayport_max7456.h"
#include "io/osd.h"
#include "pg/max7456.h"
#include "pg/pg.h"
#include "pg/pg_ids.h"
#include "pg/vcd.h"
displayPort_t max7456DisplayPort;
<API key>(<API key>, <API key>, <API key>, 0);
void <API key>(<API key> *displayPortProfile)
{
displayPortProfile->colAdjust = 0;
displayPortProfile->rowAdjust = 0;
// Set defaults as per MAX7456 datasheet
displayPortProfile->invert = false;
displayPortProfile->blackBrightness = 0;
displayPortProfile->whiteBrightness = 2;
}
static int grab(displayPort_t *displayPort)
{
// FIXME this should probably not have a dependency on the OSD or OSD slave code
UNUSED(displayPort);
#ifdef USE_OSD
osdResetAlarms();
resumeRefreshAt = 0;
#endif
return 0;
}
static int release(displayPort_t *displayPort)
{
UNUSED(displayPort);
return 0;
}
static int clearScreen(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456Invert(<API key>()->invert);
max7456Brightness(<API key>()->blackBrightness, <API key>()->whiteBrightness);
max7456ClearScreen();
return 0;
}
static int drawScreen(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456DrawScreen();
return 0;
}
static int screenSize(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return maxScreenSize;
}
static int writeString(displayPort_t *displayPort, uint8_t x, uint8_t y, const char *s)
{
UNUSED(displayPort);
max7456Write(x, y, s);
return 0;
}
static int writeChar(displayPort_t *displayPort, uint8_t x, uint8_t y, uint8_t c)
{
UNUSED(displayPort);
max7456WriteChar(x, y, c);
return 0;
}
static bool <API key>(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return <API key>();
}
static bool isSynced(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return <API key>();
}
static void resync(displayPort_t *displayPort)
{
UNUSED(displayPort);
max7456RefreshAll();
displayPort->rows = max7456GetRowsCount() + <API key>()->rowAdjust;
displayPort->cols = 30 + <API key>()->colAdjust;
}
static int heartbeat(displayPort_t *displayPort)
{
UNUSED(displayPort);
return 0;
}
static uint32_t txBytesFree(const displayPort_t *displayPort)
{
UNUSED(displayPort);
return UINT32_MAX;
}
static const displayPortVTable_t max7456VTable = {
.grab = grab,
.release = release,
.clearScreen = clearScreen,
.drawScreen = drawScreen,
.screenSize = screenSize,
.writeString = writeString,
.writeChar = writeChar,
.<API key> = <API key>,
.heartbeat = heartbeat,
.resync = resync,
.isSynced = isSynced,
.txBytesFree = txBytesFree,
};
displayPort_t *<API key>(const vcdProfile_t *vcdProfile)
{
if (
!max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock)
) {
return NULL;
}
displayInit(&max7456DisplayPort, &max7456VTable);
resync(&max7456DisplayPort);
return &max7456DisplayPort;
}
#endif // USE_MAX7456
|
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>SilentEye: SilentEyeFramework::Video Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.7.3 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">SilentEye <span id="projectnumber">0.4.1</span></div>
</td>
</tr>
</tbody>
</table>
</div>
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="<API key>.html">SilentEyeFramework</a> </li>
<li class="navelem"><a class="el" href="<API key>.html">Video</a> </li>
</ul>
</div>
</div>
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="#pro-attribs">Protected Attributes</a> </div>
<div class="headertitle">
<h1>SilentEyeFramework::Video Class Reference</h1> </div>
</div>
<div class="contents">
<!-- doxytag: class="SilentEyeFramework::Video" --><!-- doxytag: inherits="SilentEyeFramework::Media" -->
<p>Generic representation of video which can load and hide specific data according to it's format.
<a href="#_details">More...</a></p>
<p><code>#include <<a class="el" href="video_8h_source.html">video.h</a>></code></p>
<div class="dynheader">
Inheritance diagram for SilentEyeFramework::Video:</div>
<div class="dyncontent">
<div class="center">
<img src="<API key>.png" usemap="#SilentEyeFramework::Video_map" alt=""/>
<map id="SilentEyeFramework::Video_map" name="SilentEyeFramework::Video_map">
<area href="<API key>.html" alt="SilentEyeFramework::Media" shape="rect" coords="0,0,169,24"/>
</map>
</div></div>
<p><a href="<API key>.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">Video</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">~Video</a> ()</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">Video</a> (const QString &filepath)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">Video</a> (const <a class="el" href="<API key>.html">Video</a> &)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">Video</a> (<a class="el" href="<API key>.html">Video</a> *)</td></tr>
<tr><td colspan="2"><h2><a name="pro-attribs"></a>
Protected Attributes</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="<API key>.html#<API key>">m_length</a></td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">track length <a href="#<API key>"></a><br/></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<div class="textblock"><p>Generic representation of video which can load and hide specific data according to it's format. </p>
<p>Definition at line <a class="el" href="video_8h_source.html#l00026">26</a> of file <a class="el" href="video_8h_source.html">video.h</a>.</p>
</div><hr/><h2>Constructor & Destructor Documentation</h2>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::Video" ref="<API key>" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SilentEyeFramework::Video::Video </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
</div>
</div>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::~Video" ref="<API key>" args="()" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SilentEyeFramework::Video::~Video </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="video_8cpp_source.html#l00049">49</a> of file <a class="el" href="video_8cpp_source.html">video.cpp</a>.</p>
</div>
</div>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::Video" ref="<API key>" args="(const QString &filepath)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SilentEyeFramework::Video::Video </td>
<td>(</td>
<td class="paramtype">const QString & </td>
<td class="paramname"><em>filepath</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="video_8cpp_source.html#l00028">28</a> of file <a class="el" href="video_8cpp_source.html">video.cpp</a>.</p>
<p>References <a class="el" href="audio_8cpp_source.html#l00035">SilentEyeFramework::m_type</a>, and <a class="el" href="<API key>.html#<API key>">SEFormatBMP::setObjectName()</a>.</p>
</div>
</div>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::Video" ref="<API key>" args="(const Video &)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SilentEyeFramework::Video::Video </td>
<td>(</td>
<td class="paramtype">const <a class="el" href="<API key>.html">Video</a> & </td>
<td class="paramname"><em>aud</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="video_8cpp_source.html#l00035">35</a> of file <a class="el" href="video_8cpp_source.html">video.cpp</a>.</p>
<p>References <a class="el" href="audio_8cpp_source.html#l00035">SilentEyeFramework::m_type</a>, and <a class="el" href="<API key>.html#<API key>">SEFormatBMP::setObjectName()</a>.</p>
</div>
</div>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::Video" ref="<API key>" args="(Video *)" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">SilentEyeFramework::Video::Video </td>
<td>(</td>
<td class="paramtype"><a class="el" href="<API key>.html">Video</a> * </td>
<td class="paramname"><em>aud</em></td><td>)</td>
<td></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>Definition at line <a class="el" href="video_8cpp_source.html#l00042">42</a> of file <a class="el" href="video_8cpp_source.html">video.cpp</a>.</p>
<p>References <a class="el" href="audio_8cpp_source.html#l00035">SilentEyeFramework::m_type</a>, and <a class="el" href="<API key>.html#<API key>">SEFormatBMP::setObjectName()</a>.</p>
</div>
</div>
<hr/><h2>Member Data Documentation</h2>
<a class="anchor" id="<API key>"></a><!-- doxytag: member="SilentEyeFramework::Video::m_length" ref="<API key>" args="" -->
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">int <a class="el" href="<API key>.html#<API key>">SilentEyeFramework::Video::m_length</a><code> [protected]</code></td>
</tr>
</table>
</div>
<div class="memdoc">
<p>track length </p>
<p>Definition at line <a class="el" href="video_8h_source.html#l00030">30</a> of file <a class="el" href="video_8h_source.html">video.h</a>.</p>
</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>sef/<a class="el" href="video_8h_source.html">video.h</a></li>
<li>sef/<a class="el" href="video_8cpp_source.html">video.cpp</a></li>
</ul>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Sun Feb 6 2011 14:59:55 for SilentEye by 
<a href="http:
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.3 </small></address>
</body>
</html>
|
// Moodle is free software: you can redistribute it and/or modify
// (at your option) any later version.
// Moodle is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
import * as DynamicTable from 'core_table/dynamic';
import * as Str from 'core/str';
import * as Toast from 'core/toast';
import Config from 'core/config';
import Fragment from 'core/fragment';
import ModalEvents from 'core/modal_events';
import ModalFactory from 'core/modal_factory';
import Notification from 'core/notification';
import jQuery from 'jquery';
import Prefetch from 'core/prefetch';
const Selectors = {
cohortSelector: "#id_cohortlist",
triggerButtons: ".enrolusersbutton.enrol_manual_plugin [type='submit']",
<API key>: "input[value='<API key>']",
buttonWrapper: '[data-region="wrapper"]',
};
/**
* Get the content of the body for the specified context.
*
* @param {Number} contextId
* @returns {Promise}
*/
const getBodyForContext = contextId => {
return Fragment.loadFragment('enrol_manual', 'enrol_users_form', contextId, {});
};
/**
* Get the dynamic table for the button.
*
* @param {HTMLElement} element
* @returns {HTMLElement}
*/
const <API key> = element => {
const wrapper = element.closest(Selectors.buttonWrapper);
return DynamicTable.getTableFromId(wrapper.dataset.tableUniqueid);
};
/**
* Register the event listeners for this contextid.
*
* @param {Number} contextId
*/
const <API key> = contextId => {
document.addEventListener('click', e => {
if (e.target.closest(Selectors.triggerButtons)) {
e.preventDefault();
showModal(<API key>(e.target), contextId);
return;
}
});
};
/**
* Display the modal for this contextId.
*
* @param {HTMLElement} dynamicTable The table to beb refreshed when changes are made
* @param {Number} contextId
* @returns {Promise}
*/
const showModal = (dynamicTable, contextId) => {
return ModalFactory.create({
type: ModalFactory.types.SAVE_CANCEL,
large: true,
title: Str.get_string('enrolusers', 'enrol_manual'),
body: getBodyForContext(contextId),
})
.then(modal => {
modal.getRoot().on(ModalEvents.save, e => {
// Trigger a form submission, so that any mform elements can do final tricks before the form submission
// is processed.
// The actual submit even tis captured in the next handler.
e.preventDefault();
modal.getRoot().find('form').submit();
});
modal.getRoot().on('submit', 'form', e => {
e.preventDefault();
submitFormAjax(dynamicTable, modal);
});
modal.getRoot().on(ModalEvents.hidden, () => {
modal.destroy();
});
return modal;
})
.then(modal => {
modal.show();
return modal;
})
.then(modal => {
modal.setSaveButtonText(Str.get_string('enrolusers', 'enrol_manual'));
modal.getBodyPromise().then(body => {
if (body.get(0).querySelector(Selectors.cohortSelector)) {
modal.setSaveButtonText(Str.get_string('enroluserscohorts', 'enrol_manual'));
}
return body;
})
.catch();
return modal;
})
.catch(Notification.exception);
};
/**
* Submit the form via ajax.
*
* @param {HTMLElement} dynamicTable
* @param {Object} modal
*/
const submitFormAjax = (dynamicTable, modal) => {
// Note: We use a jQuery object here so that we can use its serialize functionality.
const form = modal.getRoot().find('form');
// Before send the data through AJAX, we need to parse and remove some unwanted hidden fields.
// This hidden fields are added automatically by mforms and when it reaches the AJAX we get an error.
form.get(0).querySelectorAll(Selectors.<API key>).forEach(hiddenField => hiddenField.remove());
modal.hide();
modal.destroy();
jQuery.ajax(
`${Config.wwwroot}/enrol/manual/ajax.php?${form.serialize()}`,
{
type: 'GET',
processData: false,
contentType: "application/json",
}
)
.then(response => {
if (response.error) {
throw new Error(response.error);
}
DynamicTable.refreshTableContent(dynamicTable);
return Str.get_string('totalenrolledusers', 'enrol', response.count);
})
.then(notificationBody => Toast.add(notificationBody))
.catch(error => {
Notification.addNotification({
message: error.message,
type: 'error',
});
});
};
/**
* Set up quick enrolment for the manual enrolment plugin.
*
* @param {Number} contextid The context id to setup for
*/
export const init = ({contextid}) => {
<API key>(contextid);
Prefetch.prefetchStrings('enrol_manual', [
'enrolusers',
'enroluserscohorts',
]);
Prefetch.prefetchString('enrol', 'totalenrolledusers');
};
|
#shop .productDescription .price,
div.featured-box i.fa,
.pagination>li>a,
.pagination>li>a:hover,
.pagination>li>a:active,
.pagination>li>a:focus,
.pagination>li>span,
a,
h1 em, h2 em, h3 em, h4 em, h5 em, h6 em,
#header a:hover,
#footer a:hover,
#header ul.nav li:hover>a,
#header ul.nav li ul li:hover>a,
#default .styleColor,
#topCart .bottom a:hover,
#topCart a.item:hover > p,
#topOptions li a span.items.active,
#topOptions li div.button span.items.active,
#topOptions li button span.items.active {
color:#81BA10;
font-style:normal;
}
.topShopCart .on {
color:#81BA10 !important;
}
.<API key> i.fa,
#slider-next:hover,
#slider-prev:hover {
background-color:#81BA10;
}
div.featured-box i.fa {
border:#81BA10 1px solid !important;
}
div.toggle.active > label:before {
border-bottom-color: #81BA10;
}
.item-box .item-hover .overlay {
background-color:rgba(142,205,17,0.6);
}
.pagination>.active>a,
.pagination>.active>span,
.pagination>.active>a:hover,
.pagination>.active>span:hover,
.pagination>.active>a:focus,
.pagination>.active>span:focus {
border:#81BA10 1px solid !important;
background-color:#81BA10;
}
|
<?php
/**
* Test class for \Magento\Cms\Controller\Page.
*/
namespace Magento\Cms\Controller;
class PageTest extends \Magento\TestFramework\TestCase\AbstractController
{
public function testViewAction()
{
$this->dispatch('/enable-cookies/');
$this->assertContains('What are Cookies?', $this->getResponse()->getBody());
}
/**
* Test \Magento\Cms\Block\Page::_addBreadcrumbs
*/
public function testAddBreadcrumbs()
{
$this->dispatch('/enable-cookies/');
$layout = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
'Magento\Framework\View\LayoutInterface'
);
$breadcrumbsBlock = $layout->getBlock('breadcrumbs');
$this->assertContains($breadcrumbsBlock->toHtml(), $this->getResponse()->getBody());
}
/**
* @magentoDataFixture <API key>
*/
public function <API key>()
{
$this->dispatch('/shipping/');
$content = $this->getResponse()->getBody();
$this->assertContains('Shipping Test Page', $content);
}
public static function <API key>()
{
/** @var $page \Magento\Cms\Model\Page */
$page = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Cms\Model\Page');
$page->setTitle('Test title')
->setIdentifier('shipping')
->setStores([0])
->setIsActive(1)
->setContent('<h1>Shipping Test Page</h1>')
->setPageLayout('1column')
->save();
}
}
|
#include "test.h"
#include "testutil.h"
#include "testtrace.h"
#include "memdebug.h"
struct libtest_trace_cfg <API key>;
static time_t epoch_offset; /* for test time tracing */
static int known_offset; /* for test time tracing */
static
void libtest_debug_dump(const char *timebuf, const char *text, FILE *stream,
const unsigned char *ptr, size_t size, int nohex)
{
size_t i;
size_t c;
unsigned int width = 0x10;
if(nohex)
/* without the hex output, we can fit more on screen */
width = 0x40;
fprintf(stream, "%s%s, %zu bytes (0x%zx)\n", timebuf, text,
size, size);
for(i = 0; i < size; i += width) {
fprintf(stream, "%04zx: ", i);
if(!nohex) {
/* hex not disabled, show it */
for(c = 0; c < width; c++)
if(i + c < size)
fprintf(stream, "%02x ", ptr[i + c]);
else
fputs(" ", stream);
}
for(c = 0; (c < width) && (i + c < size); c++) {
/* check for 0D0A; if found, skip past and start a new line of output */
if(nohex &&
(i + c + 1 < size) && (ptr[i + c] == 0x0D) &&
(ptr[i + c + 1] == 0x0A)) {
i += (c + 2 - width);
break;
}
fprintf(stream, "%c", ((ptr[i + c] >= 0x20) && (ptr[i + c] < 0x80)) ?
ptr[i + c] : '.');
/* check again for 0D0A, to avoid an extra \n if it's at width */
if(nohex &&
(i + c + 2 < size) && (ptr[i + c + 1] == 0x0D) &&
(ptr[i + c + 2] == 0x0A)) {
i += (c + 3 - width);
break;
}
}
fputc('\n', stream); /* newline */
}
fflush(stream);
}
int libtest_debug_cb(CURL *handle, curl_infotype type,
unsigned char *data, size_t size,
void *userp)
{
struct libtest_trace_cfg *trace_cfg = userp;
const char *text;
struct timeval tv;
char timebuf[20];
char *timestr;
time_t secs;
(void)handle;
timebuf[0] = '\0';
timestr = &timebuf[0];
if(trace_cfg->tracetime) {
struct tm *now;
tv = tutil_tvnow();
if(!known_offset) {
epoch_offset = time(NULL) - tv.tv_sec;
known_offset = 1;
}
secs = epoch_offset + tv.tv_sec;
now = localtime(&secs); /* not thread safe but we don't care */
msnprintf(timebuf, sizeof(timebuf), "%02d:%02d:%02d.%06ld ",
now->tm_hour, now->tm_min, now->tm_sec, (long)tv.tv_usec);
}
switch(type) {
case CURLINFO_TEXT:
fprintf(stderr, "%s== Info: %s", timestr, (char *)data);
/* FALLTHROUGH */
default: /* in case a new one is introduced to shock us */
return 0;
case CURLINFO_HEADER_OUT:
text = "=> Send header";
break;
case CURLINFO_DATA_OUT:
text = "=> Send data";
break;
case <API key>:
text = "=> Send SSL data";
break;
case CURLINFO_HEADER_IN:
text = "<= Recv header";
break;
case CURLINFO_DATA_IN:
text = "<= Recv data";
break;
case <API key>:
text = "<= Recv SSL data";
break;
}
libtest_debug_dump(timebuf, text, stderr, data, size, trace_cfg->nohex);
return 0;
}
|
define(['app'], function (app) {
app.controller('DevicesController', [ '$scope', '$rootScope', '$location', '$http', '$interval', function($scope,$rootScope,$location,$http,$interval) {
AddDevice = function(idx,itemname)
{
$.devIdx = idx;
if (name!='Unknown') {
$( "#dialog-adddevice #devicename" ).val(unescape(itemname));
}
$("#dialog-adddevice").i18n();
$("#dialog-adddevice").dialog( "open" );
}
RenameDevice = function(idx,itype,itemname)
{
$.devType=itype;
$.devIdx = idx;
if (name!='Unknown') {
$( "#dialog-renamedevice #devicename" ).val(unescape(itemname));
}
$("#dialog-renamedevice").i18n();
$("#dialog-renamedevice").dialog( "open" );
}
AddLightDeviceDev = function (idx, name)
{
$.devIdx = idx;
$("#<API key> #combosubdevice").html("");
$.each($.LightsAndSwitches, function(i,item){
var option = $('<option />');
option.attr('value', item.idx).text(item.name);
$("#<API key> #combosubdevice").append(option);
});
$("#<API key> #combosubdevice").val(0);
if (name!='Unknown') {
$( "#<API key> #devicename" ).val(unescape(name));
}
$("#<API key>").i18n();
$("#<API key>" ).dialog( "open" );
}
SetUnused = function(idx)
{
bootbox.confirm($.t("Are you sure to remove this Device from your used devices?"), function(result) {
if (result==true) {
$.ajax({
url: "json.htm?type=command¶m=setunused&idx=" + idx,
async: false,
dataType: 'json',
success: function(data) {
ShowDevices();
}
});
}
});
}
InvertCheck = function()
{
$('#devices input:checkbox').each(function(){
$(this).prop('checked', !$(this).is(":checked"));
});
}
<API key> = function()
{
var totalselected=$('#devices input:checkbox:checked').length;
if (totalselected==0) {
bootbox.alert($.t('No Devices selected to Delete!'));
return;
}
var d2delete = "";
var delCount = 0;
$('#devices input:checkbox:checked').each(function() {
if (d2delete!="")
d2delete+=";";
d2delete+=$(this).val();
delCount++;
});
bootbox.confirm($.t("Are you sure you want to delete the selected Devices?") + " (" + delCount + ")", function(result) {
if (result==true) {
$.ajax({
url: "json.htm?type=deletedevice&idx=" + d2delete,
async: false,
dataType: 'json',
success: function(data) {
bootbox.alert(delCount+" " + $.t("Devices deleted."));
ShowDevices();
}
});
}
});
}
<API key> = function()
{
$.LightsAndSwitches = [];
$.ajax({
url: "json.htm?type=command¶m=getlightswitches",
async: false,
dataType: 'json',
success: function(data) {
if (typeof data.result != 'undefined') {
$.each(data.result, function(i,item){
$.LightsAndSwitches.push({
idx: item.idx,
name: item.Name
}
);
});
}
}
});
}
ShowDevices = function(filter)
{
if (typeof filter != 'undefined') {
$.DevicesFilter=filter;
}
else {
if (typeof $.DevicesFilter != 'undefined') {
filter=$.DevicesFilter;
}
}
<API key>();
$("#devicestable #mUsed").attr('class', 'btnstyle3');
$("#devicestable #mAll").attr('class', 'btnstyle3');
$("#devicestable #mUnknown").attr('class', 'btnstyle3');
var ifilter="all";
if (typeof filter != 'undefined') {
if (filter == "used") {
ifilter = "true";
$("#devicestable #mUsed").attr('class', 'btnstyle3-sel');
}
else if (filter == "unknown") {
$("#devicestable #mUnknown").attr('class', 'btnstyle3-sel');
ifilter = "false";
}
else if (filter == "all") {
$("#devicestable #mAll").attr('class', 'btnstyle3-sel');
ifilter = "all";
}
}
else {
ChangeClass("mAll","btnstyle3-sel");
}
var htmlcontent = '';
htmlcontent+=$('#devicestable').html();
$('#devicescontent').html(htmlcontent);
$('#devicescontent').i18n();
$('#devicescontent #devices').dataTable( {
"sDom": '<"H"lfrC>t<"F"ip>',
"oTableTools": {
"sRowSelect": "single"
},
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0,11 ] }
],
"aoColumns": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
{ "sType": "numeric-battery" },
null,
null
],
"aaSorting": [[ 12, "desc" ]],
"bSortClasses": false,
"bProcessing": true,
"bStateSave": true,
"bJQueryUI": true,
"aLengthMenu": [[25, 50, 100, -1], [25, 50, 100, "All"]],
"iDisplayLength" : 25,
"sPaginationType": "full_numbers",
language: $.DataTableLanguage
} );
var mTable = $('#devicescontent #devices');
var oTable = mTable.dataTable();
oTable.fnClearTable();
$.ajax({
url: "json.htm?type=devices&displayhidden=1&displaydisabled=1&filter=all&used=" + ifilter,
async: false,
dataType: 'json',
success: function(data) {
if (typeof data.result != 'undefined') {
$.each(data.result, function(i,item){
if ((item.Type=="Group")||(item.Type=="Scene")) {
item.HardwareName="Domoticz";
item.ID="-";
item.Unit="-";
item.SubType="-";
item.SignalLevel="-";
item.BatteryLevel=255;
}
var itemSubIcons="";
var itemChecker = '<input type="checkbox" name="Check-' + item.ID + ' id="Check-' + item.ID + '" value="'+item.idx+'" />';
var TypeImg=item.TypeImg;
var itemImage='<img src="images/' + TypeImg + '.png" width="16" height="16">';
if (TypeImg.indexOf("Alert")==0) {
itemImage='<img src="images/Alert48_' + item.Level + '.png" width="16" height="16">';
}
else if ((TypeImg.indexOf("lightbulb")==0)||(TypeImg.indexOf("dimmer")==0)) {
if (
(item.Status == 'On')||
(item.Status == 'Chime')||
(item.Status == 'Group On')||
(item.Status.indexOf('Set ') == 0)
) {
itemImage='<img src="images/lightbulb.png" title="Turn Off" onclick="SwitchLight(' + item.idx + ',\'Off\',ShowDevices);" class="lcursor">';
}
else {
itemImage='<img src="images/lightbulboff.png" title="Turn On" onclick="SwitchLight(' + item.idx + ',\'On\',ShowDevices);" class="lcursor">';
}
}
else if (TypeImg.indexOf("pushoff")==0) {
itemImage='<img src="images/pushoff.png" title="Turn Off" onclick="SwitchLight(' + item.idx + ',\'Off\',ShowDevices);" class="lcursor">';
}
else if (TypeImg.indexOf("push")==0) {
itemImage='<img src="images/push.png" title="Turn On" onclick="SwitchLight(' + item.idx + ',\'On\',ShowDevices);" class="lcursor">';
}
else if (TypeImg.indexOf("motion")==0) {
if (
(item.Status == 'On')||
(item.Status == 'Chime')||
(item.Status == 'Group On')||
(item.Status.indexOf('Set ') == 0)
) {
itemImage='<img src="images/motion.png">';
}
else {
itemImage='<img src="images/motionoff.png">';
}
}
else if (TypeImg.indexOf("smoke")==0) {
if (item.Status == 'Panic') {
itemImage='<img src="images/smoke.png">';
}
else {
itemImage='<img src="images/smokeoff.png">';
}
}
else if (TypeImg.indexOf("scene")==0) {
itemImage='<img src="images/push.png" title="Switch Scene" onclick="SwitchScene(' + item.idx + ',\'On\',ShowDevices);" class="lcursor">';
}
else if (TypeImg.indexOf("group")==0) {
if (
(item.Status == 'On')||
(item.Status == 'Mixed')
) {
itemImage='<img src="images/pushoff.png" title="Turn Off" onclick="SwitchScene(' + item.idx + ',\'Off\',ShowDevices);" class="lcursor">';
}
else {
itemImage='<img src="images/push.png" title="Turn On" onclick="SwitchScene(' + item.idx + ',\'On\',ShowDevices);" class="lcursor">';
}
} else if (item.SubType === "Selector Switch") {
var imagePath;
if (item.CustomImage !== 0) {
imagePath = (this.levelName === "Off") ? "images/" + item.Image + "48_Off.png" : "images/" + item.Image + "48_On.png";
} else {
imagePath = (this.levelName === "Off") ? "images/" + item.TypeImg + "48_Off.png" : "images/" + item.TypeImg + "48_On.png";
}
itemImage = '<img src="' + imagePath + '" width="16" height="16">';
}
if ((item.Type == "Group")||(item.Type == "Scene")) {
itemSubIcons+=' <img src="images/empty16.png">';
itemSubIcons+='<img src="images/rename.png" title="' + $.t('Rename Device') +'" onclick="RenameDevice(' + item.idx +',\'' + item.Type +'\',\'' + escape(item.Name) + '\')">';
}
else {
if (item.Used!=0) {
itemSubIcons+='<img src="images/remove.png" title="' + $.t('Set Unused') +'" onclick="SetUnused(' + item.idx +')">';
itemSubIcons+='<img src="images/rename.png" title="' + $.t('Rename Device') +'" onclick="RenameDevice(' + item.idx +',\'' + item.Type+'\',\'' + escape(item.Name) + '\')">';
}
else {
if (
(item.Type.indexOf("Light")==0)||
(item.Type.indexOf("Security")==0)
)
{
itemSubIcons+='<img src="images/add.png" title="' + $.t('Add Light/Switch Device') + '" onclick="AddLightDeviceDev(' + item.idx +',\'' + escape(item.Name) + '\')">';
}
else {
itemSubIcons+='<img src="images/add.png" title="' + $.t('Add Device') +'" onclick="AddDevice(' + item.idx +',\'' + escape(item.Name) + '\')">';
}
itemSubIcons+='<img src="images/rename.png" title="' + $.t('Rename Device') +'" onclick="RenameDevice(' + item.idx +',\'' + item.Type +'\',\'' + escape(item.Name) + '\')">';
}
}
if (
(item.Type.indexOf("Light")==0)||
(item.Type.indexOf("Chime")==0)||
(item.Type.indexOf("Security")==0)||
(item.Type.indexOf("RFY")==0)||
(item.Type.indexOf("ASA")==0)||
(item.Type.indexOf("Blinds")==0)
)
{
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowLightLog(' + item.idx + ',\'' + escape(item.Name) + '\', \'#devicescontent\', \'ShowDevices\');">';
}
else if ((item.Type.indexOf("Temp")==0)||(item.Type.indexOf("Thermostat")==0)||(item.Type.indexOf("Humidity")==0)) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowTempLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if (item.SubType=="Voltage") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'VoltageGeneral\');">';
}
else if (item.SubType=="Current") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'CurrentGeneral\');">';
}
else if (item.SubType=="Pressure") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'Pressure\');">';
}
else if (item.SubType=="Custom Sensor") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',\'' + escape(item.SensorUnit) +'\', \'' + item.SubType + '\');">';
}
else if (item.SubType == "Percentage") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowPercentageLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if (item.SubType=="Sound Level") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'' + item.SubType + '\');">';
}
else if (typeof item.Counter != 'undefined') {
if ((item.Type == "P1 Smart Meter")&&(item.SubType=="Energy")) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowSmartLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
else if ((item.Type == "YouLess Meter")&&(item.SwitchTypeVal==0 || item.SwitchTypeVal==4)) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="<API key>(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
else {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowCounterLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
}
else if (typeof item.Direction != 'undefined') {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowWindLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if (typeof item.UVI != 'undefined') {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowUVLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if (typeof item.Rain != 'undefined') {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowRainLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if ((item.Type == "Energy")||(item.SubType == "kWh")) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="<API key>(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
else if (item.Type.indexOf("Current")==0) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowCurrentLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.displaytype + ');">';
}
else if (item.Type == "Air Quality") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowAirQualityLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if (item.Type == "Lux") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowLuxLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
else if (item.Type == "Usage") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowUsageLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\', ' + item.SwitchTypeVal + ');">';
}
else if (item.SubType == "Solar Radiation") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'Radiation\');">';
}
else if (item.SubType == "Visibility") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'Visibility\');">';
}
else if (item.SubType == "Distance") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'DistanceGeneral\');">';
}
else if (item.SubType == "Barometer") {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowBaroLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if ((item.SubType == "Text") || (item.SubType == "Alert")) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowTextLog(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\');">';
}
else if ((item.SubType == "Soil Moisture")||(item.SubType == "Leaf Wetness")||(item.SubType == "Waterflow")) {
itemSubIcons+=' <img src="images/log.png" title="' + $.t('Log') +'" onclick="ShowGeneralGraph(\'#devicescontent\',\'ShowDevices\',' + item.idx + ',\'' + escape(item.Name) + '\',' + item.SwitchTypeVal +', \'' + item.SubType + '\');">';
}
else {
itemSubIcons+=' <img src="images/empty16.png">';
}
var ID = item.ID;
if (item.Type=="Lighting 1") {
ID = String.fromCharCode(item.ID);
}
var BatteryLevel=item.BatteryLevel;
if (BatteryLevel=="255") {
BatteryLevel="-";
}
else if (BatteryLevel=="0") {
BatteryLevel=$.t("Low");
}
var addId = oTable.fnAddData([
itemChecker + " " + itemImage,
item.idx,
item.HardwareName,
ID,
item.Unit,
item.Name,
item.Type,
item.SubType,
item.Data,
item.SignalLevel,
BatteryLevel,
itemSubIcons,
item.LastUpdate
], false);
});
mTable.fnDraw();
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert("Problem retrieving devices!");
}
});
}
<API key> = function(bEnabled)
{
var trow=$("#<API key> #lighttable #subdevice");
if (bEnabled == true) {
trow.show();
}
else {
trow.hide();
}
}
jQuery.fn.dataTableExt.oSort['numeric-battery-asc'] = function(a,b) {
var x = a;
var y = b;
if (x=="-") x=101;
if (x=="Low") x=1;
if (y=="-") y=101;
if (y=="Low") y=1;
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['<API key>'] = function(a,b) {
var x = a;
var y = b;
if (x=="-") x=101;
if (x=="Low") x=1;
if (y=="-") y=101;
if (y=="Low") y=1;
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
init();
function init()
{
//global var
$.devIdx=0;
$.LightsAndSwitches = [];
$scope.MakeGlobalConfig();
var <API key> = {};
<API key>[$.t("Add Device")]=function() {
var bValid = true;
bValid = bValid && checkLength( $("#dialog-adddevice #devicename"), 2, 100 );
if ( bValid ) {
$( this ).dialog( "close" );
$.ajax({
url: "json.htm?type=setused&idx=" + $.devIdx + '&name=' + encodeURIComponent($("#dialog-adddevice #devicename").val()) + '&used=true',
async: false,
dataType: 'json',
success: function(data) {
ShowDevices();
}
});
}
};
<API key>[$.t("Cancel")]=function() {
$( this ).dialog( "close" );
};
$( "#dialog-adddevice" ).dialog({
autoOpen: false,
width: 'auto',
height: 'auto',
modal: true,
resizable: false,
title: $.t("Add Device"),
buttons: <API key>
});
var <API key> = {};
<API key>[$.t("Rename Device")]=function() {
var bValid = true;
bValid = bValid && checkLength( $("#dialog-renamedevice #devicename"), 2, 100 );
if ( bValid ) {
$( this ).dialog( "close" );
var durl;
if (($.devType=="Group")||($.devType=="Scene")) {
durl="json.htm?type=command¶m=renamescene&idx=" + $.devIdx + '&name=' + encodeURIComponent($("#dialog-renamedevice #devicename").val());
}
else {
durl="json.htm?type=command¶m=renamedevice&idx=" + $.devIdx + '&name=' + encodeURIComponent($("#dialog-renamedevice #devicename").val());
}
$.ajax({
url: durl,
async: false,
dataType: 'json',
success: function(data) {
ShowDevices();
}
});
}
};
<API key>[$.t("Cancel")]=function() {
$( this ).dialog( "close" );
};
$( "#dialog-renamedevice" ).dialog({
autoOpen: false,
width: 'auto',
height: 'auto',
modal: true,
resizable: false,
title: $.t("Rename Device"),
buttons: <API key>
});
var <API key> = {};
<API key>[$.t("Add Device")]=function() {
var bValid = true;
bValid = bValid && checkLength( $("#<API key> #devicename"), 2, 100 );
var bIsSubDevice=$("#<API key> #lighttable #how_2").is(":checked");
var MainDeviceIdx="";
if (bIsSubDevice)
{
var MainDeviceIdx=$("#<API key> #combosubdevice option:selected").val();
if (typeof MainDeviceIdx == 'undefined') {
bootbox.alert($.t('No Main Device Selected!'));
return;
}
}
if ( bValid ) {
$( this ).dialog( "close" );
$.ajax({
url: "json.htm?type=setused&idx=" + $.devIdx + '&name=' + encodeURIComponent($("#<API key> #devicename").val()) + '&used=true&maindeviceidx=' + MainDeviceIdx,
async: false,
dataType: 'json',
success: function(data) {
ShowDevices();
}
});
}
};
<API key>[$.t("Cancel")]=function() {
$( this ).dialog( "close" );
};
$( "#<API key>" ).dialog({
autoOpen: false,
width: 'auto',
height: 'auto',
modal: true,
resizable: false,
title: $.t("Add Light/Switch Device"),
buttons: <API key>
});
$("#<API key> #lighttable #how_1").click(function() {
<API key>(false);
});
$("#<API key> #lighttable #how_2").click(function() {
<API key>(true);
});
ShowDevices();
$( "#dialog-adddevice" ).keydown(function (event) {
if (event.keyCode == 13) {
$(this).siblings('.<API key>').find('button:eq(0)').trigger("click");
return false;
}
});
$( "#<API key>" ).keydown(function (event) {
if (event.keyCode == 13) {
$(this).siblings('.<API key>').find('button:eq(0)').trigger("click");
return false;
}
});
};
} ]);
});
|
<html lang="en">
<head>
<title>Symbol-Renaming Pragmas - Using the GNU Compiler Collection (GCC)</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using the GNU Compiler Collection (GCC)">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Pragmas.html#Pragmas" title="Pragmas">
<link rel="prev" href="Solaris-Pragmas.html#Solaris-Pragmas" title="Solaris Pragmas">
<link rel="next" href="<API key>.html#<API key>" title="Structure-Packing Pragmas">
<link href="http:
<!
Copyright (C) 1988-2013 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being ``Funding Free Software'', the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below). A copy of the license is included in the section entitled
``GNU Free Documentation License''.
(a) The FSF's Front-Cover Text is:
A GNU Manual
(b) The FSF's Back-Cover Text is:
You have freedom to copy and modify this GNU Manual, like GNU
software. Copies published by the Free Software Foundation raise
funds for GNU development.
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<a name="<API key>"></a>
<a name="<API key>"></a>
<p>
Next: <a rel="next" accesskey="n" href="<API key>.html#<API key>">Structure-Packing Pragmas</a>,
Previous: <a rel="previous" accesskey="p" href="Solaris-Pragmas.html#Solaris-Pragmas">Solaris Pragmas</a>,
Up: <a rel="up" accesskey="u" href="Pragmas.html#Pragmas">Pragmas</a>
<hr>
</div>
<h4 class="subsection">6.58.7 Symbol-Renaming Pragmas</h4>
<p>For compatibility with the Solaris system headers, GCC
supports two <code>#pragma</code> directives that change the name used in
assembly for a given declaration. To get this effect
on all platforms supported by GCC, use the asm labels extension (see <a href="Asm-Labels.html#Asm-Labels">Asm Labels</a>).
<dl>
<dt><code>redefine_extname </code><var>oldname</var> <var>newname</var><dd><a name="<API key>"></a>
This pragma gives the C function <var>oldname</var> the assembly symbol
<var>newname</var>. The preprocessor macro <code><API key></code>
is defined if this pragma is available (currently on all platforms).
</dl>
<p>This pragma and the asm labels extension interact in a complicated
manner. Here are some corner cases you may want to be aware of.
<ol type=1 start=1>
<li>Both pragmas silently apply only to declarations with external
linkage. Asm labels do not have this restriction.
<li>In C++, both pragmas silently apply only to declarations with
“C” linkage. Again, asm labels do not have this restriction.
<li>If any of the three ways of changing the assembly name of a
declaration is applied to a declaration whose assembly name has
already been determined (either by a previous use of one of these
features, or because the compiler needed the assembly name in order to
generate code), and the new name is different, a warning issues and
the name does not change.
<li>The <var>oldname</var> used by <code>#pragma redefine_extname</code> is
always the C-language name.
</ol>
</body></html>
|
<?php
namespace Claroline\CoreBundle\Event\Log;
class LogUserCreateEvent extends LogGenericEvent
{
const ACTION = 'user-create';
/**
* Constructor.
*/
public function __construct($receiver)
{
parent::__construct(
self::ACTION,
array(
'receiverUser' => array(
'lastName' => $receiver->getLastName(),
'firstName' => $receiver->getFirstName(),
),
),
$receiver
);
}
/**
* @return array
*/
public static function getRestriction()
{
return array(self::DISPLAYED_ADMIN);
}
}
|
package eu.siacs.conversations.xmpp.forms;
import java.util.Collection;
import java.util.Iterator;
import eu.siacs.conversations.xml.Element;
public class Field extends Element {
public Field(String name) {
super("field");
this.setAttribute("var",name);
}
private Field() {
super("field");
}
public String getFieldName() {
return this.getAttribute("var");
}
public void setValue(String value) {
this.children.clear();
this.addChild("value").setContent(value);
}
public void setValues(Collection<String> values) {
this.children.clear();
for(String value : values) {
this.addChild("value").setContent(value);
}
}
public void <API key>() {
for(Iterator<Element> iterator = this.children.iterator(); iterator.hasNext();) {
Element element = iterator.next();
if (!element.getName().equals("value")) {
iterator.remove();
}
}
}
public static Field parse(Element element) {
Field field = new Field();
field.setAttributes(element.getAttributes());
field.setChildren(element.getChildren());
return field;
}
}
|
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using Microsoft.CSharp.RuntimeBinder;
using Rubberduck.VBEditor.SafeComWrappers.Abstract;
using MSO = Microsoft.Office.Core;
// ReSharper disable once CheckNamespace - Special dispensation due to conflicting file vs namespace priorities
namespace Rubberduck.VBEditor.SafeComWrappers.Office12
{
public sealed class CommandBarButton : <API key><MSO.CommandBarButton, MSO.<API key>>, ICommandBarButton, MSO.<API key>
{
private readonly CommandBarControl _control;
public const bool <API key> = false;
public CommandBarButton(MSO.CommandBarButton target, bool rewrapping = false)
: base(target, rewrapping)
{
_control = new CommandBarControl(target, true);
}
private MSO.CommandBarButton Button => Target;
public bool IsBuiltInFace
{
get => !<API key> && Button.BuiltInFace;
set
{
if (!<API key>)
{
Button.BuiltInFace = value;
}
}
}
public int FaceId
{
get => <API key> ? 0 : Button.FaceId;
set
{
if (!<API key>)
{
Button.FaceId = value;
}
}
}
public string ShortcutText
{
get => <API key> ? string.Empty : Button.ShortcutText;
set
{
if (!<API key>)
{
Button.ShortcutText = value;
}
}
}
public ButtonState State
{
get => <API key> ? 0 : (ButtonState)Button.State;
set
{
if (!<API key>)
{
Button.State = (MSO.MsoButtonState)value;
}
}
}
public ButtonStyle Style
{
get => <API key> ? 0 : (ButtonStyle)Button.Style;
set
{
if (!<API key>)
{
Button.Style = (MSO.MsoButtonStyle)value;
}
}
}
public Image Picture { get; set; }
public Image Mask { get; set; }
public void ApplyIcon()
{
if (<API key>)
{
return;
}
Button.FaceId = 0;
if (Picture == null || Mask == null)
{
return;
}
if (!HasPictureProperty)
{
using (var image = <API key>(Picture))
{
Clipboard.SetImage(image);
Button.PasteFace();
Clipboard.Clear();
}
return;
}
Button.Picture = AxHostConverter.ImageToPictureDisp(Picture);
Button.Mask = AxHostConverter.ImageToPictureDisp(Mask);
}
private bool? _hasPictureProperty;
private bool HasPictureProperty
{
get
{
if (<API key>)
{
return false;
}
if (_hasPictureProperty.HasValue)
{
return _hasPictureProperty.Value;
}
try
{
dynamic button = Button;
var picture = button.Picture;
_hasPictureProperty = true;
}
catch (<API key>)
{
_hasPictureProperty = false;
}
catch (COMException)
{
_hasPictureProperty = false;
}
return _hasPictureProperty.Value;
}
}
private static Image <API key>(Image image)
{
//HACK - just blend image with a SystemColors value (mask is ignored)
//TODO - a real solution would use clipboard formats "Toolbar Button Face" AND "Toolbar Button Mask"
//because PasteFace apparently needs both to be present on the clipboard
//However, the clipboard formats are apparently only accessible in English versions of Office
var output = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
using (var g = Graphics.FromImage(output))
{
g.Clear(SystemColors.MenuBar);
g.DrawImage(image, 0, 0);
}
return output;
}
public bool BeginsGroup
{
get => _control.BeginsGroup;
set => _control.BeginsGroup = value;
}
public bool IsBuiltIn => _control.IsBuiltIn;
public string Caption
{
get => _control.Caption;
set => _control.Caption = value;
}
public string DescriptionText
{
get => _control.DescriptionText;
set => _control.DescriptionText=value;
}
public bool IsEnabled
{
get => _control.IsEnabled;
set=> _control.IsEnabled = value;
}
public int Height
{
get => _control.Height;
set => _control.Height = value;
}
public int Id => _control.Id;
public int Index => _control.Index;
public int Left => _control.Left;
public string OnAction
{
get => _control.OnAction;
set => _control.OnAction = value;
}
public ICommandBar Parent => _control.Parent;
public string Parameter
{
get => _control.Parameter;
set => _control.Parameter = value;
}
public int Priority
{
get => _control.Priority;
set => _control.Priority = value;
}
public string Tag
{
get => _control.Tag;
set => _control.Tag = value;
}
public string TooltipText
{
get => _control.TooltipText;
set => _control.TooltipText = value;
}
public int Top => _control.Top;
public ControlType Type => _control.Type;
public bool IsVisible
{
get => _control.IsVisible;
set => _control.IsVisible = value;
}
public int Width
{
get => _control.Width;
set => _control.Width = value;
}
public void Delete()
{
if (!<API key>)
{
DetachEvents();
}
_control.Delete();
}
public void Execute()
{
_control.Execute();
}
public bool Equals(ICommandBarControl other)
{
return _control.Equals(other);
}
public override bool Equals(ISafeComWrapper<MSO.CommandBarButton> other)
{
return _control.Equals(other);
}
public override int GetHashCode()
{
return _control.GetHashCode();
}
private readonly object _eventLock = new object();
private event EventHandler<<API key>> _click;
public event EventHandler<<API key>> Click
{
add
{
lock (_eventLock)
{
_click += value;
if (_click != null && _click.GetInvocationList().Length == 1)
{
// First subscriber attached - attach COM events
AttachEvents();
}
}
}
remove
{
lock (_eventLock)
{
_click -= value;
if (_click == null || _click.GetInvocationList().Length == 0)
{
// Last subscriber detached - detach COM events
DetachEvents();
};
}
}
}
void MSO.<API key>.Click(MSO.CommandBarButton Ctrl, ref bool CancelDefault)
{
var handler = _click;
if (handler == null || <API key>)
{
return;
}
using (var button = new CommandBarButton(Ctrl))
{
System.Diagnostics.Debug.Assert(handler.GetInvocationList().Length == 1,
"Multicast delegate is registered more than once.");
var args = new <API key>(button);
handler.Invoke(this, args);
CancelDefault = args.Cancel;
}
}
public event EventHandler Disposing;
protected override void Dispose(bool disposing)
{
Disposing?.Invoke(this, EventArgs.Empty);
base.Dispose(disposing);
_control.Dispose();
}
}
}
|
// File: Main.cpp
// Project: Launcher
#include <StdInc.h>
int ShowMessageBox(char * szText)
{
return MessageBox(NULL, szText, "IV:MP", MB_ICONEXCLAMATION | MB_OK);
}
bool <API key>(char * szProcessName, DWORD * dwProcessId)
{
bool bReturn = false;
// Create a tool help 32 process snapshot
HANDLE hProcessSnapShot = <API key>(TH32CS_SNAPPROCESS, 0);
if(!hProcessSnapShot)
return false;
PROCESSENTRY32 ProcessEntry;
ProcessEntry.dwSize = sizeof(ProcessEntry);
if(Process32First(hProcessSnapShot, &ProcessEntry))
{
// Enumerate through all processes
while(Process32Next(hProcessSnapShot, &ProcessEntry))
{
// Check the process name to see if it matches szProcessName
if(!strcmp(ProcessEntry.szExeFile, szProcessName))
{
// It matches, set the process id and return true
*dwProcessId = ProcessEntry.th32ProcessID;
bReturn = true;
break;
}
}
}
// Close the snapshot handle
CloseHandle(hProcessSnapShot);
return bReturn;
}
bool IsProcessRunning(char * szProcessName)
{
// Simply return the value of <API key>
DWORD dwProcessId = 0;
return <API key>(szProcessName, &dwProcessId);
}
bool <API key>(DWORD dwProcessId, char * szLibraryPath)
{
bool bReturn = true;
// Open our target process
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcessId);
if(!hProcess)
{
// Failed to open the process
ShowMessageBox("Failed to open the remote process, Cannot launch IV:MP.");
return false;
}
// Get the length of the library path
size_t sLibraryPathLen = (strlen(szLibraryPath) + 1);
// Allocate the a block of memory in our target process for the library name
void * pRemoteLibraryPath = VirtualAllocEx(hProcess, NULL, sLibraryPathLen, MEM_COMMIT, PAGE_READWRITE);
// Write our library name to the allocated block of memory
SIZE_T sBytesWritten = 0;
WriteProcessMemory(hProcess, pRemoteLibraryPath, (void *)szLibraryPath, sLibraryPathLen, &sBytesWritten);
if(sBytesWritten != sLibraryPathLen)
{
ShowMessageBox("Failed to write library path into remote process. Cannot launch IV:MP.");
bReturn = false;
}
else
{
// Get the handle of Kernel32.dll
HMODULE hKernel32 = GetModuleHandle("Kernel32");
// Get the address of the LoadLibraryA function from Kernel32.dll
FARPROC pfnLoadLibraryA = GetProcAddress(hKernel32, "LoadLibraryA");
// Create a thread inside the target process to load our library
HANDLE hThread = CreateRemoteThread(hProcess, NULL, 0, (<API key>)pfnLoadLibraryA, pRemoteLibraryPath, 0, NULL);
if(hThread)
{
// Wait for the created thread to end
WaitForSingleObject(hThread, INFINITE);
// Get the remote thread exit code
/*DWORD dwExitCode;
GetExitCodeThread(hThread, &dwExitCode);
if(dwExitCode != 0)
{
ShowMessageBox("Failed to inject library into remote process. Cannot launch IV:MP.");
bReturn = false;
}*/
// Close our thread handle
CloseHandle(hThread);
}
else
{
// Thread creation failed
ShowMessageBox("Failed to create remote thread in remote process. Cannot launch IV:MP.");
bReturn = false;
}
}
// Free the allocated block of memory inside the target process
VirtualFreeEx(hProcess, pRemoteLibraryPath, sizeof(pRemoteLibraryPath), MEM_RELEASE);
// If the injection failed terminate the target process
if(!bReturn)
TerminateProcess(hProcess, 0);
// Close our target process handle
CloseHandle(hProcess);
return bReturn;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
// Get the LaunchGTAIV.exe path
char szLaunchGTAIVExe[1024];
sprintf(szLaunchGTAIVExe, "%sLaunchGTAIV.exe", SharedUtil::GetAppPath());
// Check if LaunchGTAIV.exe exists
WIN32_FIND_DATA fdFileInfo;
if(FindFirstFile(szLaunchGTAIVExe, &fdFileInfo) == <API key>)
{
ShowMessageBox("Failed to find LaunchGTAIV.exe. Cannot launch IV:MP.");
return 1;
}
// Get the full path of Client.dll
char szLibraryPath[MAX_PATH];
sprintf(szLibraryPath, "%sIVMP\\Client.dll", SharedUtil::GetAppPath());
// Check if Client.dll exists
if(FindFirstFile(szLibraryPath, &fdFileInfo) == <API key>)
{
ShowMessageBox("Failed to find Client.dll. Cannot launch IV:MP.");
return 1;
}
// Get the full path of LauncherLibrary.dll
sprintf(szLibraryPath, "%sIVMP\\LauncherLibrary.dll", SharedUtil::GetAppPath());
// Check if Launcher.dll exists
if(FindFirstFile(szLibraryPath, &fdFileInfo) == <API key>)
{
ShowMessageBox("Failed to find LauncherLibrary.dll. Cannot launch IV:MP.");
return 1;
}
// Check if LaunchGTAIV.exe is already running
if(IsProcessRunning("LaunchGTAIV.exe"))
{
ShowMessageBox("LaunchGTAIV.exe is already running. Cannot launch IV:MP.");
return 1;
}
// Check if GTAIV.exe is already running
if(IsProcessRunning("GTAIV.exe"))
{
ShowMessageBox("GTAIV.exe is already running. Cannot launch IV:MP.");
return 1;
}
// Start LaunchGTAIV.exe
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if(!CreateProcess(szLaunchGTAIVExe, NULL, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, SharedUtil::GetAppPath(),
&siStartupInfo, &piProcessInfo))
{
ShowMessageBox("Failed to start LaunchGTAIV.exe. Cannot launch IV:MP.");
return 1;
}
// Inject our code into LaunchGTAIV.exe
if(!<API key>(piProcessInfo.dwProcessId, szLibraryPath))
{
TerminateProcess(piProcessInfo.hProcess, 0);
ShowMessageBox("Failed to inject LauncherLibrary.dll into LaunchGTAIV.exe. Cannot launch IV:MP.");
return 1;
}
// Resume the LaunchGTAIV.exe thread
ResumeThread(piProcessInfo.hThread);
return 0;
}
|
#include "../driver.h"
#include "../boolean.h"
// Starts a video driver in a new thread.
// Access to video driver will be mediated through this driver.
bool <API key>(const video_driver_t **out_driver, void **out_data,
const input_driver_t **input, void **input_data,
const video_driver_t *driver, const video_info_t *info);
|
#ifndef <API key>
#define <API key>
#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif
#include <magick/exception-private.h>
#include <magick/image.h>
#include <magick/color.h>
#include <magick/image-private.h>
#include <magick/quantum-private.h>
static inline MagickPixelPacket *<API key>(
const MagickPixelPacket *pixel)
{
MagickPixelPacket
*clone_pixel;
clone_pixel=(MagickPixelPacket *) <API key>(1,
sizeof(*clone_pixel));
if (clone_pixel == (MagickPixelPacket *) NULL)
ThrowFatalException(<API key>,"<API key>");
*clone_pixel=(*pixel);
return(clone_pixel);
}
static inline MagickBooleanType IsGrayPixel(const PixelPacket *pixel)
{
#if !defined(<API key>)
if ((GetPixelRed(pixel) == GetPixelGreen(pixel)) &&
(GetPixelGreen(pixel) == GetPixelBlue(pixel)))
return(MagickTrue);
#else
{
double
alpha,
beta;
alpha=GetPixelRed(pixel)-GetPixelGreen(pixel);
beta=GetPixelGreen(pixel)-GetPixelBlue(pixel);
if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
return(MagickTrue);
}
#endif
return(MagickFalse);
}
static inline MagickBooleanType IsMonochromePixel(const PixelPacket *pixel)
{
#if !defined(<API key>)
if (((GetPixelRed(pixel) == 0) ||
(GetPixelRed(pixel) == (Quantum) QuantumRange)) &&
(GetPixelRed(pixel) == GetPixelGreen(pixel)) &&
(GetPixelGreen(pixel) == GetPixelBlue(pixel)))
return(MagickTrue);
#else
{
double
alpha,
beta;
alpha=GetPixelRed(pixel)-GetPixelGreen(pixel);
beta=GetPixelGreen(pixel)-GetPixelBlue(pixel);
if (((fabs(GetPixelRed(pixel)) <= MagickEpsilon) ||
(fabs(GetPixelRed(pixel)-QuantumRange) <= MagickEpsilon)) &&
(fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
return(MagickTrue);
}
#endif
return(MagickFalse);
}
static inline void <API key>(const Image *image,
const PixelPacket *color,const IndexPacket *index,MagickPixelPacket *pixel)
{
pixel->red=(MagickRealType) GetPixelRed(color);
pixel->green=(MagickRealType) GetPixelGreen(color);
pixel->blue=(MagickRealType) GetPixelBlue(color);
pixel->opacity=(MagickRealType) GetPixelOpacity(color);
if ((image->colorspace == CMYKColorspace) &&
(index != (const IndexPacket *) NULL))
pixel->index=(MagickRealType) GetPixelIndex(index);
}
static inline void <API key>(const Image *image,
MagickPixelPacket *pixel)
{
/*
Obsoleted by MorphologyApply().
*/
pixel->red=image->bias;
pixel->green=image->bias;
pixel->blue=image->bias;
pixel->opacity=image->bias;
pixel->index=image->bias;
}
static inline void SetPixelPacket(const Image *image,
const MagickPixelPacket *pixel,PixelPacket *color,IndexPacket *index)
{
SetPixelRed(color,ClampToQuantum(pixel->red));
SetPixelGreen(color,ClampToQuantum(pixel->green));
SetPixelBlue(color,ClampToQuantum(pixel->blue));
SetPixelOpacity(color,ClampToQuantum(pixel->opacity));
if ((image->colorspace == CMYKColorspace) ||
(image->storage_class == PseudoClass))
SetPixelIndex(index,ClampToQuantum(pixel->index));
}
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif
#endif
|
var TidalResolver = Tomahawk.extend(Tomahawk.Resolver, {
apiVersion: 0.9,
/* This can also be used with WiMP service if you change next 2 lines */
api_location: 'https://listen.tidal.com/v1/',
api_<API key>,
logged_in: null, // null, = not yet tried, 0 = pending, 1 = success, 2 = failed
settings: {
cacheTime: 300,
name: 'TIDAL',
icon: '../images/icon.png',
weight: 91,
timeout: 8
},
strQuality: ['LOW', 'HIGH', 'LOSSLESS'],
numQuality: [64, 320, 1411],
getConfigUi: function () {
return {
"widget": Tomahawk.readBase64("config.ui"),
fields: [{
name: "email",
widget: "email_edit",
property: "text"
}, {
name: "password",
widget: "password_edit",
property: "text"
}, {
name: "quality",
widget: "quality",
property: "currentIndex"
}]
};
},
newConfigSaved: function (newConfig) {
var changed =
this._email !== newConfig.email ||
this._password !== newConfig.password ||
this._quality != newConfig.quality;
if (changed) {
this.init();
}
},
testConfig: function (config) {
return this._getLoginPromise(config).then(function () {
return Tomahawk.<API key>.Success;
}, function (xhr) {
if (xhr.status == 401) {
return Tomahawk.<API key>.InvalidCredentials;
} else {
return Tomahawk.<API key>.CommunicationError;
}
});
},
init: function () {
var config = this.getUserConfig();
this._email = config.email;
this._password = config.password;
this._quality = config.quality;
if (!this._email || !this._password) {
Tomahawk.reportCapabilities(<API key>.NullCapability);
//This is being called even for disabled ones
//throw new Error( "Invalid configuration." );
Tomahawk.log("Invalid Configuration");
return;
}
Tomahawk.reportCapabilities(<API key>.UrlLookup);
this._login(config);
},
_convertTracks: function (entries) {
return entries.filter(function (entry) {
return entry.allowStreaming;
}).map(this._convertTrack, this);
},
_convertTrack: function (entry) {
return {
type: Tomahawk.UrlType.Track,
artist: entry.artist.name,
album: entry.album.title,
track: entry.title,
year: entry.year,
albumpos: entry.trackNumber,
discnumber: entry.volumeNumber,
duration: entry.duration,
url: 'tidal://track/' + entry.id,
hint: 'tidal://track/' + entry.id,
checked: true,
bitrate: this.numQuality[this._quality]
};
},
_convertAlbum: function (entry) {
return {
type: Tomahawk.UrlType.Album,
artist: entry.artist.name,
album: entry.title,
url: entry.url
};
},
_convertArtist: function (entry) {
return {
type: Tomahawk.UrlType.Artist,
artist: entry.name
};
},
_convertPlaylist: function (entry) {
return {
type: Tomahawk.UrlType.Playlist,
title: entry.title,
guid: "tidal-playlist-" + entry.uuid,
info: entry.description + " (from TidalHiFi)",
creator: "tidal-user-" + entry.creator.id,
// TODO: Perhaps use tidal://playlist/uuid
url: entry.url
};
},
search: function (params) {
var query = params.query;
var limit = params.limit;
if (!this.logged_in) {
return this._defer(this.search, [query], this);
} else if (this.logged_in === 2) {
throw new Error('Failed login, cannot search.');
}
var that = this;
var settings = {
data: {
limit: limit || 9999,
query: query.replace(/[ \-]+/g, ' ').toLowerCase(),
sessionId: this._sessionId,
countryCode: this._countryCode
}
};
return Tomahawk.get(this.api_location + "search/tracks", settings)
.then(function (response) {
return that._convertTracks(response.items);
});
},
resolve: function (params) {
var artist = params.artist;
var album = params.album;
var track = params.track;
var query = [artist, album, track].join(' ');
return this.search({
query: query,
limit: 5
});
},
_parseUrlPrefix: function (url) {
return url.match(/(?:https?:\/\/)?(?:listen|play|www)\.(tidal|wimpmusic)\.com\/(?:v1\/)?([a-z]{3,}?)s?\/([\w\-]+)[\/?]?/);
},
canParseUrl: function (params) {
var url = params.url;
var type = params.type;
url = this._parseUrlPrefix(url);
if (!url) {
throw new Error("Couldn't parse URL. Invalid format?");
}
switch (type) {
case TomahawkUrlType.Album:
return url[2] == 'album';
case TomahawkUrlType.Artist:
return url[2] == 'artist';
case TomahawkUrlType.Track:
return url[2] == 'track';
case TomahawkUrlType.Playlist:
return url[2] == 'playlist';
}
},
_debugPrint: function (obj, spaces) {
spaces = spaces || '';
var str = '';
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
var b = ["{", "}"];
if (obj[key].constructor == Array) {
b = ["[", "]"];
}
str += spaces + key + ": " + b[0] + "\n" + this._debugPrint(obj[key],
spaces + ' ') + "\n" + spaces + b[1] + '\n';
} else {
str += spaces + key + ": " + obj[key] + "\n";
}
}
if (spaces != '') {
return str;
} else {
str.split('\n').map(Tomahawk.log, Tomahawk);
}
},
lookupUrl: function (params) {
var url = params.url;
return this.<API key>(url);
},
<API key>: function (url) {
if (!this.logged_in) {
return this._defer(this.lookupUrl, [url], this);
} else if (this.logged_in === 2) {
throw new Error('Failed login, cannot lookupUrl');
}
var match = this._parseUrlPrefix(url);
Tomahawk.log(url + " -> " + match[1] + " " + match[2] + " " + match[3]);
if (!match[1]) {
throw new Error("Couldn't parse given URL: " + url);
}
var that = this;
var params = {
countryCode: this._countryCode,
sessionId: this._sessionId,
limit: 9999
};
if (match[2] == 'album') {
var rqUrl = this.api_location + 'albums/' + match[3];
var getInfo = Tomahawk.get(rqUrl, {data: params});
var getTracks = Tomahawk.get(rqUrl + "/tracks", {data: params});
Tomahawk.log(rqUrl);
return RSVP.Promise.all([getInfo, getTracks]).then(function (response) {
var result = that._convertAlbum(response[0]);
result.tracks = that._convertTracks(response[1].items);
return result;
});
} else if (match[2] == 'artist') {
var rqUrl = this.api_location + 'artists/' + match[3];
return Tomahawk.get(rqUrl, {
data: params
}).then(function (response) {
return that._convertArtist(response);
});
} else if (match[2] == 'track') {
var rqUrl = this.api_location + 'tracks/' + match[3];
// I can't find any link on the site for tracks.
return Tomahawk.get(rqUrl, {
data: params
}).then(function (response) {
return that._convertTrack(response);
});
} else if (match[2] == 'playlist') {
var rqUrl = this.api_location + 'playlists/' + match[3];
var getInfo = Tomahawk.get(rqUrl, {data: params});
var getTracks = Tomahawk.get(rqUrl + "/tracks", {data: params});
return RSVP.Promise.all([getInfo, getTracks]).then(function (response) {
var result = that._convertPlaylist(response[0]);
result.tracks = that._convertTracks(response[1].items);
return result;
});
}
},
_parseUrn: function (urn) {
// "tidal://track/18692667"
var match = urn.match(/^tidal:\/\/([a-z]+)\/(.+)$/);
if (!match) {
return null;
}
return {
type: match[1],
id: match[2]
};
},
getStreamUrl: function (params) {
var url = params.url;
if (!this.logged_in) {
return this._defer(this.getStreamUrl, [url], this);
} else if (this.logged_in === 2) {
throw new Error('Failed login, cannot getStreamUrl.');
}
var parsedUrn = this._parseUrn(url);
if (!parsedUrn || parsedUrn.type != 'track') {
Tomahawk.log("Failed to get stream. Couldn't parse '" + url + "'");
return;
}
var settings = {
data: {
token: this.api_token,
countryCode: this._countryCode,
soundQuality: this.strQuality[this._quality],
sessionId: this._sessionId
}
};
return Tomahawk.get(this.api_location + "tracks/" + parsedUrn.id + "/streamUrl", settings)
.then(function (response) {
return {
url: response.url
};
});
},
_defer: function (callback, args, scope) {
if (typeof this._loginPromise !== 'undefined' && 'then' in this._loginPromise) {
args = args || [];
scope = scope || this;
Tomahawk.log('Deferring action with ' + args.length + ' arguments.');
return this._loginPromise.then(function () {
Tomahawk.log('Performing deferred action with ' + args.length + ' arguments.');
callback.call(scope, args);
});
}
},
_getLoginPromise: function (config) {
var settings = {
type: 'POST', // backwards compatibility for old versions of tomahawk.js
data: {
"username": config.email.trim(),
"password": config.password.trim()
},
headers: {'Origin': 'http://listen.tidal.com'}
};
return Tomahawk.post(this.api_location + "login/username?token=" + this.api_token,
settings);
},
_login: function (config) {
// If a login is already in progress don't start another!
if (this.logged_in === 0) {
return;
}
this.logged_in = 0;
var that = this;
this._loginPromise = this._getLoginPromise(config)
.then(function (resp) {
Tomahawk.log(that.settings.name + " successfully logged in.");
that._countryCode = resp.countryCode;
that._sessionId = resp.sessionId;
that._userId = resp.userId;
that.logged_in = 1;
}, function (error) {
Tomahawk.log(that.settings.name + " failed login.");
delete that._countryCode;
delete that._sessionId;
delete that._userId;
that.logged_in = 2;
}
);
return this._loginPromise;
}
});
Tomahawk.resolver.instance = TidalResolver;
|
<?php
namespace SMW\MediaWiki\Hooks;
use SMW\FactboxCache;
use SMW\Application;
use SMW\CacheIdGenerator;
use WikiPage;
class ArticlePurge {
/**
* @var WikiPage
*/
protected $wikiPage = null;
/**
* @since 1.9
*
* @param WikiPage $wikiPage
*/
public function __construct( WikiPage &$wikiPage ) {
$this->wikiPage = $wikiPage;
}
/**
* @since 1.9
*
* @return CacheIdGenerator
*/
public static function newCacheId( $pageId ) {
return new CacheIdGenerator( $pageId, 'autorefresh' );
}
/**
* @see FunctionHook::process
*
* @since 1.9
*
* @return true
*/
public function process() {
$pageId = $this->wikiPage->getTitle()->getArticleID();
/**
* @var Settings $settings
*/
$settings = Application::getInstance()->getSettings();
/**
* @var CacheHandler $cache
*/
$cache = Application::getInstance()->getCache();
$cache->setCacheEnabled( $pageId > 0 )
->setKey( $this->newCacheId( $pageId ) )
->set( $settings->get( '<API key>' ) );
$cache->setCacheEnabled( $settings->get( '<API key>' ) )
->setKey( FactboxCache::newCacheId( $pageId ) )
->delete();
return true;
}
}
|
#!/usr/bin/python
import argparse
import xml.etree.ElementTree as ET
def main():
parser = argparse.ArgumentParser(description="List all error without a CWE assigned in CSV format")
parser.add_argument("-F", metavar="filename", required=True, help="XML file containing output from: ./cppcheck --errorlist --xml-version=2")
parsed = parser.parse_args()
tree = ET.parse(vars(parsed)["F"])
root = tree.getroot()
for child in root.iter("error"):
if "cwe" not in child.attrib:
print child.attrib["id"], ",", child.attrib["severity"], ",", child.attrib["verbose"]
if __name__ == "__main__":
main()
|
#endregion
namespace OpenUO.Ultima
{
public sealed class SkillData
{
//public static SkillData DefaultData { get { return new SkillData(-1, "null", false, 0, 0x0, null); } }
private readonly SkillCategory _category;
private readonly int _extra;
private readonly int _index = -1;
private readonly string _name = string.Empty;
private readonly byte _unknown;
private readonly bool _useButton;
public SkillData(int index, string name, bool useButton, int extra, byte unk, SkillCategory category)
{
_index = index;
_category = category;
_name = name;
_useButton = useButton;
_extra = extra;
_unknown = unk;
}
public int Index
{
get { return _index; }
}
public string Name
{
get { return _name; }
}
public int Extra
{
get { return _extra; }
}
public bool UseButton
{
get { return _useButton; }
}
public byte Unknown
{
get { return _unknown; }
}
public SkillCategory Category
{
get { return _category; }
}
public int NameLength
{
get { return _name.Length; }
}
}
}
|
package com.playuav.android.proxy.mission.item.fragments;
import com.playuav.android.R;
import com.o3dr.services.android.lib.drone.mission.MissionItemType;
public class MissionRTLFragment extends <API key> {
@Override
protected int getResource() {
return R.layout.<API key>;
}
@Override
public void onApiConnected(){
super.onApiConnected();
typeSpinner.setSelection(commandAdapter.getPosition(MissionItemType.RETURN_TO_LAUNCH));
}
}
|
cordova.define("<API key>.mainHandle", function(require, exports, module) {
var inBrowser = false;
var NativeStorageError = require('./NativeStorageError');
function isInBrowser() {
inBrowser = (window.cordova && (window.cordova.platformId === 'browser' || window.cordova.platformId === 'osx')) || !(window.phonegap || window.cordova);
return inBrowser;
}
function <API key>() {
if (!isInBrowser()) {
return 0;
//<API key> = exec;
} else {
if (window.localStorage) {
return 1;
//<API key> = localStorageHandle;
} else {
return 2;
//console.log("ALERT! localstorage isn't supported");
}
}
}
//if storage not available gracefully fails, no error message for now
function StorageHandle() {
this.storageSupport = <API key>();
switch (this.storageSupport) {
case 0:
var exec = require('cordova/exec');
this.<API key> = exec;
break;
case 1:
var localStorageHandle = require('./LocalStorageHandle');
this.<API key> = localStorageHandle;
break;
case 2:
console.log("ALERT! localstorage isn't supported");
break;
default:
console.log("StorageSupport Error");
break;
}
}
StorageHandle.prototype.set = function(reference, value, success, error) {
if (reference === null) {
error("The reference can't be null");
return;
}
if (value === null) {
error("a Null value isn't supported");
return;
}
switch (typeof value) {
case 'undefined':
error("an undefined type isn't supported");
break;
case 'boolean': {
this.putBoolean(reference, value, success, error);
break;
}
case 'number': {
// Good now check if it's a float or an int
if (value === +value) {
if (value === (value | 0)) {
// it's an int
this.putInt(reference, value, success, error);
} else if (value !== (value | 0)) {
this.putDouble(reference, value, success, error);
}
} else {
error("The value doesn't seem to be a number");
}
break;
}
case 'string': {
this.putString(reference, value, success, error);
break;
}
case 'object': {
this.putObject(reference, value, success, error);
break;
}
default:
error("The type isn't supported or isn't been recognized");
break;
}
};
/* removing */
StorageHandle.prototype.remove = function(reference, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
if (inBrowser) {
try {
localStorage.removeItem(reference);
success();
} catch (e) {
error(e);
}
} else {
this.<API key>(success, error, "NativeStorage", "remove", [reference]);
}
};
/* clearing */
StorageHandle.prototype.clear = function(success, error) {
if (inBrowser) {
try {
localStorage.clear();
success();
} catch (e) {
error(e);
}
} else {
this.<API key>(success, error, "NativeStorage", "clear", []);
}
};
/* boolean storage */
StorageHandle.prototype.putBoolean = function(reference, aBoolean, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
if (aBoolean === null) {
error("a Null value isn't supported");
return;
}
if (typeof aBoolean === 'boolean') {
this.<API key>(function(returnedBool) {
if ('string' === typeof returnedBool) {
if ( (returnedBool === 'true') ) {
success(true);
} else if ( (returnedBool === 'false') ) {
success(false);
} else {
error("The returned boolean from SharedPreferences was not recognized: " + returnedBool);
}
} else {
success(returnedBool);
}
}, error, "NativeStorage", "putBoolean", [reference, aBoolean]);
} else {
error("Only boolean types are supported");
}
};
StorageHandle.prototype.getBoolean = function(reference, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(function(returnedBool) {
if ('string' === typeof returnedBool) {
if ( (returnedBool === 'true') ) {
success(true);
} else if ( (returnedBool === 'false') ) {
success(false);
} else {
error("The returned boolean from SharedPreferences was not recognized: " + returnedBool);
}
} else {
success(returnedBool);
}
}, error, "NativeStorage", "getBoolean", [reference]);
};
/* int storage */
StorageHandle.prototype.putInt = function(reference, anInt, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(success, error, "NativeStorage", "putInt", [reference, anInt]);
};
StorageHandle.prototype.getInt = function(reference, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(success, error, "NativeStorage", "getInt", [reference]);
};
/* float storage */
StorageHandle.prototype.putDouble = function(reference, aFloat, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(success, error, "NativeStorage", "putDouble", [reference, aFloat]);
};
StorageHandle.prototype.getDouble = function(reference, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(function(data) {
if (isNaN(data)) {
error('Expected double but got non-number');
} else {
success(parseFloat(data));
}
}, error, "NativeStorage", "getDouble", [reference]);
};
/* string storage */
StorageHandle.prototype.putString = function(reference, s, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(success, error, "NativeStorage", "putString", [reference, s]);
};
StorageHandle.prototype.getString = function(reference, success, error) {
if (reference === null) {
error("Null reference isn't supported");
return;
}
this.<API key>(success, error, "NativeStorage", "getString", [reference]);
};
/* object storage COMPOSITE AND DOESNT CARE FOR BROWSER*/
StorageHandle.prototype.putObject = function(reference, obj, success, error) {
var objAsString = "";
try {
objAsString = JSON.stringify(obj);
} catch (err) {
error(err);
}
this.putString(reference, objAsString, function(data) {
var obj = {};
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(err);
}
}, error);
};
StorageHandle.prototype.getObject = function(reference, success, error) {
this.getString(reference, function(data) {
var obj = {};
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(err);
}
}, error);
};
/* API >= 2 */
StorageHandle.prototype.setItem = function(reference, obj, success, error) {
var objAsString = "";
try {
objAsString = JSON.stringify(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
return;
}
if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
}
this.<API key>(function(data) {
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
}
}, function(code) {
error(new NativeStorageError(code, "Native", ""));
}, "NativeStorage", "setItem", [reference, objAsString]);
};
StorageHandle.prototype.getItem = function(reference, success, error) {
if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
}
var obj = {};
this.<API key>(
function(data) {
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
}
},
function(code) {
error(new NativeStorageError(code, "Native", ""));
}, "NativeStorage", "getItem", [reference]);
};
/* API >= 2 */
StorageHandle.prototype.setSecretItem = function(reference, obj, encryptConfig, success, error) {
var objAsString = "";
try {
objAsString = JSON.stringify(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
return;
}
if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
}
var action = "setItem";
var params = [reference, objAsString];
switch (encryptConfig.mode) {
case "password":
action = "setItemWithPassword";
params = [reference, objAsString, encryptConfig.value];
break;
case "key":
action = "setItemWithKey";
break;
case "none":
break;
default: {
error(new NativeStorageError(NativeStorageError.WRONG_PARAMETER, "JS", ""));
return;
}
}
this.<API key>(function(data) {
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
}
}, function(code) {
error(new NativeStorageError(code, "Native", ""));
}, "NativeStorage", action, params);
};
StorageHandle.prototype.getSecretItem = function(reference, encryptConfig, success, error) {
if (reference === null) {
error(new NativeStorageError(NativeStorageError.NULL_REFERENCE, "JS", ""));
return;
}
var obj = {};
var action = "getItem";
var params = [reference];
switch (encryptConfig.mode) {
case "password":
action = "getItemWithPassword";
params = [reference, encryptConfig.value];
break;
case "key":
action = "getItemWithKey";
break;
case "none":
break;
default: {
error(new NativeStorageError(NativeStorageError.WRONG_PARAMETER, "JS", ""));
return;
}
}
this.<API key>(
function(data) {
try {
obj = JSON.parse(data);
success(obj);
} catch (err) {
error(new NativeStorageError(NativeStorageError.JSON_ERROR, "JS", err));
}
},
function(code) {
error(new NativeStorageError(code, "Native", ""));
}, "NativeStorage", action, params);
};
/* list keys */
StorageHandle.prototype.keys = function(success, error) {
this.<API key>(success, error, "NativeStorage", "keys");
};
var storageHandle = new StorageHandle();
module.exports = storageHandle;
});
|
// The LLVM Compiler Infrastructure
// <memory>
// template <class OuterAlloc, class... InnerAllocs>
// class <API key>
// <API key>& operator=(const <API key>& other);
#include <scoped_allocator>
#include <cassert>
#include "allocators.h"
int main()
{
#ifndef <API key>
{
typedef std::<API key><A1<int>> A;
A a1(A1<int>(3));
A aN;
A1<int>::copy_called = false;
A1<int>::move_called = false;
aN = a1;
assert(A1<int>::copy_called == true);
assert(A1<int>::move_called == false);
assert(aN == a1);
}
{
typedef std::<API key><A1<int>, A2<int>> A;
A a1(A1<int>(4), A2<int>(5));
A aN;
A1<int>::copy_called = false;
A1<int>::move_called = false;
A2<int>::copy_called = false;
A2<int>::move_called = false;
aN = a1;
assert(A1<int>::copy_called == true);
assert(A1<int>::move_called == false);
assert(A2<int>::copy_called == true);
assert(A2<int>::move_called == false);
assert(aN == a1);
}
{
typedef std::<API key><A1<int>, A2<int>, A3<int>> A;
A a1(A1<int>(4), A2<int>(5), A3<int>(6));
A aN;
A1<int>::copy_called = false;
A1<int>::move_called = false;
A2<int>::copy_called = false;
A2<int>::move_called = false;
A3<int>::copy_called = false;
A3<int>::move_called = false;
aN = a1;
assert(A1<int>::copy_called == true);
assert(A1<int>::move_called == false);
assert(A2<int>::copy_called == true);
assert(A2<int>::move_called == false);
assert(A3<int>::copy_called == true);
assert(A3<int>::move_called == false);
assert(aN == a1);
}
#endif // <API key>
}
|
<?php
// Moodle is free software: you can redistribute it and/or modify
// (at your option) any later version.
// Moodle is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
defined('MOODLE_INTERNAL') || die();
$string['pluginname'] = 'Google Drive';
$string['disabled'] = 'Disabled';
$string['issuer'] = 'OAuth 2 Service';
$string['issuer_help'] = 'The OAuth 2 service used to access google drive.';
$string['test_converter'] = 'Test this converter is working properly.';
$string['test_conversion'] = 'Test document conversion';
$string['<API key>'] = 'This document converter is configured properly.';
$string['<API key>'] = 'This document converter is not configured properly.';
$string['test_issuerinvalid'] = 'The OAuth service in the document converter settings is set to an invalid value.';
$string['<API key>'] = 'The OAuth service set in the document converter settings is not enabled.';
$string['<API key>'] = 'The OAuth service set in the document converter settings does not have a system account connected.';
$string['test_issuernotset'] = 'The OAuth service needs to be set in the document converter settings.';
|
/**
* \file load.c
*
* This file contains the routines that deal with processing text strings
* for options, either from a NUL-terminated string passed in or from an
* rc/ini file.
*
* @addtogroup autoopts
* @{
*/
/* = = = <API key> = = = */
static bool
get_realpath(char * buf, size_t b_sz);
static bool
add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
static bool
add_env_val(char * buf, int buf_sz, char const * name);
static char *
assemble_arg_val(char * txt, tOptionLoadMode mode);
static char *
trim_quotes(char * arg);
static bool
direction_ok(opt_state_mask_t f, int dir);
/* = = = END-STATIC-FORWARD = = = */
static bool
get_realpath(char * buf, size_t b_sz)
{
#if defined(<API key>)
{
size_t name_len;
char * pz = <API key>(buf);
if (pz == NULL)
return false;
name_len = strlen(pz);
if (name_len >= (size_t)b_sz) {
free(pz);
return false;
}
memcpy(buf, pz, name_len + 1);
free(pz);
}
#elif defined(HAVE_REALPATH)
{
size_t name_len;
char z[PATH_MAX+1];
if (realpath(buf, z) == NULL)
return false;
name_len = strlen(z);
if (name_len >= b_sz)
return false;
memcpy(buf, z, name_len + 1);
}
#endif
return true;
}
/*=export_func optionMakePath
* private:
*
* what: translate and construct a path
* arg: + char* + p_buf + The result buffer +
* arg: + int + b_sz + The size of this buffer +
* arg: + char const* + fname + The input name +
* arg: + char const* + prg_path + The full path of the current program +
*
* ret-type: bool
* ret-desc: true if the name was handled, otherwise false.
* If the name does not start with ``$'', then it is handled
* simply by copying the input name to the output buffer and
* resolving the name with either
* @code{<API key>(3GLIBC)} or @code{realpath(3C)}.
*
* doc:
*
* This routine will copy the @code{pzName} input name into the
* @code{pzBuf} output buffer, not exceeding @code{bufSize} bytes. If the
* first character of the input name is a @code{'$'} character, then there
* is special handling:
* @*
* @code{$$} is replaced with the directory name of the @code{pzProgPath},
* searching @code{$PATH} if necessary.
* @*
* @code{$@} is replaced with the AutoGen package data installation directory
* (aka @code{pkgdatadir}).
* @*
* @code{$NAME} is replaced by the contents of the @code{NAME} environment
* variable. If not found, the search fails.
*
* Please note: both @code{$$} and @code{$NAME} must be at the start of the
* @code{pzName} string and must either be the entire string or be followed
* by the @code{'/'} (backslash on windows) character.
*
* err: @code{false} is returned if:
* @*
* @bullet{} The input name exceeds @code{bufSize} bytes.
* @*
* @bullet{} @code{$$}, @code{$@@} or @code{$NAME} is not the full string
* and the next character is not '/'.
* @*
* @bullet{} libopts was built without PKGDATADIR defined and @code{$@@}
* was specified.
* @*
* @bullet{} @code{NAME} is not a known environment variable
* @*
* @bullet{} @code{<API key>} or @code{realpath} return
* errors (cannot resolve the resulting path).
=*/
bool
optionMakePath(char * p_buf, int b_sz, char const * fname, char const * prg_path)
{
{
size_t len = strlen(fname);
if (((size_t)b_sz <= len) || (len == 0))
return false;
}
/*
* IF not an environment variable, just copy the data
*/
if (*fname != '$') {
char const * src = fname;
char * dst = p_buf;
int ct = b_sz;
for (;;) {
if ( (*(dst++) = *(src++)) == NUL)
break;
if (--ct <= 0)
return false;
}
}
/*
* IF the name starts with "$$", then it must be "$$" or
* it must start with "$$/". In either event, replace the "$$"
* with the path to the executable and append a "/" character.
*/
else switch (fname[1]) {
case NUL:
return false;
case '$':
if (! add_prog_path(p_buf, b_sz, fname, prg_path))
return false;
break;
case '@':
if (program_pkgdatadir[0] == NUL)
return false;
if (snprintf(p_buf, (size_t)b_sz, "%s%s",
program_pkgdatadir, fname + 2) >= b_sz)
return false;
break;
default:
if (! add_env_val(p_buf, b_sz, fname))
return false;
}
return get_realpath(p_buf, b_sz);
}
/**
* convert a leading "$$" into a path to the executable.
*/
static bool
add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path)
{
char const * path;
char const * pz;
int skip = 2;
switch (fname[2]) {
case DIRCH:
skip = 3;
case NUL:
break;
default:
return false;
}
/*
* See if the path is included in the program name.
* If it is, we're done. Otherwise, we have to hunt
* for the program using "pathfind".
*/
if (strchr(prg_path, DIRCH) != NULL)
path = prg_path;
else {
path = pathfind(getenv("PATH"), (char*)prg_path, "rx");
if (path == NULL)
return false;
}
pz = strrchr(path, DIRCH);
/*
* IF we cannot find a directory name separator,
* THEN we do not have a path name to our executable file.
*/
if (pz == NULL)
return false;
fname += skip;
/*
* Concatenate the file name to the end of the executable path.
* The result may be either a file or a directory.
*/
if ((unsigned)(pz - path) + 1 + strlen(fname) >= (unsigned)b_sz)
return false;
memcpy(buf, path, (size_t)((pz - path)+1));
strcpy(buf + (pz - path) + 1, fname);
/*
* If the "path" path was gotten from "pathfind()", then it was
* allocated and we need to deallocate it.
*/
if (path != prg_path)
AGFREE(path);
return true;
}
/**
* Add an environment variable value.
*/
static bool
add_env_val(char * buf, int buf_sz, char const * name)
{
char * dir_part = buf;
for (;;) {
int ch = (int)*++name;
if (! IS_VALUE_NAME_CHAR(ch))
break;
*(dir_part++) = (char)ch;
}
if (dir_part == buf)
return false;
*dir_part = NUL;
dir_part = getenv(buf);
/*
* Environment value not found -- skip the home list entry
*/
if (dir_part == NULL)
return false;
if (strlen(dir_part) + 1 + strlen(name) >= (unsigned)buf_sz)
return false;
sprintf(buf, "%s%s", dir_part, name);
return true;
}
/**
* Trim leading and trailing white space.
* If we are cooking the text and the text is quoted, then "cook"
* the string. To cook, the string must be quoted.
*
* @param[in,out] txt the input and output string
* @param[in] mode the handling mode (cooking method)
*/
LOCAL void
munge_str(char * txt, tOptionLoadMode mode)
{
char * pzE;
if (mode == OPTION_LOAD_KEEP)
return;
if (IS_WHITESPACE_CHAR(*txt)) {
char * src = <API key>(txt+1);
size_t l = strlen(src) + 1;
memmove(txt, src, l);
pzE = txt + l - 1;
} else
pzE = txt + strlen(txt);
pzE = SPN_WHITESPACE_BACK(txt, pzE);
*pzE = NUL;
if (mode == <API key>)
return;
switch (*txt) {
default: return;
case '"':
case '\'': break;
}
switch (pzE[-1]) {
default: return;
case '"':
case '\'': break;
}
(void)ao_string_cook(txt, NULL);
}
static char *
assemble_arg_val(char * txt, tOptionLoadMode mode)
{
char * end = strpbrk(txt, ARG_BREAK_STR);
int space_break;
/*
* Not having an argument to a configurable name is okay.
*/
if (end == NULL)
return txt + strlen(txt);
/*
* If we are keeping all whitespace, then the modevalue starts with the
* character that follows the end of the configurable name, regardless
* of which character caused it.
*/
if (mode == OPTION_LOAD_KEEP) {
*(end++) = NUL;
return end;
}
/*
* If the name ended on a white space character, remember that
* because we'll have to skip over an immediately following ':' or '='
* (and the white space following *that*).
*/
space_break = IS_WHITESPACE_CHAR(*end);
*(end++) = NUL;
end = <API key>(end);
if (space_break && ((*end == ':') || (*end == '=')))
end = <API key>(end+1);
return end;
}
static char *
trim_quotes(char * arg)
{
switch (*arg) {
case '"':
case '\'':
ao_string_cook(arg, NULL);
}
return arg;
}
/**
* See if the option is to be processed in the current scan direction
* (-1 or +1).
*/
static bool
direction_ok(opt_state_mask_t f, int dir)
{
if (dir == 0)
return true;
switch (f & (OPTST_IMM|OPTST_DISABLE_IMM)) {
case 0:
/*
* The selected option has no immediate action.
* THEREFORE, if the direction is PRESETTING
* THEN we skip this option.
*/
if (PRESETTING(dir))
return false;
break;
case OPTST_IMM:
if (PRESETTING(dir)) {
/*
* We are in the presetting direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((f & OPTST_DISABLED) == 0)
return false;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for enablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((f & OPTST_DISABLED) != 0)
return false;
}
break;
case OPTST_DISABLE_IMM:
if (PRESETTING(dir)) {
/*
* We are in the presetting direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if NOT disabled.
*/
if ((f & OPTST_DISABLED) != 0)
return false;
} else {
/*
* We are in the processing direction with an option we handle
* immediately for disablement, but normally for disablement.
* Therefore, skip if disabled.
*/
if ((f & OPTST_DISABLED) == 0)
return false;
}
break;
case OPTST_IMM|OPTST_DISABLE_IMM:
/*
* The selected option is always for immediate action.
* THEREFORE, if the direction is PROCESSING
* THEN we skip this option.
*/
if (PROCESSING(dir))
return false;
break;
}
return true;
}
/**
* Load an option from a block of text. The text must start with the
* configurable/option name and be followed by its associated value.
* That value may be processed in any of several ways. See "tOptionLoadMode"
* in autoopts.h.
*
* @param[in,out] opts program options descriptor
* @param[in,out] opt_state option processing state
* @param[in,out] line source line with long option name in it
* @param[in] direction current processing direction (preset or not)
* @param[in] load_mode option loading mode (OPTION_LOAD_*)
*/
LOCAL void
load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
tDirection direction, tOptionLoadMode load_mode )
{
/*
* When parsing a stored line, we only look at the characters after
* a hyphen. Long names must always be at least two characters and
* short options are always exactly one character long.
*/
line = <API key>(line);
{
char * arg = assemble_arg_val(line, load_mode);
if (IS_OPTION_NAME_CHAR(line[1])) {
if (! SUCCESSFUL(opt_find_long(opts, line, opt_state)))
return;
} else if (! SUCCESSFUL(opt_find_short(opts, *line, opt_state)))
return;
if ((! CALLED(direction)) && (opt_state->flags & OPTST_NO_INIT))
return;
opt_state->pzOptArg = trim_quotes(arg);
}
if (! direction_ok(opt_state->flags, direction))
return;
/*
* Fix up the args.
*/
if (OPTST_GET_ARGTYPE(opt_state->pOD->fOptState) == OPARG_TYPE_NONE) {
if (*opt_state->pzOptArg != NUL)
return;
opt_state->pzOptArg = NULL;
} else if (opt_state->pOD->fOptState & OPTST_ARG_OPTIONAL) {
if (*opt_state->pzOptArg == NUL)
opt_state->pzOptArg = NULL;
else {
AGDUPSTR(opt_state->pzOptArg, opt_state->pzOptArg, "opt arg");
opt_state->flags |= OPTST_ALLOC_ARG;
}
} else {
if (*opt_state->pzOptArg == NUL)
opt_state->pzOptArg = zNil;
else {
AGDUPSTR(opt_state->pzOptArg, opt_state->pzOptArg, "opt arg");
opt_state->flags |= OPTST_ALLOC_ARG;
}
}
{
tOptionLoadMode sv = option_load_mode;
option_load_mode = load_mode;
handle_opt(opts, opt_state);
option_load_mode = sv;
}
}
/*=export_func optionLoadLine
*
* what: process a string for an option name and value
*
* arg: tOptions*, opts, program options descriptor
* arg: char const*, line, NUL-terminated text
*
* doc:
*
* This is a client program callable routine for setting options from, for
* example, the contents of a file that they read in. Only one option may
* appear in the text. It will be treated as a normal (non-preset) option.
*
* When passed a pointer to the option struct and a string, it will find
* the option named by the first token on the string and set the option
* argument to the remainder of the string. The caller must NUL terminate
* the string. The caller need not skip over any introductory hyphens.
* Any embedded new lines will be included in the option
* argument. If the input looks like one or more quoted strings, then the
* input will be "cooked". The "cooking" is identical to the string
* formation used in AutoGen definition files (@pxref{basic expression}),
* except that you may not use backquotes.
*
* err: Invalid options are silently ignored. Invalid option arguments
* will cause a warning to print, but the function should return.
=*/
void
optionLoadLine(tOptions * opts, char const * line)
{
tOptState st = <API key>(SET);
char * pz;
proc_state_mask_t sv_flags = opts->fOptSet;
opts->fOptSet &= ~OPTPROC_ERRSTOP;
AGDUPSTR(pz, line, "opt line");
load_opt_line(opts, &st, pz, DIRECTION_CALLED, OPTION_LOAD_COOKED);
AGFREE(pz);
opts->fOptSet = sv_flags;
}
/** @}
*
* Local Variables:
* mode: C
* c-file-style: "stroustrup"
* indent-tabs-mode: nil
* End:
* end of autoopts/load.c */
|
#include "allegro.h"
#include "allegro/internal/aintern.h"
#include "allegro/platform/aintqnx.h"
#ifndef ALLEGRO_QNX
#error Something is wrong with the makefile
#endif
#include <pthread.h>
static BITMAP *qnx_ph_init_win(int, int, int, int, int);
static void qnx_ph_exit_win(BITMAP *);
static void qnx_ph_vsync_win(void);
static void <API key>(AL_CONST struct RGB *, int, int, int);
static BITMAP *<API key>(int width, int height);
static void <API key>(BITMAP *bmp);
static int <API key>(BITMAP *bmp);
GFX_DRIVER gfx_photon_win =
{
GFX_PHOTON,
empty_string,
empty_string,
"Photon windowed",
qnx_ph_init_win,
qnx_ph_exit_win,
NULL, /* AL_METHOD(int, scroll, (int x, int y)); */
qnx_ph_vsync_win,
<API key>,
NULL, /* AL_METHOD(int, request_scroll, (int x, int y)); */
NULL, /* AL_METHOD(int, poll_scroll, (void)); */
NULL, /* AL_METHOD(void, <API key>, (void)); */
<API key>,
<API key>,
<API key>,
NULL, /* AL_METHOD(int, <API key>, (BITMAP *bitmap)); */
NULL, /* AL_METHOD(BITMAP *, <API key>, (int width, int height)); */
NULL, /* AL_METHOD(void, <API key>, (BITMAP *bitmap)); */
NULL, /* AL_METHOD(int, set_mouse_sprite, (BITMAP *sprite, int xfocus, int yfocus)); */
NULL, /* AL_METHOD(int, show_mouse, (BITMAP *bmp, int x, int y)); */
NULL, /* AL_METHOD(void, hide_mouse, (void)); */
NULL, /* AL_METHOD(void, move_mouse, (int x, int y)); */
NULL, /* AL_METHOD(void, drawing_mode, (void)); */
NULL, /* AL_METHOD(void, save_video_state, (void)); */
NULL, /* AL_METHOD(void, restore_video_state, (void)); */
NULL, /* AL_METHOD(void, set_blender_mode, (int mode, int r, int g, int b, int a)); */
NULL, /* AL_METHOD(int, fetch_mode_list, (void)); */
0, 0, /* physical (not virtual!) screen size */
TRUE, /* true if video memory is linear */
0, /* bank size, in bytes */
0, /* bank granularity, in bytes */
0, /* video memory size, in bytes */
0, /* physical address of video memory */
TRUE
};
/* global variables */
BITMAP *pseudo_screen = NULL;
void (*ph_update_window)(PhRect_t* rect) = NULL;
/* exported only for qswitch.s */
char *ph_dirty_lines = NULL;
static <API key> *ph_window_context = NULL;
static pthread_cond_t vsync_cond;
static pthread_mutex_t ph_screen_lock;
static int lock_nesting = 0;
static char driver_desc[256];
static <API key> *colorconv_blitter = NULL;
static char *pseudo_screen_addr = NULL;
static int pseudo_screen_pitch;
static int pseudo_screen_depth;
static char *window_addr = NULL;
static int window_pitch;
static int desktop_depth;
static GFX_VTABLE _special_vtable; /* special vtable for offscreen bitmap */
static int reused_screen = FALSE;
#define RENDER_DELAY (1000/70) /* 70 Hz */
static void update_dirty_lines(void);
static void ph_acquire_win(BITMAP *bmp);
static void ph_release_win(BITMAP *bmp);
#ifdef ALLEGRO_NO_ASM
static unsigned long ph_write_line_win(BITMAP *bmp, int line);
static void ph_unwrite_line_win(BITMAP *bmp);
#else
void (*ptr_ph_acquire_win)(BITMAP *) = &ph_acquire_win;
void (*ptr_ph_release_win)(BITMAP *) = &ph_release_win;
unsigned long <API key>(BITMAP *bmp, int line);
void <API key>(BITMAP *bmp);
#endif
/* ph_acquire_win:
* Bitmap locking for Photon windowed mode.
*/
static void ph_acquire_win(BITMAP *bmp)
{
/* to prevent the drawing threads and the rendering proc
from concurrently accessing the dirty lines array */
pthread_mutex_lock(&ph_screen_lock);
PgWaitHWIdle();
lock_nesting++;
bmp->id |= BMP_ID_LOCKED;
}
/* ph_release_win:
* Bitmap unlocking for Photon windowed mode.
*/
static void ph_release_win(BITMAP *bmp)
{
if (lock_nesting > 0) {
lock_nesting
if (!lock_nesting)
bmp->id &= ~BMP_ID_LOCKED;
<API key>(&ph_screen_lock);
}
}
#ifdef ALLEGRO_NO_ASM
/* ph_write_line_win:
* Line switcher for Photon windowed mode.
*/
static unsigned long ph_write_line_win(BITMAP *bmp, int line)
{
ph_dirty_lines[line + bmp->y_ofs] = 1;
if (!(bmp->id & BMP_ID_LOCKED)) {
ph_acquire(bmp);
bmp->id |= BMP_ID_AUTOLOCK;
}
return (unsigned long)(bmp->line[line]);
}
/* ph_unwrite_line_win:
* Line updater for Photon windowed mode.
*/
static void ph_unwrite_line_win(BITMAP *bmp)
{
if (bmp->id & BMP_ID_AUTOLOCK) {
ph_release(bmp);
bmp->id &= ~BMP_ID_AUTOLOCK;
}
}
#endif
/* update_window_hw:
* Window updater for matching color depths.
*/
static void update_window_hw(PhRect_t *rect)
{
PhRect_t temp;
if (!rect) {
temp.ul.x = 0;
temp.ul.y = 0;
temp.lr.x = gfx_photon_win.w;
temp.lr.y = gfx_photon_win.h;
rect = &temp;
}
pthread_mutex_lock(&qnx_gfx_mutex);
PgContextBlit(BMP_EXTRA(pseudo_screen)->context, rect, NULL, rect);
<API key>(&qnx_gfx_mutex);
}
/* update_window:
* Window updater for non matching color depths, performing color conversion.
*/
static void update_window(PhRect_t *rect)
{
struct GRAPHICS_RECT src_gfx_rect, dest_gfx_rect;
PhRect_t temp;
if (!rect) {
temp.ul.x = 0;
temp.ul.y = 0;
temp.lr.x = gfx_photon_win.w;
temp.lr.y = gfx_photon_win.h;
rect = &temp;
}
/* fill in source graphics rectangle description */
src_gfx_rect.width = rect->lr.x - rect->ul.x;
src_gfx_rect.height = rect->lr.y - rect->ul.y;
src_gfx_rect.pitch = pseudo_screen_pitch;
src_gfx_rect.data = pseudo_screen->line[0] +
(rect->ul.y * pseudo_screen_pitch) +
(rect->ul.x * BYTES_PER_PIXEL(pseudo_screen_depth));
/* fill in destination graphics rectangle description */
dest_gfx_rect.pitch = window_pitch;
dest_gfx_rect.data = window_addr +
(rect->ul.y * window_pitch) +
(rect->ul.x * BYTES_PER_PIXEL(desktop_depth));
/* function doing the hard work */
colorconv_blitter(&src_gfx_rect, &dest_gfx_rect);
pthread_mutex_lock(&qnx_gfx_mutex);
PgContextBlit(ph_window_context, rect, NULL, rect);
<API key>(&qnx_gfx_mutex);
}
/* <API key>:
* Real screen initialization runs here.
*/
static BITMAP *<API key>(GFX_DRIVER *drv, int w, int h, int v_w, int v_h, int color_depth)
{
PgDisplaySettings_t settings;
PtArg_t arg;
PhDim_t dim;
char tmp1[128], tmp2[128];
if (1
#ifdef ALLEGRO_COLOR8
&& (color_depth != 8)
#endif
#ifdef ALLEGRO_COLOR16
&& (color_depth != 15)
&& (color_depth != 16)
#endif
#ifdef ALLEGRO_COLOR24
&& (color_depth != 24)
#endif
#ifdef ALLEGRO_COLOR32
&& (color_depth != 32)
#endif
) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Unsupported color depth"));
return NULL;
}
if ((w == 0) && (h == 0)) {
w = 320;
h = 200;
}
if (v_w < w) v_w = w;
if (v_h < h) v_h = h;
if ((v_w != w) || (v_h != h) || (w % 4)) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Resolution not supported"));
return NULL;
}
PgGetVideoMode(&settings);
<API key>(settings.refresh);
/* retrieve infos for the selected mode */
PgGetVideoModeInfo(settings.mode, &ph_gfx_mode_info);
dim.w = w;
dim.h = h;
PtSetArg(&arg, Pt_ARG_DIM, &dim, 0);
PtSetResources(ph_window, 1, &arg);
ph_window_context = <API key>(0, w, h, <API key>);
if (!ph_window_context) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Cannot create offscreen context"));
return NULL;
}
pseudo_screen_depth = color_depth;
desktop_depth = ph_gfx_mode_info.bits_per_pixel;
if (color_depth == desktop_depth) {
/* the color depths match */
ph_update_window = update_window_hw;
/* the pseudo-screen associated with the window context */
pseudo_screen = make_photon_bitmap(ph_window_context, w, h, BMP_ID_VIDEO);
}
else {
/* the color depths don't match, need color conversion */
colorconv_blitter = <API key>(color_depth, desktop_depth);
if (!colorconv_blitter) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Resolution not supported"));
return NULL;
}
ph_update_window = update_window;
/* the window context is a pre-converted offscreen buffer */
window_addr = <API key>(ph_window_context);
window_pitch = ph_window_context->pitch;
/* the pseudo-screen is a memory bitmap */
pseudo_screen_addr = _AL_MALLOC(w * h * BYTES_PER_PIXEL(color_depth));
if (!pseudo_screen_addr) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Not enough memory"));
return NULL;
}
pseudo_screen_pitch = w * BYTES_PER_PIXEL(color_depth);
pseudo_screen = _make_bitmap(w, h, (unsigned long)pseudo_screen_addr,
drv, color_depth, pseudo_screen_pitch);
}
if (!pseudo_screen) {
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Not enough memory"));
return NULL;
}
/* the last flag serves as an end of loop delimiter */
ph_dirty_lines = _AL_MALLOC((h+1) * sizeof(char));
ASSERT(ph_dirty_lines);
memset(ph_dirty_lines, 0, (h+1) * sizeof(char));
ph_dirty_lines[h] = 1;
setup_driver(drv, w, h, color_depth);
setup_direct_shifts();
memcpy(&_special_vtable, &_screen_vtable, sizeof(GFX_VTABLE));
pseudo_screen->vtable = &_special_vtable;
_special_vtable.acquire = ph_acquire_win;
_special_vtable.release = ph_release_win;
#ifdef ALLEGRO_NO_ASM
pseudo_screen->write_bank = ph_write_line_win;
_special_vtable.unwrite_bank = ph_unwrite_line_win;
#else
pseudo_screen->write_bank = <API key>;
_special_vtable.unwrite_bank = <API key>;
#endif
uszprintf(driver_desc, sizeof(driver_desc), uconvert_ascii("Photon windowed, %d bpp %s", tmp1), color_depth,
uconvert_ascii(color_depth == desktop_depth ? "in matching" : "in fast emulation", tmp2));
drv->desc = driver_desc;
PgFlush();
PgWaitHWIdle();
pthread_cond_init(&vsync_cond, NULL);
pthread_mutex_init(&ph_screen_lock, NULL);
install_int(update_dirty_lines, RENDER_DELAY);
return pseudo_screen;
}
/* <API key>:
* This is where the video driver is actually closed.
*/
static void <API key>(BITMAP *bmp)
{
PhDim_t dim;
if (bmp)
clear_bitmap(bmp);
remove_int(update_dirty_lines);
PgSetPalette(ph_palette, 0, 0, -1, 0, 0);
PgFlush();
ph_gfx_mode = PH_GFX_NONE;
if (ph_window_context) {
PhDCRelease(ph_window_context);
ph_window_context = NULL;
}
if (pseudo_screen_addr) {
_AL_FREE(pseudo_screen_addr);
pseudo_screen_addr = NULL;
}
if (ph_dirty_lines) {
_AL_FREE(ph_dirty_lines);
ph_dirty_lines = NULL;
}
if (colorconv_blitter) {
<API key>(colorconv_blitter);
colorconv_blitter = NULL;
}
<API key>(&ph_screen_lock);
<API key>(&vsync_cond);
dim.w = 1;
dim.h = 1;
PtSetResource(ph_window, Pt_ARG_DIM, &dim, 0);
}
/* qnx_ph_init_win:
* Initializes normal windowed Photon gfx driver.
*/
static BITMAP *qnx_ph_init_win(int w, int h, int v_w, int v_h, int color_depth)
{
struct BITMAP *bmp;
pthread_mutex_lock(&qnx_event_mutex);
ph_gfx_mode = PH_GFX_WINDOW;
bmp = <API key>(&gfx_photon_win, w, h, v_w, v_h, color_depth);
if (!bmp)
<API key>(NULL);
<API key>(&qnx_event_mutex);
return bmp;
}
/* qnx_ph_exit_win:
* Shuts down photon windowed gfx driver.
*/
static void qnx_ph_exit_win(BITMAP *bmp)
{
pthread_mutex_lock(&qnx_event_mutex);
<API key>(bmp);
<API key>(&qnx_event_mutex);
}
/* update_dirty_lines:
* Dirty line updater routine.
*/
static void update_dirty_lines(void)
{
PhRect_t rect;
/* to prevent the drawing threads and the rendering proc
from concurrently accessing the dirty lines array */
pthread_mutex_lock(&ph_screen_lock);
PgWaitHWIdle();
/* pseudo dirty rectangles mechanism:
* at most only one PgFlush() call is performed for each frame.
*/
rect.ul.x = 0;
rect.lr.x = gfx_photon_win.w;
/* find the first dirty line */
rect.ul.y = 0;
while (!ph_dirty_lines[rect.ul.y])
rect.ul.y++;
if (rect.ul.y < gfx_photon_win.h) {
/* find the last dirty line */
rect.lr.y = gfx_photon_win.h;
while (!ph_dirty_lines[rect.lr.y-1])
rect.lr.y
ph_update_window(&rect);
/* clean up the dirty lines */
while (rect.ul.y < rect.lr.y)
ph_dirty_lines[rect.ul.y++] = 0;
}
<API key>(&ph_screen_lock);
/* simulate vertical retrace */
<API key>(&vsync_cond);
PgFlush();
}
/* qnx_ph_vsync_win:
* Waits for vertical retrace.
*/
static void qnx_ph_vsync_win(void)
{
pthread_mutex_lock(&ph_screen_lock);
pthread_cond_wait(&vsync_cond, &ph_screen_lock);
<API key>(&ph_screen_lock);
}
/* <API key>:
* Sets hardware palette.
*/
static void <API key>(AL_CONST struct RGB *p, int from, int to, int vsync)
{
int i;
for (i=from; i<=to; i++)
ph_palette[i] = (p[i].r << 18) | (p[i].g << 10) | (p[i].b << 2);
if (desktop_depth == 8) {
if (vsync)
PgWaitVSync();
PgSetPalette(ph_palette, 0, from, to - from + 1,
<API key> | <API key>, 0);
PgFlush();
}
else {
pthread_mutex_lock(&ph_screen_lock);
<API key>(p, from, to);
/* invalidate the whole screen */
ph_dirty_lines[0] = ph_dirty_lines[gfx_photon_win.h-1] = 1;
<API key>(&ph_screen_lock);
}
}
/* <API key>:
*/
static BITMAP *<API key>(int width, int height)
{
<API key> *context;
struct BITMAP *bmp;
if ((width == screen->w) && (height == screen->h)) {
if (!reused_screen) {
reused_screen = TRUE;
return screen;
}
}
if (colorconv_blitter) {
/* If we are in color conversion mode, we fall back to
* memory bitmaps because we don't have system bitmaps.
*/
bmp = create_bitmap(width, height);
if (!bmp)
return NULL;
/* emulate the video bitmap framework */
bmp->id |= BMP_ID_VIDEO;
bmp->vtable = &_screen_vtable;
#ifdef ALLEGRO_NO_ASM
bmp->write_bank = ph_write_line;
bmp->read_bank = ph_write_line;
#else
bmp->write_bank = ph_write_line_asm;
bmp->read_bank = ph_write_line_asm;
#endif
return bmp;
}
else {
context = <API key>(0, width, height, <API key>);
if (!context)
return NULL;
return make_photon_bitmap(context, width, height, BMP_ID_VIDEO);
}
}
/* <API key>:
*/
static void <API key>(BITMAP *bmp)
{
if (bmp == screen) {
reused_screen = FALSE;
return;
}
if (bmp == pseudo_screen) {
/* in this case, 'bmp' points to the visible contents
* but 'screen' doesn't, so we first invert that
*/
<API key>(screen);
}
if (colorconv_blitter) {
bmp->id &= ~BMP_ID_VIDEO;
destroy_bitmap(bmp);
}
else {
PhDCRelease(BMP_EXTRA(bmp)->context);
<API key>(bmp);
}
}
/* <API key>:
*/
static int <API key>(BITMAP *bmp)
{
pthread_mutex_lock(&ph_screen_lock);
/* turn the pseudo_screen into a normal video normal */
pseudo_screen->vtable->acquire = ph_acquire;
pseudo_screen->vtable->release = ph_release;
#ifdef ALLEGRO_NO_ASM
pseudo_screen->write_bank = ph_write_line;
pseudo_screen->vtable->unwrite_bank = ph_unwrite_line;
#else
pseudo_screen->write_bank = ph_write_line_asm;
pseudo_screen->vtable->unwrite_bank = ph_unwrite_line_asm;
#endif
/* show the video bitmap */
pseudo_screen = bmp;
/* turn the video bitmap into the pseudo_screen */
pseudo_screen->vtable->acquire = ph_acquire_win;
pseudo_screen->vtable->release = ph_release_win;
#ifdef ALLEGRO_NO_ASM
pseudo_screen->write_bank = ph_write_line_win;
pseudo_screen->vtable->unwrite_bank = ph_unwrite_line_win;
#else
pseudo_screen->write_bank = <API key>;
pseudo_screen->vtable->unwrite_bank = <API key>;
#endif
/* invalidate the whole screen */
ph_dirty_lines[0] = ph_dirty_lines[gfx_photon_win.h-1] = 1;
<API key>(&ph_screen_lock);
return 0;
}
|
<?php
require_once $CFG->dirroot.'/mnet/xmlrpc/xmlparser.php';
require_once $CFG->dirroot.'/mnet/peer.php';
require_once $CFG->dirroot.'/mnet/environment.php';
CONSTANTS
define('RPC_OK', 0);
define('RPC_NOSUCHFILE', 1);
define('RPC_NOSUCHCLASS', 2);
define('RPC_NOSUCHFUNCTION', 3);
define('<API key>', 4);
define('RPC_NOSUCHMETHOD', 5);
define('RPC_FORBIDDENMETHOD', 6);
function <API key>($uri = null) {
$count = preg_match("@^(?:http[s]?://)?([A-Z0-9\-\.]+).*@i", $uri, $matches);
if ($count > 0) return $matches[1];
return false;
}
function mnet_get_public_key($uri, $application=null) {
global $CFG, $DB;
$mnet = <API key>();
// The key may be cached in the mnet_set_public_key function...
// check this first
$key = mnet_set_public_key($uri);
if ($key != false) {
return $key;
}
if (empty($application)) {
$application = $DB->get_record('mnet_application', array('name'=>'moodle'));
}
$rq = <API key>('system/keyswap', array($CFG->wwwroot, $mnet->public_key, $application->name), array(
'encoding' => 'utf-8',
'escaping' => 'markup',
));
$ch = curl_init($uri . $application->xmlrpc_server_url);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, <API key>, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Moodle');
curl_setopt($ch, CURLOPT_POSTFIELDS, $rq);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8"));
curl_setopt($ch, <API key>, false);
curl_setopt($ch, <API key>, 0);
// check for proxy
if (!empty($CFG->proxyhost) and !is_proxybypass($uri)) {
// SOCKS supported in PHP5 only
if (!empty($CFG->proxytype) and ($CFG->proxytype == 'SOCKS5')) {
if (defined('CURLPROXY_SOCKS5')) {
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
} else {
curl_close($ch);
print_error( 'socksnotsupported','mnet' );
}
}
curl_setopt($ch, <API key>, false);
if (empty($CFG->proxyport)) {
curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost);
} else {
curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost.':'.$CFG->proxyport);
}
if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
curl_setopt($ch, <API key>, $CFG->proxyuser.':'.$CFG->proxypassword);
if (defined('CURLOPT_PROXYAUTH')) {
// any proxy authentication if PHP 5.1
curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC | CURLAUTH_NTLM);
}
}
}
$res = xmlrpc_decode(curl_exec($ch));
// check for curl errors
$curlerrno = curl_errno($ch);
if ($curlerrno!=0) {
debugging("Request for $uri failed with curl error $curlerrno");
}
// check HTTP error code
$info = curl_getinfo($ch);
if (!empty($info['http_code']) and ($info['http_code'] != 200)) {
debugging("Request for $uri failed with HTTP code ".$info['http_code']);
}
curl_close($ch);
if (!is_array($res)) { // ! error
$public_certificate = $res;
$credentials=array();
if (strlen(trim($public_certificate))) {
$credentials = openssl_x509_parse($public_certificate);
$host = $credentials['subject']['CN'];
if (array_key_exists( 'subjectAltName', $credentials['subject'])) {
$host = $credentials['subject']['subjectAltName'];
}
if (strpos($uri, $host) !== false) {
mnet_set_public_key($uri, $public_certificate);
return $public_certificate;
}
else {
debugging("Request for $uri returned public key for different URI - $host");
}
}
else {
debugging("Request for $uri returned empty response");
}
}
else {
debugging( "Request for $uri returned unexpected result");
}
return false;
}
function mnet_set_public_key($uri, $key = null) {
static $keyarray = array();
if (isset($keyarray[$uri]) && empty($key)) {
return $keyarray[$uri];
} elseif (!empty($key)) {
$keyarray[$uri] = $key;
return true;
}
return false;
}
function mnet_sign_message($message, $privatekey = null) {
global $CFG;
$digest = sha1($message);
$mnet = <API key>();
// If the user hasn't supplied a private key (for example, one of our older,
// expired private keys, we get the current default private key and use that.
if ($privatekey == null) {
$privatekey = $mnet->get_private_key();
}
// The '$sig' value below is returned by reference.
// We initialize it first to stop my IDE from complaining.
$sig = '';
$bool = openssl_sign($message, $sig, $privatekey); // TODO: On failure?
$message = '<?xml version="1.0" encoding="iso-8859-1"?>
<signedMessage>
<Signature Id="MoodleSignature" xmlns="http://www.w3.org/2000/09/xmldsig
<SignedInfo>
<<API key> Algorithm="http:
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#XMLRPC-MSG">
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>'.$digest.'</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>'.base64_encode($sig).'</SignatureValue>
<KeyInfo>
<RetrievalMethod URI="'.$CFG->wwwroot.'/mnet/publickey.php"/>
</KeyInfo>
</Signature>
<object ID="XMLRPC-MSG">'.base64_encode($message).'</object>
<wwwroot>'.$mnet->wwwroot.'</wwwroot>
<timestamp>'.time().'</timestamp>
</signedMessage>';
return $message;
}
function <API key>($message, $remote_certificate) {
$mnet = <API key>();
// Generate a key resource from the remote_certificate text string
$publickey = <API key>($remote_certificate);
if ( gettype($publickey) != 'resource' ) {
// Remote certificate is faulty.
return false;
}
// Initialize vars
$encryptedstring = '';
$symmetric_keys = array();
// passed by ref -> &$encryptedstring &$symmetric_keys
$bool = openssl_seal($message, $encryptedstring, $symmetric_keys, array($publickey));
$message = $encryptedstring;
$symmetrickey = array_pop($symmetric_keys);
$message = '<?xml version="1.0" encoding="iso-8859-1"?>
<encryptedMessage>
<EncryptedData Id="ED" xmlns="http://www.w3.org/2001/04/xmlenc
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#arcfour"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig
<ds:RetrievalMethod URI="
<ds:KeyName>XMLENC</ds:KeyName>
</ds:KeyInfo>
<CipherData>
<CipherValue>'.base64_encode($message).'</CipherValue>
</CipherData>
</EncryptedData>
<EncryptedKey Id="EK" xmlns="http://www.w3.org/2001/04/xmlenc
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"/>
<ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig
<ds:KeyName>SSLKEY</ds:KeyName>
</ds:KeyInfo>
<CipherData>
<CipherValue>'.base64_encode($symmetrickey).'</CipherValue>
</CipherData>
<ReferenceList>
<DataReference URI="
</ReferenceList>
<CarriedKeyName>XMLENC</CarriedKeyName>
</EncryptedKey>
<wwwroot>'.$mnet->wwwroot.'</wwwroot>
</encryptedMessage>';
return $message;
}
/**
* Get your SSL keys from the database, or create them (if they don't exist yet)
*
* Get your SSL keys from the database, or (if they don't exist yet) call
* <API key> to create them
*
* @param string $string The text you want to sign
* @return string The signature over that text
*/
function mnet_get_keypair() {
global $CFG, $DB;
static $keypair = null;
if (!is_null($keypair)) return $keypair;
if ($result = get_config('mnet', 'openssl')) {
list($keypair['certificate'], $keypair['keypair_PEM']) = explode('@@@@@@@@', $result);
$keypair['privatekey'] = <API key>($keypair['keypair_PEM']);
$keypair['publickey'] = <API key>($keypair['certificate']);
return $keypair;
} else {
$keypair = <API key>();
return $keypair;
}
}
/**
* Generate public/private keys and store in the config table
*
* Use the distinguished name provided to create a CSR, and then sign that CSR
* with the same credentials. Store the keypair you create in the config table.
* If a distinguished name is not provided, create one using the fullname of
* 'the course with ID 1' as your organization name, and your hostname (as
* detailed in $CFG->wwwroot).
*
* @param array $dn The distinguished name of the server
* @return string The signature over that text
*/
function <API key>($dn = null, $days=28) {
global $CFG, $USER, $DB;
// check if lifetime has been overriden
if (!empty($CFG->mnetkeylifetime)) {
$days = $CFG->mnetkeylifetime;
}
$host = strtolower($CFG->wwwroot);
$host = preg_replace("~^http(s)?://~",'',$host);
$break = strpos($host.'/' , '/');
$host = substr($host, 0, $break);
$site = get_site();
$organization = $site->fullname;
$keypair = array();
$country = 'NZ';
$province = 'Wellington';
$locality = 'Wellington';
$email = !empty($CFG->noreplyaddress) ? $CFG->noreplyaddress : 'noreply@'.$_SERVER['HTTP_HOST'];
if(!empty($USER->country)) {
$country = $USER->country;
}
if(!empty($USER->city)) {
$province = $USER->city;
$locality = $USER->city;
}
if(!empty($USER->email)) {
$email = $USER->email;
}
if (is_null($dn)) {
$dn = array(
"countryName" => $country,
"stateOrProvinceName" => $province,
"localityName" => $locality,
"organizationName" => $organization,
"<API key>" => 'Moodle',
"commonName" => substr($CFG->wwwroot, 0, 64),
"subjectAltName" => $CFG->wwwroot,
"emailAddress" => $email
);
}
$dnlimits = array(
'countryName' => 2,
'stateOrProvinceName' => 128,
'localityName' => 128,
'organizationName' => 64,
'<API key>' => 64,
'commonName' => 64,
'emailAddress' => 128
);
foreach ($dnlimits as $key => $length) {
$dn[$key] = core_text::substr($dn[$key], 0, $length);
}
// ensure we remove trailing slashes
$dn["commonName"] = preg_replace(':/$:', '', $dn["commonName"]);
if (!empty($CFG->opensslcnf)) { //allow specification of openssl.cnf especially for Windows installs
$new_key = openssl_pkey_new(array("config" => $CFG->opensslcnf));
} else {
$new_key = openssl_pkey_new();
}
if ($new_key === false) {
// can not generate keys - missing openssl.cnf??
return null;
}
if (!empty($CFG->opensslcnf)) { //allow specification of openssl.cnf especially for Windows installs
$csr_rsc = openssl_csr_new($dn, $new_key, array("config" => $CFG->opensslcnf));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days, array("config" => $CFG->opensslcnf));
} else {
$csr_rsc = openssl_csr_new($dn, $new_key, array('private_key_bits',2048));
$selfSignedCert = openssl_csr_sign($csr_rsc, null, $new_key, $days);
}
unset($csr_rsc); // Free up the resource
// We export our self-signed certificate to a string.
openssl_x509_export($selfSignedCert, $keypair['certificate']);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_x509_free($selfSignedCert);
}
// Export your public/private key pair as a PEM encoded string. You
// can protect it with an optional passphrase if you wish.
if (!empty($CFG->opensslcnf)) { //allow specification of openssl.cnf especially for Windows installs
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM'], null, array("config" => $CFG->opensslcnf));
} else {
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM'] /* , $passphrase */);
}
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($new_key);
}
unset($new_key); // Free up the resource
return $keypair;
}
function <API key>($username, $mnet_host_id, $accessctrl) {
global $DB;
$mnethost = $DB->get_record('mnet_host', array('id'=>$mnet_host_id));
if ($aclrecord = $DB->get_record('<API key>', array('username'=>$username, 'mnet_host_id'=>$mnet_host_id))) {
// Update.
$aclrecord->accessctrl = $accessctrl;
$DB->update_record('<API key>', $aclrecord);
// Trigger access control updated event.
$params = array(
'objectid' => $aclrecord->id,
'context' => context_system::instance(),
'other' => array(
'username' => $username,
'hostname' => $mnethost->name,
'accessctrl' => $accessctrl
)
);
$event = \core\event\<API key>::create($params);
$event->add_record_snapshot('mnet_host', $mnethost);
$event->trigger();
} else {
// Insert.
$aclrecord = new stdClass();
$aclrecord->username = $username;
$aclrecord->accessctrl = $accessctrl;
$aclrecord->mnet_host_id = $mnet_host_id;
$aclrecord->id = $DB->insert_record('<API key>', $aclrecord);
// Trigger access control created event.
$params = array(
'objectid' => $aclrecord->id,
'context' => context_system::instance(),
'other' => array(
'username' => $username,
'hostname' => $mnethost->name,
'accessctrl' => $accessctrl
)
);
$event = \core\event\<API key>::create($params);
$event->add_record_snapshot('mnet_host', $mnethost);
$event->trigger();
}
return true;
}
function mnet_get_peer_host ($mnethostid) {
global $DB;
static $hosts;
if (!isset($hosts[$mnethostid])) {
$host = $DB->get_record('mnet_host', array('id' => $mnethostid));
$hosts[$mnethostid] = $host;
}
return $hosts[$mnethostid];
}
/**
* Inline function to modify a url string so that mnet users are requested to
* log in at their mnet identity provider (if they are not already logged in)
* before ultimately being directed to the original url.
*
* @param string $jumpurl the url which user should initially be directed to.
* This is a URL associated with a moodle networking peer when it
* is fulfiling a role as an identity provider (IDP). Different urls for
* different peers, the jumpurl is formed partly from the IDP's webroot, and
* partly from a predefined local path within that webwroot.
* The result of the user hitting this jump url is that they will be asked
* to login (at their identity provider (if they aren't already)), mnet
* will prepare the necessary authentication information, then redirect
* them back to somewhere at the content provider(CP) moodle (this moodle)
* @param array $url array with 2 elements
* 0 - context the url was taken from, possibly just the url, possibly href="url"
* 1 - the destination url
* @return string the url the remote user should be supplied with.
*/
function <API key> ($jumpurl, $url) {
global $USER, $CFG;
$localpart='';
$urlparts = parse_url($url[1]);
if($urlparts) {
if (isset($urlparts['path'])) {
$path = $urlparts['path'];
// if our wwwroot has a path component, need to strip that path from beginning of the
// 'localpart' to make it relative to moodle's wwwroot
$wwwrootpath = parse_url($CFG->wwwroot, PHP_URL_PATH);
if (!empty($wwwrootpath) and strpos($path, $wwwrootpath) === 0) {
$path = substr($path, strlen($wwwrootpath));
}
$localpart .= $path;
}
if (isset($urlparts['query'])) {
$localpart .= '?'.$urlparts['query'];
}
if (isset($urlparts['fragment'])) {
$localpart .= '#'.$urlparts['fragment'];
}
}
$indirecturl = $jumpurl . urlencode($localpart);
//If we matched on more than just a url (ie an html link), return the url to an href format
if ($url[0] != $url[1]) {
$indirecturl = 'href="'.$indirecturl.'"';
}
return $indirecturl;
}
function <API key> ($applicationid) {
global $DB;
static $appjumppaths;
if (!isset($appjumppaths[$applicationid])) {
$ssojumpurl = $DB->get_field('mnet_application', 'sso_jump_url', array('id' => $applicationid));
$appjumppaths[$applicationid] = $ssojumpurl;
}
return $appjumppaths[$applicationid];
}
/**
* Output debug information about mnet. this will go to the <b>error_log</b>.
*
* @param mixed $debugdata this can be a string, or array or object.
* @param int $debuglevel optional , defaults to 1. bump up for very noisy debug info
*/
function mnet_debug($debugdata, $debuglevel=1) {
global $CFG;
$setlevel = get_config('', 'mnet_rpcdebug');
if (empty($setlevel) || $setlevel < $debuglevel) {
return;
}
if (is_object($debugdata)) {
$debugdata = (array)$debugdata;
}
if (is_array($debugdata)) {
mnet_debug('DUMPING ARRAY');
foreach ($debugdata as $key => $value) {
mnet_debug("$key: $value");
}
mnet_debug('END DUMPING ARRAY');
return;
}
$prefix = 'MNET DEBUG ';
if (defined('MNET_SERVER')) {
$prefix .= " (server $CFG->wwwroot";
if ($peer = <API key>() && !empty($peer->wwwroot)) {
$prefix .= ", remote peer " . $peer->wwwroot;
}
$prefix .= ')';
} else {
$prefix .= " (client $CFG->wwwroot) ";
}
error_log("$prefix $debugdata");
}
/**
* Return an array of information about all moodle's profile fields
* which ones are optional, which ones are forced.
* This is used as the basis of providing lists of profile fields to the administrator
* to pick which fields to import/export over MNET
*
* @return array(forced => array, optional => array)
*/
function <API key>() {
global $DB;
static $info;
if (!empty($info)) {
return $info;
}
$excludes = array(
'id', // makes no sense
'mnethostid', // makes no sense
'timecreated', // will be set to relative to the host anyway
'timemodified', // will be set to relative to the host anyway
'auth', // going to be set to 'mnet'
'deleted', // we should never get deleted users sent over, but don't send this anyway
'confirmed', // unconfirmed users can't log in to their home site, all remote users considered confirmed
'password', // no password for mnet users
'theme', // handled separately
'lastip', // will be set to relative to the host anyway
);
// these are the ones that <API key> will complain about
// and also special case ones
$forced = array(
'username',
'email',
'firstname',
'lastname',
'auth',
'wwwroot',
'session.gc_lifetime',
'<API key>',
'<API key>',
);
// these are the ones we used to send/receive (pre 2.0)
$legacy = array(
'username',
'email',
'auth',
'deleted',
'firstname',
'lastname',
'city',
'country',
'lang',
'timezone',
'description',
'mailformat',
'maildigest',
'maildisplay',
'htmleditor',
'wwwroot',
'picture',
);
// get a random user record from the database to pull the fields off
$randomuser = $DB->get_record('user', array(), '*', IGNORE_MULTIPLE);
foreach ($randomuser as $key => $discard) {
if (in_array($key, $excludes) || in_array($key, $forced)) {
continue;
}
$fields[$key] = $key;
}
$info = array(
'forced' => $forced,
'optional' => $fields,
'legacy' => $legacy,
);
return $info;
}
/**
* Returns information about MNet peers
*
* @param bool $withdeleted should the deleted peers be returned too
* @return array
*/
function mnet_get_hosts($withdeleted = false) {
global $CFG, $DB;
$sql = "SELECT h.id, h.deleted, h.wwwroot, h.ip_address, h.name, h.public_key, h.public_key_expires,
h.transport, h.portno, h.last_connect_time, h.last_log_id, h.applicationid,
a.name as app_name, a.display_name as app_display_name, a.xmlrpc_server_url
FROM {mnet_host} h
JOIN {mnet_application} a ON h.applicationid = a.id
WHERE h.id <> ?";
if (!$withdeleted) {
$sql .= " AND h.deleted = 0";
}
$sql .= " ORDER BY h.deleted, h.name, h.id";
return $DB->get_records_sql($sql, array($CFG->mnet_localhost_id));
}
/**
* return an array information about services enabled for the given peer.
* in two modes, fulldata or very basic data.
*
* @param mnet_peer $mnet_peer the peer to get information abut
* @param boolean $fulldata whether to just return which services are published/subscribed, or more information (defaults to full)
*
* @return array If $fulldata is false, an array is returned like:
* publish => array(
* serviceid => boolean,
* serviceid => boolean,
* ),
* subscribe => array(
* serviceid => boolean,
* serviceid => boolean,
* )
* If $fulldata is true, an array is returned like:
* servicename => array(
* apiversion => array(
* name => string
* offer => boolean
* apiversion => int
* plugintype => string
* pluginname => string
* hostsubscribes => boolean
* hostpublishes => boolean
* ),
* )
*/
function <API key>(mnet_peer $mnet_peer, $fulldata=true) {
global $CFG, $DB;
$requestkey = (!empty($fulldata) ? 'fulldata' : 'mydata');
static $cache = array();
if (array_key_exists($mnet_peer->id, $cache)) {
return $cache[$mnet_peer->id][$requestkey];
}
$id_list = $mnet_peer->id;
if (!empty($CFG->mnet_all_hosts_id)) {
$id_list .= ', '.$CFG->mnet_all_hosts_id;
}
$concat = $DB->sql_concat('COALESCE(h2s.id,0) ', ' \'-\' ', ' svc.id', '\'-\'', 'r.plugintype', '\'-\'', 'r.pluginname');
$query = "
SELECT DISTINCT
$concat as id,
svc.id as serviceid,
svc.name,
svc.offer,
svc.apiversion,
r.plugintype,
r.pluginname,
h2s.hostid,
h2s.publish,
h2s.subscribe
FROM
{mnet_service2rpc} s2r,
{mnet_rpc} r,
{mnet_service} svc
LEFT JOIN
{mnet_host2service} h2s
ON
h2s.hostid in ($id_list) AND
h2s.serviceid = svc.id
WHERE
svc.offer = '1' AND
s2r.serviceid = svc.id AND
s2r.rpcid = r.id
ORDER BY
svc.name ASC";
$resultset = $DB->get_records_sql($query);
if (is_array($resultset)) {
$resultset = array_values($resultset);
} else {
$resultset = array();
}
require_once $CFG->dirroot.'/mnet/xmlrpc/client.php';
$remoteservices = array();
if ($mnet_peer->id != $CFG->mnet_all_hosts_id) {
// Create a new request object
$mnet_request = new mnet_xmlrpc_client();
// Tell it the path to the method that we want to execute
$mnet_request->set_method('system/listServices');
$mnet_request->send($mnet_peer);
if (is_array($mnet_request->response)) {
foreach($mnet_request->response as $service) {
$remoteservices[$service['name']][$service['apiversion']] = $service;
}
}
}
$myservices = array();
$mydata = array();
foreach($resultset as $result) {
$result->hostpublishes = false;
$result->hostsubscribes = false;
if (isset($remoteservices[$result->name][$result->apiversion])) {
if ($remoteservices[$result->name][$result->apiversion]['publish'] == 1) {
$result->hostpublishes = true;
}
if ($remoteservices[$result->name][$result->apiversion]['subscribe'] == 1) {
$result->hostsubscribes = true;
}
}
if (empty($myservices[$result->name][$result->apiversion])) {
$myservices[$result->name][$result->apiversion] = array('serviceid' => $result->serviceid,
'name' => $result->name,
'offer' => $result->offer,
'apiversion' => $result->apiversion,
'plugintype' => $result->plugintype,
'pluginname' => $result->pluginname,
'hostsubscribes' => $result->hostsubscribes,
'hostpublishes' => $result->hostpublishes
);
}
// allhosts_publish allows us to tell the admin that even though he
// is disabling a service, it's still available to the host because
// he's also publishing it to 'all hosts'
if ($result->hostid == $CFG->mnet_all_hosts_id && $CFG->mnet_all_hosts_id != $mnet_peer->id) {
$myservices[$result->name][$result->apiversion]['allhosts_publish'] = $result->publish;
$myservices[$result->name][$result->apiversion]['allhosts_subscribe'] = $result->subscribe;
} elseif (!empty($result->hostid)) {
$myservices[$result->name][$result->apiversion]['I_publish'] = $result->publish;
$myservices[$result->name][$result->apiversion]['I_subscribe'] = $result->subscribe;
}
$mydata['publish'][$result->serviceid] = $result->publish;
$mydata['subscribe'][$result->serviceid] = $result->subscribe;
}
$cache[$mnet_peer->id]['fulldata'] = $myservices;
$cache[$mnet_peer->id]['mydata'] = $mydata;
return $cache[$mnet_peer->id][$requestkey];
}
/**
* return an array of the profile fields to send
* with user information to the given mnet host.
*
* @param mnet_peer $peer the peer to send the information to
*
* @return array (like 'username', 'firstname', etc)
*/
function mnet_fields_to_send(mnet_peer $peer) {
return _mnet_field_helper($peer, 'export');
}
/**
* return an array of the profile fields to import
* from the given host, when creating/updating user accounts
*
* @param mnet_peer $peer the peer we're getting the information from
*
* @return array (like 'username', 'firstname', etc)
*/
function <API key>(mnet_peer $peer) {
return _mnet_field_helper($peer, 'import');
}
/**
* helper for {@see <API key>} and {@mnet_fields_to_send}
*
* @access private
*
* @param mnet_peer $peer the peer object
* @param string $key 'import' or 'export'
*
* @return array (like 'username', 'firstname', etc)
*/
function _mnet_field_helper(mnet_peer $peer, $key) {
$tmp = <API key>();
$defaults = explode(',', get_config('moodle', 'mnetprofile' . $key . 'fields'));
if ('1' === get_config('mnet', 'host' . $peer->id . $key . 'default')) {
return array_merge($tmp['forced'], $defaults);
}
$hostsettings = get_config('mnet', 'host' . $peer->id . $key . 'fields');
if (false === $hostsettings) {
return array_merge($tmp['forced'], $defaults);
}
return array_merge($tmp['forced'], explode(',', $hostsettings));
}
/**
* given a user object (or array) and a list of allowed fields,
* strip out all the fields that should not be included.
* This can be used both for outgoing data and incoming data.
*
* @param mixed $user array or object representing a database record
* @param array $fields an array of allowed fields (usually from mnet_fields_to_{send,import}
*
* @return mixed array or object, depending what type of $user object was passed (datatype is respected)
*/
function mnet_strip_user($user, $fields) {
if (is_object($user)) {
$user = (array)$user;
$wasobject = true; // so we can cast back before we return
}
foreach ($user as $key => $value) {
if (!in_array($key, $fields)) {
unset($user[$key]);
}
}
if (!empty($wasobject)) {
$user = (object)$user;
}
return $user;
}
|
#ifndef _GCONF_FILE_HPP_
#define _GCONF_FILE_HPP_
#include <gconf/gconf.h>
#include <gconf/gconf-client.h>
#include <string>
#include <vector>
#include "config_file.hpp"
class gconf_file : public config_file {
public:
explicit gconf_file(const std::string& path);
~gconf_file();
bool read_bool(const gchar *sect, const gchar *key, bool& val);
bool read_int(const gchar *sect, const gchar *key, int& val);
bool read_string(const gchar *, const gchar *, std::string&);
bool read_strlist(const gchar *, const gchar *, std::list<std::string>&);
void write_bool(const gchar *sect, const gchar *key, bool val);
void write_int(const gchar *sect, const gchar *key, int val);
void write_string(const gchar *sect, const gchar *key, const std::string& val);
void write_strlist(const gchar *sect, const gchar *key, const std::list<std::string>& slist);
void notify_add(const gchar *, const gchar *,
const sigc::slot<void, const baseconfval*>&);
private:
std::string cfgname;
GConfClient *gconf_client;
std::vector<guint> notification_ids;
};
#endif//!_GCONF_FILE_HPP_
|
#ifndef MPLAYER_GUI_GUI_H
#define MPLAYER_GUI_GUI_H
#include "config.h"
#include "mplayer.h"
#include "playtree.h"
#include "m_config.h"
#include "skinload.h"
#include "playlist.h"
extern float sub_aspect;
extern play_tree_t* playtree;
extern int sub_window;
extern int console;
extern NOTIFYICONDATA nid;
extern char *codecname;
typedef struct window_priv_t window_priv_t;
struct window_priv_t
{
HWND hwnd;
image img;
image *background;
HBITMAP bitmap;
int type;
};
typedef struct gui_t gui_t;
struct gui_t
{
/* screenproperties */
int screenw, screenh, screenbpp;
/* window related stuff */
char *classname;
HICON icon;
unsigned int window_priv_count;
window_priv_t **window_priv;
HWND mainwindow;
HWND subwindow;
/* for event handling */
widget *activewidget;
int mousewx, mousewy; /* mousepos inside widget */
int mousex, mousey;
HMENU menu;
HMENU diskmenu;
HMENU traymenu;
HMENU trayplaymenu;
HMENU trayplaybackmenu;
HMENU submenu;
HMENU subtitlemenu;
HMENU aspectmenu;
HMENU dvdmenu;
HMENU playlistmenu;
int skinbrowserwindow;
int playlistwindow;
int aboutwindow;
skin_t *skin;
playlist_t *playlist;
void (*startplay)(gui_t *gui);
void (*updatedisplay)(gui_t *gui, HWND hwnd);
void (*playercontrol)(int event); /* userdefine call back function */
void (*uninit)(gui_t *gui);
};
#define wsShowWindow 8
#define wsHideWindow 16
#define wsShowFrame 1
#define wsMovable 2
#define wsSizeable 4
gui_t *create_gui(char *skindir, char *skinName, void (*playercontrol)(int event));
int destroy_window(gui_t *gui);
int create_window(gui_t *gui, char *skindir);
int create_subwindow(gui_t *gui, char *skindir);
int parse_filename(char *file, play_tree_t *playtree, m_config_t *mconfig, int clear);
void capitalize(char *filename);
/* Dialogs */
void <API key>(gui_t *gui);
void <API key>(void);
int <API key>(gui_t *gui, int add);
void <API key>(gui_t *gui, int add);
void display_skinbrowser(gui_t *gui);
void <API key>(gui_t *gui);
void display_eqwindow(gui_t *gui);
void display_prefswindow(gui_t *gui);
void <API key>(gui_t *gui);
#endif /* MPLAYER_GUI_GUI_H */
|
<?php
namespace core\dao\json;
class Item implements \ArrayAccess, \IteratorAggregate, \JsonSerializable {
protected $data = array();
public function __construct($data) {
if (!$data instanceof \Traversable && !is_array($data)) {
throw new \<API key>('Invalid data : variable must be an array or traversable');
}
foreach($data as $key => $value) {
$this->data[$key] = $value;
}
}
public function offsetGet($key) {
return isset($this->data[$key]) ? $this->data[$key] : null;
}
public function offsetSet($key, $value) {
$this->data[$key] = $value;
}
public function offsetExists($key) {
return isset($this->data[$key]);
}
public function offsetUnset($key) {
throw new \Exception('Cannot delete any field');
}
public function getIterator() {
return new \ArrayIterator($this->data);
}
public function toArray() {
return $this->data;
}
public function jsonSerialize() {
return $this->toArray();
}
}
|
<HTML>
<BODY>
<PRE>
<!-- Manpage converted by man2html 3.0.1 -->
<B>-</B> <B>specify</B> <B>material</B> <B>parameters</B> <B>for</B> <B>the</B> <B>lighting</B> <B>model</B>
</PRE>
<H2>C SPECIFICATION</H2><PRE>
</PRE>
<H2>PARAMETERS</H2><PRE>
_param1 Specifies which face or faces are being updated.
Must be one of <B>GL_FRONT</B>, <B>GL_BACK</B>, or
<B>GL_FRONT_AND_BACK</B>.
_param2 Specifies the single-valued material parameter of
the face or faces that is being updated. Must be
<B>GL_SHININESS</B>.
_param3 Specifies the value that parameter <B>GL_SHININESS</B>
will be set to.
</PRE>
<H2>C SPECIFICATION</H2><PRE>
</PRE>
<H2>PARAMETERS</H2><PRE>
_param1
Specifies which face or faces are being updated.
Must be one of <B>GL_FRONT</B>, <B>GL_BACK</B>, or
<B>GL_FRONT_AND_BACK</B>.
_param2
Specifies the material parameter of the face or
faces that is being updated. Must be one of
<B>GL_AMBIENT</B>, <B>GL_DIFFUSE</B>, <B>GL_SPECULAR</B>, <B>GL_EMISSION</B>,
<B>GL_SHININESS</B>, <B><API key></B>, or
<B>GL_COLOR_INDEXES</B>.
_param3
Specifies a pointer to the value or values that
_param2 will be set to.
</PRE>
<H2>DESCRIPTION</H2><PRE>
<B>glMaterial</B> assigns values to material parameters. There
are two matched sets of material parameters. One, the
<I>front-facing</I> set, is used to shade points, lines, bitmaps,
and all polygons (when two-sided lighting is disabled), or
just front-facing polygons (when two-sided lighting is
enabled). The other set, <I>back-facing</I>, is used to shade
back-facing polygons only when two-sided lighting is
enabled. Refer to the <B>glLightModel</B> reference page for
details concerning one- and two-sided lighting calcula-
tions.
<B>glMaterial</B> takes three arguments. The first, _param1,
specifies whether the <B>GL_FRONT</B> materials, the <B>GL_BACK</B>
materials, or both <B>GL_FRONT_AND_BACK</B> materials will be
modified. The second, _param2, specifies which of several
parameters in one or both sets will be modified. The
third, _param3, specifies what value or values will be
most negative representable value maps
to -1.0. Floating-point values are
mapped directly. Neither integer nor
floating-point values are clamped.
The initial ambient reflectance for
both front- and back-facing materials
is (0.2, 0.2, 0.2, 1.0).
<B>GL_DIFFUSE</B> _param3 contains four integer or
floating-point values that specify the
diffuse RGBA reflectance of the mate-
rial. Integer values are mapped lin-
early such that the most positive rep-
resentable value maps to 1.0, and the
most negative representable value maps
to -1.0. Floating-point values are
mapped directly. Neither integer nor
floating-point values are clamped.
The initial diffuse reflectance for
both front- and back-facing materials
is (0.8, 0.8, 0.8, 1.0).
<B>GL_SPECULAR</B> _param3 contains four integer or
floating-point values that specify the
specular RGBA reflectance of the mate-
rial. Integer values are mapped lin-
early such that the most positive rep-
resentable value maps to 1.0, and the
most negative representable value maps
to -1.0. Floating-point values are
mapped directly. Neither integer nor
floating-point values are clamped.
The initial specular reflectance for
both front- and back-facing materials
is (0, 0, 0, 1).
<B>GL_EMISSION</B> _param3 contains four integer or
floating-point values that specify the
RGBA emitted light intensity of the
material. Integer values are mapped
linearly such that the most positive
representable value maps to 1.0, and
the most negative representable value
maps to -1.0. Floating-point values
are mapped directly. Neither integer
nor floating-point values are clamped.
The initial emission intensity for
both front- and back-facing materials
is (0, 0, 0, 1).
<B>GL_SHININESS</B> _param3 is a single integer or float-
ing-point value that specifies the
floating-point values specifying the
color indices for ambient, diffuse,
and specular lighting. These three
values, and <B>GL_SHININESS</B>, are the only
material values used by the color
index mode lighting equation. Refer
to the <B>glLightModel</B> reference page for
a discussion of color index lighting.
</PRE>
<H2>NOTES</H2><PRE>
The material parameters can be updated at any time. In
particular, <B>glMaterial</B> can be called between a call to
<B>glBegin</B> and the corresponding call to <B>glEnd</B>. If only a
single material parameter is to be changed per vertex,
however, <B>glColorMaterial</B> is preferred over <B>glMaterial</B> (see
<B>glColorMaterial</B>).
While the ambient, diffuse, specular and emission material
parameters all have alpha components, only the diffuse
alpha component is used in the lighting computation.
</PRE>
<H2>ERRORS</H2><PRE>
<B>GL_INVALID_ENUM</B> is generated if either _param1 or _param2
is not an accepted value.
<B>GL_INVALID_VALUE</B> is generated if a specular exponent out-
side the range [0,128] is specified.
</PRE>
<H2>ASSOCIATED GETS</H2><PRE>
<B>glGetMaterial</B>
</PRE>
<H2>SEE ALSO</H2><PRE>
<B>glColorMaterial</B>, <B>glLight</B>, <B>glLightModel</B>
1
</PRE>
</BODY>
</HTML>
|
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import { Component, ElementRef, EventEmitter, HostListener, Input, Optional, Output, Renderer, ViewEncapsulation } from '@angular/core';
import { Config } from '../../config/config';
import { Form } from '../../util/form';
import { Ion } from '../ion';
import { isBlank, isCheckedProperty, isPresent, isTrueProperty } from '../../util/util';
import { Item } from '../item/item';
import { RadioGroup } from './radio-group';
export var RadioButton = (function (_super) {
__extends(RadioButton, _super);
function RadioButton(_form, config, elementRef, renderer, _item, _group) {
_super.call(this, config, elementRef, renderer, 'radio');
this._form = _form;
this._item = _item;
this._group = _group;
/**
* @internal
*/
this._checked = false;
/**
* @internal
*/
this._disabled = false;
/**
* @internal
*/
this._value = null;
/**
* @output {any} expression to be evaluated when selected
*/
this.ionSelect = new EventEmitter();
_form.register(this);
if (_group) {
// register with the radiogroup
this.id = 'rb-' + _group.add(this);
}
if (_item) {
// register the input inside of the item
// reset to the item's id instead of the radiogroup id
this.id = 'rb-' + _item.registerInput('radio');
this._labelId = 'lbl-' + _item.id;
this._item.setElementClass('item-radio', true);
}
}
Object.defineProperty(RadioButton.prototype, "color", {
/**
* @input {string} The predefined color to use. For example: `"primary"`, `"secondary"`, `"danger"`.
*/
set: function (val) {
this._setColor(val);
if (this._item) {
this._item._updateColor(val, 'item-radio');
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RadioButton.prototype, "mode", {
/**
* @input {string} The mode to apply to this component. Mode can be `ios`, `wp`, or `md`.
*/
set: function (val) {
this._setMode(val);
},
enumerable: true,
configurable: true
});
Object.defineProperty(RadioButton.prototype, "value", {
/**
* @input {any} The value of the radio button. Defaults to the generated id.
*/
get: function () {
// if the value is not defined then use it's unique id
return isBlank(this._value) ? this.id : this._value;
},
set: function (val) {
this._value = val;
},
enumerable: true,
configurable: true
});
Object.defineProperty(RadioButton.prototype, "checked", {
/**
* @input {boolean} Whether the radio button should be checked or not. Default false.
*/
get: function () {
return this._checked;
},
set: function (isChecked) {
this._checked = isTrueProperty(isChecked);
if (this._item) {
this._item.setElementClass('item-radio-checked', this._checked);
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(RadioButton.prototype, "disabled", {
/**
* @input {boolean} Whether the radio button should be disabled or not. Default false.
*/
get: function () {
return this._disabled;
},
set: function (val) {
this._disabled = isTrueProperty(val);
this._item && this._item.setElementClass('item-radio-disabled', this._disabled);
},
enumerable: true,
configurable: true
});
/**
* @private
*/
RadioButton.prototype.initFocus = function () {
this._elementRef.nativeElement.querySelector('button').focus();
};
/**
* @internal
*/
RadioButton.prototype._click = function (ev) {
(void 0) /* console.debug */;
ev.preventDefault();
ev.stopPropagation();
this.checked = true;
this.ionSelect.emit(this.value);
};
/**
* @internal
*/
RadioButton.prototype.ngOnInit = function () {
if (this._group && isPresent(this._group.value)) {
this.checked = isCheckedProperty(this._group.value, this.value);
}
};
/**
* @internal
*/
RadioButton.prototype.ngOnDestroy = function () {
this._form.deregister(this);
this._group && this._group.remove(this);
};
RadioButton.decorators = [
{ type: Component, args: [{
selector: 'ion-radio',
template: '<div class="radio-icon" [class.radio-checked]="_checked"> ' +
'<div class="radio-inner"></div> ' +
'</div> ' +
'<button role="radio" ' +
'type="button" ' +
'ion-button="item-cover" ' +
'[id]="id" ' +
'[attr.aria-checked]="_checked" ' +
'[attr.aria-labelledby]="_labelId" ' +
'[attr.aria-disabled]="_disabled" ' +
'class="item-cover"> ' +
'</button>',
host: {
'[class.radio-disabled]': '_disabled'
},
encapsulation: ViewEncapsulation.None,
},] },
];
/** @nocollapse */
RadioButton.ctorParameters = [
{ type: Form, },
{ type: Config, },
{ type: ElementRef, },
{ type: Renderer, },
{ type: Item, decorators: [{ type: Optional },] },
{ type: RadioGroup, decorators: [{ type: Optional },] },
];
RadioButton.propDecorators = {
'color': [{ type: Input },],
'mode': [{ type: Input },],
'ionSelect': [{ type: Output },],
'value': [{ type: Input },],
'checked': [{ type: Input },],
'disabled': [{ type: Input },],
'_click': [{ type: HostListener, args: ['click', ['$event'],] },],
};
return RadioButton;
}(Ion));
//# sourceMappingURL=radio-button.js.map
|
subroutine s3(n, z, y)
!$ use m2, only: s2
integer, intent(in) :: n
real, intent(out) :: z(:)
real, intent(in) :: y(:)
!$ include "i2.f90"
end subroutine s3
|
<?php
// This file is part of BOINC.
// BOINC is free software; you can redistribute it and/or modify it
// as published by the Free Software Foundation,
// BOINC is distributed in the hope that it will be useful,
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
require_once("../inc/util.inc");
require_once("../inc/team.inc");
require_once("../inc/cache.inc");
check_get_args(array("sort_by", "offset", "teamid"));
if (isset($_GET["sort_by"])) {
$sort_by = $_GET["sort_by"];
$sort_by = strip_tags($sort_by); // remove XSS nonsense
} else {
$sort_by = "expavg_credit";
}
$offset = get_int("offset", true);
if (!$offset) $offset=0;
if ($offset > 1000) {
error_page(tra("Limit exceeded: Can only display the first 1000 members."));
}
$teamid = get_int("teamid");
$cache_args = "teamid=$teamid";
$team = unserialize(get_cached_data(TEAM_PAGE_TTL, $cache_args));
if (!$team) {
$team = BoincTeam::lookup_id($teamid);
if (!$team) error_page("no such team");
set_cached_data(TEAM_PAGE_TTL, serialize($team), $cache_args);
}
page_head(tra("Members of %1", "<a href=team_display.php?teamid=$teamid>$team->name</a>"));
<API key>($team, $offset, $sort_by);
page_tail();
?>
|
#pragma once
#include <functional>
namespace dreal {
template <class T>
inline void hash_combine(std::size_t & seed, const T & v) {
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
} // namespace dreal
|
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>The source code</title>
<link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="../resources/prettify/prettify.js"></script>
<style type="text/css">
.highlight { display: block; background-color: #ddd; }
</style>
<script type="text/javascript">
function highlight() {
document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
}
</script>
</head>
<body onload="prettyPrint(); highlight();">
<pre class="prettyprint lang-js"><span id='<API key>'>/**
</span> * @class Ext.chart.series.Area
* @extends Ext.chart.series.StackedCartesian
*
* Creates an Area Chart.
*
* @example preview
* var chart = new Ext.chart.CartesianChart({
* animate: true,
* store: {
* fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
* data: [
* {'name':'metric one', 'data1':10, 'data2':12, 'data3':14, 'data4':8, 'data5':13},
* {'name':'metric two', 'data1':7, 'data2':8, 'data3':16, 'data4':10, 'data5':3},
* {'name':'metric three', 'data1':5, 'data2':2, 'data3':14, 'data4':12, 'data5':7},
* {'name':'metric four', 'data1':2, 'data2':14, 'data3':6, 'data4':1, 'data5':23},
* {'name':'metric five', 'data1':27, 'data2':38, 'data3':36, 'data4':13, 'data5':33}
* ]
* },
* axes: [{
* type: 'numeric',
* position: 'left',
* fields: ['data1'],
* title: {
* text: 'Sample Values',
* fontSize: 15
* },
* grid: true,
* minimum: 0
* }, {
* type: 'category',
* position: 'bottom',
* fields: ['name'],
* title: {
* text: 'Sample Values',
* fontSize: 15
* }
* }],
* series: [{
* type: 'area',
* subStyle: {
* fill: ['blue', 'green', 'red']
* },
* xField: 'name',
* yField: ['data1', 'data2', 'data3']
*
* }]
* });
* Ext.Viewport.setLayout('fit');
* Ext.Viewport.add(chart);
*/
Ext.define('Ext.chart.series.Area', {
extend: 'Ext.chart.series.StackedCartesian',
alias: 'series.area',
<span id='<API key>'> type: 'area',
</span><span id='<API key>'> seriesType: 'areaSeries',
</span>
requires: ['Ext.chart.series.sprite.Area']
});
</pre>
</body>
</html>
|
// Test the JS shell's toy principals.
var count = 0;
// Given a string of letters |expected|, say "abc", assert that the stack
// contains calls to a series of functions named by the next letter from
// the string, say a, b, and then c. Younger frames appear earlier in
// |expected| than older frames.
function check(expected, stack) {
print("check(" + uneval(expected) + ") against:\n" + stack);
count++;
// Extract only the function names from the stack trace. Omit the frames
// for the top-level evaluation, if it is present.
var split = stack.split(/(.)?@.*\n/).slice(0, -1);
if (split[split.length - 1] === undefined)
split = split.slice(0, -2);
// Check the function names against the expected sequence.
assertEq(split.length, expected.length * 2);
for (var i = 0; i < expected.length; i++)
assertEq(split[i * 2 + 1], expected[i]);
}
var low = newGlobal({ principal: 0 });
var mid = newGlobal({ principal: 0xffff });
var high = newGlobal({ principal: 0xfffff });
eval('function a() { check("a", Error().stack); b(); }');
low .eval('function b() { check("b", Error().stack); c(); }');
mid .eval('function c() { check("cba", Error().stack); d(); }');
high.eval('function d() { check("dcba", Error().stack); e(); }');
// Globals created with no explicit principals get 0xffff.
eval('function e() { check("ecba", Error().stack); f(); }');
low .eval('function f() { check("fb", Error().stack); g(); }');
mid .eval('function g() { check("gfecba", Error().stack); h(); }');
high.eval('function h() { check("hgfedcba", Error().stack); }');
// Make everyone's functions visible to each other, as needed.
b = low .b;
low .c = mid .c;
mid .d = high.d;
high.e = e;
f = low .f;
low .g = mid .g;
mid .h = high.h;
low.check = mid.check = high.check = check;
// Kick the whole process off.
a();
assertEq(count, 8);
|
package org.openmrs.module.radiology.modality;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.hamcrest.core.IsNull.nullValue;
import static org.junit.Assert.assertThat;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.openmrs.test.<API key>;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Tests {@link <API key>}.
*/
public class <API key> extends <API key> {
private static final String TEST_DATASET =
"org/openmrs/module/radiology/include/<API key>.xml";
private static final String <API key> = "<API key>";
private static final String <API key> = "<API key>";
@Autowired
private <API key> <API key>;
@Rule
public ExpectedException expectedException = ExpectedException.none();
@Before
public void setUp() throws Exception {
executeDataSet(TEST_DATASET);
}
/**
* @see <API key>#setAsText(String)
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
editor.setAsText("1");
assertThat(editor.getValue(), is(notNullValue()));
assertThat((RadiologyModality) editor.getValue(), is(<API key>.<API key>(1)));
}
/**
* @see <API key>#setAsText(String)
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
editor.setAsText(<API key>);
assertThat(editor.getValue(), is(notNullValue()));
assertThat((RadiologyModality) editor.getValue(),
is(<API key>.<API key>(<API key>)));
}
/**
* @see <API key>#setAsText(String)
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
expectedException.expect(<API key>.class);
expectedException.expectMessage("RadiologyModality not found: ");
editor.setAsText(<API key>);
}
/**
* @see <API key>#setAsText(String)
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
editor.setAsText("");
assertThat(editor.getValue(), is(nullValue()));
}
/**
* @see <API key>#getAsText()
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
editor.setAsText("");
assertThat(editor.getAsText(), is(""));
}
/**
* @see <API key>#getAsText()
*/
@Test
public void <API key>() throws Exception {
<API key> editor = new <API key>();
editor.setAsText("1");
assertThat(editor.getAsText(), is("1"));
}
}
|
String.join = function(list, seperator){
var output = "";
for(var i = 0; i < list.length; i++){
if (output != "") output += seperator;
output += list[i];
}//for
return output;
};
//RETURN THE STRING BETWEEN THE start AND end
//IF end IS UNDEFINED, THEN GRABS TO END OF STRING
String.prototype.between=function(start, end){
var s=this.indexOf(start);
if (s==-1) return null;
s+=start.length;
if (end===undefined) return this.substring(s);
var e=this.indexOf(end, s);
if (e==-1) return null;
return this.substring(s, e);
};
String.prototype.indent=function(numTabs){
var indent="\t\t\t\t\t\t".left(numTabs);
return indent+this.toString().replaceAll("\n", "\n"+indent);
};
String.prototype.replacePrefix=function(oldPrefix, newPrefix){
if (this.startsWith(oldPrefix)){
return newPrefix+this.rightBut(oldPrefix.length);
}//endif
return this;
};
//FIND LAST INSTANCE OF find AND REPLACE WITH replace
String.prototype.replaceLast=function(find, replace){
find = Array.newInstance(find);
for(var f=0;f<find.length;f++){
var i=this.lastIndexOf(find[f]);
if (i==-1) continue;
return this.left(i)+replace+this.rightBut(i+find[f].length);
}//for
return this;
};
String.prototype.rtrim=function(value){
if (value===undefined) value=" ";
var i=this.length-1;
for(;i>=0;i--) if (this.charAt(i)!=value) break;
return this.substring(0, i+1);
};
String.prototype.startsWith=function(value){
return this.substring(0, value.length)==value;
};
REPLACE ALL INSTANCES OF find WITH REPLACE, ONLY ONCE
String.prototype.replaceAll = function(find, replace){
return this.split(find).join(replace);
};//method
String.prototype.deformat = function(){
var output=[];
for(var i=0;i<this.length;i++){
var c=this.charAt(i);
if ((c>='a' && c<='z') || (c>='0' && c<='9')){
output.push(c);
}else if (c>='A' && c<='Z'){
output.push(String.fromCharCode(c.charCodeAt(0)+32));
}//endif
}//for
return output.join("");
};//method
String.prototype.left = function(amount){
return this.substring(0, aMath.min(this.length, amount));
};//method
String.prototype.right = function(amount){
return this.substring(this.length - amount);
};//method
String.prototype.leftBut = function(amount){
return this.substring(0, this.length - amount);
};//method
String.prototype.rightBut = function(amount){
return this.substring(amount, this.length);
};//method
String.prototype.endsWith=function(value){
return this.substring(this.length - value.length)==value;
};//method
//MAP STRINGS TO OTHER STRINGS, IF NOT DEFINED, DO NOT TOUCH CHARACTERS
String.prototype.escape=function(map){
var output="";
var keys=Object.keys(map);
var s=0;
while(true){
var min=this.length;
var kk;
for(var k=0;k<keys.length;k++){
var m=this.indexOf(keys[k], s);
if (m>=0 && m<min){
min=m;
kk=keys[k];
}//endif
}//for
output+=this.substring(s, min);
if (min==this.length) return output;
output+=map[kk];
s=min+kk.length;
}//while
};//method
String.prototype.ltrim=function(c){
var e=this.length;
while(e>0 && this.charAt(e-1)==c) e
return this.substring(0, e);
};//method
function isString(value){
return (typeof value)=="string";
}//method
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.