answer
stringlengths 15
1.25M
|
|---|
<!DOCTYPE HTML PUBLIC "-
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (version 1.7.0_60) on Thu Jul 17 09:47:20 BST 2014 -->
<title>tools</title>
<meta name="date" content="2014-07-17">
<link rel="stylesheet" type="text/css" href="../stylesheet.css" title="Style">
</head>
<body>
<script type="text/javascript"><!
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="tools";
}
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<div class="topNav"><a name="navbar_top">
</a><a href="#skip-navbar_top" title="Skip navigation links"></a><a name="navbar_top_firstrow">
</a>
<ul class="navList" title="Navigation">
<li><a href="../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-files/index-1.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../ontology/sprites/producer/package-summary.html">Prev Package</a></li>
<li>Next Package</li>
</ul>
<ul class="navList">
<li><a href="../index.html?tools/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_top">
</a></div>
<div class="header">
<h1 title="Package" class="title">Package tools</h1>
</div>
<div class="contentContainer">
<ul class="blockList">
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Class Summary table, listing classes, and an explanation">
<caption><span>Class Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../tools/ElapsedCpuTimer.html" title="class in tools">ElapsedCpuTimer</a></td>
<td class="colLast"> </td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../tools/IO.html" title="class in tools">IO</a></td>
<td class="colLast">
<div class="block">Created with IntelliJ IDEA.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../tools/JEasyFrame.html" title="class in tools">JEasyFrame</a></td>
<td class="colLast">
<div class="block">Frame for the graphics.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../tools/KeyInput.html" title="class in tools">KeyInput</a></td>
<td class="colLast">
<div class="block">This class is used to manage the key input.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../tools/Pair.html" title="class in tools">Pair</a></td>
<td class="colLast">
<div class="block">Created with IntelliJ IDEA.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../tools/StatSummary.html" title="class in tools">StatSummary</a></td>
<td class="colLast">
<div class="block">This class is used to model the statistics
of a fix of numbers.</div>
</td>
</tr>
<tr class="altColor">
<td class="colFirst"><a href="../tools/Utils.html" title="class in tools">Utils</a></td>
<td class="colLast">
<div class="block">Created with IntelliJ IDEA.</div>
</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><a href="../tools/Vector2d.html" title="class in tools">Vector2d</a></td>
<td class="colLast">
<div class="block">This class represents a vector, or a position, in the map.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="packageSummary" border="0" cellpadding="3" cellspacing="0" summary="Enum Summary table, listing enums, and an explanation">
<caption><span>Enum Summary</span><span class="tabEnd"> </span></caption>
<tr>
<th class="colFirst" scope="col">Enum</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<td class="colFirst"><a href="../tools/ElapsedCpuTimer.TimerType.html" title="enum in tools">ElapsedCpuTimer.TimerType</a></td>
<td class="colLast"> </td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
<div class="bottomNav"><a name="navbar_bottom">
</a><a href="#skip-navbar_bottom" title="Skip navigation links"></a><a name="<API key>">
</a>
<ul class="navList" title="Navigation">
<li><a href="../overview-summary.html">Overview</a></li>
<li class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../deprecated-list.html">Deprecated</a></li>
<li><a href="../index-files/index-1.html">Index</a></li>
<li><a href="../help-doc.html">Help</a></li>
</ul>
</div>
<div class="subNav">
<ul class="navList">
<li><a href="../ontology/sprites/producer/package-summary.html">Prev Package</a></li>
<li>Next Package</li>
</ul>
<ul class="navList">
<li><a href="../index.html?tools/package-summary.html" target="_top">Frames</a></li>
<li><a href="package-summary.html" target="_top">No Frames</a></li>
</ul>
<ul class="navList" id="<API key>">
<li><a href="../allclasses-noframe.html">All Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!
allClassesLink = document.getElementById("<API key>");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
</script>
</div>
<a name="skip-navbar_bottom">
</a></div>
</body>
</html>
|
; void <API key>(p_forward_list_t *list)
SECTION code_clib
SECTION <API key>
PUBLIC <API key>
EXTERN <API key>
defc <API key> = <API key>
|
// Roundcube calendar UI client class
function rcube_calendar_ui(settings)
{
// extend base class
rcube_calendar.call(this, settings);
/*** member vars ***/
this.is_loading = false;
this.selected_event = null;
this.selected_calendar = null;
this.search_request = null;
this.saving_lock;
/*** private vars ***/
var DAY_MS = 86400000;
var HOUR_MS = 3600000;
var me = this;
var gmt_offset = (new Date().getTimezoneOffset() / -60) - (settings.timezone || 0) - (settings.dst || 0);
var client_timezone = new Date().getTimezoneOffset();
var day_clicked = day_clicked_ts = 0;
var ignore_click = false;
var event_defaults = { free_busy:'busy', alarms:'' };
var event_attendees = [];
var attendees_list;
var freebusy_ui = { workinhoursonly:false, needsupdate:false };
var freebusy_data = {};
var current_view = null;
var exec_deferred = bw.ie6 ? 5 : 1;
var sensitivitylabels = { 'public':rcmail.gettext('public','calendar'), 'private':rcmail.gettext('private','calendar'), 'confidential':rcmail.gettext('confidential','calendar') };
var ui_loading = rcmail.set_busy(true, 'loading');
// general datepicker settings
var datepicker_settings = {
// translate from fullcalendar format to datepicker format
dateFormat: settings['date_format'].replace(/M/g, 'm').replace(/mmmmm/, 'MM').replace(/mmm/, 'M').replace(/dddd/, 'DD').replace(/ddd/, 'D').replace(/yy/g, 'y'),
firstDay : settings['first_day'],
dayNamesMin: settings['days_short'],
monthNames: settings['months'],
monthNamesShort: settings['months'],
changeMonth: false,
showOtherMonths: true,
selectOtherMonths: true
};
/*** imports ***/
var Q = this.quote_html;
var text2html = this.text2html;
var event_date_text = this.event_date_text;
var parse_datetime = this.parse_datetime;
var date2unixtime = this.date2unixtime;
var fromunixtime = this.fromunixtime;
var parseISO8601 = this.parseISO8601;
var init_alarms_edit = this.init_alarms_edit;
/*** private methods ***/
// same as str.split(delimiter) but it ignores delimiters within quoted strings
var <API key> = function(str, delimiter)
{
var result = [],
strlen = str.length,
q, p, i, char, last;
for (q = p = i = 0; i < strlen; i++) {
char = str.charAt(i);
if (char == '"' && last != '\\') {
q = !q;
}
else if (!q && char == delimiter) {
result.push(str.substring(p, i));
p = i + 1;
}
last = char;
}
result.push(str.substr(p));
return result;
};
// clone the given date object and optionally adjust time
var clone_date = function(date, adjust)
{
var d = new Date(date.getTime());
// set time to 00:00
if (adjust == 1) {
d.setHours(0);
d.setMinutes(0);
}
// set time to 23:59
else if (adjust == 2) {
d.setHours(23);
d.setMinutes(59);
}
return d;
};
// fix date if jumped over a DST change
var fix_date = function(date)
{
if (date.getHours() == 23)
date.setTime(date.getTime() + HOUR_MS);
else if (date.getHours() > 0)
date.setHours(0);
};
// turn the given date into an ISO 8601 date string understandable by PHPs strtotime()
var date2servertime = function(date)
{
return date.getFullYear()+'-'+zeropad(date.getMonth()+1)+'-'+zeropad(date.getDate())
+ 'T'+zeropad(date.getHours())+':'+zeropad(date.getMinutes())+':'+zeropad(date.getSeconds());
}
var date2timestring = function(date, dateonly)
{
return date2servertime(date).replace(/[^0-9]/g, '').substr(0, (dateonly ? 8 : 14));
}
var zeropad = function(num)
{
return (num < 10 ? '0' : '') + num;
}
var render_link = function(url)
{
var islink = false, href = url;
if (url.match(/^[fhtpsmailo]+?:\/\
islink = true;
}
else if (url.match(/^[a-z0-9.-:]+(\/|$)/i)) {
islink = true;
href = 'http://' + url;
}
return islink ? '<a href="' + Q(href) + '" target="_blank">' + Q(url) + '</a>' : Q(url);
}
// determine whether the given date is on a weekend
var is_weekend = function(date)
{
return date.getDay() == 0 || date.getDay() == 6;
};
var is_workinghour = function(date)
{
if (settings['work_start'] > settings['work_end'])
return date.getHours() >= settings['work_start'] || date.getHours() < settings['work_end'];
else
return date.getHours() >= settings['work_start'] && date.getHours() < settings['work_end'];
};
// check if the event has 'real' attendees, excluding the current user
var has_attendees = function(event)
{
return (event.attendees && event.attendees.length && (event.attendees.length > 1 || String(event.attendees[0].email).toLowerCase() != settings.identity.email));
};
// check if the current user is an attendee of this event
var is_attendee = function(event, role, email)
{
var emails = email ? ';'+email.toLowerCase() : settings.identity.emails;
for (var i=0; event.attendees && i < event.attendees.length; i++) {
if ((!role || event.attendees[i].role == role) && event.attendees[i].email && emails.indexOf(';'+event.attendees[i].email.toLowerCase()) >= 0)
return event.attendees[i];
}
return false;
};
// check if the current user is the organizer
var is_organizer = function(event, email)
{
return is_attendee(event, 'ORGANIZER', email) || !event.id;
};
var load_attachment = function(event, att)
{
var qstring = '_id='+urlencode(att.id)+'&_event='+urlencode(event.recurrence_id||event.id)+'&_cal='+urlencode(event.calendar);
// open attachment in frame if it's of a supported mimetype
if (id && att.mimetype && $.inArray(att.mimetype, settings.mimetypes)>=0) {
if (rcmail.open_window(rcmail.env.comm_path+'&_action=get-attachment&'+qstring+'&_frame=1', true, true)) {
return;
}
}
rcmail.goto_url('get-attachment', qstring+'&_download=1', false);
};
// build event attachments list
var <API key> = function(list, container, event, edit)
{
var i, id, len, img, content, li, elem,
ul = document.createElement('UL');
ul.className = 'attachmentslist';
for (i=0, len=list.length; i<len; i++) {
elem = list[i];
li = document.createElement('LI');
li.className = elem.classname;
if (edit) {
rcmail.env.attachments[elem.id] = elem;
// delete icon
content = document.createElement('A');
content.href = '#delete';
content.title = rcmail.gettext('delete');
content.className = 'delete';
$(content).click({id: elem.id}, function(e) { remove_attachment(this, e.data.id); return false; });
if (!rcmail.env.deleteicon)
content.innerHTML = rcmail.gettext('delete');
else {
img = document.createElement('IMG');
img.src = rcmail.env.deleteicon;
img.alt = rcmail.gettext('delete');
content.appendChild(img);
}
li.appendChild(content);
}
// name/link
content = document.createElement('A');
content.innerHTML = elem.name;
content.className = 'file';
content.href = '#load';
$(content).click({event: event, att: elem}, function(e) {
load_attachment(e.data.event, e.data.att); return false; });
li.appendChild(content);
ul.appendChild(li);
}
if (edit && rcmail.gui_objects.attachmentlist) {
ul.id = rcmail.gui_objects.attachmentlist.id;
rcmail.gui_objects.attachmentlist = ul;
}
container.empty().append(ul);
};
var remove_attachment = function(elem, id)
{
$(elem.parentNode).hide();
rcmail.env.deleted_attachments.push(id);
delete rcmail.env.attachments[id];
};
// event details dialog (show only)
var event_show_dialog = function(event)
{
var $dialog = $("#eventshow").removeClass().addClass('uidialog');
var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { editable:false };
me.selected_event = event;
// allow other plugins to do actions when event form is opened
rcmail.triggerEvent('calendar-event-init', {o: event});
$dialog.find('div.event-section, div.event-line').hide();
$('#event-title').html(Q(event.title)).show();
if (event.location)
$('#event-location').html('@ ' + text2html(event.location)).show();
if (event.description)
$('#event-description').show().children('.event-text').html(text2html(event.description, 300, 6));
if (event.vurl)
$('#event-url').show().children('.event-text').html(render_link(event.vurl));
// render from-to in a nice human-readable way
// -> now shown in dialog title
// $('#event-date').html(Q(me.event_date_text(event))).show();
if (event.recurrence && event.recurrence_text)
$('#event-repeat').show().children('.event-text').html(Q(event.recurrence_text));
if (event.alarms && event.alarms_text)
$('#event-alarm').show().children('.event-text').html(Q(event.alarms_text));
if (calendar.name)
$('#event-calendar').show().children('.event-text').html(Q(calendar.name)).removeClass().addClass('event-text').addClass('cal-'+calendar.id);
if (event.categories)
$('#event-category').show().children('.event-text').html(Q(event.categories)).removeClass().addClass('event-text cat-'+String(event.categories).replace(rcmail.identifier_expr, ''));
if (event.free_busy)
$('#event-free-busy').show().children('.event-text').html(Q(rcmail.gettext(event.free_busy, 'calendar')));
if (event.priority > 0) {
var priolabels = [ '', rcmail.gettext('highest'), rcmail.gettext('high'), '', '', rcmail.gettext('normal'), '', '', rcmail.gettext('low'), rcmail.gettext('lowest') ];
$('#event-priority').show().children('.event-text').html(Q(event.priority+' '+priolabels[event.priority]));
}
if (event.sensitivity && event.sensitivity != 'public') {
$('#event-sensitivity').show().children('.event-text').html(Q(sensitivitylabels[event.sensitivity]));
$dialog.addClass('sensitivity-'+event.sensitivity);
}
// create attachments list
if ($.isArray(event.attachments)) {
<API key>(event.attachments, $('#event-attachments').children('.event-text'), event);
if (event.attachments.length > 0) {
$('#event-attachments').show();
}
}
else if (calendar.attachments) {
// fetch attachments, some drivers doesn't set 'attachments' prop of the event?
}
// list event attendees
if (calendar.attendees && event.attendees) {
var data, dispname, organizer = false, rsvp = false, line, morelink, html = '',overflow = '';
for (var j=0; j < event.attendees.length; j++) {
data = event.attendees[j];
dispname = Q(data.name || data.email);
if (data.email) {
dispname = '<a href="mailto:' + data.email + '" title="' + Q(data.email) + '" class="mailtolink">' + dispname + '</a>';
if (data.role == 'ORGANIZER')
organizer = true;
else if ((data.status == 'NEEDS-ACTION' || data.status == 'TENTATIVE') && settings.identity.emails.indexOf(';'+data.email) >= 0)
rsvp = data.status.toLowerCase();
}
line = '<span class="attendee ' + String(data.role == 'ORGANIZER' ? 'organizer' : data.status).toLowerCase() + '">' + dispname + '</span> ';
if (morelink)
overflow += line;
else
html += line;
// stop listing attendees
if (j == 7 && event.attendees.length >= 7) {
morelink = $('<a href="#more" class="morelink"></a>').html(rcmail.gettext('andnmore', 'calendar').replace('$nr', event.attendees.length - j - 1));
}
}
if (html && (event.attendees.length > 1 || !organizer)) {
$('#event-attendees').show()
.children('.event-text')
.html(html)
.find('a.mailtolink').click(function(e) { rcmail.redirect(rcmail.url('mail/compose', { _to:this.href.substr(7) })); return false; });
// display all attendees in a popup when clicking the "more" link
if (morelink) {
$('#event-attendees .event-text').append(morelink);
morelink.click(function(e){
rcmail.show_popup_dialog(
'<div id="all-event-attendees" class="event-attendees">' + html + overflow + '</div>',
rcmail.gettext('tabattendees','calendar'),
null,
{ width:450, modal:false });
$('#all-event-attendees a.mailtolink').click(function(e) { rcmail.redirect(rcmail.url('mail/compose', { _to:this.href.substr(7) })); return false; });
return false;
})
}
}
$('#event-rsvp')[(rsvp&&!organizer?'show':'hide')]();
$('#event-rsvp .rsvp-buttons input').prop('disabled', false).filter('input[rel='+rsvp+']').prop('disabled', true);
}
var buttons = {};
if (calendar.editable && event.editable !== false) {
buttons[rcmail.gettext('edit', 'calendar')] = function() {
event_edit_dialog('edit', event);
};
buttons[rcmail.gettext('remove', 'calendar')] = function() {
me.delete_event(event);
$dialog.dialog('close');
};
}
else {
buttons[rcmail.gettext('close', 'calendar')] = function(){
$dialog.dialog('close');
};
}
// open jquery UI dialog
$dialog.dialog({
modal: false,
resizable: !bw.ie6,
closeOnEscape: (!bw.ie6 && !bw.ie7), // disable for performance reasons
title: Q(me.event_date_text(event)),
open: function() {
$dialog.parent().find('.ui-button').first().focus();
},
close: function() {
$dialog.dialog('destroy').hide();
},
buttons: buttons,
minWidth: 320,
width: 420
}).show();
// set dialog size according to content
me.dialog_resize($dialog.get(0), $dialog.height(), 420);
/*
// add link for "more options" drop-down
$('<a>')
.attr('href', '#')
.html('More Options')
.addClass('dropdown-link')
.click(function(){ return false; })
.insertBefore($dialog.parent().find('.ui-dialog-buttonset').children().first());
*/
};
// bring up the event dialog (jquery-ui popup)
var event_edit_dialog = function(action, event)
{
// close show dialog first
$("#eventshow:ui-dialog").dialog('close');
var $dialog = $('<div>');
var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { editable:action=='new' };
me.selected_event = $.extend($.extend({}, event_defaults), event); // clone event object (with defaults)
event = me.selected_event; // change reference to clone
freebusy_ui.needsupdate = false;
// reset dialog first
$('#eventtabs').get(0).reset();
// allow other plugins to do actions when event form is opened
rcmail.triggerEvent('calendar-event-init', {o: event});
// event details
var title = $('#edit-title').val(event.title || '');
var location = $('#edit-location').val(event.location || '');
var description = $('#edit-description').html(event.description || '');
var vurl = $('#edit-url').val(event.vurl || '');
var categories = $('#edit-categories').val(event.categories);
var calendars = $('#edit-calendar').val(event.calendar);
var freebusy = $('#edit-free-busy').val(event.free_busy);
var priority = $('#edit-priority').val(event.priority);
var sensitivity = $('#edit-sensitivity').val(event.sensitivity);
var duration = Math.round((event.end.getTime() - event.start.getTime()) / 1000);
var startdate = $('#edit-startdate').val($.fullCalendar.formatDate(event.start, settings['date_format'])).data('duration', duration);
var starttime = $('#edit-starttime').val($.fullCalendar.formatDate(event.start, settings['time_format'])).show();
var enddate = $('#edit-enddate').val($.fullCalendar.formatDate(event.end, settings['date_format']));
var endtime = $('#edit-endtime').val($.fullCalendar.formatDate(event.end, settings['time_format'])).show();
var allday = $('#edit-allday').get(0);
var notify = $('#<API key>').get(0);
var invite = $('#<API key>').get(0);
notify.checked = has_attendees(event), invite.checked = true;
if (event.allDay) {
starttime.val("12:00").hide();
endtime.val("13:00").hide();
allday.checked = true;
}
else {
allday.checked = false;
}
// set alarm(s)
// TODO: support multiple alarm entries
if (event.alarms || action != 'new') {
if (typeof event.alarms == 'string')
event.alarms = event.alarms.split(';');
var valarms = event.alarms || [''];
for (var alarm, i=0; i < valarms.length; i++) {
alarm = String(valarms[i]).split(':');
if (!alarm[1] && alarm[0]) alarm[1] = 'DISPLAY';
$('#eventedit select.edit-alarm-type').val(alarm[1]);
if (alarm[0].match(/@(\d+)/)) {
var ondate = fromunixtime(parseInt(RegExp.$1));
$('#eventedit select.edit-alarm-offset').val('@');
$('#eventedit input.edit-alarm-date').val($.fullCalendar.formatDate(ondate, settings['date_format']));
$('#eventedit input.edit-alarm-time').val($.fullCalendar.formatDate(ondate, settings['time_format']));
}
else if (alarm[0].match(/([-+])(\d+)([MHD])/)) {
$('#eventedit input.edit-alarm-value').val(RegExp.$2);
$('#eventedit select.edit-alarm-offset').val(''+RegExp.$1+RegExp.$3);
}
}
}
// set correct visibility by triggering onchange handlers
$('#eventedit select.edit-alarm-type, #eventedit select.edit-alarm-offset').change();
// enable/disable alarm property according to backend support
$('#edit-alarms')[(calendar.alarms ? 'show' : 'hide')]();
// check categories drop-down: add value if not exists
if (event.categories && !categories.find("option[value='"+event.categories+"']").length) {
$('<option>').attr('value', event.categories).text(event.categories).appendTo(categories).prop('selected', true);
}
// set recurrence form
var recurrence, interval, rrtimes, rrenddate;
var load_recurrence_tab = function()
{
recurrence = $('#<API key>').val(event.recurrence ? event.recurrence.FREQ : '').change();
interval = $('#eventedit select.<API key>').val(event.recurrence ? event.recurrence.INTERVAL : 1);
rrtimes = $('#<API key>').val(event.recurrence ? event.recurrence.COUNT : 1);
rrenddate = $('#<API key>').val(event.recurrence && event.recurrence.UNTIL ? $.fullCalendar.formatDate(parseISO8601(event.recurrence.UNTIL), settings['date_format']) : '');
$('#eventedit input.<API key>:checked').prop('checked', false);
var weekdays = ['SU','MO','TU','WE','TH','FR','SA'];
var rrepeat_id = '#<API key>';
if (event.recurrence && event.recurrence.COUNT) rrepeat_id = '#<API key>';
else if (event.recurrence && event.recurrence.UNTIL) rrepeat_id = '#<API key>';
$(rrepeat_id).prop('checked', true);
if (event.recurrence && event.recurrence.BYDAY && event.recurrence.FREQ == 'WEEKLY') {
var wdays = event.recurrence.BYDAY.split(',');
$('input.<API key>').val(wdays);
}
if (event.recurrence && event.recurrence.BYMONTHDAY) {
$('input.<API key>').val(String(event.recurrence.BYMONTHDAY).split(','));
$('input.<API key>').val(['BYMONTHDAY']);
}
if (event.recurrence && event.recurrence.BYDAY && (event.recurrence.FREQ == 'MONTHLY' || event.recurrence.FREQ == 'YEARLY')) {
var byday, section = event.recurrence.FREQ.toLowerCase();
if ((byday = String(event.recurrence.BYDAY).match(/(-?[1-4])([A-Z]+)/))) {
$('#edit-recurrence-'+section+'-prefix').val(byday[1]);
$('#edit-recurrence-'+section+'-byday').val(byday[2]);
}
$('input.edit-recurrence-'+section+'-mode').val(['BYDAY']);
}
else if (event.start) {
$('#<API key>').val(weekdays[event.start.getDay()]);
}
if (event.recurrence && event.recurrence.BYMONTH) {
$('input.<API key>').val(String(event.recurrence.BYMONTH).split(','));
}
else if (event.start) {
$('input.<API key>').val([String(event.start.getMonth()+1)]);
}
};
// show warning if editing a recurring event
if (event.id && event.recurrence) {
var sel = event.thisandfuture ? 'future' : (event.isexception ? 'current' : 'all');
$('#<API key>').show();
$('input.<API key>[value="'+sel+'"]').prop('checked', true);
}
else
$('#<API key>').hide();
// init attendees tab
var organizer = !event.attendees || is_organizer(event),
allow_invitations = organizer || (calendar.owner && calendar.owner == 'anonymous') || settings.invite_shared;
event_attendees = [];
attendees_list = $('#<API key> > tbody').html('');
$('#<API key>')[(notify.checked && allow_invitations ? 'show' : 'hide')]();
$('#<API key>')[(has_attendees(event) && !(allow_invitations || (calendar.owner && is_organizer(event, calendar.owner))) ? 'show' : 'hide')]();
var load_attendees_tab = function()
{
if (event.attendees) {
for (var j=0; j < event.attendees.length; j++)
add_attendee(event.attendees[j], !allow_invitations);
}
// select the correct organizer identity
var identity_id = 0;
$.each(settings.identities, function(i,v){
if (organizer && v == organizer.email) {
identity_id = i;
return false;
}
});
$('#<API key>').val(identity_id);
$('#edit-attendees-form')[(allow_invitations?'show':'hide')]();
$('#<API key>')[(calendar.freebusy?'show':'hide')]();
};
// attachments
var <API key> = function()
{
rcmail.enable_command('remove-attachment', !calendar.readonly);
rcmail.env.deleted_attachments = [];
// we're sharing some code for uploads handling with app.js
rcmail.env.attachments = [];
rcmail.env.compose_id = event.id; // for rcmail.async_upload_form()
if ($.isArray(event.attachments)) {
<API key>(event.attachments, $('#edit-attachments'), event, true);
}
else {
$('#edit-attachments > ul').empty();
// fetch attachments, some drivers doesn't set 'attachments' array for event?
}
};
// init dialog buttons
var buttons = {};
// save action
buttons[rcmail.gettext('save', 'calendar')] = function() {
var start = parse_datetime(allday.checked ? '12:00' : starttime.val(), startdate.val());
var end = parse_datetime(allday.checked ? '13:00' : endtime.val(), enddate.val());
// basic input validatetion
if (start.getTime() > end.getTime()) {
alert(rcmail.gettext('invalideventdates', 'calendar'));
return false;
}
// post data to server
var data = {
calendar: event.calendar,
start: date2servertime(start),
end: date2servertime(end),
allday: allday.checked?1:0,
title: title.val(),
description: description.val(),
location: location.val(),
categories: categories.val(),
vurl: vurl.val(),
free_busy: freebusy.val(),
priority: priority.val(),
sensitivity: sensitivity.val(),
recurrence: '',
alarms: '',
attendees: event_attendees,
deleted_attachments: rcmail.env.deleted_attachments,
attachments: []
};
// serialize alarm settings
// TODO: support multiple alarm entries
var alarm = $('#eventedit select.edit-alarm-type').val();
if (alarm) {
var val, offset = $('#eventedit select.edit-alarm-offset').val();
if (offset == '@')
data.alarms = '@' + date2unixtime(parse_datetime($('#eventedit input.edit-alarm-time').val(), $('#eventedit input.edit-alarm-date').val())) + ':' + alarm;
else if ((val = parseInt($('#eventedit input.edit-alarm-value').val())) && !isNaN(val) && val >= 0)
data.alarms = offset[0] + val + offset[1] + ':' + alarm;
}
// uploaded attachments list
for (var i in rcmail.env.attachments)
if (i.match(/^rcmfile(.+)/))
data.attachments.push(RegExp.$1);
// read attendee roles
$('select.edit-attendee-role').each(function(i, elem){
if (data.attendees[i])
data.attendees[i].role = $(elem).val();
});
if (organizer)
data._identity = $('#<API key> option:selected').val();
// don't submit attendees if only myself is added as organizer
if (data.attendees.length == 1 && data.attendees[0].role == 'ORGANIZER' && String(data.attendees[0].email).toLowerCase() == settings.identity.email)
data.attendees = [];
// tell server to send notifications
if ((data.attendees.length || (event.id && event.attendees.length)) && allow_invitations && (notify.checked || invite.checked)) {
data._notify = 1;
}
// gather recurrence settings
var freq;
if ((freq = recurrence.val()) != '') {
data.recurrence = {
FREQ: freq,
INTERVAL: $('#<API key>-'+freq.toLowerCase()).val()
};
var until = $('input.<API key>:checked').val();
if (until == 'count')
data.recurrence.COUNT = rrtimes.val();
else if (until == 'until')
data.recurrence.UNTIL = date2servertime(parse_datetime(endtime.val(), rrenddate.val()));
if (freq == 'WEEKLY') {
var byday = [];
$('input.<API key>:checked').each(function(){ byday.push(this.value); });
if (byday.length)
data.recurrence.BYDAY = byday.join(',');
}
else if (freq == 'MONTHLY') {
var mode = $('input.<API key>:checked').val(), bymonday = [];
if (mode == 'BYMONTHDAY') {
$('input.<API key>:checked').each(function(){ bymonday.push(this.value); });
if (bymonday.length)
data.recurrence.BYMONTHDAY = bymonday.join(',');
}
else
data.recurrence.BYDAY = $('#<API key>').val() + $('#<API key>').val();
}
else if (freq == 'YEARLY') {
var byday, bymonth = [];
$('input.<API key>:checked').each(function(){ bymonth.push(this.value); });
if (bymonth.length)
data.recurrence.BYMONTH = bymonth.join(',');
if ((byday = $('#<API key>').val()))
data.recurrence.BYDAY = $('#<API key>').val() + byday;
}
}
data.calendar = calendars.val();
if (event.id) {
data.id = event.id;
if (event.recurrence)
data._savemode = $('input.<API key>:checked').val();
if (data.calendar && data.calendar != event.calendar)
data._fromcalendar = event.calendar;
}
update_event(action, data);
$dialog.dialog("close");
};
if (event.id) {
buttons[rcmail.gettext('remove', 'calendar')] = function() {
me.delete_event(event);
$dialog.dialog('close');
};
}
buttons[rcmail.gettext('cancel', 'calendar')] = function() {
$dialog.dialog("close");
};
// show/hide tabs according to calendar's feature support
$('#edit-tab-attendees')[(calendar.attendees?'show':'hide')]();
$('#<API key>')[(calendar.attachments?'show':'hide')]();
// activate the first tab
$('#eventtabs').tabs('select', 0);
// hack: set task to 'calendar' to make all dialog actions work correctly
var comm_path_before = rcmail.env.comm_path;
rcmail.env.comm_path = comm_path_before.replace(/_task=[a-z]+/, '_task=calendar');
var editform = $("#eventedit");
// open jquery UI dialog
$dialog.dialog({
modal: true,
resizable: (!bw.ie6 && !bw.ie7), // disable for performance reasons
closeOnEscape: false,
title: rcmail.gettext((action == 'edit' ? 'edit_event' : 'new_event'), 'calendar'),
close: function() {
editform.hide().appendTo(document.body);
$dialog.dialog("destroy").remove();
rcmail.ksearch_blur();
rcmail.ksearch_destroy();
freebusy_data = {};
rcmail.env.comm_path = comm_path_before; // restore comm_path
},
buttons: buttons,
minWidth: 500,
width: 580
}).append(editform.show()); // adding form content AFTERWARDS massively speeds up opening on IE6
// set dialog size according to form content
me.dialog_resize($dialog.get(0), editform.height() + (bw.ie ? 20 : 0), 530);
title.select();
// init other tabs asynchronously
window.setTimeout(load_recurrence_tab, exec_deferred);
if (calendar.attendees)
window.setTimeout(load_attendees_tab, exec_deferred);
if (calendar.attachments)
window.setTimeout(<API key>, exec_deferred);
};
// open a dialog to display detailed free-busy information and to find free slots
var <API key> = function()
{
var $dialog = $('#eventfreebusy'),
event = me.selected_event;
if ($dialog.is(':ui-dialog'))
$dialog.dialog('close');
if (!event_attendees.length)
return false;
// set form elements
var allday = $('#edit-allday').get(0);
var duration = Math.round((event.end.getTime() - event.start.getTime()) / 1000);
freebusy_ui.startdate = $('#schedule-startdate').val($.fullCalendar.formatDate(event.start, settings['date_format'])).data('duration', duration);
freebusy_ui.starttime = $('#schedule-starttime').val($.fullCalendar.formatDate(event.start, settings['time_format'])).show();
freebusy_ui.enddate = $('#schedule-enddate').val($.fullCalendar.formatDate(event.end, settings['date_format']));
freebusy_ui.endtime = $('#schedule-endtime').val($.fullCalendar.formatDate(event.end, settings['time_format'])).show();
if (allday.checked) {
freebusy_ui.starttime.val("12:00").hide();
freebusy_ui.endtime.val("13:00").hide();
event.allDay = true;
}
// read attendee roles from drop-downs
$('select.edit-attendee-role').each(function(i, elem){
if (event_attendees[i])
event_attendees[i].role = $(elem).val();
});
// render time slots
var now = new Date(), fb_start = new Date(), fb_end = new Date();
fb_start.setTime(event.start);
fb_start.setHours(0); fb_start.setMinutes(0); fb_start.setSeconds(0); fb_start.setMilliseconds(0);
fb_end.setTime(fb_start.getTime() + DAY_MS);
freebusy_data = { required:{}, all:{} };
freebusy_ui.loading = 1; // prevent <API key>() to load data yet
freebusy_ui.numdays = Math.max(allday.checked ? 14 : 1, Math.ceil(duration * 2 / 86400));
freebusy_ui.interval = allday.checked ? 1440 : 60;
freebusy_ui.start = fb_start;
freebusy_ui.end = new Date(freebusy_ui.start.getTime() + DAY_MS * freebusy_ui.numdays);
<API key>(0);
// render list of attendees
freebusy_ui.attendees = {};
var domid, dispname, data, role_html, list_html = '';
for (var i=0; i < event_attendees.length; i++) {
data = event_attendees[i];
dispname = Q(data.name || data.email);
domid = String(data.email).replace(rcmail.identifier_expr, '');
role_html = '<a class="<API key>" id="rcmlia' + domid + '" title="' + Q(rcmail.gettext('togglerole', 'calendar')) + '"> </a>';
list_html += '<div class="attendee ' + String(data.role).toLowerCase() + '" id="rcmli' + domid + '">' + role_html + dispname + '</div>';
// clone attendees data for local modifications
freebusy_ui.attendees[i] = freebusy_ui.attendees[domid] = $.extend({}, data);
}
// add total row
list_html += '<div class="attendee spacer"> </div>';
list_html += '<div class="attendee total">' + rcmail.gettext('reqallattendees','calendar') + '</div>';
$('#<API key>').html(list_html)
.unbind('click.roleicons')
.bind('click.roleicons', function(e){
// toggle attendee status upon click on icon
if (e.target.id && e.target.id.match(/rcmlia(.+)/)) {
var attendee, domid = RegExp.$1, roles = [ 'REQ-PARTICIPANT', 'OPT-PARTICIPANT', 'CHAIR' ];
if ((attendee = freebusy_ui.attendees[domid]) && attendee.role != 'ORGANIZER') {
var req = attendee.role != 'OPT-PARTICIPANT';
var j = $.inArray(attendee.role, roles);
j = (j+1) % roles.length;
attendee.role = roles[j];
$(e.target).parent().removeClass().addClass('attendee '+String(attendee.role).toLowerCase());
// update total display if required-status changed
if (req != (roles[j] != 'OPT-PARTICIPANT')) {
<API key>();
<API key>(attendee.email);
}
}
}
return false;
});
// enable/disable buttons
$('#shedule-find-prev').button('option', 'disabled', (fb_start.getTime() < now.getTime()));
// dialog buttons
var buttons = {};
buttons[rcmail.gettext('select', 'calendar')] = function() {
$('#edit-startdate').val(freebusy_ui.startdate.val());
$('#edit-starttime').val(freebusy_ui.starttime.val());
$('#edit-enddate').val(freebusy_ui.enddate.val());
$('#edit-endtime').val(freebusy_ui.endtime.val());
// write role changes back to main dialog
$('select.edit-attendee-role').each(function(i, elem){
if (event_attendees[i] && freebusy_ui.attendees[i]) {
event_attendees[i].role = freebusy_ui.attendees[i].role;
$(elem).val(event_attendees[i].role);
}
});
if (freebusy_ui.needsupdate)
<API key>(me.selected_event);
freebusy_ui.needsupdate = false;
$dialog.dialog("close");
};
buttons[rcmail.gettext('cancel', 'calendar')] = function() {
$dialog.dialog("close");
};
$dialog.dialog({
modal: true,
resizable: true,
closeOnEscape: (!bw.ie6 && !bw.ie7),
title: rcmail.gettext('scheduletime', 'calendar'),
open: function() {
$dialog.parent().find('.ui-dialog-buttonset .ui-button').first().focus();
},
close: function() {
if (bw.ie6)
$("#<API key>").css('visibility','visible');
$dialog.dialog("destroy").hide();
},
resizeStop: function() {
<API key>();
},
buttons: buttons,
minWidth: 640,
width: 850
}).show();
// hide edit dialog on IE6 because of drop-down elements
if (bw.ie6)
$("#<API key>").css('visibility','hidden');
// adjust dialog size to fit grid without scrolling
var gridw = $('#<API key>').width();
var overflow = gridw - $('#<API key> td.times').width() + 1;
me.dialog_resize($dialog.get(0), $dialog.height() + (bw.ie ? 20 : 0), 800 + Math.max(0, overflow));
// fetch data from server
freebusy_ui.loading = 0;
load_freebusy_data(freebusy_ui.start, freebusy_ui.interval);
};
// render an HTML table showing free-busy status for all the event attendees
var <API key> = function(delta)
{
if (delta) {
freebusy_ui.start.setTime(freebusy_ui.start.getTime() + DAY_MS * delta);
fix_date(freebusy_ui.start);
// skip weekends if in <API key>
if (Math.abs(delta) == 1 && freebusy_ui.workinhoursonly) {
while (is_weekend(freebusy_ui.start))
freebusy_ui.start.setTime(freebusy_ui.start.getTime() + DAY_MS * delta);
fix_date(freebusy_ui.start);
}
freebusy_ui.end = new Date(freebusy_ui.start.getTime() + DAY_MS * freebusy_ui.numdays);
}
var dayslots = Math.floor(1440 / freebusy_ui.interval);
var date_format = 'ddd '+ (dayslots <= 2 ? settings.date_short : settings.date_format);
var lastdate, datestr, css,
curdate = new Date(),
allday = (freebusy_ui.interval == 1440),
times_css = (allday ? 'allday ' : ''),
dates_row = '<tr class="dates">',
times_row = '<tr class="times">',
slots_row = '';
for (var s = 0, t = freebusy_ui.start.getTime(); t < freebusy_ui.end.getTime(); s++) {
curdate.setTime(t);
datestr = fc.fullCalendar('formatDate', curdate, date_format);
if (datestr != lastdate) {
if (lastdate && !allday) break;
dates_row += '<th colspan="' + dayslots + '" class="boxtitle date' + $.fullCalendar.formatDate(curdate, 'ddMMyyyy') + '">' + Q(datestr) + '</th>';
lastdate = datestr;
}
// set css class according to working hours
css = is_weekend(curdate) || (freebusy_ui.interval <= 60 && !is_workinghour(curdate)) ? 'offhours' : 'workinghours';
times_row += '<td class="' + times_css + css + '" id="t-' + Math.floor(t/1000) + '">' + Q(allday ? rcmail.gettext('all-day','calendar') : $.fullCalendar.formatDate(curdate, settings['time_format'])) + '</td>';
slots_row += '<td class="' + css + ' unknown"> </td>';
t += freebusy_ui.interval * 60000;
}
dates_row += '</tr>';
times_row += '</tr>';
// render list of attendees
var domid, data, list_html = '', times_html = '';
for (var i=0; i < event_attendees.length; i++) {
data = event_attendees[i];
domid = String(data.email).replace(rcmail.identifier_expr, '');
times_html += '<tr id="fbrow' + domid + '">' + slots_row + '</tr>';
}
// add line for all/required attendees
times_html += '<tr class="spacer"><td colspan="' + (dayslots * freebusy_ui.numdays) + '"> </td>';
times_html += '<tr id="fbrowall">' + slots_row + '</tr>';
var table = $('#<API key>');
table.children('thead').html(dates_row + times_row);
table.children('tbody').html(times_html);
// initialize event handlers on grid
if (!freebusy_ui.grid_events) {
freebusy_ui.grid_events = true;
table.children('thead').click(function(e){
// move event to the clicked date/time
if (e.target.id && e.target.id.match(/t-(\d+)/)) {
var newstart = new Date(RegExp.$1 * 1000);
// set time to 00:00
if (me.selected_event.allDay) {
newstart.setMinutes(0);
newstart.setHours(0);
}
<API key>(newstart, new Date(newstart.getTime() + freebusy_ui.startdate.data('duration') * 1000));
<API key>();
}
})
}
// if we have loaded free-busy data, show it
if (!freebusy_ui.loading) {
if (freebusy_ui.start < freebusy_data.start || freebusy_ui.end > freebusy_data.end || freebusy_ui.interval != freebusy_data.interval) {
load_freebusy_data(freebusy_ui.start, freebusy_ui.interval);
}
else {
for (var email, i=0; i < event_attendees.length; i++) {
if ((email = event_attendees[i].email))
<API key>(email);
}
}
}
// render current event date/time selection over grid table
// use timeout to let the dom attributes (width/height/offset) be set first
window.setTimeout(function(){ <API key>(); }, 10);
};
// render overlay element over the grid to visiualize the current event date/time
var <API key> = function()
{
var overlay = $('#schedule-event-time');
if (me.selected_event.end.getTime() <= freebusy_ui.start.getTime() || me.selected_event.start.getTime() >= freebusy_ui.end.getTime()) {
overlay.hide();
if (overlay.data('isdraggable'))
overlay.draggable('disable');
}
else {
var table = $('#<API key>'),
width = 0,
pos = { top:table.children('thead').height(), left:0 },
eventstart = date2unixtime(clone_date(me.selected_event.start, me.selected_event.allDay?1:0)),
eventend = date2unixtime(clone_date(me.selected_event.end, me.selected_event.allDay?2:0)) - 60,
slotstart = date2unixtime(freebusy_ui.start),
slotsize = freebusy_ui.interval * 60,
slotend, fraction, $cell;
// iterate through slots to determine position and size of the overlay
table.children('thead').find('td').each(function(i, cell){
slotend = slotstart + slotsize - 1;
// event starts in this slot: compute left
if (eventstart >= slotstart && eventstart <= slotend) {
fraction = 1 - (slotend - eventstart) / slotsize;
pos.left = Math.round(cell.offsetLeft + cell.offsetWidth * fraction);
}
// event ends in this slot: compute width
if (eventend >= slotstart && eventend <= slotend) {
fraction = 1 - (slotend - eventend) / slotsize;
width = Math.round(cell.offsetLeft + cell.offsetWidth * fraction) - pos.left;
}
slotstart = slotstart + slotsize;
});
if (!width)
width = table.width() - pos.left;
// overlay is visible
if (width > 0) {
overlay.css({ width: (width-5)+'px', height:(table.children('tbody').height() - 4)+'px', left:pos.left+'px', top:pos.top+'px' }).show();
// configure draggable
if (!overlay.data('isdraggable')) {
overlay.draggable({
axis: 'x',
scroll: true,
stop: function(e, ui){
// convert pixels to time
var px = ui.position.left;
var range_p = $('#<API key>').width();
var range_t = freebusy_ui.end.getTime() - freebusy_ui.start.getTime();
var newstart = new Date(freebusy_ui.start.getTime() + px * (range_t / range_p));
newstart.setSeconds(0); newstart.setMilliseconds(0);
// snap to day boundaries
if (me.selected_event.allDay) {
if (newstart.getHours() >= 12) // snap to next day
newstart.setTime(newstart.getTime() + DAY_MS);
newstart.setMinutes(0);
newstart.setHours(0);
}
else {
// round to 5 minutes
var round = newstart.getMinutes() % 5;
if (round > 2.5) newstart.setTime(newstart.getTime() + (5 - round) * 60000);
else if (round > 0) newstart.setTime(newstart.getTime() - round * 60000);
}
// update event times and display
<API key>(newstart, new Date(newstart.getTime() + freebusy_ui.startdate.data('duration') * 1000));
if (me.selected_event.allDay)
<API key>();
}
}).data('isdraggable', true);
}
else
overlay.draggable('enable');
}
else
overlay.draggable('disable').hide();
}
};
// fetch free-busy information for each attendee from server
var load_freebusy_data = function(from, interval)
{
var start = new Date(from.getTime() - DAY_MS * 2); // start 2 days before event
fix_date(start);
var end = new Date(start.getTime() + DAY_MS * Math.max(14, freebusy_ui.numdays + 7)); // load min. 14 days
freebusy_ui.numrequired = 0;
freebusy_data.all = [];
freebusy_data.required = [];
// load free-busy information for every attendee
var domid, email;
for (var i=0; i < event_attendees.length; i++) {
if ((email = event_attendees[i].email)) {
domid = String(email).replace(rcmail.identifier_expr, '');
$('#rcmli' + domid).addClass('loading');
freebusy_ui.loading++;
$.ajax({
type: 'GET',
dataType: 'json',
url: rcmail.url('freebusy-times'),
data: { email:email, start:date2servertime(clone_date(start, 1)), end:date2servertime(clone_date(end, 2)), interval:interval, _remote:1 },
success: function(data) {
freebusy_ui.loading
// find attendee
var attendee = null;
for (var i=0; i < event_attendees.length; i++) {
if (freebusy_ui.attendees[i].email == data.email) {
attendee = freebusy_ui.attendees[i];
break;
}
}
// copy data to member var
var ts, req = attendee.role != 'OPT-PARTICIPANT';
freebusy_data.start = parseISO8601(data.start);
freebusy_data[data.email] = {};
for (var i=0; i < data.slots.length; i++) {
ts = data.times[i] + '';
freebusy_data[data.email][ts] = data.slots[i];
// set totals
if (!freebusy_data.required[ts])
freebusy_data.required[ts] = [0,0,0,0];
if (req)
freebusy_data.required[ts][data.slots[i]]++;
if (!freebusy_data.all[ts])
freebusy_data.all[ts] = [0,0,0,0];
freebusy_data.all[ts][data.slots[i]]++;
}
freebusy_data.end = parseISO8601(data.end);
freebusy_data.interval = data.interval;
// hide loading indicator
var domid = String(data.email).replace(rcmail.identifier_expr, '');
$('#rcmli' + domid).removeClass('loading');
// update display
<API key>(data.email);
}
});
// count required attendees
if (freebusy_ui.attendees[i].role != 'OPT-PARTICIPANT')
freebusy_ui.numrequired++;
}
}
};
// re-calculate total status after role change
var <API key> = function()
{
freebusy_ui.numrequired = 0;
freebusy_data.all = [];
freebusy_data.required = [];
var email, req, status;
for (var i=0; i < event_attendees.length; i++) {
if (!(email = event_attendees[i].email))
continue;
req = freebusy_ui.attendees[i].role != 'OPT-PARTICIPANT';
if (req)
freebusy_ui.numrequired++;
for (var ts in freebusy_data[email]) {
if (!freebusy_data.required[ts])
freebusy_data.required[ts] = [0,0,0,0];
if (!freebusy_data.all[ts])
freebusy_data.all[ts] = [0,0,0,0];
status = freebusy_data[email][ts];
freebusy_data.all[ts][status]++;
if (req)
freebusy_data.required[ts][status]++;
}
}
};
// update free-busy grid with status loaded from server
var <API key> = function(email)
{
var status_classes = ['unknown','free','busy','tentative','out-of-office'];
var domid = String(email).replace(rcmail.identifier_expr, '');
var row = $('#fbrow' + domid);
var rowall = $('#fbrowall').children();
var dateonly = freebusy_ui.interval > 60,
t, ts = date2timestring(freebusy_ui.start, dateonly),
curdate = new Date(),
fbdata = freebusy_data[email];
if (fbdata && fbdata[ts] !== undefined && row.length) {
t = freebusy_ui.start.getTime();
row.children().each(function(i, cell){
curdate.setTime(t);
ts = date2timestring(curdate, dateonly);
cell.className = cell.className.replace('unknown', fbdata[ts] ? status_classes[fbdata[ts]] : 'unknown');
// also update total row if all data was loaded
if (freebusy_ui.loading == 0 && freebusy_data.all[ts] && (cell = rowall.get(i))) {
var workinghours = cell.className.indexOf('workinghours') >= 0;
var all_status = freebusy_data.all[ts][2] ? 'busy' : 'unknown';
req_status = freebusy_data.required[ts][2] ? 'busy' : 'free';
for (var j=1; j < status_classes.length; j++) {
if (freebusy_ui.numrequired && freebusy_data.required[ts][j] >= freebusy_ui.numrequired)
req_status = status_classes[j];
if (freebusy_data.all[ts][j] == event_attendees.length)
all_status = status_classes[j];
}
cell.className = (workinghours ? 'workinghours ' : 'offhours ') + req_status + ' all-' + all_status;
}
t += freebusy_ui.interval * 60000;
});
}
};
// write changed event date/times back to form fields
var <API key> = function(start, end)
{
// fix all-day evebt times
if (me.selected_event.allDay) {
var numdays = Math.floor((me.selected_event.end.getTime() - me.selected_event.start.getTime()) / DAY_MS);
start.setHours(12);
start.setMinutes(0);
end.setTime(start.getTime() + numdays * DAY_MS);
end.setHours(13);
end.setMinutes(0);
}
me.selected_event.start = start;
me.selected_event.end = end;
freebusy_ui.startdate.val($.fullCalendar.formatDate(start, settings['date_format']));
freebusy_ui.starttime.val($.fullCalendar.formatDate(start, settings['time_format']));
freebusy_ui.enddate.val($.fullCalendar.formatDate(end, settings['date_format']));
freebusy_ui.endtime.val($.fullCalendar.formatDate(end, settings['time_format']));
freebusy_ui.needsupdate = true;
};
// attempt to find a time slot where all attemdees are available
var freebusy_find_slot = function(dir)
{
// exit if free-busy data isn't available yet
if (!freebusy_data || !freebusy_data.start)
return false;
var event = me.selected_event,
eventstart = clone_date(event.start, event.allDay ? 1 : 0).getTime(), // calculate with integers
eventend = clone_date(event.end, event.allDay ? 2 : 0).getTime(),
duration = eventend - eventstart - (event.allDay ? HOUR_MS : 0), // make sure we don't cross day borders on DST change
sinterval = freebusy_data.interval * 60000,
intvlslots = 1,
numslots = Math.ceil(duration / sinterval),
checkdate, slotend, email, ts, slot, slotdate = new Date();
// shift event times to next possible slot
eventstart += sinterval * intvlslots * dir;
eventend += sinterval * intvlslots * dir;
// iterate through free-busy slots and find candidates
var candidatecount = 0, candidatestart = candidateend = success = false;
for (slot = dir > 0 ? freebusy_data.start.getTime() : freebusy_data.end.getTime() - sinterval;
(dir > 0 && slot < freebusy_data.end.getTime()) || (dir < 0 && slot >= freebusy_data.start.getTime());
slot += sinterval * dir) {
slotdate.setTime(slot);
// fix slot if just crossed a DST change
if (event.allDay) {
fix_date(slotdate);
slot = slotdate.getTime();
}
slotend = slot + sinterval;
if ((dir > 0 && slotend <= eventstart) || (dir < 0 && slot >= eventend)) // skip
continue;
// respect workingours setting
if (freebusy_ui.workinhoursonly) {
if (is_weekend(slotdate) || (freebusy_data.interval <= 60 && !is_workinghour(slotdate))) { // skip off-hours
candidatestart = candidateend = false;
candidatecount = 0;
continue;
}
}
if (!candidatestart)
candidatestart = slot;
// check freebusy data for all attendees
ts = date2timestring(slotdate, freebusy_data.interval > 60);
for (var i=0; i < event_attendees.length; i++) {
if (freebusy_ui.attendees[i].role != 'OPT-PARTICIPANT' && (email = freebusy_ui.attendees[i].email) && freebusy_data[email] && freebusy_data[email][ts] > 1) {
candidatestart = candidateend = false;
break;
}
}
// occupied slot
if (!candidatestart) {
slot += Math.max(0, intvlslots - candidatecount - 1) * sinterval * dir;
candidatecount = 0;
continue;
}
// set candidate end to slot end time
candidatecount++;
if (dir < 0 && !candidateend)
candidateend = slotend;
// if candidate is big enough, this is it!
if (candidatecount == numslots) {
if (dir > 0) {
event.start.setTime(candidatestart);
event.end.setTime(candidatestart + duration);
}
else {
event.end.setTime(candidateend);
event.start.setTime(candidateend - duration);
}
success = true;
break;
}
}
// update event date/time display
if (success) {
<API key>(event.start, event.end);
// move freebusy grid if necessary
var offset = Math.ceil((event.start.getTime() - freebusy_ui.end.getTime()) / DAY_MS);
if (event.start.getTime() >= freebusy_ui.end.getTime())
<API key>(Math.max(1, offset));
else if (event.end.getTime() <= freebusy_ui.start.getTime())
<API key>(Math.min(-1, offset));
else
<API key>();
var now = new Date();
$('#shedule-find-prev').button('option', 'disabled', (event.start.getTime() < now.getTime()));
}
else {
alert(rcmail.gettext('noslotfound','calendar'));
}
};
// update event properties and attendees availability if event times have changed
var event_times_changed = function()
{
if (me.selected_event) {
var allday = $('#edit-allday').get(0);
me.selected_event.allDay = allday.checked;
me.selected_event.start = parse_datetime(allday.checked ? '12:00' : $('#edit-starttime').val(), $('#edit-startdate').val());
me.selected_event.end = parse_datetime(allday.checked ? '13:00' : $('#edit-endtime').val(), $('#edit-enddate').val());
if (event_attendees)
freebusy_ui.needsupdate = true;
$('#edit-startdate').data('duration', Math.round((me.selected_event.end.getTime() - me.selected_event.start.getTime()) / 1000));
}
};
// add the given list of participants
var add_attendees = function(names)
{
names = <API key>(names.replace(/,\s*$/, ''), ',');
// parse name/email pairs
var item, email, name, success = false;
for (var i=0; i < names.length; i++) {
email = name = '';
item = $.trim(names[i]);
if (!item.length) {
continue;
} // address in brackets without name (do nothing)
else if (item.match(/^<[^@]+@[^>]+>$/)) {
email = item.replace(/[<>]/g, '');
} // address without brackets and without name (add brackets)
else if (rcube_check_email(item)) {
email = item;
} // address with name
else if (item.match(/([^\s<@]+@[^>]+)>*$/)) {
email = RegExp.$1;
name = item.replace(email, '').replace(/^["\s<>]+/, '').replace(/["\s<>]+$/, '');
}
if (email) {
add_attendee({ email:email, name:name, role:'REQ-PARTICIPANT', status:'NEEDS-ACTION' });
success = true;
}
else {
alert(rcmail.gettext('noemailwarning'));
}
}
return success;
};
// add the given attendee to the list
var add_attendee = function(data, readonly)
{
// check for dupes...
var exists = false;
$.each(event_attendees, function(i, v){ exists |= (v.email == data.email); });
if (exists)
return false;
var dispname = Q(data.name || data.email);
if (data.email)
dispname = '<a href="mailto:' + data.email + '" title="' + Q(data.email) + '" class="mailtolink">' + dispname + '</a>';
// role selection
var organizer = data.role == 'ORGANIZER';
var opts = {};
if (organizer)
opts.ORGANIZER = rcmail.gettext('calendar.roleorganizer');
opts['REQ-PARTICIPANT'] = rcmail.gettext('calendar.rolerequired');
opts['OPT-PARTICIPANT'] = rcmail.gettext('calendar.roleoptional');
opts['CHAIR'] = rcmail.gettext('calendar.rolechair');
if (organizer && !readonly)
dispname = rcmail.env['identities-selector'];
var select = '<select class="edit-attendee-role"' + (organizer || readonly ? ' disabled="true"' : '') + '>';
for (var r in opts)
select += '<option value="'+ r +'" class="' + r.toLowerCase() + '"' + (data.role == r ? ' selected="selected"' : '') +'>' + Q(opts[r]) + '</option>';
select += '</select>';
// availability
var avail = data.email ? 'loading' : 'unknown';
// delete icon
var icon = rcmail.env.deleteicon ? '<img src="' + rcmail.env.deleteicon + '" alt="" />' : rcmail.gettext('delete');
var dellink = '<a href="#delete" class="iconlink delete deletelink" title="' + Q(rcmail.gettext('delete')) + '">' + icon + '</a>';
var html = '<td class="role">' + select + '</td>' +
'<td class="name">' + dispname + '</td>' +
'<td class="availability"><img src="./program/resources/blank.gif" class="availabilityicon ' + avail + '" /></td>' +
'<td class="confirmstate"><span class="' + String(data.status).toLowerCase() + '">' + Q(data.status) + '</span></td>' +
'<td class="options">' + (organizer || readonly ? '' : dellink) + '</td>';
var tr = $('<tr>')
.addClass(String(data.role).toLowerCase())
.html(html)
.appendTo(attendees_list);
tr.find('a.deletelink').click({ id:(data.email || data.name) }, function(e) { remove_attendee(this, e.data.id); return false; });
tr.find('a.mailtolink').click(function(e) { rcmail.redirect(rcmail.url('mail/compose', { _to:this.href.substr(7) })); return false; });
// select organizer identity
if (data.identity_id)
$('#<API key>').val(data.identity_id);
// check free-busy status
if (avail == 'loading') {
<API key>(tr.find('img.availabilityicon'), data.email, me.selected_event);
}
event_attendees.push(data);
};
// iterate over all attendees and update their free-busy status display
var <API key> = function(event)
{
var icons = attendees_list.find('img.availabilityicon');
for (var i=0; i < event_attendees.length; i++) {
if (icons.get(i) && event_attendees[i].email)
<API key>(icons.get(i), event_attendees[i].email, event);
}
freebusy_ui.needsupdate = false;
};
// load free-busy status from server and update icon accordingly
var <API key> = function(icon, email, event)
{
var calendar = event.calendar && me.calendars[event.calendar] ? me.calendars[event.calendar] : { freebusy:false };
if (!calendar.freebusy) {
$(icon).removeClass().addClass('availabilityicon unknown');
return;
}
icon = $(icon).removeClass().addClass('availabilityicon loading');
$.ajax({
type: 'GET',
dataType: 'html',
url: rcmail.url('freebusy-status'),
data: { email:email, start:date2servertime(clone_date(event.start, event.allDay?1:0)), end:date2servertime(clone_date(event.end, event.allDay?2:0)), _remote: 1 },
success: function(status){
icon.removeClass('loading').addClass(String(status).toLowerCase());
},
error: function(){
icon.removeClass('loading').addClass('unknown');
}
});
};
// remove an attendee from the list
var remove_attendee = function(elem, id)
{
$(elem).closest('tr').remove();
event_attendees = $.grep(event_attendees, function(data){ return (data.name != id && data.email != id) });
};
// when the user accepts or declines an event invitation
var event_rsvp = function(response)
{
if (me.selected_event && me.selected_event.attendees && response) {
// update attendee status
for (var data, i=0; i < me.selected_event.attendees.length; i++) {
data = me.selected_event.attendees[i];
if (settings.identity.emails.indexOf(';'+String(data.email).toLowerCase()) >= 0)
data.status = response.toUpperCase();
}
event_show_dialog(me.selected_event);
// submit status change to server
me.saving_lock = rcmail.set_busy(true, 'calendar.savingdata');
rcmail.http_post('event', { action:'rsvp', e:me.selected_event, status:response });
}
}
// post the given event data to server
var update_event = function(action, data)
{
me.saving_lock = rcmail.set_busy(true, 'calendar.savingdata');
rcmail.http_post('calendar/event', { action:action, e:data });
// render event temporarily into the calendar
if ((data.start && data.end) || data.id) {
var event = data.id ? $.extend(fc.fullCalendar('clientEvents', function(e){ return e.id == data.id; })[0], data) : data;
if (data.start)
event.start = data.start;
if (data.end)
event.end = data.end;
if (data.allday !== undefined)
event.allDay = data.allday;
event.editable = false;
event.temp = true;
event.className = 'fc-event-cal-'+data.calendar+' fc-event-temp';
fc.fullCalendar(data.id ? 'updateEvent' : 'renderEvent', event);
}
};
// mouse-click handler to check if the show dialog is still open and prevent default action
var dialog_check = function(e)
{
var showd = $("#eventshow");
if (showd.is(':visible') && !$(e.target).closest('.ui-dialog').length) {
showd.dialog('close');
e.<API key>();
ignore_click = true;
return false;
}
else if (ignore_click) {
window.setTimeout(function(){ ignore_click = false; }, 20);
return false;
}
return true;
};
// display confirm dialog when modifying/deleting an event
var <API key> = function(action, event, data)
{
if (!data) data = event;
var decline = false, notify = false, html = '', cal = me.calendars[event.calendar];
// event has attendees, ask whether to notify them
if (has_attendees(event)) {
if (is_organizer(event)) {
notify = true;
html += '<div class="message">' +
'<label><input class="<API key>" type="checkbox" checked="checked" value="1" name="notify" /> ' +
rcmail.gettext((action == 'remove' ? 'sendcancellation' : 'sendnotifications'), 'calendar') +
'</label></div>';
}
else if (action == 'remove' && is_attendee(event)) {
decline = true;
html += '<div class="message">' +
'<label><input class="<API key>" type="checkbox" checked="checked" value="1" name="decline" /> ' +
rcmail.gettext('itipdeclineevent', 'calendar') +
'</label></div>';
}
else {
html += '<div class="message">' + rcmail.gettext('localchangeswarning', 'calendar') + '</div>';
}
}
// recurring event: user needs to select the savemode
if (event.recurrence) {
html += '<div class="message"><span class="ui-icon ui-icon-alert"></span>' +
rcmail.gettext((action == 'remove' ? '<API key>' : '<API key>'), 'calendar') + '</div>' +
'<div class="savemode">' +
'<a href="#current" class="button">' + rcmail.gettext('currentevent', 'calendar') + '</a>' +
'<a href="#future" class="button">' + rcmail.gettext('futurevents', 'calendar') + '</a>' +
'<a href="#all" class="button">' + rcmail.gettext('allevents', 'calendar') + '</a>' +
(action != 'remove' ? '<a href="#new" class="button">' + rcmail.gettext('saveasnew', 'calendar') + '</a>' : '') +
'</div>';
}
// show dialog
if (html) {
var $dialog = $('<div>').html(html);
$dialog.find('a.button').button().click(function(e){
data._savemode = String(this.href).replace(/.+
if ($dialog.find('input.<API key>').get(0))
data._notify = notify && $dialog.find('input.<API key>').get(0).checked ? 1 : 0;
if (decline && $dialog.find('input.<API key>:checked'))
data.decline = 1;
update_event(action, data);
$dialog.dialog("destroy").hide();
return false;
});
var buttons = [{
text: rcmail.gettext('cancel', 'calendar'),
click: function() {
$(this).dialog("close");
}
}];
if (!event.recurrence) {
buttons.push({
text: rcmail.gettext((action == 'remove' ? 'remove' : 'save'), 'calendar'),
click: function() {
data._notify = notify && $dialog.find('input.<API key>').get(0).checked ? 1 : 0;
data.decline = decline && $dialog.find('input.<API key>:checked').length ? 1 : 0;
update_event(action, data);
$(this).dialog("close");
}
});
}
$dialog.dialog({
modal: true,
width: 460,
dialogClass: 'warning',
title: rcmail.gettext((action == 'remove' ? 'removeeventconfirm' : 'changeeventconfirm'), 'calendar'),
buttons: buttons,
close: function(){
$dialog.dialog("destroy").hide();
if (!rcmail.busy)
fc.fullCalendar('refetchEvents');
}
}).addClass('<API key>').show();
return false;
}
// show regular confirm box when deleting
else if (action == 'remove' && !cal.undelete) {
if (!confirm(rcmail.gettext('deleteventconfirm', 'calendar')))
return false;
}
// do update
update_event(action, data);
return true;
};
var <API key> = function()
{
$('#agenda-listrange').val(fc.fullCalendar('option', 'listRange'));
$('#agenda-listsections').val(fc.fullCalendar('option', 'listSections'));
}
/*** fullcalendar event handlers ***/
var fc_event_render = function(event, element, view) {
if (view.name != 'list' && view.name != 'table') {
var prefix = event.sensitivity && event.sensitivity != 'public' ? String(sensitivitylabels[event.sensitivity]).toUpperCase()+': ' : '';
element.attr('title', prefix + event.title);
}
if (view.name != 'month') {
if (event.location) {
element.find('div.fc-event-title').after('<div class="fc-event-location">@ ' + Q(event.location) + '</div>');
}
if (event.sensitivity && event.sensitivity != 'public')
element.find('div.fc-event-time').append('<i class="fc-icon-sensitive"></i>');
if (event.recurrence)
element.find('div.fc-event-time').append('<i class="fc-icon-recurring"></i>');
if (event.alarms)
element.find('div.fc-event-time').append('<i class="fc-icon-alarms"></i>');
}
};
/*** public methods ***/
/**
* Remove saving lock and free the UI for new input
*/
this.unlock_saving = function()
{
if (me.saving_lock)
rcmail.set_busy(false, null, me.saving_lock);
};
// opens calendar day-view in a popup
this.fisheye_view = function(date)
{
$('#fish-eye-view:ui-dialog').dialog('close');
// create list of active event sources
var src, cals = {}, sources = [];
for (var id in this.calendars) {
src = $.extend({}, this.calendars[id]);
src.editable = false;
src.url = null;
src.events = [];
if (src.active) {
cals[id] = src;
sources.push(src);
}
}
// copy events already loaded
var events = fc.fullCalendar('clientEvents');
for (var event, i=0; i< events.length; i++) {
event = events[i];
if (event.source && (src = cals[event.source.id])) {
src.events.push(event);
}
}
var h = $(window).height() - 50;
var dialog = $('<div>')
.attr('id', 'fish-eye-view')
.dialog({
modal: true,
width: 680,
height: h,
title: $.fullCalendar.formatDate(date, 'dddd ' + settings['date_long']),
close: function(){
dialog.dialog("destroy");
me.fisheye_date = null;
}
})
.fullCalendar({
header: { left: '', center: '', right: '' },
height: h - 50,
defaultView: 'agendaDay',
date: date.getDate(),
month: date.getMonth(),
year: date.getFullYear(),
ignoreTimezone: true, // will treat the given date strings as in local (browser's) timezone
eventSources: sources,
monthNames : settings['months'],
monthNamesShort : settings['months_short'],
dayNames : settings['days'],
dayNamesShort : settings['days_short'],
firstDay : settings['first_day'],
firstHour : settings['first_hour'],
slotMinutes : 60/settings['timeslots'],
timeFormat: { '': settings['time_format'] },
axisFormat : settings['time_format'],
columnFormat: { day: 'dddd ' + settings['date_short'] },
titleFormat: { day: 'dddd ' + settings['date_long'] },
allDayText: rcmail.gettext('all-day', 'calendar'),
<API key>: settings.time_indicator,
eventRender: fc_event_render,
eventClick: function(event) {
event_show_dialog(event);
}
});
this.fisheye_date = date;
};
//public method to show the print dialog.
this.print_calendars = function(view)
{
if (!view) view = fc.fullCalendar('getView').name;
var date = fc.fullCalendar('getDate') || new Date();
var range = fc.fullCalendar('option', 'listRange');
var sections = fc.fullCalendar('option', 'listSections');
rcmail.open_window(rcmail.url('print', { view: view, date: date2unixtime(date), range: range, sections: sections, search: this.search_query }), true, true);
};
// public method to bring up the new event dialog
this.add_event = function(templ) {
if (this.selected_calendar) {
var now = new Date();
var date = fc.fullCalendar('getDate');
if (typeof date != 'Date')
date = now;
date.setHours(now.getHours()+1);
date.setMinutes(0);
var end = new Date(date.getTime());
end.setHours(date.getHours()+1);
event_edit_dialog('new', $.extend({ start:date, end:end, allDay:false, calendar:this.selected_calendar }, templ || {}));
}
};
// delete the given event after showing a confirmation dialog
this.delete_event = function(event) {
// show confirm dialog for recurring events, use jquery UI dialog
return <API key>('remove', event, { id:event.id, calendar:event.calendar, attendees:event.attendees });
};
// opens a jquery UI dialog with event properties (or empty for creating a new calendar)
this.<API key> = function(calendar)
{
// close show dialog first
var $dialog = $("#calendarform");
if ($dialog.is(':ui-dialog'))
$dialog.dialog('close');
if (!calendar)
calendar = { name:'', color:'cc0000', editable:true, showalarms:true };
var form, name, color, alarms;
$dialog.html(rcmail.get_label('loading'));
$.ajax({
type: 'GET',
dataType: 'html',
url: rcmail.url('calendar'),
data: { action:(calendar.id ? 'form-edit' : 'form-new'), c:{ id:calendar.id } },
success: function(data) {
$dialog.html(data);
// resize and reposition dialog window
form = $('#calendarpropform');
me.dialog_resize('#calendarform', form.height(), form.width());
name = $('#calendar-name').prop('disabled', !calendar.editable).val(calendar.editname || calendar.name);
color = $('#calendar-color').val(calendar.color).miniColors({ value: calendar.color, colorValues:rcmail.env.mscolors });
alarms = $('#calendar-showalarms').prop('checked', calendar.showalarms).get(0);
name.select();
}
});
// dialog buttons
var buttons = {};
buttons[rcmail.gettext('save', 'calendar')] = function() {
// form is not loaded
if (!form || !form.length)
return;
// TODO: do some input validation
if (!name.val() || name.val().length < 2) {
alert(rcmail.gettext('<API key>', 'calendar'));
name.select();
return;
}
// post data to server
var data = form.serializeJSON();
if (data.color)
data.color = data.color.replace(/^
if (calendar.id)
data.id = calendar.id;
if (alarms)
data.showalarms = alarms.checked ? 1 : 0;
me.saving_lock = rcmail.set_busy(true, 'calendar.savingdata');
rcmail.http_post('calendar', { action:(calendar.id ? 'edit' : 'new'), c:data });
$dialog.dialog("close");
};
buttons[rcmail.gettext('cancel', 'calendar')] = function() {
$dialog.dialog("close");
};
// open jquery UI dialog
$dialog.dialog({
modal: true,
resizable: true,
closeOnEscape: false,
title: rcmail.gettext((calendar.id ? 'editcalendar' : 'createcalendar'), 'calendar'),
close: function() {
$dialog.html('').dialog("destroy").hide();
},
buttons: buttons,
minWidth: 400,
width: 420
}).show();
};
this.calendar_remove = function(calendar)
{
if (confirm(rcmail.gettext(calendar.children ? '<API key>' : '<API key>', 'calendar'))) {
rcmail.http_post('calendar', { action:'remove', c:{ id:calendar.id } });
return true;
}
return false;
};
this.<API key> = function(id)
{
var delete_ids = [];
if (this.calendars[id]) {
// find sub-calendars
if (this.calendars[id].children) {
for (var child_id in this.calendars) {
if (String(child_id).indexOf(id) == 0)
delete_ids.push(child_id);
}
}
else {
delete_ids.push(id);
}
}
// delete all calendars in the list
for (var i=0; i < delete_ids.length; i++) {
id = delete_ids[i];
fc.fullCalendar('removeEventSource', this.calendars[id]);
$(rcmail.get_folder_li(id, 'rcmlical')).remove();
$('#edit-calendar option[value="'+id+'"]').remove();
delete this.calendars[id];
}
};
// open a dialog to upload an .ics file with events to be imported
this.import_events = function(calendar)
{
// close show dialog first
var $dialog = $("#eventsimport"),
form = rcmail.gui_objects.importform;
if ($dialog.is(':ui-dialog'))
$dialog.dialog('close');
if (calendar)
$('#<API key>').val(calendar.id);
var buttons = {};
buttons[rcmail.gettext('import', 'calendar')] = function() {
if (form && form.elements._data.value) {
rcmail.async_upload_form(form, 'import_events', function(e) {
rcmail.set_busy(false, null, me.saving_lock);
$('.<API key> button', $dialog.parent()).button('enable');
// display error message if no sophisticated response from server arrived (e.g. iframe load error)
if (me.import_succeeded === null)
rcmail.display_message(rcmail.get_label('importerror', 'calendar'), 'error');
});
// display upload indicator (with extended timeout)
var timeout = rcmail.env.request_timeout;
rcmail.env.request_timeout = 600;
me.import_succeeded = null;
me.saving_lock = rcmail.set_busy(true, 'uploading');
$('.<API key> button', $dialog.parent()).button('disable');
// restore settings
rcmail.env.request_timeout = timeout;
}
};
buttons[rcmail.gettext('cancel', 'calendar')] = function() {
$dialog.dialog("close");
};
// open jquery UI dialog
$dialog.dialog({
modal: true,
resizable: false,
closeOnEscape: false,
title: rcmail.gettext('importevents', 'calendar'),
close: function() {
$('.<API key> button', $dialog.parent()).button('enable');
$dialog.dialog("destroy").hide();
},
buttons: buttons,
width: 520
}).show();
};
// callback from server if import succeeded
this.import_success = function(p)
{
this.import_succeeded = true;
$("#eventsimport:ui-dialog").dialog('close');
rcmail.set_busy(false, null, me.saving_lock);
rcmail.gui_objects.importform.reset();
if (p.refetch)
this.refresh(p);
};
// callback from server to report errors on import
this.import_error = function(p)
{
this.import_succeeded = false;
rcmail.display_message(p.message || rcmail.get_label('importerror', 'calendar'), 'error');
}
// show URL of the given calendar in a dialog box
this.showurl = function(calendar)
{
var $dialog = $('#calendarurlbox');
if ($dialog.is(':ui-dialog'))
$dialog.dialog('close');
if (calendar.feedurl) {
if (calendar.caldavurl) {
$('#caldavurl').val(calendar.caldavurl);
$('#calendarcaldavurl').show();
}
else {
$('#calendarcaldavurl').hide();
}
$dialog.dialog({
resizable: true,
closeOnEscape: true,
title: rcmail.gettext('showurl', 'calendar'),
close: function() {
$dialog.dialog("destroy").hide();
},
width: 520
}).show();
$('#calfeedurl').val(calendar.feedurl).select();
}
};
// refresh the calendar view after saving event data
this.refresh = function(p)
{
var source = me.calendars[p.source];
if (source && (p.refetch || (p.update && !source.active))) {
// activate event source if new event was added to an invisible calendar
if (!source.active) {
source.active = true;
fc.fullCalendar('addEventSource', source);
$('#' + rcmail.get_folder_li(source.id, 'rcmlical').id + ' input').prop('checked', true);
}
else
fc.fullCalendar('refetchEvents', source);
}
// add/update single event object
else if (source && p.update) {
var event = p.update;
event.temp = false;
event.editable = source.editable;
var existing = fc.fullCalendar('clientEvents', event._id);
if (existing.length) {
$.extend(existing[0], event);
fc.fullCalendar('updateEvent', existing[0]);
}
else {
event.source = source; // link with source
fc.fullCalendar('renderEvent', event);
}
// refresh fish-eye view
if (me.fisheye_date)
me.fisheye_view(me.fisheye_date);
}
// remove temp events
fc.fullCalendar('removeEvents', function(e){ return e.temp; });
};
// modify query parameters for refresh requests
this.before_refresh = function(query)
{
var view = fc.fullCalendar('getView');
query.start = date2unixtime(view.visStart);
query.end = date2unixtime(view.visEnd);
if (this.search_query)
query.q = this.search_query;
return query;
};
/*** event searching ***/
// execute search
this.quicksearch = function()
{
if (rcmail.gui_objects.qsearchbox) {
var q = rcmail.gui_objects.qsearchbox.value;
if (q != '') {
var id = 'search-'+q;
var sources = [];
if (this._search_message)
rcmail.hide_message(this._search_message);
for (var sid in this.calendars) {
if (this.calendars[sid]) {
this.calendars[sid].url = this.calendars[sid].url.replace(/&q=.+/, '') + '&q='+escape(q);
sources.push(sid);
}
}
id += '@'+sources.join(',');
// ignore if query didn't change
if (this.search_request == id) {
return;
}
// remember current view
else if (!this.search_request) {
this.default_view = fc.fullCalendar('getView').name;
}
this.search_request = id;
this.search_query = q;
// change to list view
fc.fullCalendar('option', 'listSections', 'month')
.fullCalendar('option', 'listRange', Math.max(60, settings['agenda_range']))
.fullCalendar('changeView', 'table');
<API key>();
// refetch events with new url (if not already triggered by changeView)
if (!this.is_loading)
fc.fullCalendar('refetchEvents');
}
else // empty search input equals reset
this.reset_quicksearch();
}
};
// reset search and get back to normal event listing
this.reset_quicksearch = function()
{
$(rcmail.gui_objects.qsearchbox).val('');
if (this._search_message)
rcmail.hide_message(this._search_message);
if (this.search_request) {
// hide bottom links of agenda view
fc.find('.fc-list-content > .fc-listappend').hide();
// restore original event sources and view mode from fullcalendar
fc.fullCalendar('option', 'listSections', settings['agenda_sections'])
.fullCalendar('option', 'listRange', settings['agenda_range']);
<API key>();
for (var sid in this.calendars) {
if (this.calendars[sid])
this.calendars[sid].url = this.calendars[sid].url.replace(/&q=.+/, '');
}
if (this.default_view)
fc.fullCalendar('changeView', this.default_view);
if (!this.is_loading)
fc.fullCalendar('refetchEvents');
this.search_request = this.search_query = null;
}
};
// callback if all sources have been fetched from server
this.events_loaded = function(count)
{
var addlinks, append = '';
// enhance list view when searching
if (this.search_request) {
if (!count) {
this._search_message = rcmail.display_message(rcmail.gettext('searchnoresults', 'calendar'), 'notice');
append = '<div class="message">' + rcmail.gettext('searchnoresults', 'calendar') + '</div>';
}
append += '<div class="fc-bottomlinks formlinks"></div>';
addlinks = true;
}
if (fc.fullCalendar('getView').name == 'table') {
var container = fc.find('.fc-list-content > .fc-listappend');
if (append) {
if (!container.length)
container = $('<div class="fc-listappend"></div>').appendTo(fc.find('.fc-list-content'));
container.html(append).show();
}
else if (container.length)
container.hide();
// add links to adjust search date range
if (addlinks) {
var lc = container.find('.fc-bottomlinks');
$('<a>').attr('href', '#').html(rcmail.gettext('searchearlierdates', 'calendar')).appendTo(lc).click(function(){
fc.fullCalendar('incrementDate', 0, -1, 0);
});
lc.append(" ");
$('<a>').attr('href', '#').html(rcmail.gettext('searchlaterdates', 'calendar')).appendTo(lc).click(function(){
var range = fc.fullCalendar('option', 'listRange');
if (range < 90) {
fc.fullCalendar('option', 'listRange', fc.fullCalendar('option', 'listRange') + 30).fullCalendar('render');
<API key>();
}
else
fc.fullCalendar('incrementDate', 0, 1, 0);
});
}
}
if (this.fisheye_date)
this.fisheye_view(this.fisheye_date);
};
// resize and reposition (center) the dialog window
this.dialog_resize = function(id, height, width)
{
var win = $(window), w = win.width(), h = win.height();
$(id).dialog('option', { height: Math.min(h-20, height+130), width: Math.min(w-20, width+50) })
.dialog('option', 'position', ['center', 'center']); // only works in a separate call (!?)
};
// adjust calendar view size
this.view_resize = function()
{
var footer = fc.fullCalendar('getView').name == 'table' ? $('#agendaoptions').outerHeight() : 0;
fc.fullCalendar('option', 'height', $('#calendar').height() - footer);
};
/*** startup code ***/
// create list of event sources AKA calendars
this.calendars = {};
var li, cal, active, event_sources = [];
for (var id in rcmail.env.calendars) {
cal = rcmail.env.calendars[id];
this.calendars[id] = $.extend({
url: "./?_task=calendar&_action=load_events&source="+escape(id),
editable: !cal.readonly,
className: 'fc-event-cal-'+id,
id: id
}, cal);
this.calendars[id].color = settings.event_coloring % 2 ? '' : '#' + cal.color;
if ((active = cal.active || false)) {
event_sources.push(this.calendars[id]);
}
// init event handler on calendar list checkbox
if ((li = rcmail.get_folder_li(id, 'rcmlical'))) {
$('#'+li.id+' input').click(function(e){
var id = $(this).data('id');
if (me.calendars[id]) { // add or remove event source on click
var action;
if (this.checked) {
action = 'addEventSource';
me.calendars[id].active = true;
}
else {
action = 'removeEventSource';
me.calendars[id].active = false;
}
// add/remove event source
fc.fullCalendar(action, me.calendars[id]);
rcmail.http_post('calendar', { action:'subscribe', c:{ id:id, active:me.calendars[id].active?1:0 } });
}
}).data('id', id).get(0).checked = active;
$(li).click(function(e){
var id = $(this).data('id');
rcmail.select_folder(id, 'rcmlical');
rcmail.enable_command('calendar-edit', true);
rcmail.enable_command('calendar-remove', 'calendar-showurl', true);
me.selected_calendar = id;
})
.dblclick(function(){ me.<API key>(me.calendars[me.selected_calendar]); })
.data('id', id);
}
if (!cal.readonly && !this.selected_calendar) {
this.selected_calendar = id;
rcmail.enable_command('addevent', true);
}
}
// select default calendar
if (settings.default_calendar && this.calendars[settings.default_calendar] && !this.calendars[settings.default_calendar].readonly)
this.selected_calendar = settings.default_calendar;
var viewdate = new Date();
if (rcmail.env.date)
viewdate.setTime(fromunixtime(rcmail.env.date));
// initalize the fullCalendar plugin
var fc = $('#calendar').fullCalendar({
header: {
right: 'prev,next today',
center: 'title',
left: 'agendaDay,agendaWeek,month,table'
},
aspectRatio: 1,
date: viewdate.getDate(),
month: viewdate.getMonth(),
year: viewdate.getFullYear(),
ignoreTimezone: true, // will treat the given date strings as in local (browser's) timezone
height: $('#calendar').height(),
eventSources: event_sources,
monthNames : settings['months'],
monthNamesShort : settings['months_short'],
dayNames : settings['days'],
dayNamesShort : settings['days_short'],
firstDay : settings['first_day'],
firstHour : settings['first_hour'],
slotMinutes : 60/settings['timeslots'],
timeFormat: {
'': settings['time_format'],
agenda: settings['time_format'] + '{ - ' + settings['time_format'] + '}',
list: settings['time_format'] + '{ - ' + settings['time_format'] + '}',
table: settings['time_format'] + '{ - ' + settings['time_format'] + '}'
},
axisFormat : settings['time_format'],
columnFormat: {
month: 'ddd', // Mon
week: 'ddd ' + settings['date_short'], // Mon 9/7
day: 'dddd ' + settings['date_short'], // Monday 9/7
table: settings['date_agenda']
},
titleFormat: {
month: 'MMMM yyyy',
week: settings['dates_long'],
day: 'dddd ' + settings['date_long'],
table: settings['dates_long']
},
listPage: 1, // advance one day in agenda view
listRange: settings['agenda_range'],
listSections: settings['agenda_sections'],
tableCols: ['handle', 'date', 'time', 'title', 'location'],
defaultView: rcmail.env.view || settings['default_view'],
allDayText: rcmail.gettext('all-day', 'calendar'),
buttonText: {
prev: (bw.ie6 ? ' << ' : ' ◄ '),
next: (bw.ie6 ? ' >> ' : ' ► '),
today: settings['today'],
day: rcmail.gettext('day', 'calendar'),
week: rcmail.gettext('week', 'calendar'),
month: rcmail.gettext('month', 'calendar'),
table: rcmail.gettext('agenda', 'calendar')
},
listTexts: {
until: rcmail.gettext('until', 'calendar'),
past: rcmail.gettext('pastevents', 'calendar'),
today: rcmail.gettext('today', 'calendar'),
tomorrow: rcmail.gettext('tomorrow', 'calendar'),
thisWeek: rcmail.gettext('thisweek', 'calendar'),
nextWeek: rcmail.gettext('nextweek', 'calendar'),
thisMonth: rcmail.gettext('thismonth', 'calendar'),
nextMonth: rcmail.gettext('nextmonth', 'calendar'),
future: rcmail.gettext('futureevents', 'calendar'),
week: rcmail.gettext('weekofyear', 'calendar')
},
selectable: true,
selectHelper: false,
<API key>: settings.time_indicator,
loading: function(isLoading) {
me.is_loading = isLoading;
this._rc_loading = rcmail.set_busy(isLoading, 'loading', this._rc_loading);
// trigger callback
if (!isLoading)
me.events_loaded($(this).fullCalendar('clientEvents').length);
},
// event rendering
eventRender: fc_event_render,
// render element indicating more (invisible) events
overflowRender: function(data, element) {
element.html(rcmail.gettext('andnmore', 'calendar').replace('$nr', data.count))
.click(function(e){ me.fisheye_view(data.date); });
},
// callback for date range selection
select: function(start, end, allDay, e, view) {
var range_select = (!allDay || start.getDate() != end.getDate())
if (dialog_check(e) && range_select)
event_edit_dialog('new', { start:start, end:end, allDay:allDay, calendar:me.selected_calendar });
if (range_select || ignore_click)
view.calendar.unselect();
},
// callback for clicks in all-day box
dayClick: function(date, allDay, e, view) {
var now = new Date().getTime();
if (now - day_clicked_ts < 400 && day_clicked == date.getTime()) { // emulate double-click on day
var enddate = new Date(); enddate.setTime(date.getTime() + DAY_MS - 60000);
return event_edit_dialog('new', { start:date, end:enddate, allDay:allDay, calendar:me.selected_calendar });
}
if (!ignore_click) {
view.calendar.gotoDate(date);
if (day_clicked && new Date(day_clicked).getMonth() != date.getMonth())
view.calendar.select(date, date, allDay);
}
day_clicked = date.getTime();
day_clicked_ts = now;
},
// callback when a specific event is clicked
eventClick: function(event) {
if (!event.temp)
event_show_dialog(event);
},
// callback when an event was dragged and finally dropped
eventDrop: function(event, dayDelta, minuteDelta, allDay, revertFunc) {
if (event.end == null || event.end.getTime() < event.start.getTime()) {
event.end = new Date(event.start.getTime() + (allDay ? DAY_MS : HOUR_MS));
}
// moved to all-day section: set times to 12:00 - 13:00
if (allDay && !event.allDay) {
event.start.setHours(12);
event.start.setMinutes(0);
event.start.setSeconds(0);
event.end.setHours(13);
event.end.setMinutes(0);
event.end.setSeconds(0);
}
// moved from all-day section: set times to working hours
else if (event.allDay && !allDay) {
var newstart = event.start.getTime();
revertFunc(); // revert to get original duration
var numdays = Math.max(1, Math.round((event.end.getTime() - event.start.getTime()) / DAY_MS)) - 1;
event.start = new Date(newstart);
event.end = new Date(newstart + numdays * DAY_MS);
event.end.setHours(settings['work_end'] || 18);
event.end.setMinutes(0);
if (event.end.getTime() < event.start.getTime())
event.end = new Date(newstart + HOUR_MS);
}
// send move request to server
var data = {
id: event.id,
calendar: event.calendar,
start: date2servertime(event.start),
end: date2servertime(event.end),
allday: allDay?1:0
};
<API key>('move', event, data);
},
// callback for event resizing
eventResize: function(event, delta) {
// sanitize event dates
if (event.allDay)
event.start.setHours(12);
if (!event.end || event.end.getTime() < event.start.getTime())
event.end = new Date(event.start.getTime() + HOUR_MS);
// send resize request to server
var data = {
id: event.id,
calendar: event.calendar,
start: date2servertime(event.start),
end: date2servertime(event.end)
};
<API key>('resize', event, data);
},
viewDisplay: function(view) {
$('#agendaoptions')[view.name == 'table' ? 'show' : 'hide']();
if (minical) {
window.setTimeout(function(){ minical.datepicker('setDate', fc.fullCalendar('getDate')); }, exec_deferred);
if (view.name != current_view)
me.view_resize();
current_view = view.name;
}
},
viewRender: function(view) {
if (fc && view.name == 'month')
fc.fullCalendar('option', 'maxHeight', Math.floor((view.element.parent().height()-18) / 6) - 35);
}
});
// format time string
var formattime = function(hour, minutes, start) {
var time, diff, unit, duration = '', d = new Date();
d.setHours(hour);
d.setMinutes(minutes);
time = $.fullCalendar.formatDate(d, settings['time_format']);
if (start) {
diff = Math.floor((d.getTime() - start.getTime()) / 60000);
if (diff > 0) {
unit = 'm';
if (diff >= 60) {
unit = 'h';
diff = Math.round(diff / 3) / 20;
}
duration = ' (' + diff + unit + ')';
}
}
return [time, duration];
};
var autocomplete_times = function(p, callback) {
/* Time completions */
var result = [];
var now = new Date();
var st, start = (String(this.element.attr('id')).indexOf('endtime') > 0
&& (st = $('#edit-starttime').val())
&& $('#edit-startdate').val() == $('#edit-enddate').val())
? parse_datetime(st, '') : null;
var full = p.term - 1 > 0 || p.term.length > 1;
var hours = start ? start.getHours() :
(full ? parse_datetime(p.term, '') : now).getHours();
var step = 15;
var minutes = hours * 60 + (full ? 0 : now.getMinutes());
var min = Math.ceil(minutes / step) * step % 60;
var hour = Math.floor(Math.ceil(minutes / step) * step / 60);
// list hours from 0:00 till now
for (var h = start ? start.getHours() : 0; h < hours; h++)
result.push(formattime(h, 0, start));
// list 15min steps for the next two hours
for (; h < hour + 2 && h < 24; h++) {
while (min < 60) {
result.push(formattime(h, min, start));
min += step;
}
min = 0;
}
// list the remaining hours till 23:00
while (h < 24)
result.push(formattime((h++), 0, start));
return callback(result);
};
var autocomplete_open = function(event, ui) {
// scroll to current time
var $this = $(this);
var widget = $this.autocomplete('widget');
var menu = $this.data('autocomplete').menu;
var amregex = /^(.+)(a[.m]*)/i;
var pmregex = /^(.+)(a[.m]*)/i;
var val = $(this).val().replace(amregex, '0:$1').replace(pmregex, '1:$1');
var li, html;
widget.css('width', '10em');
widget.children().each(function(){
li = $(this);
html = li.children().first().html().replace(/\s+\(.+\)$/, '').replace(amregex, '0:$1').replace(pmregex, '1:$1');
if (html.indexOf(val) == 0)
menu._scrollIntoView(li);
});
};
// if start date is changed, shift end date according to initial duration
var shift_enddate = function(dateText) {
var newstart = parse_datetime('0', dateText);
var newend = new Date(newstart.getTime() + $('#edit-startdate').data('duration') * 1000);
$('#edit-enddate').val($.fullCalendar.formatDate(newend, me.settings['date_format']));
event_times_changed();
};
// Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
// Uses the default $.datepicker.iso8601Week() function but takes firstDay setting into account.
var iso8601Week = datepicker_settings.calculateWeek = function(date) {
var mondayOffset = Math.abs(1 - datepicker_settings.firstDay);
return $.datepicker.iso8601Week(new Date(date.getTime() + mondayOffset * 86400000));
};
var minical;
var init_calendar_ui = function()
{
// initialize small calendar widget using jQuery UI datepicker
minical = $('#datepicker').datepicker($.extend(datepicker_settings, {
inline: true,
showWeek: true,
changeMonth: false, // maybe enable?
changeYear: false, // maybe enable?
onSelect: function(dateText, inst) {
ignore_click = true;
var d = minical.datepicker('getDate'); //parse_datetime('0:0', dateText);
fc.fullCalendar('gotoDate', d).fullCalendar('select', d, d, true);
},
onChangeMonthYear: function(year, month, inst) {
minical.data('year', year).data('month', month);
},
beforeShowDay: function(date) {
var view = fc.fullCalendar('getView');
var active = view.visStart && date.getTime() >= view.visStart.getTime() && date.getTime() < view.visEnd.getTime();
return [ true, (active ? '<API key> <API key>-' + view.name : ''), ''];
}
})) // set event handler for clicks on calendar week cell of the datepicker widget
.click(function(e) {
var cell = $(e.target);
if (e.target.tagName == 'TD' && cell.hasClass('<API key>')) {
var base_date = minical.datepicker('getDate');
if (minical.data('month'))
base_date.setMonth(minical.data('month')-1);
if (minical.data('year'))
base_date.setYear(minical.data('year'));
base_date.setHours(12);
base_date.setDate(base_date.getDate() - ((base_date.getDay() + 6) % 7) + datepicker_settings.firstDay);
var day_off = base_date.getDay() - datepicker_settings.firstDay;
var base_kw = iso8601Week(base_date);
var target_kw = parseInt(cell.html());
var diff = (target_kw - base_kw) * 7 * DAY_MS;
// select monday of the chosen calendar week
var date = new Date(base_date.getTime() - day_off * DAY_MS + diff);
fc.fullCalendar('gotoDate', date).fullCalendar('setDate', date).fullCalendar('changeView', 'agendaWeek');
minical.datepicker('setDate', date);
}
});
// init event dialog
$('#eventtabs').tabs({
show: function(event, ui) {
if (ui.panel.id == 'event-tab-3') {
$('#edit-attendee-name').select();
// update free-busy status if needed
if (freebusy_ui.needsupdate && me.selected_event)
<API key>(me.selected_event);
// add current user as organizer if non added yet
if (!event_attendees.length) {
add_attendee($.extend({ role:'ORGANIZER' }, settings.identity));
$('#edit-attendees-form .attendees-invitebox').show();
}
}
}
});
$('#edit-enddate').datepicker(datepicker_settings);
$('#edit-startdate').datepicker(datepicker_settings).datepicker('option', 'onSelect', shift_enddate).change(function(){ shift_enddate(this.value); });
$('#edit-enddate').datepicker('option', 'onSelect', event_times_changed).change(event_times_changed);
$('#edit-allday').click(function(){ $('#edit-starttime, #edit-endtime')[(this.checked?'hide':'show')](); event_times_changed(); });
// configure drop-down menu on time input fields based on jquery UI autocomplete
$('#edit-starttime, #edit-endtime, #eventedit input.edit-alarm-time')
.attr('autocomplete', "off")
.autocomplete({
delay: 100,
minLength: 1,
source: autocomplete_times,
open: autocomplete_open,
change: event_times_changed,
select: function(event, ui) {
$(this).val(ui.item[0]);
return false;
}
})
.click(function() { // show drop-down upon clicks
$(this).autocomplete('search', $(this).val() ? $(this).val().replace(/\D.*/, "") : " ");
}).each(function(){
$(this).data('autocomplete')._renderItem = function(ul, item) {
return $('<li>')
.data('item.autocomplete', item)
.append('<a>' + item[0] + item[1] + '</a>')
.appendTo(ul);
};
});
// register events on alarm fields
init_alarms_edit('#eventedit');
// toggle recurrence frequency forms
$('#<API key>').change(function(e){
var freq = $(this).val().toLowerCase();
$('.recurrence-form').hide();
if (freq)
$('#recurrence-form-'+freq+', #<API key>').show();
});
$('#<API key>').datepicker(datepicker_settings).click(function(){ $("#<API key>").prop('checked', true) });
$('#<API key>').change(function(e){ $('#<API key>').prop('checked', true); });
// init attendees autocompletion
var ac_props;
// parallel autocompletion
if (rcmail.env.<API key> > 0) {
ac_props = {
threads: rcmail.env.<API key>,
sources: rcmail.env.<API key>
};
}
rcmail.<API key>($('#edit-attendee-name'), ac_props);
rcmail.addEventListener('autocomplete_insert', function(e){ $('#edit-attendee-add').click(); });
$('#edit-attendee-add').click(function(){
var input = $('#edit-attendee-name');
rcmail.ksearch_blur();
if (add_attendees(input.val())) {
input.val('');
}
});
// keep these two checkboxes in sync
$('#<API key>, #<API key>').click(function(){
$('#<API key>, #<API key>').prop('checked', this.checked);
});
$('#<API key>').click(function(){
<API key>();
});
$('#<API key>').html(bw.ie6 ? '<<' : '◄').button().click(function(){ <API key>(-1); });
$('#<API key>').html(bw.ie6 ? '>>' : '►').button().click(function(){ <API key>(1); }).parent().buttonset();
$('#shedule-find-prev').button().click(function(){ freebusy_find_slot(-1); });
$('#shedule-find-next').button().click(function(){ freebusy_find_slot(1); });
$('#<API key>').click(function(){
freebusy_ui.workinhoursonly = this.checked;
$('#workinghourscss').remove();
if (this.checked)
$('<style type="text/css" id="workinghourscss"> td.offhours { opacity:0.3; filter:alpha(opacity=30) } </style>').appendTo('head');
});
$('#event-rsvp input.button').click(function(){
event_rsvp($(this).attr('rel'))
});
$('#agenda-listrange').change(function(e){
settings['agenda_range'] = parseInt($(this).val());
fc.fullCalendar('option', 'listRange', settings['agenda_range']).fullCalendar('render');
// TODO: save new settings in prefs
}).val(settings['agenda_range']);
$('#agenda-listsections').change(function(e){
settings['agenda_sections'] = $(this).val();
fc.fullCalendar('option', 'listSections', settings['agenda_sections']).fullCalendar('render');
// TODO: save new settings in prefs
}).val(fc.fullCalendar('option', 'listSections'));
// hide event dialog when clicking somewhere into document
$(document).bind('mousedown', dialog_check);
rcmail.set_busy(false, 'loading', ui_loading);
}
// initialize more UI elements (deferred)
window.setTimeout(init_calendar_ui, exec_deferred);
if (!bw.ie)
$('div.fc-content').addClass('rcube-fc-content');
// IE supresses 2nd click event when double-clicking
if (bw.ie && bw.vendver < 9) {
$('div.fc-content').bind('dblclick', function(e){
if (!$(this).hasClass('fc-widget-header') && fc.fullCalendar('getView').name != 'table') {
var date = fc.fullCalendar('getDate');
var enddate = new Date(); enddate.setTime(date.getTime() + DAY_MS - 60000);
event_edit_dialog('new', { start:date, end:enddate, allDay:true, calendar:me.selected_calendar });
}
});
}
} // end rcube_calendar class
/* calendar plugin initialization */
window.rcmail && rcmail.addEventListener('init', function(evt) {
// configure toolbar buttons
rcmail.register_command('addevent', function(){ cal.add_event(); }, true);
rcmail.register_command('print', function(){ cal.print_calendars(); }, true);
// configure list operations
rcmail.register_command('calendar-create', function(){ cal.<API key>(null); }, true);
rcmail.register_command('calendar-edit', function(){ cal.<API key>(cal.calendars[cal.selected_calendar]); }, false);
rcmail.register_command('calendar-remove', function(){ cal.calendar_remove(cal.calendars[cal.selected_calendar]); }, false);
rcmail.register_command('events-import', function(){ cal.import_events(cal.calendars[cal.selected_calendar]); }, true);
rcmail.register_command('calendar-showurl', function(){ cal.showurl(cal.calendars[cal.selected_calendar]); }, false);
// search and export events
rcmail.register_command('export', function(){ rcmail.goto_url('export_events', { source:cal.selected_calendar }); }, true);
rcmail.register_command('search', function(){ cal.quicksearch(); }, true);
rcmail.register_command('reset-search', function(){ cal.reset_quicksearch(); }, true);
// register callback commands
rcmail.addEventListener('plugin.destroy_source', function(p){ cal.<API key>(p.id); });
rcmail.addEventListener('plugin.unlock_saving', function(p){ cal.unlock_saving(); });
rcmail.addEventListener('plugin.refresh_calendar', function(p){ cal.refresh(p); });
rcmail.addEventListener('plugin.import_success', function(p){ cal.import_success(p); });
rcmail.addEventListener('plugin.import_error', function(p){ cal.import_error(p); });
rcmail.addEventListener('requestrefresh', function(q){ return cal.before_refresh(q); });
// let's go
var cal = new rcube_calendar_ui($.extend(rcmail.env.calendar_settings, rcmail.env.libcal_settings));
$(window).resize(function(e) {
// check target due to bugs in jquery
if (e.target == window) {
cal.view_resize();
}
}).resize();
// show calendars list when ready
$('#calendars').css('visibility', 'inherit');
// show toolbar
$('#toolbar').show();
});
|
<?php
//-- No direct access
defined('_JEXEC') || die('=;)');
$time = time();
$app =& JFactory::getApplication();
$db = JFactory::getDbo();
$request_v =& JRequest::getVar( 'request', '', 'post', 'string' );
$app->setUserState('request', $request_v);
$titlu_anunt =& JRequest::getVar( 'titlu_anunt', '', 'post', 'string' );
$app->setUserState('titlu_anunt', $titlu_anunt);
$marca =& JRequest::getVar( 'marca', '', 'post', 'string' );
$model_auto =& JRequest::getVar( 'model_auto', '', 'post', 'string' );
$app->setUserState('model_auto', $model_auto);
$an_fabricatie =& JRequest::getVar( 'an_fabricatie', '', 'post', 'string' );
$app->setUserState('an_fabricatie', $an_fabricatie);
$cilindree =& JRequest::getVar( 'cilindree', '', 'post', 'string' );
$app->setUserState('cilindree', $cilindree);
$carburant =& JRequest::getVar( 'carburant', '', 'post', 'string' );
$app->setUserState('carburant', $carburant);
$caroserie =& JRequest::getVar( 'caroserie', '', 'post', 'string' );
$app->setUserState('caroserie', $caroserie);
$serie_caroserie =& JRequest::getVar( 'serie_caroserie', '', 'post', 'string' );
$app->setUserState('serie_caroserie', $serie_caroserie);
$anunt =& JRequest::getVar( 'anunt8', '', 'post', 'string', JREQUEST_ALLOWHTML );
$app->setUserState('anunt', $anunt);
$judet =& JRequest::getVar( 'judet', '', 'post', 'string' );
$city =& JRequest::getVar( 'localitate', '', 'post', 'string' );
$query = "SELECT `id` FROM #__sa_judete WHERE `judet` = '".$judet."'";
$db->setQuery($query);
$id_judet = $db->loadResult();
$transmisie =& JRequest::getVar( 'transmisie', '', 'post', 'string' );
$app->setUserState('transmisie', $transmisie);
$user =& JFactory::getUser();
$uid = $user->id;
$register_anunt = 0;
//echo '>>>>> marca '.$marca.' >>>> '.$new_marca.' >>>>> '.$model_auto.' >>>>> '.$new_model.'<br />';
$link_redirect = JRoute::_('index.php?option=com_sauto&view=add_request');
if ($marca == '') {
//nu am selectat marca
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
//marca existenta, obtinem id-ul
$query = "SELECT `id` FROM #__sa_marca_auto WHERE `marca_auto` = '".$marca."'";
$db->setQuery($query);
$mid = $db->loadResult();
$marca_auto_id = $mid;
$app->setUserState('marca', $mid);
//echo '<br />>>>>>'.$marca_auto_id.'<br />';
$model_auto_id = $model_auto;
$app->setUserState('model_auto', $model_auto);
}
//echo '<br />>>>>>'.$model_auto_id.'<br />';
//verificam campurile introduse
if ($titlu_anunt == '') {
//nu avem introdus titlul
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($an_fabricatie == '') {
//nu avem introdus anul fabricatiei
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($cilindree == '') {
//cilindreea nu este introdusa
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($carburant == '') {
//carburantul nu este ales
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($caroserie == '') {
//nu este aleasa caroseria
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($serie_caroserie == '') {
//seria caroseriei nu este introdusa
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
if ($anunt == '') {
//nu este adaugat anuntul
//SautoViewAdding::deleteModels($marca_noua_id, $model_nou_id);
$app->redirect($link_redirect, JText::_('<API key>'));
} else {
//e ok
$register_anunt = 1;
}
}
}
}
}
}
}
//sfarsit verificare
if ($register_anunt == 1) {
//obtin data curenta
$curentDate = date('Y-m-d H:i:s', $time);
$expiryDate = date('Y-m-d H:i:s', ($time+2592000));
//echo '<br />caroserie>>>>'.$caroserie.'<br />';
//adaug in baza de date
$query = "INSERT INTO #__sa_anunturi
(`titlu_anunt`, `anunt`, `tip_anunt`, `marca_auto`, `model_auto`, `an_fabricatie`,
`cilindree`, `carburant`, `caroserie`, `serie_caroserie`, `proprietar`, `data_adaugarii`,
`status_anunt`, `raportat`, `data_expirarii`, `judet`, `city`, `transmisie`)
VALUES
('".$titlu_anunt."', '".$anunt."', '8', '".$marca_auto_id."', '".$model_auto_id."', '".$an_fabricatie."',
'".$cilindree."', '".$carburant."','".$caroserie."', '".$serie_caroserie."', '".$uid."', '".$curentDate."',
'1', '0', '".$expiryDate."', '".$id_judet."', '".$city."', '".$transmisie."')";
$db->setQuery($query);
$db->query();
$anunt_id = $db->insertid();
SautoViewAdding::uploadImg($time, $uid, $anunt_id);
SautoViewAdding::sendMail($anunt_id);
//parcam masina daca este cazul....
$parcheaza =& JRequest::getVar( 'parcheaza', '', 'post', 'string' );
if ($parcheaza == 1) {
$query = "INSERT INTO #__sa_garaj
(`owner`, `marca`, `model`, `an_fabricatie`, `cilindree`, `carburant`,
`caroserie`, `serie_caroserie`, `transmisie`)
VALUES
('".$uid."', '".$marca_auto_id."', '".$model_auto_id."', '".$an_fabricatie."', '".$cilindree."',
'".$carburant."', '".$caroserie."', '".$serie_caroserie."', '".$transmisie."')";
$db->setQuery($query);
$db->query();
}
//end parcare masina
$app->setUserState('an_fabricatie', '');
$app->setUserState('cilindree', '');
$app->setUserState('carburant', '');
$app->setUserState('marca', '');
$app->setUserState('caroserie', '');
$app->setUserState('serie_caroserie', '');
$app->setUserState('model_auto', '');
$app->setUserState('request', '');$app->setUserState('transmisie', '');
$app->setUserState('titlu_anunt', '');
$app->setUserState('transmisie', '');
$app->setUserState('anunt', '');
$link_redirect_fr = JRoute::_('index.php?option=com_sauto');
$app->redirect($link_redirect_fr, JText::_('SAUTO_SUCCESS_ADDED'));
}
?>
|
#!/usr/bin/env python3
# This file is part of <API key>
# This program is free software; you can redistribute it and/or
# as published by the Free Software Foundation; either version 2
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
# andreas.lindh (a) hiced.com
import math
import os
import sys
import xml.etree.ElementTree as ETree
import tabulate
from mdutils.mdutils import MdUtils
DEFAULT_INI = {'global': {'unusedholes': 'yes',
'onebitenum': 'no'}}
def <API key>(regName,
fieldNameList,
bitOffsetList,
bitWidthList,
fieldDescList,
enumTypeList,
unusedHoles=True):
# sort the lists, highest offset first
fieldNameList = fieldNameList
bitOffsetList = [int(x) for x in bitOffsetList]
bitWidthList = [int(x) for x in bitWidthList]
fieldDescList = fieldDescList
enumTypeList = enumTypeList
matrix = list(zip(bitOffsetList, fieldNameList, bitWidthList, fieldDescList, enumTypeList))
matrix.sort(key=lambda x: x[0]) # , reverse=True)
bitOffsetList, fieldNameList, bitWidthList, fieldDescList, enumTypeList = list(zip(*matrix))
# zip return tuples not lists
fieldNameList = list(fieldNameList)
bitOffsetList = list([int(x) for x in bitOffsetList])
bitWidthList = list([int(x) for x in bitWidthList])
fieldDescList = list(fieldDescList)
enumTypeList = list(enumTypeList)
if unusedHoles:
unUsedCnt = 0
<API key> = 0
# fill up the holes
index = 0
register_width = bitOffsetList[-1] + bitWidthList[-1]
while register_width > <API key>:
if <API key> != bitOffsetList[index]:
newBitWidth = bitOffsetList[index] - <API key>
bitOffsetList.insert(index, <API key>)
fieldNameList.insert(index, 'unused' + str(unUsedCnt))
bitWidthList.insert(index, newBitWidth)
fieldDescList.insert(index, 'unused')
enumTypeList.insert(index, '')
unUsedCnt += 1
<API key> = int(bitOffsetList[index]) + int(bitWidthList[index])
index += 1
return regName, fieldNameList, bitOffsetList, bitWidthList, fieldDescList, enumTypeList
class documentClass():
def __init__(self, name):
self.name = name
self.memoryMapList = []
def addMemoryMap(self, memoryMap):
self.memoryMapList.append(memoryMap)
class memoryMapClass():
def __init__(self, name):
self.name = name
self.addressBlockList = []
def addAddressBlock(self, addressBlock):
self.addressBlockList.append(addressBlock)
class addressBlockClass():
def __init__(self, name, addrWidth, dataWidth):
self.name = name
self.addrWidth = addrWidth
self.dataWidth = dataWidth
self.registerList = []
self.suffix = ""
def addRegister(self, reg):
assert isinstance(reg, registerClass)
self.registerList.append(reg)
def setRegisterList(self, registerList):
self.registerList = registerList
def returnAsString(self):
raise NotImplementedError("method returnAsString() is virutal and must be overridden.")
class registerClass():
def __init__(self, name, address, resetValue, size, access, desc, fieldNameList,
bitOffsetList, bitWidthList, fieldDescList, enumTypeList):
assert isinstance(enumTypeList, list), 'enumTypeList is not a list'
self.name = name
self.address = address
self.resetValue = resetValue
self.size = size
self.access = access
self.desc = desc
self.fieldNameList = fieldNameList
self.bitOffsetList = bitOffsetList
self.bitWidthList = bitWidthList
self.fieldDescList = fieldDescList
self.enumTypeList = enumTypeList
class <API key>():
""" should perhaps be a singleton instead """
def __init__(self):
self.listOfEnums = []
def enumAllReadyExist(self, enum):
for e in self.listOfEnums:
if e.compare(enum):
enum.allReadyExist = True
enum.enumName = e.name
break
self.listOfEnums.append(enum)
return enum
class enumTypeClass():
def __init__(self, name, bitWidth, keyList, valueList, descrList):
self.name = name
self.bitWidth = bitWidth
matrix = list(zip(valueList, keyList, descrList))
matrix.sort(key=lambda x: x[0])
valueList, keyList, descrList = list(zip(*matrix))
self.keyList = list(keyList)
self.valueList = list(valueList)
self.allReadyExist = False
self.enumName = None
self.descrList = descrList
def compare(self, other):
result = True
result = self.bitWidth == other.bitWidth and result
result = self.compareLists(self.keyList, other.keyList) and result
return result
def compareLists(self, list1, list2):
for val in list1:
if val in list2:
return True
return False
class rstAddressBlock(addressBlockClass):
"""Generates a ReStructuredText file from a IP-XACT register description"""
def __init__(self, name, addrWidth, dataWidth):
self.name = name
self.addrWidth = addrWidth
self.dataWidth = dataWidth
self.registerList = []
self.suffix = ".rst"
def <API key>(self, enumTypeObj):
if isinstance(enumTypeObj, enumTypeClass):
l = []
for i in range(len(enumTypeObj.keyList)):
l.append(enumTypeObj.keyList[i] + '=' + enumTypeObj.valueList[i])
s = ", ".join(l)
else:
s = ''
return s
def returnAsString(self):
r = ""
regNameList = [reg.name for reg in self.registerList]
regAddressList = [reg.address for reg in self.registerList]
regDescrList = [reg.desc for reg in self.registerList]
r += self.returnRstTitle()
r += self.returnRstSubTitle()
summary_table = []
for i in range(len(regNameList)):
summary_table.append(["%#04x" % regAddressList[i], str(regNameList[i]) + "_", str(regDescrList[i])])
r += tabulate.tabulate(summary_table,
headers=['Address', 'Register Name', 'Description'],
tablefmt="grid")
r += "\n"
r += "\n"
for reg in self.registerList:
r += self.returnRstRegDesc(reg.name, reg.address, reg.size, reg.resetValue, reg.desc, reg.access)
reg_table = []
for fieldIndex in reversed(list(range(len(reg.fieldNameList)))):
bits = "[" + str(reg.bitOffsetList[fieldIndex] + reg.bitWidthList[fieldIndex] - 1) + \
":" + str(reg.bitOffsetList[fieldIndex]) + "]"
_line = [bits,
reg.fieldNameList[fieldIndex]]
if reg.resetValue:
temp = (int(reg.resetValue, 0) >> reg.bitOffsetList[fieldIndex])
mask = (2 ** reg.bitWidthList[fieldIndex]) - 1
temp &= mask
temp = "{value:#0{width}x}".format(value=temp,
width=math.ceil(reg.bitWidthList[fieldIndex] / 4) + 2)
_line.append(temp)
_line.append(reg.fieldDescList[fieldIndex])
reg_table.append(_line)
_headers = ['Bits', 'Field name']
if reg.resetValue:
_headers.append('Reset')
_headers.append('Description')
r += tabulate.tabulate(reg_table,
headers=_headers,
tablefmt="grid")
r += "\n"
r += "\n"
# enumerations
for enum in reg.enumTypeList:
if enum:
# header
r += enum.name + "\n"
r += ',' * len(enum.name) + "\n"
r += "\n"
# table
enum_table = []
for i in range(len(enum.keyList)):
_value = "{value:#0{width}x}".format(value=int(enum.valueList[i], 0),
width=math.ceil(int(enum.bitWidth, 0) / 4) + 2)
_line = [enum.keyList[i],
_value,
enum.descrList[i]]
enum_table.append(_line)
r += tabulate.tabulate(enum_table,
headers=['Name', 'Value', 'Description'],
tablefmt="grid")
r += "\n\n"
return r
def returnRstTitle(self):
r = ''
r += "====================\n"
r += "Register description\n"
r += "====================\n\n"
return r
def returnRstSubTitle(self):
r = ''
r += "Registers\n"
r += "
return r
def returnRstRegDesc(self, name, address, size, resetValue, desc, access):
r = ""
r += name + "\n"
r += len(name) * '-' + "\n"
r += "\n"
r += ":Name: " + str(name) + "\n"
r += ":Address: " + hex(address) + "\n"
if resetValue:
# display the resetvalue in hex notation in the full length of the register
r += ":Reset Value: {value:#0{size:d}x}\n".format(value=int(resetValue, 0), size=size // 4 + 2)
r += ":Access: " + access + "\n"
r += ":Description: " + desc + "\n"
r += "\n"
return r
class mdAddressBlock(addressBlockClass):
"""Generates a Markdown file from a IP-XACT register description"""
def __init__(self, name, addrWidth, dataWidth):
self.name = name
self.addrWidth = addrWidth
self.dataWidth = dataWidth
self.registerList = []
self.suffix = ".md"
self.mdFile = MdUtils(file_name="none",
title="")
def <API key>(self, enumTypeObj):
if isinstance(enumTypeObj, enumTypeClass):
l = []
for i in range(len(enumTypeObj.keyList)):
l.append(enumTypeObj.keyList[i] + '=' + enumTypeObj.valueList[i])
s = ", ".join(l)
else:
s = ''
return s
def returnAsString(self):
regNameList = [reg.name for reg in self.registerList]
regAddressList = [reg.address for reg in self.registerList]
regDescrList = [reg.desc for reg in self.registerList]
self.mdFile.new_header(level=1, title="Register description")
self.mdFile.new_header(level=2, title="Registers")
# summary
header = ['Address', 'Register Name', 'Description']
rows = []
for i in range(len(regNameList)):
rows.extend(["{:#04x}".format(regAddressList[i]),
f"[{regNameList[i]}](#{regNameList[i]})",
str(regDescrList[i])])
self.mdFile.new_table(columns=len(header),
rows=len(regNameList) + 1, # header + data
text=header + rows,
text_align='left')
# all registers
for reg in self.registerList:
headers = ['Bits', 'Field name']
if reg.resetValue:
headers.append('Reset')
headers.append('Description')
self.returnMdRegDesc(reg.name, reg.address, reg.size, reg.resetValue, reg.desc, reg.access)
reg_table = []
for fieldIndex in reversed(list(range(len(reg.fieldNameList)))):
bits = "[" + str(reg.bitOffsetList[fieldIndex] + reg.bitWidthList[fieldIndex] - 1) + \
":" + str(reg.bitOffsetList[fieldIndex]) + "]"
reg_table.append(bits)
reg_table.append(reg.fieldNameList[fieldIndex])
if reg.resetValue:
temp = (int(reg.resetValue, 0) >> reg.bitOffsetList[fieldIndex])
mask = (2 ** reg.bitWidthList[fieldIndex]) - 1
temp &= mask
temp = "{value:#0{width}x}".format(value=temp,
width=math.ceil(reg.bitWidthList[fieldIndex] / 4) + 2)
reg_table.append(temp)
reg_table.append(reg.fieldDescList[fieldIndex])
self.mdFile.new_table(columns=len(headers),
rows=len(reg.fieldNameList) + 1,
text=headers + reg_table,
text_align='left')
# enumerations
for enum in reg.enumTypeList:
if enum:
self.mdFile.new_header(level=4,
title=enum.name)
enum_table = []
for i in range(len(enum.keyList)):
_value = "{value:#0{width}x}".format(value=int(enum.valueList[i], 0),
width=math.ceil(int(enum.bitWidth, 0) / 4) + 2)
enum_table.append(enum.keyList[i])
enum_table.append(_value)
enum_table.append(enum.descrList[i])
headers = ['Name', 'Value', 'Description']
self.mdFile.new_table(columns=len(headers),
rows=len(enum.keyList) + 1,
text=headers + enum_table,
text_align='left')
return self.mdFile.file_data_text
def returnMdRegDesc(self, name, address, size, resetValue, desc, access):
self.mdFile.new_header(level=3, title=name)
self.mdFile.new_line("**Name** " + str(name))
self.mdFile.new_line("**Address** " + hex(address))
if resetValue:
# display the resetvalue in hex notation in the full length of the register
self.mdFile.new_line(
"**Reset Value** {value:#0{size:d}x}".format(value=int(resetValue, 0), size=size // 4 + 2))
self.mdFile.new_line("**Access** " + access)
self.mdFile.new_line("**Description** " + desc)
class vhdlAddressBlock(addressBlockClass):
"""Generates a vhdl file from a IP-XACT register description"""
def __init__(self, name, addrWidth, dataWidth):
self.name = name
self.addrWidth = addrWidth
self.dataWidth = dataWidth
self.registerList = []
self.suffix = "_vhd_pkg.vhd"
def returnAsString(self):
r = ''
r += self.<API key>()
r += "\n\n"
r += self.returnPkgBodyString()
return r
def <API key>(self):
r = ''
r += "
r += "-- Automatically generated\n"
r += "-- with the command '%s'\n" % (' '.join(sys.argv))
r += "
r += "-- Do not manually edit!\n"
r += "
r += "-- VHDL 93\n"
r += "
r += "\n"
r += "library ieee;\n"
r += "use ieee.std_logic_1164.all;\n"
r += "use ieee.numeric_std.all;\n"
r += "\n"
r += "package " + self.name + "_vhd_pkg is\n"
r += "\n"
r += " constant addr_width : natural := " + str(self.addrWidth) + ";\n"
r += " constant data_width : natural := " + str(self.dataWidth) + ";\n"
r += "\n\n"
r += self.<API key>(True)
for reg in self.registerList:
r += " constant {name}_addr : natural := {address} ; -- {address:#0{width}x}\n".format(name=reg.name,
address=reg.address,
width=math.ceil(
self.addrWidth / 4) + 2) # +2 for the '0x'
r += "\n"
for reg in self.registerList:
if reg.resetValue:
r += " constant {name}_reset_value : std_ulogic_vector(data_width-1 downto 0) := std_ulogic_vector(to_unsigned({value:d}, data_width)); -- {value:#0{width}x}\n".format(
name=reg.name,
value=int(reg.resetValue, 0),
width=math.ceil((self.dataWidth / 4)) + 2)
r += "\n\n"
for reg in self.registerList:
r += self.<API key>(reg)
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += "end;\n"
return r
def <API key>(self, prototype):
r = ''
for reg in self.registerList:
for enum in reg.enumTypeList:
if isinstance(enum, enumTypeClass) and not enum.allReadyExist:
r += " -- {}\n".format(enum.name) # group the enums in the package
if prototype:
t = " type " + enum.name + "_enum is ("
indent = t.find('(') + 1
r += t
for ki in range(len(enum.keyList)):
if ki != 0: # no indentation for the first element
r += " " * indent
r += enum.keyList[ki]
if ki != len(enum.keyList) - 1: # no ',' for the last element
r += ","
else: # last element
r += ");"
if enum.descrList[ki]:
r += " -- " + enum.descrList[ki]
if ki != len(enum.keyList) - 1: # no new line for the last element
r += "\n"
r += "\n"
r += " function " + enum.name + \
"_enum_to_sulv(v: " + enum.name + "_enum ) return std_ulogic_vector"
if prototype:
r += ";\n"
else:
r += " is\n"
r += " variable r : std_ulogic_vector(" + str(enum.bitWidth) + "-1 downto 0);\n"
r += " begin\n"
r += " case v is\n"
for i in range(len(enum.keyList)):
r += ' when {key} => r:="{value_int:0{bitwidth}b}"; -- {value}\n'.format(
key=enum.keyList[i],
value=enum.valueList[i],
value_int=int(enum.valueList[i]),
bitwidth=int(enum.bitWidth))
r += " end case;\n"
r += " return r;\n"
r += " end function;\n\n"
r += " function sulv_to_" + enum.name + \
"_enum(v: std_ulogic_vector(" + str(enum.bitWidth) + "-1 downto 0)) return " + \
enum.name + "_enum"
if prototype:
r += ";\n"
else:
r += " is\n"
r += " variable r : " + enum.name + "_enum;\n"
r += " begin\n"
r += " case v is\n"
for i in range(len(enum.keyList)):
r += ' when "{value_int:0{bitwidth}b}" => r:={key};\n'.format(key=enum.keyList[i],
value_int=int(
enum.valueList[
i]),
bitwidth=int(
enum.bitWidth))
r += ' when others => r:=' + enum.keyList[0] + '; -- error\n'
r += " end case;\n"
r += " return r;\n"
r += " end function;\n\n"
if prototype:
r += "\n"
if prototype:
r += "\n"
return r
def <API key>(self, reg):
r = ''
r += " type " + reg.name + "_record_type is record\n"
for i in reversed(list(range(len(reg.fieldNameList)))):
bits = "[" + str(reg.bitOffsetList[i] + reg.bitWidthList[i] - 1) + ":" + str(reg.bitOffsetList[i]) + "]"
bit = "[" + str(reg.bitOffsetList[i]) + "]"
if isinstance(reg.enumTypeList[i], enumTypeClass):
if not reg.enumTypeList[i].allReadyExist:
r += " " + reg.fieldNameList[i] + " : " + \
reg.enumTypeList[i].name + "_enum; -- " + bits + "\n"
else:
r += " " + reg.fieldNameList[i] + " : " + \
reg.enumTypeList[i].enumName + "_enum; -- " + bits + "\n"
else:
if reg.bitWidthList[i] == 1: # single bit
r += " " + reg.fieldNameList[i] + " : std_ulogic; -- " + bit + "\n"
else: # vector
r += " " + reg.fieldNameList[i] + " : std_ulogic_vector(" + str(reg.bitWidthList[i] - 1) + \
" downto 0); -- " + bits + "\n"
r += " end record;\n\n"
return r
def <API key>(self):
r = ""
r += " type " + self.name + "_in_record_type is record\n"
for reg in self.registerList:
if reg.access == "read-only":
r += " {name} : {name}_record_type; -- addr {addr:#0{width}x}\n".format(name=reg.name,
addr=reg.address,
width=math.ceil(
self.addrWidth / 4) + 2) # +2 for the '0x'
r += " end record;\n\n"
return r
def <API key>(self):
r = ""
r += " type " + self.name + "_out_record_type is record\n"
for reg in self.registerList:
if reg.access != "read-only":
r += " {name} : {name}_record_type; -- addr {addr:#0{width}x}\n".format(name=reg.name,
addr=reg.address,
width=math.ceil(
self.addrWidth / 4) + 2) # +2 for the '0x'
r += " end record;\n\n"
return r
def <API key>(self):
r = " function read_" + self.name + "(registers_i : " + self.name + "_in_record_type;\n"
indent = r.find('(') + 1
r += " " * indent + "registers_o : " + self.name + "_out_record_type;\n"
r += " " * indent + "address : std_ulogic_vector(addr_width-1 downto 0)\n"
r += " " * indent + ") return std_ulogic_vector;\n\n"
return r
def <API key>(self):
r = " function write_" + self.name + "(value : std_ulogic_vector(data_width-1 downto 0);\n"
indent = r.find('(') + 1
r += " " * indent + "address : std_ulogic_vector(addr_width-1 downto 0);\n"
r += " " * indent + "registers_o : " + self.name + "_out_record_type\n"
r += " " * indent + ") return " + self.name + "_out_record_type;\n\n"
return r
def <API key>(self):
r = " function reset_" + self.name + " return " + self.name + "_out_record_type;\n"
r += " function reset_" + self.name + "(address: std_ulogic_vector(addr_width-1 downto 0);\n"
indent = r.splitlines()[-1].find('(') + 1
r += " " * indent + "registers_o : " + self.name + "_out_record_type\n"
r += " " * indent + ") return " + self.name + "_out_record_type;\n\n"
return r
def <API key>(self, reg):
r = ""
r += " function " + reg.name + \
"<API key>(v : " + reg.name + "_record_type) return std_ulogic_vector is\n"
r += " variable r : std_ulogic_vector(data_width-1 downto 0);\n"
r += " begin\n"
r += " r := (others => '0');\n"
for i in reversed(list(range(len(reg.fieldNameList)))):
bits = str(reg.bitOffsetList[i] + reg.bitWidthList[i] - 1) + " downto " + str(reg.bitOffsetList[i])
bit = str(reg.bitOffsetList[i])
if isinstance(reg.enumTypeList[i], enumTypeClass):
if not reg.enumTypeList[i].allReadyExist:
r += " r(" + bits + ") := " + \
reg.enumTypeList[i].name + "_enum_to_sulv(v." + reg.fieldNameList[i] + ");\n"
else:
r += " r(" + bits + ") := " + \
reg.enumTypeList[i].enumName + "_enum_to_sulv(v." + reg.fieldNameList[i] + ");\n"
else:
if reg.bitWidthList[i] == 1: # single bit
r += " r(" + bit + ") := v." + reg.fieldNameList[i] + ";\n"
else: # vector
r += " r(" + bits + ") := v." + reg.fieldNameList[i] + ";\n"
r += " return r;\n"
r += " end function;\n\n"
return r
def <API key>(self, reg):
r = ""
r += " function sulv_to_" + reg.name + \
"_record_type(v : std_ulogic_vector) return " + reg.name + "_record_type is\n"
r += " variable r : " + reg.name + "_record_type;\n"
r += " begin\n"
for i in reversed(list(range(len(reg.fieldNameList)))):
bits = str(reg.bitOffsetList[i] + reg.bitWidthList[i] - 1) + " downto " + str(reg.bitOffsetList[i])
bit = str(reg.bitOffsetList[i])
if isinstance(reg.enumTypeList[i], enumTypeClass):
if not reg.enumTypeList[i].allReadyExist:
r += " r." + reg.fieldNameList[i] + " := sulv_to_" + \
reg.enumTypeList[i].name + "_enum(v(" + bits + "));\n"
else:
r += " r." + reg.fieldNameList[i] + " := sulv_to_" + \
reg.enumTypeList[i].enumName + "_enum(v(" + bits + "));\n"
else:
if reg.bitWidthList[i] == 1: # single bit
r += " r." + reg.fieldNameList[i] + " := v(" + bit + ");\n"
else:
r += " r." + reg.fieldNameList[i] + " := v(" + bits + ");\n"
r += " return r;\n"
r += " end function;\n\n"
return r
def <API key>(self):
r = ""
t = " function read_" + self.name + "(registers_i : " + self.name + "_in_record_type;\n"
indent = t.find('(') + 1
r += t
r += " " * indent + "registers_o : " + self.name + "_out_record_type;\n"
r += " " * indent + "address : std_ulogic_vector(addr_width-1 downto 0)\n"
r += " " * indent + ") return std_ulogic_vector is\n"
r += " variable r : std_ulogic_vector(data_width-1 downto 0);\n"
r += " begin\n"
r += " case to_integer(unsigned(address)) is\n"
for reg in self.registerList:
if reg.access == "read-only":
r += " when " + reg.name + "_addr => r:= " + reg.name + \
"<API key>(registers_i." + reg.name + ");\n"
else:
r += " when " + reg.name + "_addr => r:= " + reg.name + \
"<API key>(registers_o." + reg.name + ");\n"
r += " when others => r := (others => '0');\n"
r += " end case;\n"
r += " return r;\n"
r += " end function;\n\n"
return r
def <API key>(self):
r = ""
t = " function write_" + self.name + "(value : std_ulogic_vector(data_width-1 downto 0);\n"
r += t
indent = t.find('(') + 1
r += " " * indent + "address : std_ulogic_vector(addr_width-1 downto 0);\n"
r += " " * indent + "registers_o : " + self.name + "_out_record_type\n"
r += " " * indent + ") return " + self.name + "_out_record_type is\n"
r += " variable r : " + self.name + "_out_record_type;\n"
r += " begin\n"
r += " r := registers_o;\n"
r += " case to_integer(unsigned(address)) is\n"
for reg in self.registerList:
if reg.access != "read-only":
r += " when " + reg.name + "_addr => r." + reg.name + \
" := sulv_to_" + reg.name + "_record_type(value);\n"
r += " when others => null;\n"
r += " end case;\n"
r += " return r;\n"
r += " end function;\n\n"
return r
def <API key>(self):
r = ""
r += " function reset_" + self.name + " return " + self.name + "_out_record_type is\n"
r += " variable r : " + self.name + "_out_record_type;\n"
r += " begin\n"
for reg in self.registerList:
if reg.resetValue:
if reg.access != "read-only":
r += " r." + reg.name + " := sulv_to_" + \
reg.name + "_record_type(" + reg.name + "_reset_value);\n"
r += " return r;\n"
r += " end function;\n"
r += "\n"
r += " function reset_" + self.name + "(address: std_ulogic_vector(addr_width-1 downto 0);\n"
indent = r.splitlines()[-1].find('(') + 1
r += " " * indent + "registers_o : " + self.name + "_out_record_type\n"
r += " " * indent + ") return " + self.name + "_out_record_type is\n"
r += " variable r : " + self.name + "_out_record_type;\n"
r += " begin\n"
r += " r := registers_o;\n"
r += " case to_integer(unsigned(address)) is\n"
for reg in self.registerList:
if reg.resetValue:
if reg.access != "read-only":
r += " when " + reg.name + "_addr => r." + reg.name + \
" := sulv_to_" + reg.name + "_record_type(" + reg.name + "_reset_value);\n"
r += " when others => null;\n"
r += " end case;\n"
r += " return r;\n"
r += " end function;\n\n"
return r
def returnPkgBodyString(self):
r = ""
r += "package body " + self.name + "_vhd_pkg is\n\n"
r += self.<API key>(False)
for reg in self.registerList:
r += self.<API key>(reg)
r += self.<API key>(reg)
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += "end package body;\n"
return r
class <API key>(addressBlockClass):
def __init__(self, name, addrWidth, dataWidth):
self.name = name
self.addrWidth = addrWidth
self.dataWidth = dataWidth
self.registerList = []
self.suffix = "_sv_pkg.sv"
def returnIncludeString(self):
r = "\n"
r += "`define " + self.name + "_addr_width " + str(self.addrWidth) + "\n"
r += "`define " + self.name + "_data_width " + str(self.dataWidth) + "\n"
return r
def returnSizeString(self):
r = "\n"
r += "const int addr_width = " + str(self.addrWidth) + ";\n"
r += "const int data_width = " + str(self.dataWidth) + ";\n"
return r
def <API key>(self):
r = "\n"
for reg in self.registerList:
r += "const int " + reg.name + "_addr = " + str(reg.address) + ";\n"
r += "\n"
return r
def <API key>(self):
r = "\n"
r = "//synopsys translate_off\n"
r += "const int " + self.name + "_regAddresses [" + str(len(self.registerList)) + "] = '{"
l = []
for reg in self.registerList:
l.append("\n " + reg.name + "_addr")
r += ",".join(l)
r += "};\n"
r += "\n"
r += "const string " + self.name + "_regNames [" + str(len(self.registerList)) + "] = '{"
l = []
for reg in self.registerList:
l.append('\n "' + reg.name + '"')
r += ",".join(l)
r += "};\n"
r += "const reg " + self.name + "<API key> [" + str(len(self.registerList)) + "] = '{"
l = []
for reg in self.registerList:
if reg.resetValue:
l.append("\n 1'b0")
else:
l.append("\n 1'b1")
r += ",".join(l)
r += "};\n"
r += "\n"
r += "//synopsys translate_on\n\n"
return r
def enumeratedType(self, prepend, fieldName, valueNames, values):
r = "\n"
members = []
# dont want to create to simple names in the global names space.
# should preppend with name from ipxact file
for index in range(len(valueNames)):
name = valueNames[index]
value = values[index]
members.append(name + "=" + value)
r += "typedef enum { " + ",".join(members) + "} enum_" + fieldName + ";\n"
return r
def <API key>(self):
r = ""
for reg in self.registerList:
if reg.resetValue:
r += "const " + reg.name + "_struct_type " + reg.name + \
"_reset_value = " + str(int(reg.resetValue, 0)) + ";\n"
r += "\n"
return r
def returnStructString(self):
r = "\n"
for reg in self.registerList:
r += "\ntypedef struct packed {\n"
for i in reversed(list(range(len(reg.fieldNameList)))):
bits = "bits [" + str(reg.bitOffsetList[i] + reg.bitWidthList[i] - 1) + \
":" + str(reg.bitOffsetList[i]) + "]"
r += " bit [" + str(reg.bitWidthList[i] - 1) + ":0] " + \
str(reg.fieldNameList[i]) + ";//" + bits + "\n"
r += "} " + reg.name + "_struct_type;\n\n"
return r
def <API key>(self):
r = "typedef struct packed {\n"
for reg in self.registerList:
r += " " + reg.name + "_struct_type " + reg.name + ";\n"
r += "} " + self.name + "_struct_type;\n\n"
return r
def <API key>(self):
r = "function bit [31:0] read_" + self.name + "(" + self.name + "_struct_type registers,int address);\n"
r += " bit [31:0] r;\n"
r += " case(address)\n"
for reg in self.registerList:
r += " " + reg.name + "_addr: r[$bits(registers." + reg.name + ")-1:0] = registers." + reg.name + ";\n"
r += " default: r =0;\n"
r += " endcase\n"
r += " return r;\n"
r += "endfunction\n\n"
return r
def <API key>(self):
t = "function " + self.name + "_struct_type write_" + self.name + "(bit [31:0] data, int address,\n"
r = t
indent = r.find('(') + 1
r += " " * indent + self.name + "_struct_type registers);\n"
r += " " + self.name + "_struct_type r;\n"
r += " r = registers;\n"
r += " case(address)\n"
for reg in self.registerList:
r += " " + reg.name + "_addr: r." + reg.name + " = data[$bits(registers." + reg.name + ")-1:0];\n"
r += " endcase // case address\n"
r += " return r;\n"
r += "endfunction\n\n"
return r
def <API key>(self):
r = "function " + self.name + "_struct_type reset_" + self.name + "();\n"
r += " " + self.name + "_struct_type r;\n"
for reg in self.registerList:
if reg.resetValue:
r += " r." + reg.name + "=" + reg.name + "_reset_value;\n"
r += " return r;\n"
r += "endfunction\n"
r += "\n"
return r
def returnAsString(self):
r = ''
r += "// Automatically generated\n"
r += "// with the command '%s'\n" % (' '.join(sys.argv))
r += "
r += "// Do not manually edit!\n"
r += "
r += "package " + self.name + "_sv_pkg;\n\n"
r += self.returnSizeString()
r += self.<API key>()
r += self.<API key>()
r += self.returnStructString()
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += self.<API key>()
r += "endpackage //" + self.name + "_sv_pkg\n"
return r
class ipxactParser():
def __init__(self, srcFile, config):
self.srcFile = srcFile
self.config = config
self.<API key> = <API key>()
def returnDocument(self):
spirit_ns = 'http:
tree = ETree.parse(self.srcFile)
ETree.register_namespace('spirit', spirit_ns)
namespace = tree.getroot().tag[1:].split("}")[0]
spiritString = '{' + spirit_ns + '}'
docName = tree.find(spiritString + "name").text
d = documentClass(docName)
memoryMaps = tree.find(spiritString + "memoryMaps")
memoryMapList = memoryMaps.findall(spiritString + "memoryMap") if memoryMaps is not None else []
for memoryMap in memoryMapList:
memoryMapName = memoryMap.find(spiritString + "name").text
addressBlockList = memoryMap.findall(spiritString + "addressBlock")
m = memoryMapClass(memoryMapName)
for addressBlock in addressBlockList:
addressBlockName = addressBlock.find(spiritString + "name").text
registerList = addressBlock.findall(spiritString + "register")
baseAddress = int(addressBlock.find(spiritString + "baseAddress").text, 0)
nbrOfAddresses = int(addressBlock.find(spiritString + "range").text, 0) # TODO, this is wrong
addrWidth = int(math.ceil((math.log(baseAddress + nbrOfAddresses, 2))))
dataWidth = int(addressBlock.find(spiritString + "width").text, 0)
a = addressBlockClass(addressBlockName, addrWidth, dataWidth)
for registerElem in registerList:
regName = registerElem.find(spiritString + "name").text
reset = registerElem.find(spiritString + "reset")
if reset is not None:
resetValue = reset.find(spiritString + "value").text
else:
resetValue = None
size = int(registerElem.find(spiritString + "size").text, 0)
access = registerElem.find(spiritString + "access").text
if registerElem.find(spiritString + "description") != None:
desc = registerElem.find(spiritString + "description").text
else:
desc = ""
regAddress = baseAddress + int(registerElem.find(spiritString + "addressOffset").text, 0)
r = self.returnRegister(spiritString, registerElem, regAddress,
resetValue, size, access, desc, dataWidth)
a.addRegister(r)
m.addAddressBlock(a)
d.addMemoryMap(m)
return d
def returnRegister(self, spiritString, registerElem, regAddress, resetValue, size, access, regDesc, dataWidth):
regName = registerElem.find(spiritString + "name").text
fieldList = registerElem.findall(spiritString + "field")
fieldNameList = [item.find(spiritString + "name").text for item in fieldList]
bitOffsetList = [item.find(spiritString + "bitOffset").text for item in fieldList]
bitWidthList = [item.find(spiritString + "bitWidth").text for item in fieldList]
fieldDescList = [item.find(spiritString + "description").text for item in fieldList]
enumTypeList = []
for index in range(len(fieldList)):
fieldElem = fieldList[index]
bitWidth = bitWidthList[index]
fieldName = fieldNameList[index]
<API key> = fieldElem.find(spiritString + "enumeratedValues")
if <API key> is not None:
enumeratedValueList = <API key>.findall(spiritString + "enumeratedValue")
valuesNameList = [item.find(spiritString + "name").text for item in enumeratedValueList]
descrList = [item.find(spiritString + "description").text if item.find(
spiritString + "description") is not None else "" for item in enumeratedValueList]
valuesList = [item.find(spiritString + "value").text for item in enumeratedValueList]
if len(valuesNameList) > 0:
if int(bitWidth) > 1: # if the field of a enum is longer than 1 bit, always use enums
enum = enumTypeClass(fieldName, bitWidth, valuesNameList, valuesList, descrList)
enum = self.<API key>.enumAllReadyExist(enum)
enumTypeList.append(enum)
else: # bit field of 1 bit
if self.config['global'].getboolean('onebitenum'): # do create one bit enums
enum = enumTypeClass(fieldName, bitWidth, valuesNameList, valuesList, descrList)
enum = self.<API key>.enumAllReadyExist(enum)
enumTypeList.append(enum)
else: # dont create enums of booleans because this only decreases readability
enumTypeList.append(None)
else:
enumTypeList.append(None)
else:
enumTypeList.append(None)
if len(fieldNameList) == 0:
fieldNameList.append(regName)
bitOffsetList.append(0)
bitWidthList.append(dataWidth)
fieldDescList.append('')
enumTypeList.append(None)
(regName, fieldNameList, bitOffsetList, bitWidthList, fieldDescList, enumTypeList) = <API key>(
regName, fieldNameList, bitOffsetList, bitWidthList, fieldDescList, enumTypeList,
self.config['global'].getboolean('unusedholes'))
reg = registerClass(regName, regAddress, resetValue, size, access, regDesc, fieldNameList,
bitOffsetList, bitWidthList, fieldDescList, enumTypeList)
return reg
class <API key>():
def __init__(self, destDir, namingScheme="addressBlockName"):
self.destDir = destDir
self.namingScheme = namingScheme
def write(self, fileName, string):
_dest = os.path.join(self.destDir, fileName)
print("writing file " + _dest)
if not os.path.exists(os.path.dirname(_dest)):
os.makedirs(os.path.dirname(_dest))
with open(_dest, "w") as f:
f.write(string)
def generate(self, generatorClass, document):
self.document = document
docName = document.name
for memoryMap in document.memoryMapList:
mapName = memoryMap.name
for addressBlock in memoryMap.addressBlockList:
blockName = addressBlock.name
block = generatorClass(addressBlock.name,
addressBlock.addrWidth,
addressBlock.dataWidth)
block.setRegisterList(addressBlock.registerList)
s = block.returnAsString()
if self.namingScheme == "addressBlockName":
fileName = blockName + block.suffix
else:
fileName = docName + '_' + mapName + '_' + blockName + block.suffix
self.write(fileName, s)
if generatorClass == <API key>:
includeFileName = fileName + "h"
includeString = block.returnIncludeString()
self.write(includeFileName, includeString)
|
#ifndef <API key>
#define <API key>
#include <KCModule>
#include <QVariantList>
#include "<API key>.h"
class <API key> : public KCModule
{
Q_OBJECT
private:
Ui::<API key> ui;
private slots:
void slotChanged();
public:
explicit <API key>(QWidget* parent, const QVariantList& args=QVariantList());
void save();
void load();
~<API key>();
};
#endif
|
package ome.server.itests.hibernate;
import java.util.Arrays;
import java.util.Set;
import ome.model.IAnnotated;
import ome.model.ILink;
import ome.model.IObject;
import ome.model.annotations.Annotation;
import ome.model.annotations.BasicAnnotation;
import ome.model.annotations.LongAnnotation;
import ome.model.containers.Dataset;
import ome.model.containers.DatasetImageLink;
import ome.model.containers.Project;
import ome.model.containers.ProjectDatasetLink;
import ome.model.core.Image;
import ome.model.core.Pixels;
import ome.model.display.RenderingDef;
import ome.model.meta.Experimenter;
import ome.server.itests.<API key>;
import ome.testing.ObjectFactory;
import ome.tools.hibernate.ExtendedMetadata;
import org.hibernate.SessionFactory;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class <API key> extends <API key> {
ExtendedMetadata.Impl metadata;
@BeforeClass
public void init() throws Exception {
setUp();
metadata = new ExtendedMetadata.Impl();
metadata.setSessionFactory((SessionFactory)applicationContext.getBean("sessionFactory"));
tearDown();
}
@Test
public void <API key>() throws Exception {
Set<Class<IAnnotated>> anns = metadata.getAnnotatableTypes();
assertTrue(anns.contains(Image.class));
assertTrue(anns.contains(Project.class));
// And several others
}
@Test
public void <API key>() throws Exception {
Set<Class<Annotation>> anns = metadata.getAnnotationTypes();
assertTrue(anns.toString(), anns.contains(Annotation.class));
assertTrue(anns.toString(), anns.contains(BasicAnnotation.class));
assertTrue(anns.toString(), anns.contains(LongAnnotation.class));
// And several others
}
/**
* Where a superclass has a relationship to a class (Annotation to some link type),
* it is also necessary to be able to find the same relationship from a subclass
* (e.g. FileAnnotation).
*/
@Test
public void <API key>() {
assertNotNull(
metadata.getRelationship("ImageAnnotationLink", "FileAnnotation"));
}
/**
* For simplicity, the relationship map currently holds only the short
* class names. Here we are adding a test which checks for the full ones
* under "broken" to remember to re-evaluate.
*/
@Test(groups = {"broken","fixme"})
public void <API key>() throws Exception {
Set<Class<IAnnotated>> anns = metadata.getAnnotatableTypes();
assertTrue(anns.contains(Image.class));
assertTrue(anns.contains(Project.class));
// And several others
}
// ~ Locking
@Test
public void <API key>() throws Exception {
Project p = new Project();
Dataset d = new Dataset();
p.linkDataset(d);
ILink l = (ILink) p.collectDatasetLinks(null).iterator().next();
assertDoesntContain(metadata.getLockCandidates(p), d);
assertContains(metadata.getLockCandidates(l), d);
}
@Test
// Because Pixels does not have a reference to RenderingDef
public void <API key>() throws Exception {
Pixels p = ObjectFactory.createPixelGraph(null);
RenderingDef r = ObjectFactory.createRenderingDef();
r.setPixels(p);
assertContains(metadata.getLockCandidates(r), p);
}
@Test(groups = "ticket:357")
// quirky because of defaultTag
public void <API key>() throws Exception {
Pixels p = ObjectFactory.createPixelGraph(null);
Image i = new Image();
i.setName("locking");
i.addPixels(p);
assertContains(metadata.getLockCandidates(p), i);
}
@Test
public void <API key>() throws Exception {
Experimenter e = new Experimenter();
Project p = new Project();
p.getDetails().setOwner(e);
assertDoesntContain(metadata.getLockCandidates(p), e);
}
@Test
public void testNoNulls() throws Exception {
Project p = new Project();
ProjectDatasetLink pdl = new ProjectDatasetLink();
pdl.link(p, null);
assertDoesntContain(metadata.getLockCandidates(pdl), null);
}
// ~ Unlocking
@Test
public void <API key>() throws Exception {
assertContains(metadata.getLockChecks(Project.class),
ProjectDatasetLink.class.getName(), "parent");
}
@Test
// Because Pixels does not have a reference to RenderingDef
public void <API key>() throws Exception {
assertContains(metadata.getLockChecks(Pixels.class), RenderingDef.class
.getName(), "pixels");
}
@Test(groups = "ticket:357")
// quirky because of defaultTag
public void <API key>() throws Exception {
assertContains(metadata.getLockChecks(Image.class), Pixels.class
.getName(), "image");
}
// ~ Updating
@Test(groups = { "ticket:346", "broken" })
public void <API key>() throws Exception {
assertContains(metadata.getImmutableFields(Image.class),
"details.creationEvent");
}
// ~ Counting
@Test(groups = { "ticket:657" })
public void <API key>() throws Exception {
assertEquals(metadata.getCountQuery(DatasetImageLink.CHILD), metadata
.getCountQuery(DatasetImageLink.CHILD),
"select target.child.id, count(target) "
+ "from ome.model.containers.DatasetImageLink target "
+ "group by target.child.id");
assertEquals(metadata.getCountQuery(Pixels.IMAGE), metadata
.getCountQuery(Pixels.IMAGE),
"select target.image.id, count(target) "
+ "from ome.model.core.Pixels target "
+ "group by target.image.id");
}
@Test(groups = { "ticket:657" })
public void testTargetTypes() throws Exception {
assertEquals(metadata.getTargetType(Pixels.IMAGE), Image.class);
assertEquals(metadata.getTargetType(DatasetImageLink.CHILD),
Image.class);
}
// ~ Relationships
@Test(groups = "ticket:2665")
public void testRelationships() {
String rel;
rel = metadata.getRelationship(Pixels.class.getSimpleName(), Image.class.getSimpleName());
assertEquals("image", rel);
rel = metadata.getRelationship(Image.class.getSimpleName(), Pixels.class.getSimpleName());
assertEquals("pixels", rel);
}
// ~ Helpers
private void assertContains(Object[] array, Object i) {
if (!contained(array, i)) {
fail(i + " not contained in " + Arrays.toString(array));
}
}
private void assertDoesntContain(IObject[] array, IObject i) {
if (contained(array, i)) {
fail(i + " contained in " + Arrays.toString(array));
}
}
private void assertContains(String[][] array, String t1, String t2) {
boolean contained = false;
for (int i = 0; i < array.length; i++) {
String[] test = array[i];
if (test[0].equals(t1) && test[1].equals(t2)) {
contained |= true;
}
}
assertTrue(contained);
}
private boolean contained(Object[] array, Object i) {
boolean contained = false;
for (Object object : array) {
if (i == null) {
if (object == null) {
contained = true;
}
} else {
if (i.equals(object)) {
contained = true;
}
}
}
return contained;
}
}
|
class CreateTeachers < ActiveRecord::Migration
def change
create_table :teachers do |t|
t.string :name, null: false
t.integer :grade
t.integer :college_id
t.integer :user_id
t.string :address
t.string :phone
t.string :email
t.timestamps null: false
end
end
end
|
<html>
<head>
<title>RunUO Documentation - Class Overview - OnItemConsumed</title>
</head>
<body bgcolor="white" style="font-family: Courier New" text="#000000" link="#000000" vlink="#000000" alink="#808080">
<h4><a href="../namespaces/Server.Items.html">Back to Server.Items</a></h4>
<h2>OnItemConsumed : MulticastDelegate, <!-- DBG-2.1 --><font color="blue">ICloneable</font>, <!-- DBG-2.1 --><font color="blue">ISerializable</font></h2>
(<font color="blue">ctor</font>) OnItemConsumed( <font color="blue">object</font> object, IntPtr method )<br>
<font color="blue">virtual</font> IAsyncResult BeginInvoke( <!-- DBG-0 --><a href="Item.html">Item</a> item, <font color="blue">int</font> amount, AsyncCallback callback, <font color="blue">object</font> object )<br>
<font color="blue">virtual</font> <font color="blue">void</font> EndInvoke( IAsyncResult result )<br>
<font color="blue">virtual</font> <font color="blue">void</font> Invoke( <!-- DBG-0 --><a href="Item.html">Item</a> item, <font color="blue">int</font> amount )<br>
</body>
</html>
|
describe('<API key>', function() {
var Mock = {};
var factory;
var whoAmI;
beforeEach(function() {
angular.mock.module('studio');
mockElement();
inject(function(_$injector_) {
mockWidgetScope(_$injector_);
factory = _$injector_.get('<API key>');
});
widget = factory.create(Mock.scope, Mock.element);
});
describe('Start a PastDate Factory Object', function() {
it('should return a PastDate Validator Object', function() {
pending();
});
it('should start the data field as date', function() {
expect(widget.data).toBeDefined();
expect(widget.data).toEqual(false);
});
});
describe('updates on data', function() {
xit('should model data value be equal to self value', function() {
// expect(Mock.question.fillingRules.options['pastDate'].data.reference).toEqual(widget.data);
});
it('should call updateFillingRules from parente widget', function() {
spyOn(Mock.parentWidget, 'updateFillingRules');
widget.updateData();
expect(Mock.parentWidget.updateFillingRules).toHaveBeenCalled();
});
});
function mockElement() {
Mock.element = {};
}
function mockWidgetScope($injector) {
Mock.scope = {
class: '',
$parent: {
widget: mockParentWidget($injector)
}
};
return Mock.scope;
}
function mockParentWidget($injector) {
mockQuestion($injector);
Mock.parentWidget = {
getItem: function() {
return Mock.question;
},
updateFillingRules: function() {}
};
return Mock.parentWidget;
}
function mockQuestion($injector) {
Mock.question = $injector.get('SurveyItemFactory').create('IntegerQuestion', 'Q1');
Mock.question.fillingRules.options.pastDate = $injector.get('RulesFactory').create('pastDate');
return Mock.question;
}
function mockAdd($injector) {
Mock.add = $injector.get('<API key>').create();
}
});
|
#include <linux/platform_device.h>
#include <plat/vrfb.h>
#include "omapfb.h"
#define TRUE 1
#define FALSE 0
static int progress_flag = FALSE;
static int progress_pos;
static struct timer_list progress_timer;
#define <API key> 54
#define <API key> 425
#define <API key> 576
#define PROGRESS_BAR_WIDTH 4
#define PROGRESS_BAR_HEIGHT 8
static unsigned char <API key>[] = {
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00
};
static unsigned char <API key>[] = {
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00
};
static unsigned char <API key>[] = {
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00,
0xf3, 0xc5, 0x00, 0x00, 0xf3, 0xc5, 0x00, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00
};
static unsigned char <API key>[] = {
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00,
0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00, 0x33, 0x33, 0x33, 0x00
};
static void <API key>(unsigned long data);
static int show_progress = 1;
module_param_named(progress, show_progress, bool, 0);
static void <API key>( \
struct fb_info *fb, int x, int y, void *buffer, \
int src_width, int src_height)
{
struct omapfb_info *ofbi = FB2OFB(fb);
struct omapfb2_device *fbdev = ofbi->fbdev;
struct fb_fix_screeninfo *fix = &fb->fix;
struct fb_var_screeninfo *var = &fb->var;
int row;
int bytes_per_pixel = (var->bits_per_pixel / 8);
unsigned char *pSrc = buffer;
unsigned char *pDst = fb->screen_base;
if (x+src_width > var->xres || y+src_height > var->yres) {
dev_err(fbdev->dev, "invalid destination coordinate or" \
" source size (%d, %d) (%d %d)\n", \
x, y, src_width, src_height);
return;
}
pDst += y * fix->line_length + x * bytes_per_pixel;
for (row = 0; row < src_height ; row++) {
memcpy(pDst, pSrc, src_width * bytes_per_pixel);
pSrc += src_width * bytes_per_pixel;
pDst += fix->line_length;
}
}
void <API key>(struct fb_info *fb)
{
int x_pos;
if (!show_progress)
return;
init_timer(&progress_timer);
progress_timer.expires = (get_jiffies_64() + (HZ/20));
progress_timer.data = (long)fb;
progress_timer.function = <API key>;
progress_pos = <API key>;
/* draw progress background. */
for (x_pos = <API key>; x_pos <= <API key>; \
x_pos += PROGRESS_BAR_WIDTH){
<API key>(fb,
x_pos,
<API key>,
(void *)<API key>,
PROGRESS_BAR_WIDTH,
PROGRESS_BAR_HEIGHT);
}
<API key>(fb,
<API key>,
<API key>,
(void *)<API key>,
PROGRESS_BAR_WIDTH,
PROGRESS_BAR_HEIGHT);
progress_pos += PROGRESS_BAR_WIDTH;
<API key>(fb,
progress_pos,
<API key>,
(void *)<API key>,
PROGRESS_BAR_WIDTH,
PROGRESS_BAR_HEIGHT);
add_timer(&progress_timer);
progress_flag = TRUE;
}
static void <API key>(void)
{
if (progress_flag == FALSE)
return;
del_timer(&progress_timer);
progress_flag = 0;
}
static void <API key>(unsigned long data)
{
int i;
for (i = 0; i < PROGRESS_BAR_WIDTH; i++) {
<API key>((struct fb_info *)data,
progress_pos++,
<API key>,
(void *)<API key>,
1,
PROGRESS_BAR_HEIGHT);
}
<API key>((struct fb_info *)data,
progress_pos,
<API key>,
(void *)<API key>,
PROGRESS_BAR_WIDTH,
PROGRESS_BAR_HEIGHT);
if (progress_pos + PROGRESS_BAR_WIDTH >= <API key> ) {
<API key>();
} else {
progress_timer.expires = (get_jiffies_64() + (HZ/20));
progress_timer.function = <API key>;
add_timer(&progress_timer);
}
}
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package bc;
import be.ReporteFumigacion;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
/**
*
* @author argos
*/
@Stateless
public class <API key> extends AbstractFacade<ReporteFumigacion> implements <API key> {
@PersistenceContext(unitName = "sistema-ejbPU")
private EntityManager em;
protected EntityManager getEntityManager() {
return em;
}
public <API key>() {
super(ReporteFumigacion.class);
}
}
|
#include "pbd/memento_command.h"
#include "evoral/Parameter.hpp"
#include "ardour/session.h"
namespace ARDOUR {
class MidiSource;
class AutomationList;
/** A class for late-binding a MidiSource and a Parameter to an AutomationList */
class <API key> : public <API key><ARDOUR::AutomationList>
{
public:
<API key> (boost::shared_ptr<ARDOUR::MidiSource>, Evoral::Parameter);
<API key> (XMLNode *, ARDOUR::Session::SourceMap const &);
ARDOUR::AutomationList* get () const;
void add_state (XMLNode *);
private:
boost::shared_ptr<ARDOUR::MidiSource> _source;
Evoral::Parameter _parameter;
};
}
|
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <telepathy-glib/<API key>.h>
#include <telepathy-glib/simple-handler.h>
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/util.h>
#include <libempathy/<API key>.h>
#include <libempathy/empathy-utils.h>
#include "<API key>.h"
#include "<API key>.h"
#define DEBUG_FLAG EMPATHY_DEBUG_VOIP
#include <libempathy/empathy-debug.h>
G_DEFINE_TYPE(<API key>, <API key>, G_TYPE_OBJECT)
static void handle_channels_cb (TpSimpleHandler *handler,
TpAccount *account,
TpConnection *connection,
GList *channels,
GList *requests_satisfied,
gint64 user_action_time,
<API key> *context,
gpointer user_data);
/* signal enum */
enum
{
<API key>,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = {0};
/* private structure */
typedef struct {
TpBaseClient *handler;
gboolean dispose_has_run;
} <API key>;
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, <API key>)
static GObject *call_factory = NULL;
static void
<API key> (<API key> *obj)
{
<API key> *priv = <API key> (obj,
<API key>, <API key>);
TpAccountManager *am;
obj->priv = priv;
am = <API key> ();
priv->handler = <API key> (am, FALSE, FALSE,
<API key>, FALSE, handle_channels_cb, obj, NULL);
<API key> (priv->handler, tp_asv_new (
<API key>, G_TYPE_STRING,
<API key>,
<API key>, G_TYPE_UINT, <API key>,
NULL));
<API key> (priv->handler, tp_asv_new (
<API key>, G_TYPE_STRING,
<API key>,
<API key>, G_TYPE_UINT, <API key>,
<API key>, G_TYPE_BOOLEAN, TRUE,
NULL));
<API key> (priv->handler, tp_asv_new (
<API key>, G_TYPE_STRING,
<API key>,
<API key>, G_TYPE_UINT, <API key>,
<API key>, G_TYPE_BOOLEAN, TRUE,
NULL));
<API key> (priv->handler,
"org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/ice-udp",
"org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/gtalk-p2p",
"org.freedesktop.Telepathy.Channel.Interface.MediaSignalling/video/h264",
NULL);
g_object_unref (am);
}
static GObject *
<API key> (GType type, guint n_construct_params,
<API key> *construct_params)
{
<API key> (call_factory == NULL, NULL);
call_factory = G_OBJECT_CLASS (<API key>)->constructor
(type, n_construct_params, construct_params);
<API key> (call_factory, (gpointer)&call_factory);
return call_factory;
}
static void
<API key> (GObject *object)
{
/* free any data held directly by the object here */
if (G_OBJECT_CLASS (<API key>)->finalize)
G_OBJECT_CLASS (<API key>)->finalize (object);
}
static void
<API key> (GObject *object)
{
<API key> *priv = GET_PRIV (object);
if (priv->dispose_has_run)
return;
priv->dispose_has_run = TRUE;
tp_clear_object (&priv->handler);
if (G_OBJECT_CLASS (<API key>)->dispose)
G_OBJECT_CLASS (<API key>)->dispose (object);
}
static void
<API key> (
<API key> *<API key>)
{
GObjectClass *object_class = G_OBJECT_CLASS (<API key>);
<API key> (<API key>,
sizeof (<API key>));
object_class->constructor = <API key>;
object_class->dispose = <API key>;
object_class->finalize = <API key>;
signals[<API key>] =
g_signal_new ("<API key>",
G_TYPE_FROM_CLASS (<API key>),
G_SIGNAL_RUN_LAST, 0,
NULL, NULL,
<API key>,
G_TYPE_NONE,
2, <API key>, G_TYPE_BOOLEAN);
}
<API key> *
<API key> (void)
{
<API key> (call_factory == NULL, NULL);
return <API key> (g_object_new (<API key>, NULL));
}
<API key> *
<API key> (void)
{
<API key> (call_factory != NULL, NULL);
return <API key> (call_factory);
}
static void
<API key> (<API key> *factory,
<API key> *call)
{
<API key> *handler;
g_return_if_fail (factory != NULL);
handler = <API key> (call);
g_signal_emit (factory, signals[<API key>], 0,
handler, FALSE);
g_object_unref (handler);
}
static void
<API key> (<API key> *call,
GParamSpec *spec,
<API key> *self)
{
if (<API key> (call) <= <API key>)
return;
<API key> (self, call);
<API key> (call, <API key>, self);
g_object_unref (call);
}
static void
handle_channels_cb (TpSimpleHandler *handler,
TpAccount *account,
TpConnection *connection,
GList *channels,
GList *requests_satisfied,
gint64 user_action_time,
<API key> *context,
gpointer user_data)
{
<API key> *self = user_data;
GList *l;
for (l = channels; l != NULL; l = g_list_next (l))
{
TpChannel *channel = l->data;
<API key> *call;
if (<API key> (channel) != NULL)
continue;
if (<API key> (channel) !=
<API key>)
continue;
call = <API key> (account, channel);
if (<API key> (call) <= <API key>)
{
/* We have to wait that the TpStreamedMedia is ready as the
* call-handler rely on it. */
<API key> (call, "notify::status",
G_CALLBACK (<API key>), self, 0);
continue;
}
<API key> (self, call);
g_object_unref (call);
}
<API key> (context);
}
gboolean
<API key> (<API key> *self,
GError **error)
{
<API key> *priv = GET_PRIV (self);
return <API key> (priv->handler, error);
}
|
require File.dirname(__FILE__) + '/../spec_helper'
describe PagesController do
describe 'handling GET for a single post' do
before(:each) do
@page = mock_model(Page)
Page.stub(:find_by_slug).and_return(@page)
end
def do_get
get :show, :id => 'a-page'
end
it "should be successful" do
do_get
response.should be_success
end
it "should render show template" do
do_get
response.should render_template('show')
end
it 'should find the page requested' do
Page.should_receive(:find_by_slug).with('a-page').and_return(@page)
do_get
end
it 'should assign the page found for the view' do
do_get
assigns[:page].should equal(@page)
end
end
describe 'handling GET with invalid page' do
it 'raises a RecordNotFound error' do
Page.stub(:find_by_slug).and_return(nil)
lambda {
get :show, :id => 'a-page'
}.should raise_error(ActiveRecord::RecordNotFound)
end
end
end
|
#ifndef <API key>
#define <API key>
#include "<API key>.hpp"
#include <assert.h>
class CylinderZone;
class <API key> : public <API key> {
const bool radius_editable;
public:
<API key>(CylinderZone &oz, bool _length_editable);
protected:
const CylinderZone &GetObject() const {
return (const CylinderZone &)<API key>::GetObject();
}
CylinderZone &GetObject() {
return (CylinderZone &)<API key>::GetObject();
}
public:
/* virtual methods from class Widget */
virtual void Prepare(ContainerWindow &parent,
const PixelRect &rc) override;
virtual bool Save(bool &changed) override;
};
#endif
|
<?php defined('_JEXEC') or die('Restricted access');
// SEF problem
$isThereQMR = false;
$isThereQMR = preg_match("/\?/i", $this->tmpl['action']);
if ($isThereQMR) {
$amp = '&';
} else {
$amp = '?';
}
if ((int)$this->tmpl['displayratingimg'] == 1) {
// Leave message for already voted images
$vote = JRequest::getVar('vote', 0, '', 'int');
if ($vote == 1) {
$voteMsg = JText::_('PHOCA GALLERY IMAGE RATED');
} else {
$voteMsg = JText::_('You have already rated this image');
}
?><table style="text-align:left" border="0"><tr><td><?php
echo '<strong>' . JText::_('Rating'). '</strong>: ' . $this->tmpl['votesaverageimg'] .' / '.$this->tmpl['votescountimg'] . ' ' . JText::_($this->tmpl['votestextimg']). ' ';
if ($this->tmpl['alreadyratedimg']) {
echo '<td style="text-align:left"><ul class="star-rating">'
.'<li class="current-rating" style="width:'.$this->tmpl['voteswidthimg'].'px"></li>'
.'<li><span class="star1"></span></li>';
for ($i = 2;$i < 6;$i++) {
echo '<li><span class="stars'.$i.'"></span></li>';
}
echo '</ul></td>'
.'<td style="text-align:left" colspan="4"> '.$voteMsg.'</td></tr>';
} else if ($this->tmpl['notregisteredimg']) {
echo '<td style="text-align:left"><ul class="star-rating">'
.'<li class="current-rating" style="width:'.$this->tmpl['voteswidthimg'].'px"></li>'
.'<li><span class="star1"></span></li>';
for ($i = 2;$i < 6;$i++) {
echo '<li><span class="stars'.$i.'"></span></li>';
}
echo '</ul></td>'
.'<td style="text-align:left" colspan="4"> '.JText::_('Only registered and logged in user can rate this image').'</td>';
} else {
echo '<td style="text-align:left"><ul class="star-rating">'
.'<li class="current-rating" style="width:'.$this->tmpl['voteswidthimg'].'px"></li>'
.'<li><a href="'.$this->tmpl['action'].$amp.'controller=detail&task=rate&rating=1" title="1 '. JText::_('star out of').' 5" class="star1">1</a></li>';
for ($i = 2;$i < 6;$i++) {
echo '<li><a href="'.$this->tmpl['action'].$amp.'controller=detail&task=rate&rating='.$i.'" title="'.$i.' '. JText::_('star out of').' 5" class="stars'.$i.'">'.$i.'</a></li>';
}
echo '</td>';
}
?></tr></table><?php
}
?>
|
#!/usr/bin/python
# encoding: utf-8
# filename: <API key>.py
# scriptLattes V8
# Livre(FSF) Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from scriptLattes import *
from geradorDePaginasWeb import *
import re
class <API key>:
item = None # dado bruto
idMembro = None
relevante = None
autores = None
titulo = None
ano = None
natureza = None # tipo de producao
chave = None
def __init__(self, idMembro, partesDoItem='', relevante=''):
self.idMembro = set([])
self.idMembro.add(idMembro)
if not partesDoItem=='':
# partesDoItem[0]: Numero (NAO USADO)
# partesDoItem[1]: Descricao do livro (DADO BRUTO)
self.relevante = relevante
self.item = partesDoItem[1]
# Dividir o item na suas partes constituintes
partes = self.item.partition(" . ")
self.autores = partes[0].strip()
partes = partes[2]
aux = re.findall(u' \((.*?)\)\.$', partes)
if len(aux)>0:
self.natureza = aux[-1]
partes = partes.rpartition(" (")
partes = partes[0]
else:
self.natureza = ''
aux = re.findall(u' ((?:19|20)\d\d)\\b', partes)
if len(aux)>0:
self.ano = aux[-1] #.strip().rstrip(".").rstrip(",")
partes = partes.rpartition(" ")
partes = partes[0]
else:
self.ano = ''
self.titulo = partes.strip().rstrip(".").rstrip(",")
self.chave = self.autores
else:
self.relevante = ''
self.autores = ''
self.titulo = ''
self.ano = ''
self.natureza = ''
def compararCom(self, objeto):
if self.idMembro.isdisjoint(objeto.idMembro) and compararCadeias(self.titulo, objeto.titulo):
self.idMembro.update(objeto.idMembro)
if len(self.autores)<len(objeto.autores):
self.autores = objeto.autores
if len(self.titulo)<len(objeto.titulo):
self.titulo = objeto.titulo
if len(self.natureza)<len(objeto.natureza):
self.natureza = objeto.natureza
return self
else: # nao similares
return None
def html(self, listaDeMembros):
s = self.autores + '. <b>' + self.titulo + '</b>. '
s+= str(self.ano) + '. ' if str(self.ano).isdigit() else '. '
s+= self.natureza if not self.natureza=='' else ''
s+= menuHTMLdeBuscaPB(self.titulo)
return s
def __str__(self):
s = "\n[OUTRO TIPO DE PRODUCAO BIBLIOGRAFICA] \n"
s += "+ID-MEMBRO : " + str(self.idMembro) + "\n"
s += "+RELEVANTE : " + str(self.relevante) + "\n"
s += "+AUTORES : " + self.autores.encode('utf8','replace') + "\n"
s += "+TITULO : " + self.titulo.encode('utf8','replace') + "\n"
s += "+ANO : " + str(self.ano) + "\n"
s += "+NATUREZA : " + self.natureza.encode('utf8','replace') + "\n"
s += "+item : " + self.item.encode('utf8','replace') + "\n"
return s
|
using System.IO;
using System.Text;
namespace CodeMask.WPF.Controls.Gif.Decoding
{
internal class GifCommentExtension : GifExtension
{
internal const int ExtensionLabel = 0xFE;
private GifCommentExtension()
{
}
public string Text { get; private set; }
internal override GifBlockKind Kind
{
get { return GifBlockKind.SpecialPurpose; }
}
internal static GifCommentExtension ReadComment(Stream stream)
{
var comment = new GifCommentExtension();
comment.Read(stream);
return comment;
}
private void Read(Stream stream)
{
// Note: at this point, the label (0xFE) has already been read
var bytes = GifHelpers.ReadDataBlocks(stream, false);
if (bytes != null)
Text = Encoding.ASCII.GetString(bytes);
}
}
}
|
#include "SleepTimer.h"
#include "InterruptHandler.h"
#include "cc2538_include.h"
SleepTimer::SleepTimer(uint32_t interrupt):
interrupt_(interrupt)
{
}
void SleepTimer::start(uint32_t counts)
{
uint32_t current;
// Get current counter
current = <API key>();
// Set future timeout
<API key>(current + counts);
}
void SleepTimer::stop(void)
{
// Nothing to do here, SleepTimer cannot be stopped
}
uint32_t SleepTimer::sleep(void)
{
return 0;
}
void SleepTimer::wakeup(uint32_t ticks)
{
}
uint32_t SleepTimer::getCounter(void)
{
// Get current counter
return <API key>();
}
bool SleepTimer::isExpired(uint32_t future)
{
uint32_t current;
int32_t delta;
// Get current counter
current = <API key>();
// Calculate delta
delta = (int32_t) (current - future);
// Return true if expired
return (delta < 0);
}
void SleepTimer::setCallback(Callback* callback)
{
callback_ = callback;
}
void SleepTimer::clearCallback(void)
{
callback_ = nullptr;
}
void SleepTimer::enableInterrupts(void)
{
InterruptHandler::getInstance().setInterruptHandler(this);
IntEnable(interrupt_);
}
void SleepTimer::disableInterrupts(void)
{
IntDisable(interrupt_);
InterruptHandler::getInstance().<API key>(this);
}
void SleepTimer::interruptHandler(void)
{
if (callback_ != nullptr)
{
callback_->execute();
}
}
|
<?php
// Initialisations files
require_once("../lib/initialisations.inc.php");
// Resume session
$resultat_session = $session_gepi->security_check();
if ($resultat_session == '0') {
header("Location: ../logout.php?auto=1");
die();
};
|
#include <igraph.h>
#include "test_utilities.inc"
int main() {
igraph_t g_empty, g_lm;
igraph_vector_t result;
igraph_vs_t vids;
igraph_rng_seed(igraph_rng_default(), 42);
igraph_vector_init(&result, 0);
igraph_vs_all(&vids);
igraph_small(&g_empty, 0, 0, -1);
igraph_small(&g_lm, 6, 1, 0,1, 0,2, 1,1, 1,3, 2,0, 2,3, 3,4, 3,4, -1);
printf("No vertices:\n");
IGRAPH_ASSERT(<API key>(&g_empty, &result, vids, /*order*/ 1,
/*mode*/ IGRAPH_ALL, /*mindist*/ 0) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 0:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 0,
/*mode*/ IGRAPH_ALL, /*mindist*/ 0) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 1, ignoring direction:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 1,
/*mode*/ IGRAPH_ALL, /*mindist*/ 0) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 1, only checking IGRAPH_IN:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 1,
/*mode*/ IGRAPH_IN, /*mindist*/ 0) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 10, ignoring direction:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 10,
/*mode*/ IGRAPH_ALL, /*mindist*/ 0) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 2, mindist 2, IGRAPH_OUT:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 2,
/*mode*/ IGRAPH_OUT, /*mindist*/ 2) == IGRAPH_SUCCESS);
print_vector(&result);
printf("Directed graph with loops and multi-edges, order 4, mindist 4, IGRAPH_ALL:\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 4,
/*mode*/ IGRAPH_ALL, /*mindist*/ 4) == IGRAPH_SUCCESS);
print_vector(&result);
<API key>();
<API key>(<API key>);
printf("Negative order.\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ -4,
/*mode*/ IGRAPH_ALL, /*mindist*/ 4) == IGRAPH_EINVAL);
printf("Negative mindist.\n");
IGRAPH_ASSERT(<API key>(&g_lm, &result, vids, /*order*/ 4,
/*mode*/ IGRAPH_ALL, /*mindist*/ -4) == IGRAPH_EINVAL);
<API key>(&result);
igraph_destroy(&g_empty);
igraph_destroy(&g_lm);
<API key>();
return 0;
}
|
#include <linux/mm.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/kernel_stat.h>
#include <linux/swap.h>
#include <linux/pagemap.h>
#include <linux/init.h>
#include <linux/highmem.h>
#include <linux/vmstat.h>
#include <linux/file.h>
#include <linux/writeback.h>
#include <linux/blkdev.h>
#include <linux/buffer_head.h> /* for try_to_release_page(),
<API key> */
#include <linux/mm_inline.h>
#include <linux/pagevec.h>
#include <linux/backing-dev.h>
#include <linux/rmap.h>
#include <linux/topology.h>
#include <linux/cpu.h>
#include <linux/cpuset.h>
#include <linux/notifier.h>
#include <linux/rwsem.h>
#include <linux/delay.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include <asm/tlbflush.h>
#include <asm/div64.h>
#include <linux/swapops.h>
#include "internal.h"
struct scan_control {
/* Incremented by the number of inactive pages that were scanned */
unsigned long nr_scanned;
/* This context's GFP mask */
gfp_t gfp_mask;
int may_writepage;
/* Can pages be swapped as part of reclaim? */
int may_swap;
/* This context's SWAP_CLUSTER_MAX. If freeing memory for
* suspend, we effectively ignore SWAP_CLUSTER_MAX.
* In this context, it doesn't matter that we scan the
* whole list at once. */
int swap_cluster_max;
int swappiness;
int all_unreclaimable;
};
/*
* The list of shrinker callbacks used by to apply pressure to
* ageable caches.
*/
struct shrinker {
shrinker_t shrinker;
struct list_head list;
int seeks; /* seeks to recreate an obj */
long nr; /* objs pending delete */
};
#define lru_to_page(_head) (list_entry((_head)->prev, struct page, lru))
#ifdef ARCH_HAS_PREFETCH
#define <API key>(_page, _base, _field) \
do { \
if ((_page)->lru.prev != _base) { \
struct page *prev; \
\
prev = lru_to_page(&(_page->lru)); \
prefetch(&prev->_field); \
} \
} while (0)
#else
#define <API key>(_page, _base, _field) do { } while (0)
#endif
#ifdef ARCH_HAS_PREFETCHW
#define <API key>(_page, _base, _field) \
do { \
if ((_page)->lru.prev != _base) { \
struct page *prev; \
\
prev = lru_to_page(&(_page->lru)); \
prefetchw(&prev->_field); \
} \
} while (0)
#else
#define <API key>(_page, _base, _field) do { } while (0)
#endif
/*
* From 0 .. 100. Higher means more swappy.
*/
int vm_swappiness = 60;
long vm_total_pages; /* The total number of pages which the VM controls */
static LIST_HEAD(shrinker_list);
static DECLARE_RWSEM(shrinker_rwsem);
/*
* Add a shrinker callback to be called from the vm
*/
struct shrinker *set_shrinker(int seeks, shrinker_t theshrinker)
{
struct shrinker *shrinker;
shrinker = kmalloc(sizeof(*shrinker), GFP_KERNEL);
if (shrinker) {
shrinker->shrinker = theshrinker;
shrinker->seeks = seeks;
shrinker->nr = 0;
down_write(&shrinker_rwsem);
list_add_tail(&shrinker->list, &shrinker_list);
up_write(&shrinker_rwsem);
}
return shrinker;
}
EXPORT_SYMBOL(set_shrinker);
/*
* Remove one
*/
void remove_shrinker(struct shrinker *shrinker)
{
down_write(&shrinker_rwsem);
list_del(&shrinker->list);
up_write(&shrinker_rwsem);
kfree(shrinker);
}
EXPORT_SYMBOL(remove_shrinker);
#define SHRINK_BATCH 128
/*
* Call the shrink functions to age shrinkable caches
*
* Here we assume it costs one seek to replace a lru page and that it also
* takes a seek to recreate a cache object. With this in mind we age equal
* percentages of the lru and ageable caches. This should balance the seeks
* generated by these structures.
*
* If the vm encounted mapped pages on the LRU it increase the pressure on
* slab to avoid swapping.
*
* We do weird things to avoid (scanned*seeks*entries) overflowing 32 bits.
*
* `lru_pages' represents the number of on-LRU pages in all the zones which
* are eligible for the caller's allocation attempt. It is used for balancing
* slab reclaim versus page reclaim.
*
* Returns the number of slab objects which we shrunk.
*/
unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
unsigned long lru_pages)
{
struct shrinker *shrinker;
unsigned long ret = 0;
if (scanned == 0)
scanned = SWAP_CLUSTER_MAX;
if (!down_read_trylock(&shrinker_rwsem))
return 1; /* Assume we'll be able to shrink next time */
list_for_each_entry(shrinker, &shrinker_list, list) {
unsigned long long delta;
unsigned long total_scan;
unsigned long max_pass = (*shrinker->shrinker)(0, gfp_mask);
delta = (4 * scanned) / shrinker->seeks;
delta *= max_pass;
do_div(delta, lru_pages + 1);
shrinker->nr += delta;
if (shrinker->nr < 0) {
printk(KERN_ERR "%s: nr=%ld\n",
__FUNCTION__, shrinker->nr);
shrinker->nr = max_pass;
}
/*
* Avoid risking looping forever due to too large nr value:
* never try to free more than twice the estimate number of
* freeable entries.
*/
if (shrinker->nr > max_pass * 2)
shrinker->nr = max_pass * 2;
total_scan = shrinker->nr;
shrinker->nr = 0;
while (total_scan >= SHRINK_BATCH) {
long this_scan = SHRINK_BATCH;
int shrink_ret;
int nr_before;
nr_before = (*shrinker->shrinker)(0, gfp_mask);
shrink_ret = (*shrinker->shrinker)(this_scan, gfp_mask);
if (shrink_ret == -1)
break;
if (shrink_ret < nr_before)
ret += nr_before - shrink_ret;
count_vm_events(SLABS_SCANNED, this_scan);
total_scan -= this_scan;
cond_resched();
}
shrinker->nr += total_scan;
}
up_read(&shrinker_rwsem);
return ret;
}
/* Called without lock on whether page is mapped, so answer is unstable */
static inline int page_mapping_inuse(struct page *page)
{
struct address_space *mapping;
/* Page is in somebody's page tables. */
if (page_mapped(page))
return 1;
/* Be more reluctant to reclaim swapcache than pagecache */
if (PageSwapCache(page))
return 1;
mapping = page_mapping(page);
if (!mapping)
return 0;
/* File is mmap'd by somebody? */
return mapping_mapped(mapping);
}
static inline int <API key>(struct page *page)
{
return page_count(page) - !!PagePrivate(page) == 2;
}
static int may_write_to_queue(struct backing_dev_info *bdi)
{
if (current->flags & PF_SWAPWRITE)
return 1;
if (!bdi_write_congested(bdi))
return 1;
if (bdi == current->backing_dev_info)
return 1;
return 0;
}
/*
* We detected a synchronous write error writing a page out. Probably
* -ENOSPC. We need to propagate that into the address_space for a subsequent
* fsync(), msync() or close().
*
* The tricky part is that after writepage we cannot touch the mapping: nothing
* prevents it from being freed up. But we have a ref on the page and once
* that page is locked, the mapping is pinned.
*
* We're allowed to run sleeping lock_page() here because we know the caller has
* __GFP_FS.
*/
static void handle_write_error(struct address_space *mapping,
struct page *page, int error)
{
lock_page(page);
if (page_mapping(page) == mapping) {
if (error == -ENOSPC)
set_bit(AS_ENOSPC, &mapping->flags);
else
set_bit(AS_EIO, &mapping->flags);
}
unlock_page(page);
}
/* possible outcome of pageout() */
typedef enum {
/* failed to write page out, page is locked */
PAGE_KEEP,
/* move page to the active list, page is locked */
PAGE_ACTIVATE,
/* page has been sent to the disk successfully, page is unlocked */
PAGE_SUCCESS,
/* page is clean and locked */
PAGE_CLEAN,
} pageout_t;
/*
* pageout is called by shrink_page_list() for each dirty page.
* Calls ->writepage().
*/
static pageout_t pageout(struct page *page, struct address_space *mapping)
{
/*
* If the page is dirty, only perform writeback if that write
* will be non-blocking. To prevent this allocation from being
* stalled by pagecache activity. But note that there may be
* stalls if we need to run get_block(). We could test
* PagePrivate for that.
*
* If this process is currently in generic_file_write() against
* this page's queue, we can perform writeback even if that
* will block.
*
* If the page is swapcache, write it back even if that would
* block, for some throttling. This happens by accident, because
* <API key> is bust: it doesn't reflect the
* congestion state of the swapdevs. Easy to fix, if needed.
* See swapfile.c:<API key>().
*/
if (!<API key>(page))
return PAGE_KEEP;
if (!mapping) {
/*
* Some data journaling orphaned pages can have
* page->mapping == NULL while being dirty with clean buffers.
*/
if (PagePrivate(page)) {
if (try_to_free_buffers(page)) {
ClearPageDirty(page);
printk("%s: orphaned page\n", __FUNCTION__);
return PAGE_CLEAN;
}
}
return PAGE_KEEP;
}
if (mapping->a_ops->writepage == NULL)
return PAGE_ACTIVATE;
if (!may_write_to_queue(mapping->backing_dev_info))
return PAGE_KEEP;
if (<API key>(page)) {
int res;
struct writeback_control wbc = {
.sync_mode = WB_SYNC_NONE,
.nr_to_write = SWAP_CLUSTER_MAX,
.range_start = 0,
.range_end = LLONG_MAX,
.nonblocking = 1,
.for_reclaim = 1,
};
SetPageReclaim(page);
res = mapping->a_ops->writepage(page, &wbc);
if (res < 0)
handle_write_error(mapping, page, res);
if (res == <API key>) {
ClearPageReclaim(page);
return PAGE_ACTIVATE;
}
if (!PageWriteback(page)) {
/* synchronous write or broken a_ops? */
ClearPageReclaim(page);
}
inc_zone_page_state(page, NR_VMSCAN_WRITE);
return PAGE_SUCCESS;
}
return PAGE_CLEAN;
}
/*
* Attempt to detach a locked page from its ->mapping. If it is dirty or if
* someone else has a ref on the page, abort and return 0. If it was
* successfully detached, return 1. Assumes the caller has a single ref on
* this page.
*/
int remove_mapping(struct address_space *mapping, struct page *page)
{
BUG_ON(!PageLocked(page));
BUG_ON(mapping != page_mapping(page));
write_lock_irq(&mapping->tree_lock);
/*
* The non racy check for a busy page.
*
* Must be careful with the order of the tests. When someone has
* a ref to the page, it may be possible that they dirty it then
* drop the reference. So if PageDirty is tested before page_count
* here, then the following race may occur:
*
* get_user_pages(&page);
* [user mapping goes away]
* write_to(page);
* !PageDirty(page) [good]
* SetPageDirty(page);
* put_page(page);
* !page_count(page) [good, discard it]
*
* [oops, our write_to data is lost]
*
* Reversing the order of the tests ensures such a situation cannot
* escape unnoticed. The smp_rmb is needed to ensure the page->flags
* load is not satisfied before that of page->_count.
*
* Note that if SetPageDirty is always performed via set_page_dirty,
* and thus under tree_lock, then this ordering is not required.
*/
if (unlikely(page_count(page) != 2))
goto cannot_free;
smp_rmb();
if (unlikely(PageDirty(page)))
goto cannot_free;
if (PageSwapCache(page)) {
swp_entry_t swap = { .val = page_private(page) };
<API key>(page);
write_unlock_irq(&mapping->tree_lock);
swap_free(swap);
__put_page(page); /* The pagecache ref */
return 1;
}
<API key>(page);
write_unlock_irq(&mapping->tree_lock);
__put_page(page);
return 1;
cannot_free:
write_unlock_irq(&mapping->tree_lock);
return 0;
}
/*
* shrink_page_list() returns the number of reclaimed pages
*/
static unsigned long shrink_page_list(struct list_head *page_list,
struct scan_control *sc)
{
LIST_HEAD(ret_pages);
struct pagevec freed_pvec;
int pgactivate = 0;
unsigned long nr_reclaimed = 0;
cond_resched();
pagevec_init(&freed_pvec, 1);
while (!list_empty(page_list)) {
struct address_space *mapping;
struct page *page;
int may_enter_fs;
int referenced;
cond_resched();
page = lru_to_page(page_list);
list_del(&page->lru);
if (TestSetPageLocked(page))
goto keep;
VM_BUG_ON(PageActive(page));
sc->nr_scanned++;
if (!sc->may_swap && page_mapped(page))
goto keep_locked;
/* Double the slab pressure for mapped and swapcache pages */
if (page_mapped(page) || PageSwapCache(page))
sc->nr_scanned++;
if (PageWriteback(page))
goto keep_locked;
referenced = page_referenced(page, 1);
/* In active use or really unfreeable? Activate it. */
if (referenced && page_mapping_inuse(page))
goto activate_locked;
#ifdef CONFIG_SWAP
/*
* Anonymous process memory has backing store?
* Try to allocate it some swap space here.
*/
if (PageAnon(page) && !PageSwapCache(page))
if (!add_to_swap(page, GFP_ATOMIC))
goto activate_locked;
#endif /* CONFIG_SWAP */
mapping = page_mapping(page);
may_enter_fs = (sc->gfp_mask & __GFP_FS) ||
(PageSwapCache(page) && (sc->gfp_mask & __GFP_IO));
/*
* The page is mapped into the page tables of one or more
* processes. Try to unmap it here.
*/
if (page_mapped(page) && mapping) {
switch (try_to_unmap(page, 0)) {
case SWAP_FAIL:
goto activate_locked;
case SWAP_AGAIN:
goto keep_locked;
case SWAP_SUCCESS:
; /* try to free the page below */
}
}
if (PageDirty(page)) {
if (referenced)
goto keep_locked;
if (!may_enter_fs)
goto keep_locked;
if (!sc->may_writepage)
goto keep_locked;
/* Page is dirty, try to write it out here */
switch(pageout(page, mapping)) {
case PAGE_KEEP:
goto keep_locked;
case PAGE_ACTIVATE:
goto activate_locked;
case PAGE_SUCCESS:
if (PageWriteback(page) || PageDirty(page))
goto keep;
/*
* A synchronous write - probably a ramdisk. Go
* ahead and try to reclaim the page.
*/
if (TestSetPageLocked(page))
goto keep;
if (PageDirty(page) || PageWriteback(page))
goto keep_locked;
mapping = page_mapping(page);
case PAGE_CLEAN:
; /* try to free the page below */
}
}
/*
* If the page has buffers, try to free the buffer mappings
* associated with this page. If we succeed we try to free
* the page as well.
*
* We do this even if the page is PageDirty().
* try_to_release_page() does not perform I/O, but it is
* possible for a page to have PageDirty set, but it is actually
* clean (all its buffers are clean). This happens if the
* buffers were written out directly, with submit_bh(). ext3
* will do this, as well as the blockdev mapping.
* try_to_release_page() will discover that cleanness and will
* drop the buffers and mark the page clean - it can be freed.
*
* Rarely, pages can have buffers and no ->mapping. These are
* the pages which were not successfully invalidated in
* <API key>(). We try to drop those buffers here
* and if that worked, and the page is no longer mapped into
* process address space (page_count == 1) it can be freed.
* Otherwise, leave the page on the LRU so it is swappable.
*/
if (PagePrivate(page)) {
if (!try_to_release_page(page, sc->gfp_mask))
goto activate_locked;
if (!mapping && page_count(page) == 1)
goto free_it;
}
if (!mapping || !remove_mapping(mapping, page))
goto keep_locked;
free_it:
unlock_page(page);
nr_reclaimed++;
if (!pagevec_add(&freed_pvec, page))
<API key>(&freed_pvec);
continue;
activate_locked:
SetPageActive(page);
pgactivate++;
keep_locked:
unlock_page(page);
keep:
list_add(&page->lru, &ret_pages);
VM_BUG_ON(PageLRU(page));
}
list_splice(&ret_pages, page_list);
if (pagevec_count(&freed_pvec))
<API key>(&freed_pvec);
count_vm_events(PGACTIVATE, pgactivate);
return nr_reclaimed;
}
/*
* zone->lru_lock is heavily contended. Some of the functions that
* shrink the lists perform better by taking out a batch of pages
* and working on them outside the LRU lock.
*
* For pagecache intensive workloads, this function is the hottest
* spot in the kernel (apart from copy_*_user functions).
*
* Appropriate locks must be held before calling this function.
*
* @nr_to_scan: The number of pages to look through on the list.
* @src: The LRU list to pull pages off.
* @dst: The temp list to put pages on to.
* @scanned: The number of pages that were scanned.
*
* returns how many pages were moved onto *@dst.
*/
static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
struct list_head *src, struct list_head *dst,
unsigned long *scanned)
{
unsigned long nr_taken = 0;
struct page *page;
unsigned long scan;
for (scan = 0; scan < nr_to_scan && !list_empty(src); scan++) {
struct list_head *target;
page = lru_to_page(src);
<API key>(page, src, flags);
VM_BUG_ON(!PageLRU(page));
list_del(&page->lru);
target = src;
if (likely(<API key>(page))) {
/*
* Be careful not to clear PageLRU until after we're
* sure the page is not being freed elsewhere -- the
* page release code relies on it.
*/
ClearPageLRU(page);
target = dst;
nr_taken++;
} /* else it is being freed elsewhere */
list_add(&page->lru, target);
}
*scanned = scan;
return nr_taken;
}
/*
* <API key>() is a helper for shrink_zone(). It returns the number
* of reclaimed pages
*/
static unsigned long <API key>(unsigned long max_scan,
struct zone *zone, struct scan_control *sc)
{
LIST_HEAD(page_list);
struct pagevec pvec;
unsigned long nr_scanned = 0;
unsigned long nr_reclaimed = 0;
pagevec_init(&pvec, 1);
lru_add_drain();
spin_lock_irq(&zone->lru_lock);
do {
struct page *page;
unsigned long nr_taken;
unsigned long nr_scan;
unsigned long nr_freed;
nr_taken = isolate_lru_pages(sc->swap_cluster_max,
&zone->inactive_list,
&page_list, &nr_scan);
<API key>(zone, NR_INACTIVE, -nr_taken);
zone->pages_scanned += nr_scan;
spin_unlock_irq(&zone->lru_lock);
nr_scanned += nr_scan;
nr_freed = shrink_page_list(&page_list, sc);
nr_reclaimed += nr_freed;
local_irq_disable();
if (current_is_kswapd()) {
<API key>(PGSCAN_KSWAPD, zone, nr_scan);
__count_vm_events(KSWAPD_STEAL, nr_freed);
} else
<API key>(PGSCAN_DIRECT, zone, nr_scan);
<API key>(PGSTEAL, zone, nr_freed);
if (nr_taken == 0)
goto done;
spin_lock(&zone->lru_lock);
/*
* Put back any unfreeable pages.
*/
while (!list_empty(&page_list)) {
page = lru_to_page(&page_list);
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
list_del(&page->lru);
if (PageActive(page))
<API key>(zone, page);
else
<API key>(zone, page);
if (!pagevec_add(&pvec, page)) {
spin_unlock_irq(&zone->lru_lock);
__pagevec_release(&pvec);
spin_lock_irq(&zone->lru_lock);
}
}
} while (nr_scanned < max_scan);
spin_unlock(&zone->lru_lock);
done:
local_irq_enable();
pagevec_release(&pvec);
return nr_reclaimed;
}
/*
* We are about to scan this zone at a certain priority level. If that priority
* level is smaller (ie: more urgent) than the previous priority, then note
* that priority level within the zone. This is done so that when the next
* process comes in to scan this zone, it will immediately start out at this
* priority level rather than having to build up its own scanning priority.
* Here, this priority affects only the reclaim-mapped threshold.
*/
static inline void <API key>(struct zone *zone, int priority)
{
if (priority < zone->prev_priority)
zone->prev_priority = priority;
}
static inline int zone_is_near_oom(struct zone *zone)
{
return zone->pages_scanned >= (zone_page_state(zone, NR_ACTIVE)
+ zone_page_state(zone, NR_INACTIVE))*3;
}
/*
* This moves pages from the active list to the inactive list.
*
* We move them the other way if the page is referenced by one or more
* processes, from rmap.
*
* If the pages are mostly unmapped, the processing is fast and it is
* appropriate to hold zone->lru_lock across the whole operation. But if
* the pages are mapped, the processing is slow (page_referenced()) so we
* should drop zone->lru_lock around each page. It's impossible to balance
* this, so instead we remove the pages from the LRU while processing them.
* It is safe to rely on PG_active against the non-LRU pages in here because
* nobody will play with that bit on a non-LRU page.
*
* The downside is that we have to touch page->_count against each page.
* But we had to alter page->flags anyway.
*/
static void shrink_active_list(unsigned long nr_pages, struct zone *zone,
struct scan_control *sc, int priority)
{
unsigned long pgmoved;
int pgdeactivate = 0;
unsigned long pgscanned;
LIST_HEAD(l_hold); /* The pages which were snipped off */
LIST_HEAD(l_inactive); /* Pages to go onto the inactive_list */
LIST_HEAD(l_active); /* Pages to go onto the active_list */
struct page *page;
struct pagevec pvec;
int reclaim_mapped = 0;
if (sc->may_swap) {
long mapped_ratio;
long distress;
long swap_tendency;
if (zone_is_near_oom(zone))
goto <API key>;
/*
* `distress' is a measure of how much trouble we're having
* reclaiming pages. 0 -> no problems. 100 -> great trouble.
*/
distress = 100 >> min(zone->prev_priority, priority);
/*
* The point of this algorithm is to decide when to start
* reclaiming mapped memory instead of just pagecache. Work out
* how much memory
* is mapped.
*/
mapped_ratio = ((global_page_state(NR_FILE_MAPPED) +
global_page_state(NR_ANON_PAGES)) * 100) /
vm_total_pages;
/*
* Now decide how much we really want to unmap some pages. The
* mapped ratio is downgraded - just because there's a lot of
* mapped memory doesn't necessarily mean that page reclaim
* isn't succeeding.
*
* The distress ratio is important - we don't want to start
* going oom.
*
* A 100% value of vm_swappiness overrides this algorithm
* altogether.
*/
swap_tendency = mapped_ratio / 2 + distress + sc->swappiness;
/*
* Now use this metric to decide whether to start moving mapped
* memory onto the inactive list.
*/
if (swap_tendency >= 100)
<API key>:
reclaim_mapped = 1;
}
lru_add_drain();
spin_lock_irq(&zone->lru_lock);
pgmoved = isolate_lru_pages(nr_pages, &zone->active_list,
&l_hold, &pgscanned);
zone->pages_scanned += pgscanned;
<API key>(zone, NR_ACTIVE, -pgmoved);
spin_unlock_irq(&zone->lru_lock);
while (!list_empty(&l_hold)) {
cond_resched();
page = lru_to_page(&l_hold);
list_del(&page->lru);
if (page_mapped(page)) {
if (!reclaim_mapped ||
(total_swap_pages == 0 && PageAnon(page)) ||
page_referenced(page, 0)) {
list_add(&page->lru, &l_active);
continue;
}
}
list_add(&page->lru, &l_inactive);
}
pagevec_init(&pvec, 1);
pgmoved = 0;
spin_lock_irq(&zone->lru_lock);
while (!list_empty(&l_inactive)) {
page = lru_to_page(&l_inactive);
<API key>(page, &l_inactive, flags);
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
VM_BUG_ON(!PageActive(page));
ClearPageActive(page);
list_move(&page->lru, &zone->inactive_list);
pgmoved++;
if (!pagevec_add(&pvec, page)) {
<API key>(zone, NR_INACTIVE, pgmoved);
spin_unlock_irq(&zone->lru_lock);
pgdeactivate += pgmoved;
pgmoved = 0;
if (<API key>)
pagevec_strip(&pvec);
__pagevec_release(&pvec);
spin_lock_irq(&zone->lru_lock);
}
}
<API key>(zone, NR_INACTIVE, pgmoved);
pgdeactivate += pgmoved;
if (<API key>) {
spin_unlock_irq(&zone->lru_lock);
pagevec_strip(&pvec);
spin_lock_irq(&zone->lru_lock);
}
pgmoved = 0;
while (!list_empty(&l_active)) {
page = lru_to_page(&l_active);
<API key>(page, &l_active, flags);
VM_BUG_ON(PageLRU(page));
SetPageLRU(page);
VM_BUG_ON(!PageActive(page));
list_move(&page->lru, &zone->active_list);
pgmoved++;
if (!pagevec_add(&pvec, page)) {
<API key>(zone, NR_ACTIVE, pgmoved);
pgmoved = 0;
spin_unlock_irq(&zone->lru_lock);
__pagevec_release(&pvec);
spin_lock_irq(&zone->lru_lock);
}
}
<API key>(zone, NR_ACTIVE, pgmoved);
<API key>(PGREFILL, zone, pgscanned);
__count_vm_events(PGDEACTIVATE, pgdeactivate);
spin_unlock_irq(&zone->lru_lock);
pagevec_release(&pvec);
}
/*
* This is a basic per-zone page freer. Used by both kswapd and direct reclaim.
*/
static unsigned long shrink_zone(int priority, struct zone *zone,
struct scan_control *sc)
{
unsigned long nr_active;
unsigned long nr_inactive;
unsigned long nr_to_scan;
unsigned long nr_reclaimed = 0;
atomic_inc(&zone->reclaim_in_progress);
/*
* Add one to `nr_to_scan' just to make sure that the kernel will
* slowly sift through the active list.
*/
zone->nr_scan_active +=
(zone_page_state(zone, NR_ACTIVE) >> priority) + 1;
nr_active = zone->nr_scan_active;
if (nr_active >= sc->swap_cluster_max)
zone->nr_scan_active = 0;
else
nr_active = 0;
zone->nr_scan_inactive +=
(zone_page_state(zone, NR_INACTIVE) >> priority) + 1;
nr_inactive = zone->nr_scan_inactive;
if (nr_inactive >= sc->swap_cluster_max)
zone->nr_scan_inactive = 0;
else
nr_inactive = 0;
while (nr_active || nr_inactive) {
if (nr_active) {
nr_to_scan = min(nr_active,
(unsigned long)sc->swap_cluster_max);
nr_active -= nr_to_scan;
shrink_active_list(nr_to_scan, zone, sc, priority);
}
if (nr_inactive) {
nr_to_scan = min(nr_inactive,
(unsigned long)sc->swap_cluster_max);
nr_inactive -= nr_to_scan;
nr_reclaimed += <API key>(nr_to_scan, zone,
sc);
}
}
<API key>(sc->gfp_mask);
atomic_dec(&zone->reclaim_in_progress);
return nr_reclaimed;
}
/*
* This is the direct reclaim path, for page-allocating processes. We only
* try to reclaim pages from zones which will satisfy the caller's allocation
* request.
*
* We reclaim from a zone even if that zone is over pages_high. Because:
* a) The caller may be trying to free *extra* pages to satisfy a higher-order
* allocation or
* b) The zones may be over pages_high but they must go *over* pages_high to
* satisfy the `incremental min' zone defense algorithm.
*
* Returns the number of reclaimed pages.
*
* If a zone is deemed to be full of pinned pages then just give it a light
* scan then give up on it.
*/
static unsigned long shrink_zones(int priority, struct zone **zones,
struct scan_control *sc)
{
unsigned long nr_reclaimed = 0;
int i;
sc->all_unreclaimable = 1;
for (i = 0; zones[i] != NULL; i++) {
struct zone *zone = zones[i];
if (!populated_zone(zone))
continue;
if (!<API key>(zone, GFP_KERNEL))
continue;
<API key>(zone, priority);
if (zone->all_unreclaimable && priority != DEF_PRIORITY)
continue; /* Let kswapd poll it */
sc->all_unreclaimable = 0;
nr_reclaimed += shrink_zone(priority, zone, sc);
}
return nr_reclaimed;
}
/*
* This is the main entry point to direct page reclaim.
*
* If a full scan of the inactive list fails to free enough memory then we
* are "out of memory" and something needs to be killed.
*
* If the caller is !__GFP_FS then the probability of a failure is reasonably
* high - the zone may be full of dirty or under-writeback pages, which this
* caller can't do much about. We kick pdflush and take explicit naps in the
* hope that some of these pages can be written. But if the allocating task
* holds filesystem locks which prevent writeout this might not work, and the
* allocation attempt will fail.
*/
unsigned long try_to_free_pages(struct zone **zones, gfp_t gfp_mask)
{
int priority;
int ret = 0;
unsigned long total_scanned = 0;
unsigned long nr_reclaimed = 0;
struct reclaim_state *reclaim_state = current->reclaim_state;
unsigned long lru_pages = 0;
int i;
struct scan_control sc = {
.gfp_mask = gfp_mask,
.may_writepage = !laptop_mode,
.swap_cluster_max = SWAP_CLUSTER_MAX,
.may_swap = 1,
.swappiness = vm_swappiness,
};
count_vm_event(ALLOCSTALL);
for (i = 0; zones[i] != NULL; i++) {
struct zone *zone = zones[i];
if (!<API key>(zone, GFP_KERNEL))
continue;
lru_pages += zone_page_state(zone, NR_ACTIVE)
+ zone_page_state(zone, NR_INACTIVE);
}
for (priority = DEF_PRIORITY; priority >= 0; priority
sc.nr_scanned = 0;
if (!priority)
disable_swap_token();
nr_reclaimed += shrink_zones(priority, zones, &sc);
shrink_slab(sc.nr_scanned, gfp_mask, lru_pages);
if (reclaim_state) {
nr_reclaimed += reclaim_state->reclaimed_slab;
reclaim_state->reclaimed_slab = 0;
}
total_scanned += sc.nr_scanned;
if (nr_reclaimed >= sc.swap_cluster_max) {
ret = 1;
goto out;
}
/*
* Try to write back as many pages as we just scanned. This
* tends to cause slow streaming writers to write data to the
* disk smoothly, at the dirtying rate, which is nice. But
* that's undesirable in laptop mode, where we *want* lumpy
* writeout. So in laptop mode, write out the whole world.
*/
if (total_scanned > sc.swap_cluster_max +
sc.swap_cluster_max / 2) {
wakeup_pdflush(laptop_mode ? 0 : total_scanned);
sc.may_writepage = 1;
}
/* Take a nap, wait for some writeback to complete */
if (sc.nr_scanned && priority < DEF_PRIORITY - 2)
congestion_wait(WRITE, HZ/10);
}
/* top priority shrink_caches still had more to do? don't OOM, then */
if (!sc.all_unreclaimable)
ret = 1;
out:
/*
* Now that we've scanned all the zones at this priority level, note
* that level within the zone so that the next thread which performs
* scanning of this zone will immediately start out at this priority
* level. This affects only the decision whether or not to bring
* mapped pages onto the inactive list.
*/
if (priority < 0)
priority = 0;
for (i = 0; zones[i] != 0; i++) {
struct zone *zone = zones[i];
if (!<API key>(zone, GFP_KERNEL))
continue;
zone->prev_priority = priority;
}
return ret;
}
/*
* For kswapd, balance_pgdat() will work across all this node's zones until
* they are all at pages_high.
*
* Returns the number of pages which were actually freed.
*
* There is special handling here for zones which are full of pinned pages.
* This can happen if the pages are all mlocked, or if they are all used by
* device drivers (say, ZONE_DMA). Or if they are all in use by hugetlb.
* What we do is to detect the case where all pages in the zone have been
* scanned twice and there has been zero successful reclaim. Mark the zone as
* dead and from now on, only perform a short scan. Basically we're polling
* the zone for when the problem goes away.
*
* kswapd scans the zones in the highmem->normal->dma direction. It skips
* zones which have free_pages > pages_high, but once a zone is found to have
* free_pages <= pages_high, we scan that zone and the lower zones regardless
* of the number of free pages in the lower zones. This interoperates with
* the page allocator fallback scheme to ensure that aging of pages is balanced
* across the zones.
*/
static unsigned long balance_pgdat(pg_data_t *pgdat, int order)
{
int all_zones_ok;
int priority;
int i;
unsigned long total_scanned;
unsigned long nr_reclaimed;
struct reclaim_state *reclaim_state = current->reclaim_state;
struct scan_control sc = {
.gfp_mask = GFP_KERNEL,
.may_swap = 1,
.swap_cluster_max = SWAP_CLUSTER_MAX,
.swappiness = vm_swappiness,
};
/*
* temp_priority is used to remember the scanning priority at which
* this zone was successfully refilled to free_pages == pages_high.
*/
int temp_priority[MAX_NR_ZONES];
loop_again:
total_scanned = 0;
nr_reclaimed = 0;
sc.may_writepage = !laptop_mode;
count_vm_event(PAGEOUTRUN);
for (i = 0; i < pgdat->nr_zones; i++)
temp_priority[i] = DEF_PRIORITY;
for (priority = DEF_PRIORITY; priority >= 0; priority
int end_zone = 0; /* Inclusive. 0 = ZONE_DMA */
unsigned long lru_pages = 0;
/* The swap token gets in the way of swapout... */
if (!priority)
disable_swap_token();
all_zones_ok = 1;
/*
* Scan in the highmem->dma direction for the highest
* zone which needs scanning
*/
for (i = pgdat->nr_zones - 1; i >= 0; i
struct zone *zone = pgdat->node_zones + i;
if (!populated_zone(zone))
continue;
if (zone->all_unreclaimable && priority != DEF_PRIORITY)
continue;
if (!zone_watermark_ok(zone, order, zone->pages_high,
0, 0)) {
end_zone = i;
break;
}
}
if (i < 0)
goto out;
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
lru_pages += zone_page_state(zone, NR_ACTIVE)
+ zone_page_state(zone, NR_INACTIVE);
}
/*
* Now scan the zone in the dma->highmem direction, stopping
* at the last zone which needs scanning.
*
* We do this because the page allocator works in the opposite
* direction. This prevents the page allocator from allocating
* pages behind kswapd's direction of progress, which would
* cause too much scanning of the lower zones.
*/
for (i = 0; i <= end_zone; i++) {
struct zone *zone = pgdat->node_zones + i;
int nr_slab;
if (!populated_zone(zone))
continue;
if (zone->all_unreclaimable && priority != DEF_PRIORITY)
continue;
if (!zone_watermark_ok(zone, order, zone->pages_high,
end_zone, 0))
all_zones_ok = 0;
temp_priority[i] = priority;
sc.nr_scanned = 0;
<API key>(zone, priority);
nr_reclaimed += shrink_zone(priority, zone, &sc);
reclaim_state->reclaimed_slab = 0;
nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL,
lru_pages);
nr_reclaimed += reclaim_state->reclaimed_slab;
total_scanned += sc.nr_scanned;
if (zone->all_unreclaimable)
continue;
if (nr_slab == 0 && zone->pages_scanned >=
(zone_page_state(zone, NR_ACTIVE)
+ zone_page_state(zone, NR_INACTIVE)) * 6)
zone->all_unreclaimable = 1;
/*
* If we've done a decent amount of scanning and
* the reclaim ratio is low, start doing writepage
* even in laptop mode
*/
if (total_scanned > SWAP_CLUSTER_MAX * 2 &&
total_scanned > nr_reclaimed + nr_reclaimed / 2)
sc.may_writepage = 1;
}
if (all_zones_ok)
break; /* kswapd: all done */
/*
* OK, kswapd is getting into trouble. Take a nap, then take
* another pass across the zones.
*/
if (total_scanned && priority < DEF_PRIORITY - 2)
congestion_wait(WRITE, HZ/10);
/*
* We do this so kswapd doesn't build up large priorities for
* example when it is freeing in parallel with allocators. It
* matches the direct reclaim path behaviour in terms of impact
* on zone->*_priority.
*/
if (nr_reclaimed >= SWAP_CLUSTER_MAX)
break;
}
out:
/*
* Note within each zone the priority level at which this zone was
* brought into a happy state. So that the next thread which scans this
* zone will start out at that priority level.
*/
for (i = 0; i < pgdat->nr_zones; i++) {
struct zone *zone = pgdat->node_zones + i;
zone->prev_priority = temp_priority[i];
}
if (!all_zones_ok) {
cond_resched();
try_to_freeze();
goto loop_again;
}
return nr_reclaimed;
}
/*
* The background pageout daemon, started as a kernel thread
* from the init process.
*
* This basically trickles out pages so that we have _some_
* free memory available even if there is no other activity
* that frees anything up. This is needed for things like routing
* etc, where we otherwise might have all activity going on in
* asynchronous contexts that cannot page things out.
*
* If there are applications that are active memory-allocators
* (most normal use), this basically shouldn't matter.
*/
static int kswapd(void *p)
{
unsigned long order;
pg_data_t *pgdat = (pg_data_t*)p;
struct task_struct *tsk = current;
DEFINE_WAIT(wait);
struct reclaim_state reclaim_state = {
.reclaimed_slab = 0,
};
cpumask_t cpumask;
cpumask = node_to_cpumask(pgdat->node_id);
if (!cpus_empty(cpumask))
set_cpus_allowed(tsk, cpumask);
current->reclaim_state = &reclaim_state;
/*
* Tell the memory management that we're a "memory allocator",
* and that if we need more memory we should get access to it
* regardless (see "__alloc_pages()"). "kswapd" should
* never get caught in the normal page freeing logic.
*
* (Kswapd normally doesn't need memory anyway, but sometimes
* you need a small amount of memory in order to be able to
* page out something else, and this flag essentially protects
* us from recursively trying to free more memory as we're
* trying to free the first piece of memory in the first place).
*/
tsk->flags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD;
order = 0;
for ( ; ; ) {
unsigned long new_order;
try_to_freeze();
prepare_to_wait(&pgdat->kswapd_wait, &wait, TASK_INTERRUPTIBLE);
new_order = pgdat->kswapd_max_order;
pgdat->kswapd_max_order = 0;
if (order < new_order) {
/*
* Don't sleep if someone wants a larger 'order'
* allocation
*/
order = new_order;
} else {
schedule();
order = pgdat->kswapd_max_order;
}
finish_wait(&pgdat->kswapd_wait, &wait);
balance_pgdat(pgdat, order);
}
return 0;
}
/*
* A zone is low on free memory, so wake its kswapd task to service it.
*/
void wakeup_kswapd(struct zone *zone, int order)
{
pg_data_t *pgdat;
if (!populated_zone(zone))
return;
pgdat = zone->zone_pgdat;
if (zone_watermark_ok(zone, order, zone->pages_low, 0, 0))
return;
if (pgdat->kswapd_max_order < order)
pgdat->kswapd_max_order = order;
if (!<API key>(zone, GFP_KERNEL))
return;
if (!waitqueue_active(&pgdat->kswapd_wait))
return;
<API key>(&pgdat->kswapd_wait);
}
#ifdef CONFIG_PM
/*
* Helper function for shrink_all_memory(). Tries to reclaim 'nr_pages' pages
* from LRU lists system-wide, for given pass and priority, and returns the
* number of reclaimed pages
*
* For pass > 3 we also try to shrink the LRU lists that contain a few pages
*/
static unsigned long shrink_all_zones(unsigned long nr_pages, int prio,
int pass, struct scan_control *sc)
{
struct zone *zone;
unsigned long nr_to_scan, ret = 0;
for_each_zone(zone) {
if (!populated_zone(zone))
continue;
if (zone->all_unreclaimable && prio != DEF_PRIORITY)
continue;
/* For pass = 0 we don't shrink the active list */
if (pass > 0) {
zone->nr_scan_active +=
(zone_page_state(zone, NR_ACTIVE) >> prio) + 1;
if (zone->nr_scan_active >= nr_pages || pass > 3) {
zone->nr_scan_active = 0;
nr_to_scan = min(nr_pages,
zone_page_state(zone, NR_ACTIVE));
shrink_active_list(nr_to_scan, zone, sc, prio);
}
}
zone->nr_scan_inactive +=
(zone_page_state(zone, NR_INACTIVE) >> prio) + 1;
if (zone->nr_scan_inactive >= nr_pages || pass > 3) {
zone->nr_scan_inactive = 0;
nr_to_scan = min(nr_pages,
zone_page_state(zone, NR_INACTIVE));
ret += <API key>(nr_to_scan, zone, sc);
if (ret >= nr_pages)
return ret;
}
}
return ret;
}
static unsigned long count_lru_pages(void)
{
return global_page_state(NR_ACTIVE) + global_page_state(NR_INACTIVE);
}
/*
* Try to free `nr_pages' of memory, system-wide, and return the number of
* freed pages.
*
* Rather than trying to age LRUs the aim is to preserve the overall
* LRU order by reclaiming preferentially
* inactive > active > active referenced > active mapped
*/
unsigned long shrink_all_memory(unsigned long nr_pages)
{
unsigned long lru_pages, nr_slab;
unsigned long ret = 0;
int pass;
struct reclaim_state reclaim_state;
struct scan_control sc = {
.gfp_mask = GFP_KERNEL,
.may_swap = 0,
.swap_cluster_max = nr_pages,
.may_writepage = 1,
.swappiness = vm_swappiness,
};
current->reclaim_state = &reclaim_state;
lru_pages = count_lru_pages();
nr_slab = global_page_state(NR_SLAB_RECLAIMABLE);
/* If slab caches are huge, it's better to hit them first */
while (nr_slab >= lru_pages) {
reclaim_state.reclaimed_slab = 0;
shrink_slab(nr_pages, sc.gfp_mask, lru_pages);
if (!reclaim_state.reclaimed_slab)
break;
ret += reclaim_state.reclaimed_slab;
if (ret >= nr_pages)
goto out;
nr_slab -= reclaim_state.reclaimed_slab;
}
/*
* We try to shrink LRUs in 5 passes:
* 0 = Reclaim from inactive_list only
* 1 = Reclaim from active list but don't reclaim mapped
* 2 = 2nd pass of type 1
* 3 = Reclaim mapped (normal reclaim)
* 4 = 2nd pass of type 3
*/
for (pass = 0; pass < 5; pass++) {
int prio;
/* Force reclaiming mapped pages in the passes #3 and #4 */
if (pass > 2) {
sc.may_swap = 1;
sc.swappiness = 100;
}
for (prio = DEF_PRIORITY; prio >= 0; prio
unsigned long nr_to_scan = nr_pages - ret;
sc.nr_scanned = 0;
ret += shrink_all_zones(nr_to_scan, prio, pass, &sc);
if (ret >= nr_pages)
goto out;
reclaim_state.reclaimed_slab = 0;
shrink_slab(sc.nr_scanned, sc.gfp_mask,
count_lru_pages());
ret += reclaim_state.reclaimed_slab;
if (ret >= nr_pages)
goto out;
if (sc.nr_scanned && prio < DEF_PRIORITY - 2)
congestion_wait(WRITE, HZ / 10);
}
}
/*
* If ret = 0, we could not shrink LRUs, but there may be something
* in slab caches
*/
if (!ret) {
do {
reclaim_state.reclaimed_slab = 0;
shrink_slab(nr_pages, sc.gfp_mask, count_lru_pages());
ret += reclaim_state.reclaimed_slab;
} while (ret < nr_pages && reclaim_state.reclaimed_slab > 0);
}
out:
current->reclaim_state = NULL;
return ret;
}
#endif
/* It's optimal to keep kswapds on the same CPUs as their memory, but
not required for correctness. So if the last cpu in a node goes
away, we get changed to run anywhere: as the first one comes back,
restore their cpu bindings. */
static int __devinit cpu_callback(struct notifier_block *nfb,
unsigned long action, void *hcpu)
{
pg_data_t *pgdat;
cpumask_t mask;
if (action == CPU_ONLINE) {
<API key>(pgdat) {
mask = node_to_cpumask(pgdat->node_id);
if (any_online_cpu(mask) != NR_CPUS)
/* One of our CPUs online: restore mask */
set_cpus_allowed(pgdat->kswapd, mask);
}
}
return NOTIFY_OK;
}
/*
* This kswapd start function will be called by init and node-hot-add.
* On node-hot-add, kswapd will moved to proper cpus if cpus are hot-added.
*/
int kswapd_run(int nid)
{
pg_data_t *pgdat = NODE_DATA(nid);
int ret = 0;
if (pgdat->kswapd)
return 0;
pgdat->kswapd = kthread_run(kswapd, pgdat, "kswapd%d", nid);
if (IS_ERR(pgdat->kswapd)) {
/* failure at boot is fatal */
BUG_ON(system_state == SYSTEM_BOOTING);
printk("Failed to start kswapd on node %d\n",nid);
ret = -1;
}
return ret;
}
static int __init kswapd_init(void)
{
int nid;
swap_setup();
<API key>(nid)
kswapd_run(nid);
hotcpu_notifier(cpu_callback, 0);
return 0;
}
module_init(kswapd_init)
#ifdef CONFIG_NUMA
/*
* Zone reclaim mode
*
* If non-zero call zone_reclaim when the number of free pages falls below
* the watermarks.
*/
int zone_reclaim_mode __read_mostly;
#define RECLAIM_OFF 0
#define RECLAIM_ZONE (1<<0) /* Run shrink_cache on the zone */
#define RECLAIM_WRITE (1<<1) /* Writeout pages during reclaim */
#define RECLAIM_SWAP (1<<2) /* Swap pages out during reclaim */
/*
* Priority for ZONE_RECLAIM. This determines the fraction of pages
* of a node considered for each zone_reclaim. 4 scans 1/16th of
* a zone.
*/
#define <API key> 4
/*
* Percentage of pages in a zone that must be unmapped for zone_reclaim to
* occur.
*/
int <API key> = 1;
/*
* If the number of slab pages in a zone grows beyond this percentage then
* slab reclaim needs to occur.
*/
int <API key> = 5;
/*
* Try to free up some pages from this zone through reclaim.
*/
static int __zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
{
/* Minimum pages needed in order to stay on node */
const unsigned long nr_pages = 1 << order;
struct task_struct *p = current;
struct reclaim_state reclaim_state;
int priority;
unsigned long nr_reclaimed = 0;
struct scan_control sc = {
.may_writepage = !!(zone_reclaim_mode & RECLAIM_WRITE),
.may_swap = !!(zone_reclaim_mode & RECLAIM_SWAP),
.swap_cluster_max = max_t(unsigned long, nr_pages,
SWAP_CLUSTER_MAX),
.gfp_mask = gfp_mask,
.swappiness = vm_swappiness,
};
unsigned long slab_reclaimable;
disable_swap_token();
cond_resched();
/*
* We need to be able to allocate from the reserves for RECLAIM_SWAP
* and we also need to be able to write out pages for RECLAIM_WRITE
* and RECLAIM_SWAP.
*/
p->flags |= PF_MEMALLOC | PF_SWAPWRITE;
reclaim_state.reclaimed_slab = 0;
p->reclaim_state = &reclaim_state;
if (zone_page_state(zone, NR_FILE_PAGES) -
zone_page_state(zone, NR_FILE_MAPPED) >
zone->min_unmapped_pages) {
/*
* Free memory by calling shrink zone with increasing
* priorities until we have enough memory freed.
*/
priority = <API key>;
do {
<API key>(zone, priority);
nr_reclaimed += shrink_zone(priority, zone, &sc);
priority
} while (priority >= 0 && nr_reclaimed < nr_pages);
}
slab_reclaimable = zone_page_state(zone, NR_SLAB_RECLAIMABLE);
if (slab_reclaimable > zone->min_slab_pages) {
/*
* shrink_slab() does not currently allow us to determine how
* many pages were freed in this zone. So we take the current
* number of slab pages and shake the slab until it is reduced
* by the same nr_pages that we used for reclaiming unmapped
* pages.
*
* Note that shrink_slab will free memory on all zones and may
* take a long time.
*/
while (shrink_slab(sc.nr_scanned, gfp_mask, order) &&
zone_page_state(zone, NR_SLAB_RECLAIMABLE) >
slab_reclaimable - nr_pages)
;
/*
* Update nr_reclaimed by the number of slab pages we
* reclaimed from this zone.
*/
nr_reclaimed += slab_reclaimable -
zone_page_state(zone, NR_SLAB_RECLAIMABLE);
}
p->reclaim_state = NULL;
current->flags &= ~(PF_MEMALLOC | PF_SWAPWRITE);
return nr_reclaimed >= nr_pages;
}
int zone_reclaim(struct zone *zone, gfp_t gfp_mask, unsigned int order)
{
cpumask_t mask;
int node_id;
/*
* Zone reclaim reclaims unmapped file backed pages and
* slab pages if we are over the defined limits.
*
* A small portion of unmapped file backed pages is needed for
* file I/O otherwise pages read by file I/O will be immediately
* thrown out if the zone is overallocated. So we do not reclaim
* if less than a specified percentage of the zone is used by
* unmapped file backed pages.
*/
if (zone_page_state(zone, NR_FILE_PAGES) -
zone_page_state(zone, NR_FILE_MAPPED) <= zone->min_unmapped_pages
&& zone_page_state(zone, NR_SLAB_RECLAIMABLE)
<= zone->min_slab_pages)
return 0;
/*
* Avoid concurrent zone reclaims, do not reclaim in a zone that does
* not have reclaimable pages and if we should not delay the allocation
* then do not scan.
*/
if (!(gfp_mask & __GFP_WAIT) ||
zone->all_unreclaimable ||
atomic_read(&zone->reclaim_in_progress) > 0 ||
(current->flags & PF_MEMALLOC))
return 0;
/*
* Only run zone reclaim on the local zone or on zones that do not
* have associated processors. This will favor the local processor
* over remote processors and spread off node memory allocations
* as wide as possible.
*/
node_id = zone_to_nid(zone);
mask = node_to_cpumask(node_id);
if (!cpus_empty(mask) && node_id != numa_node_id())
return 0;
return __zone_reclaim(zone, gfp_mask, order);
}
#endif
|
#include <fenv.h>
#include <string.h>
int
feupdateenv (const fenv_t *envp)
{
union { unsigned long long l; unsigned int sw[2]; } s;
fenv_t temp;
/* Get the current exception status */
__asm__ ("fstd %%fr0,0(%1) \n\t"
"fldd 0(%1),%%fr0 \n\t"
: "=m" (s.l) : "r" (&s.l));
memcpy(&temp, envp, sizeof(fenv_t));
/* Currently raised exceptions not cleared */
temp.__status_word |= s.sw[0] & (FE_ALL_EXCEPT << 27);
/* Install new environment. */
fesetenv (&temp);
/* Success. */
return 0;
}
|
# This program is free software; you can redistribute it and/or
# version 2 as published by the Free Software Foundation.
# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Authors:
# Pierre-Yves Chibon <pingou@pingoured.fr>
"""This test module contains tests for the migration system."""
import os
import subprocess
import unittest
REPO_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
class TestAlembic(unittest.TestCase):
"""This test class contains tests pertaining to alembic."""
def <API key>(self):
"""Enforce a linear alembic history.
This test runs the `alembic history | grep ' (head), '` command,
and ensure it returns only one line.
"""
proc1 = subprocess.Popen(
["alembic", "history"], cwd=REPO_PATH, stdout=subprocess.PIPE
)
proc2 = subprocess.Popen(
["grep", " (head), "], stdin=proc1.stdout, stdout=subprocess.PIPE
)
stdout = proc2.communicate()[0]
stdout = stdout.strip().split(b"\n")
self.assertEqual(len(stdout), 1)
proc1.communicate()
|
import pybedtools
import os
testdir = os.path.dirname(__file__)
test_tempdir = os.path.join(os.path.abspath(testdir), 'tmp')
unwriteable = os.path.join(os.path.abspath(testdir), 'unwriteable')
def setup():
if not os.path.exists(test_tempdir):
os.system('mkdir -p %s' % test_tempdir)
pybedtools.set_tempdir(test_tempdir)
def teardown():
if os.path.exists(test_tempdir):
os.system('rm -r %s' % test_tempdir)
pybedtools.cleanup()
|
# Gramps - a GTK+/GNOME based genealogy program
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
__all__ = ["LinkBox"]
# Standard python modules
import logging
_LOG = logging.getLogger(".widgets.linkbox")
# GTK/Gnome modules
from gi.repository import GObject
from gi.repository import Gtk
# LinkBox class
class LinkBox(Gtk.HBox):
def __init__(self, link, button):
GObject.GObject.__init__(self)
self.set_spacing(6)
self.pack_start(link, False, True, 0)
if button:
self.pack_start(button, False, True, 0)
self.show()
|
#include "ConditionMonitors.hpp"
#include "<API key>.hpp"
#include "<API key>.hpp"
#include "<API key>.hpp"
#include "<API key>.hpp"
#include "<API key>.hpp"
#include "<API key>.hpp"
static <API key> cm_wind;
static <API key> cm_finalglide;
static <API key> cm_sunset;
static <API key> cm_aattime;
static <API key> cm_glideterrain;
static <API key> <API key>;
void
<API key>(const NMEAInfo &basic, const DerivedInfo &calculated,
const ComputerSettings &settings)
{
cm_wind.Update(basic, calculated, settings);
cm_finalglide.Update(basic, calculated, settings);
cm_sunset.Update(basic, calculated, settings);
cm_aattime.Update(basic, calculated, settings);
cm_glideterrain.Update(basic, calculated, settings);
<API key>.Update(basic, calculated, settings);
}
|
/*
* Automatically generated C config: don't edit
* Linux/arm 3.0.36 Kernel Configuration
*/
#define CONFIG_RING_BUFFER 1
#define <API key> 1
#define CONFIG_SCSI_DMA 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_RFS_ACCEL 1
#define <API key> 1
#define CONFIG_CRC32 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HAVE_AOUT 1
#define <API key> 1
#define CONFIG_VFP 1
#define <API key> 1
#define CONFIG_AEABI 1
#define CONFIG_APANIC 1
#define <API key> 1
#define <API key> 1
#define CONFIG_BLK_DEV_DM 1
#define <API key> 1
#define <API key> 1
#define CONFIG_BT_RFCOMM 1
#define <API key> 1
#define <API key> 1
#define CONFIG_INOTIFY_USER 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_DEINTERLACE 1
#define CONFIG_EXPERIMENTAL 1
#define CONFIG_PPP_SYNC_TTY 1
#define <API key> 1
#define CONFIG_RC_CORE 1
#define CONFIG_ARM_UNWIND 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_SSB_POSSIBLE 1
#define CONFIG_NF_NAT_SIP 1
#define CONFIG_MTD_RKNAND 1
#define <API key> 1
#define CONFIG_UART3_RK29 1
#define <API key> 1
#define CONFIG_NET_SCH_FIFO 1
#define CONFIG_FSNOTIFY 1
#define CONFIG_STP 1
#define CONFIG_MFD_TPS65910 1
#define CONFIG_INET6_TUNNEL 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_FIB_RULES 1
#define CONFIG_HID_ACRUX_FF 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_EMS_FF 1
#define CONFIG_KTIME_SCALAR 1
#define <API key> 1
#define CONFIG_LCDC1_RK30 1
#define CONFIG_IPV6 1
#define <API key> 1
#define CONFIG_CRYPTO_AEAD 1
#define <API key> "cubic"
#define <API key> ""
#define CONFIG_USB_DEVICEFS 1
#define <API key> 1
#define CONFIG_DEVTMPFS 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HOTPLUG_CPU 1
#define CONFIG_WLAN 1
#define <API key> 4
#define CONFIG_HAVE_ARM_SCU 1
#define CONFIG_BLK_DEV_BSG 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_XFRM_IPCOMP 1
#define CONFIG_CRYPTO_RNG2 1
#define <API key> 1
#define CONFIG_TUN 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_DM_CRYPT 1
#define <API key> 1
#define CONFIG_HID_BELKIN 1
#define CONFIG_VIDEO_IR_I2C 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_ACRUX 1
#define CONFIG_BT_AUTOSLEEP 1
#define CONFIG_USB 1
#define CONFIG_SWITCH_GPIO 1
#define CONFIG_CRYPTO_HMAC 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_CHERRY 1
#define CONFIG_I2C0_RK30 1
#define CONFIG_HID_SUNPLUS 1
#define CONFIG_HID_PICOLCD 1
#define <API key> 1
#define <API key> 11
#define CONFIG_SND_SOC 1
#define CONFIG_CAN_PM_TRACE 1
#define <API key> 1
#define CONFIG_I2C3_RK30 1
#define CONFIG_PRINTK 1
#define CONFIG_FIQ_GLUE 1
#define <API key> 1
#define <API key> 1
#define CONFIG_TIMERFD 1
#define <API key> 1
#define CONFIG_RK_PL330_DMA 1
#define CONFIG_TRACEPOINTS 1
#define CONFIG_MTD_CFI_I2 1
#define <API key> 1
#define <API key> 32
#define CONFIG_BOUNCE 1
#define CONFIG_SHMEM 1
#define CONFIG_MIGRATION 1
#define CONFIG_MTD 1
#define <API key> 8
#define CONFIG_DWC_CONN_EN 1
#define <API key> 1
#define CONFIG_CRYPTO_DES 1
#define <API key> 1
#define <API key> 1
#define CONFIG_MTD_NAND_IDS 1
#define CONFIG_NET_CLS_U32 1
#define CONFIG_FIQ_DEBUGGER 1
#define <API key> 1
#define CONFIG_ARM_GIC 1
#define CONFIG_SERIO 1
#define CONFIG_SCHEDSTATS 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_ZLIB_INFLATE 1
#define <API key> 1
#define CONFIG_GPIO_WM831X 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_ARM 1
#define <API key> 5
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_INPUT_TABLET 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HAS_WAKELOCK 1
#define CONFIG_LOGO 1
#define CONFIG_USB_STORAGE 1
#define CONFIG_STANDALONE 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_I2C2_RK30 1
#define CONFIG_ASHMEM 1
#define CONFIG_BLOCK 1
#define CONFIG_HAVE_IDE 1
#define CONFIG_HID_APPLE 1
#define <API key> 1
#define <API key> 32
#define <API key> 1
#define CONFIG_GENERIC_GPIO 1
#define <API key> 1
#define CONFIG_BUG 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PM 1
#define <API key> 1
#define CONFIG_SWITCH 1
#define CONFIG_DEVKMEM 1
#define CONFIG_PPP_DEFLATE 1
#define <API key> 1
#define CONFIG_RK_SN 1
#define CONFIG_VT 1
#define <API key> 1
#define <API key> 1
#define <API key> 4
#define CONFIG_BT_SCO 1
#define CONFIG_POWER_SUPPLY 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_WEXT_CORE 1
#define CONFIG_NLS 1
#define <API key> 1
#define <API key> 1
#define CONFIG_MFD_SUPPORT 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_KEYTOUCH 1
#define CONFIG_HID_CYPRESS 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_ZYDACRON 1
#define CONFIG_PPP_MPPE 1
#define <API key> 1
#define <API key> 1
#define CONFIG_RFKILL 1
#define CONFIG_NETDEVICES 1
#define CONFIG_NET_KEY 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_CPU_TLB_V7 1
#define CONFIG_EVENTFD 1
#define CONFIG_IPV6_SIT 1
#define CONFIG_XFRM 1
#define <API key> "/lib/modules/$UNAME_RELEASE/.config"
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_GREENASIA_FF 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PHONET 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_LCPOWER 1
#define <API key> 1
#define <API key> 1
#define CONFIG_CPU_COPY_V6 1
#define CONFIG_PM_DEBUG 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 0
#define <API key> 1
#define <API key> 1
#define CONFIG_MAGIC_SYSRQ 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HAVE_ARM_TWD 1
#define CONFIG_IP_NF_MANGLE 1
#define CONFIG_DEFAULT_CFQ 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_IP_NF_FILTER 1
#define CONFIG_HID_ZEROPLUS 1
#define CONFIG_EXT3_FS 1
#define <API key> 1
#define CONFIG_FAT_FS 1
#define <API key> 1
#define CONFIG_HIGHMEM 1
#define CONFIG_IP6_NF_RAW 1
#define CONFIG_INET_TUNNEL 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_IOSCHED_CFQ 1
#define CONFIG_MFD_CORE 1
#define CONFIG_CPU_CP15_MMU 1
#define CONFIG_STOP_MACHINE 1
#define CONFIG_CPU_FREQ 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NLS_ASCII 1
#define CONFIG_SDMMC0_RK29 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_SND_USB 1
#define CONFIG_LOGIG940_FF 1
#define CONFIG_RD_GZIP 1
#define <API key> 1
#define <API key> 1
#define CONFIG_LBDAF 1
#define CONFIG_BP_AUTO 1
#define CONFIG_HID_ROCCAT 1
#define <API key> 1
#define CONFIG_CRYPTO_MD5 1
#define <API key> 1
#define <API key> 1
#define CONFIG_BINFMT_ELF 1
#define CONFIG_SCSI_PROC_FS 1
#define CONFIG_HOTPLUG 1
#define CONFIG_INET6_AH 1
#define CONFIG_CPU_CP15 1
#define CONFIG_USB_SERIAL 1
#define CONFIG_I2C_RK30 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PM_SLEEP_SMP 1
#define CONFIG_CRYPTO_HW 1
#define CONFIG_ION 1
#define <API key> 1
#define <API key> 0
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NET_ACT_GACT 1
#define CONFIG_HID_GYRATION 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_EARLYSUSPEND 1
#define CONFIG_USB_ACM 1
#define CONFIG_CRC16 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NET_CLS 1
#define CONFIG_CPU_HAS_PMU 1
#define <API key> 1
#define CONFIG_TMPFS 1
#define CONFIG_LS_ISL29023 1
#define CONFIG_ANON_INODES 1
#define <API key> 1
#define CONFIG_FUTEX 1
#define <API key> 1
#define CONFIG_VMSPLIT_3G 1
#define CONFIG_RTC_HCTOSYS 1
#define CONFIG_LCDC_RK30 1
#define CONFIG_USB_HID 1
#define CONFIG_RTL8192CU 1
#define CONFIG_ANDROID 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_CGROUP_SCHED 1
#define <API key> 1
#define <API key> 1
#define CONFIG_MODULES 1
#define <API key> 1
#define CONFIG_CPU_HAS_ASID 1
#define CONFIG_USB_GADGET 1
#define <API key> 1
#define CONFIG_SOUND 1
#define <API key> 1
#define CONFIG_UNIX 1
#define CONFIG_HAVE_CLK 1
#define CONFIG_CRYPTO_HASH2 1
#define <API key> "(none)"
#define <API key> 1
#define CONFIG_XPS 1
#define CONFIG_INET_ESP 1
#define CONFIG_HID_QUANTA 1
#define <API key> 1
#define CONFIG_MD 1
#define <API key> 1
#define <API key> 1
#define CONFIG_BRIDGE 1
#define CONFIG_MEDIA_TUNER 1
#define <API key> 1
#define CONFIG_MISC_DEVICES 1
#define CONFIG_INPUT_UINPUT 1
#define <API key> 1
#define <API key> 0
#define CONFIG_MTD_CFI_I1 1
#define CONFIG_NF_NAT 1
#define CONFIG_CPU_IDLE 1
#define <API key> 1
#define CONFIG_REGULATOR 1
#define <API key> 1
#define <API key> 1
#define CONFIG_SND_RK29_SOC 1
#define CONFIG_CRYPTO_HASH 1
#define <API key> 1
#define CONFIG_GS_MMA7660 1
#define <API key> 19
#define <API key> 1
#define <API key> ""
#define CONFIG_CACHE_L2X0 1
#define <API key> 1
#define CONFIG_VIRT_TO_BUS 1
#define CONFIG_VFAT_FS 1
#define <API key> 1
#define CONFIG_CPU_RMAP 1
#define CONFIG_BLK_DEV_LOOP 1
#define CONFIG_WAKELOCK 1
#define CONFIG_NF_NAT_IRC 1
#define <API key> 1
#define <API key> 1
#define CONFIG_INPUT_MISC 1
#define CONFIG_CPU_PABRT_V7 1
#define CONFIG_SOC_CAMERA 1
#define CONFIG_SUSPEND 1
#define CONFIG_CRYPTO_CBC 1
#define <API key> 1
#define CONFIG_UART1_RK29 1
#define CONFIG_RTC_CLASS 1
#define CONFIG_USB20_HOST 1
#define CONFIG_CPU_PM 1
#define CONFIG_HDMI_RK30 1
#define CONFIG_ARCH_RK30 1
#define <API key> 1
#define CONFIG_NF_NAT_TFTP 1
#define CONFIG_OUTER_CACHE 1
#define <API key> 0
#define CONFIG_CPU_CACHE_V7 1
#define CONFIG_ZEROPLUS_FF 1
#define <API key> 1
#define <API key> 2
#define <API key> 1
#define CONFIG_SLUB 1
#define CONFIG_PM_SLEEP 1
#define CONFIG_I2C 1
#define <API key> 1
#define <API key> 1
#define <API key> 0
#define CONFIG_BT_HIDP 1
#define <API key> 1
#define CONFIG_CPU_ABRT_EV7 1
#define CONFIG_WLAN_80211 1
#define <API key> 1
#define CONFIG_CRYPTO_ECB 1
#define <API key> 1
#define CONFIG_DEBUG_FS 1
#define <API key> 1
#define CONFIG_BASE_FULL 1
#define <API key> 1
#define CONFIG_ZLIB_DEFLATE 1
#define CONFIG_GPIO_SYSFS 1
#define CONFIG_FW_LOADER 1
#define CONFIG_KALLSYMS 1
#define <API key> "rtc0"
#define <API key> 1
#define CONFIG_MII 1
#define CONFIG_SIGNALFD 1
#define <API key> 1
#define <API key> 1
#define CONFIG_EXT4_FS 1
#define CONFIG_CRYPTO_SHA1 1
#define <API key> 1
#define CONFIG_SUSPEND_TIME 1
#define CONFIG_IPV6_PRIVACY 1
#define CONFIG_USB_BELKIN 1
#define <API key> 1
#define CONFIG_HAS_IOMEM 1
#define CONFIG_PPPOPNS 1
#define CONFIG_KERNEL_LZO 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_EPOLL 1
#define CONFIG_SND_PCM 1
#define CONFIG_PM_RUNTIME 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NET 1
#define CONFIG_INPUT_EVDEV 1
#define CONFIG_SND_JACK 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_VFPv3 1
#define CONFIG_RFKILL_RK 1
#define <API key> 1
#define CONFIG_PACKET 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NOP_TRACER 1
#define <API key> 1
#define CONFIG_INET 1
#define <API key> 1
#define <API key> 1
#define CONFIG_FREEZER 1
#define CONFIG_BT 1
#define CONFIG_RFKILL_PM 1
#define CONFIG_NET_CLS_ACT 1
#define CONFIG_I2C4_RK30 1
#define CONFIG_HID_WACOM 1
#define CONFIG_RTC_LIB 1
#define <API key> 1
#define CONFIG_HAVE_KPROBES 1
#define CONFIG_CRYPTO_AES 1
#define <API key> 1
#define CONFIG_GPIOLIB 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_WALTOP 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NETFILTER 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_DVFS 1
#define CONFIG_DWC_OTG 1
#define <API key> 1
#define CONFIG_LIRC 1
#define CONFIG_BT_BNEP 1
#define CONFIG_FB_ROCKCHIP 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PREEMPT_RCU 1
#define <API key> 1
#define CONFIG_SERIAL_RK29 1
#define CONFIG_GS_MMA8452 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NO_HZ 1
#define <API key> 1
#define CONFIG_RK_BOARD_ID 1
#define <API key> 1
#define <API key> 1
#define CONFIG_MTD_BLKDEVS 1
#define <API key> 1
#define CONFIG_INET6_ESP 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PAGE_OFFSET 0xC0000000
#define CONFIG_CPU_V7 1
#define CONFIG_GS_LIS3DH 1
#define CONFIG_HID_TWINHAN 1
#define <API key> 1
#define <API key> 0x0
#define <API key> 1
#define <API key> 1
#define CONFIG_SMP 1
#define <API key> 1
#define <API key> 1
#define CONFIG_DM_UEVENT 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_LIBCRC32C 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_SONY 1
#define CONFIG_HW_CONSOLE 1
#define CONFIG_DEVMEM 1
#define CONFIG_HID_MONTEREY 1
#define CONFIG_HID_EZKEY 1
#define CONFIG_IOSCHED_NOOP 1
#define CONFIG_LCD_MR13 1
#define <API key> 1
#define CONFIG_NEON 1
#define CONFIG_DEBUG_KERNEL 1
#define CONFIG_ARCH_RK30XX 1
#define CONFIG_COMPAT_BRK 1
#define CONFIG_LOCALVERSION "+"
#define <API key> 1
#define <API key> 1
#define CONFIG_DDR_TEST 1
#define CONFIG_CRYPTO 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 32768
#define <API key> 1
#define <API key> 1
#define CONFIG_CMDLINE "console=ttyFIQ0 androidboot.console=ttyFIQ0 init=/init"
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_SAMSUNG 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_SCSI_MOD 1
#define <API key> 1
#define CONFIG_SERIAL_CORE 1
#define CONFIG_FUSE_FS 1
#define CONFIG_UID16 1
#define CONFIG_EMBEDDED 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_VIDEO_DEV 1
#define CONFIG_MFD_WM831X 1
#define CONFIG_PPP_FILTER 1
#define CONFIG_HAS_DMA 1
#define <API key> 1
#define CONFIG_BT_L2CAP 1
#define CONFIG_SCSI 1
#define <API key> 1
#define CONFIG_NF_NAT_PPTP 1
#define CONFIG_HID_CHICONY 1
#define CONFIG_HID 1
#define CONFIG_LOGIWII_FF 1
#define CONFIG_USB_ARMLINUX 1
#define <API key> 1
#define CONFIG_KEYS_RK29 1
#define <API key> 1
#define <API key> 1
#define CONFIG_JBD2 1
#define CONFIG_LCDC0_RK30 1
#define CONFIG_INET6_IPCOMP 1
#define CONFIG_PHYLIB 1
#define CONFIG_IPV6_TUNNEL 1
#define <API key> 1
#define CONFIG_FTRACE 1
#define <API key> 1
#define CONFIG_IP_NF_RAW 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_TOPSEED 1
#define <API key> 1
#define CONFIG_NF_NAT_H323 1
#define CONFIG_HID_A4TECH 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 60
#define <API key> 0
#define <API key> 1
#define CONFIG_SOC_RK3066 1
#define <API key> 1
#define <API key> 1
#define CONFIG_CACHE_PL310 1
#define <API key> 1
#define CONFIG_CRYPTO_ARC4 1
#define CONFIG_SLHC 1
#define CONFIG_HAVE_SMP 1
#define CONFIG_RGA_RK30 1
#define <API key> 1
#define CONFIG_NET_SCH_HTB 1
#define CONFIG_PPP_BSDCOMP 1
#define CONFIG_RT_MUTEXES 1
#define CONFIG_VECTORS_BASE 0xffff0000
#define CONFIG_HID_ORTEK 1
#define <API key> 1
#define <API key> 1
#define CONFIG_MMC_BLOCK 1
#define CONFIG_EXPERT 1
#define CONFIG_WIRELESS 1
#define CONFIG_WEXT_PROC 1
#define <API key> 1
#define <API key> "iso8859-1"
#define CONFIG_FRAME_WARN 1024
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> ""
#define <API key> 1
#define CONFIG_CGROUPS 1
#define CONFIG_MMC 1
#define CONFIG_SDMMC1_RK29 1
#define CONFIG_HID_LOGITECH 1
#define <API key> 1
#define CONFIG_STACKTRACE 1
#define CONFIG_PPPOLAC 1
#define <API key> "kpanic"
#define CONFIG_VIDEO_RK29 1
#define <API key> 1
#define CONFIG_UART0_RK29 1
#define CONFIG_HAS_IOPORT 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HZ 100
#define CONFIG_USB20_OTG_EN 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> "cfq"
#define <API key> 1
#define CONFIG_IPV6_MIP6 1
#define <API key> 1
#define CONFIG_NLATTR 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NR_CPUS 2
#define <API key> 1
#define <API key> 1
#define CONFIG_LOGITECH_FF 1
#define CONFIG_HID_KYE 1
#define CONFIG_SYSFS 1
#define <API key> 1
#define <API key> 1
#define CONFIG_ARM_THUMB 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_FB 1
#define CONFIG_TRACING 1
#define CONFIG_CPU_32v7 1
#define CONFIG_ADC 1
#define <API key> 1
#define <API key> 2
#define CONFIG_BT_HCIUART 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_HID_PETALYNX 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 0
#define <API key> 1
#define CONFIG_RPS 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_VIDEO_MEDIA 1
#define CONFIG_IP_MULTICAST 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_CPU_32v6K 1
#define <API key> ""
#define CONFIG_TICK_ONESHOT 1
#define <API key> 1
#define CONFIG_CGROUP_DEBUG 1
#define CONFIG_WIRELESS_EXT 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_BASE_SMALL 0
#define <API key> 1
#define CONFIG_COMPACTION 1
#define CONFIG_PROC_FS 1
#define CONFIG_MTD_BLOCK 1
#define CONFIG_RC_MAP 1
#define CONFIG_WEXT_PRIV 1
#define <API key> 1
#define <API key> 1
#define CONFIG_SND 1
#define CONFIG_FLATMEM 1
#define <API key> 1
#define <API key> 0
#define <API key> 1
#define <API key> 1
#define CONFIG_SYSCTL 1
#define CONFIG_PLAT_RK 1
#define CONFIG_LOCAL_TIMERS 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_XFRM_USER 1
#define <API key> 1
#define CONFIG_PPP_ASYNC 1
#define CONFIG_UID_STAT 1
#define CONFIG_GS_KXTIK 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_IDBLOCK 1
#define CONFIG_HID_ELECOM 1
#define CONFIG_SND_TIMER 1
#define <API key> 437
#define CONFIG_BLK_DEV 1
#define <API key> 1
#define <API key> 1
#define CONFIG_UNIX98_PTYS 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NET_SCHED 1
#define CONFIG_JBD 1
#define CONFIG_PRINTK_TIME 1
#define CONFIG_PPP 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_INET_DIAG 1
#define CONFIG_I2C1_RK30 1
#define CONFIG_NF_NAT_FTP 1
#define <API key> 1
#define <API key> 1
#define CONFIG_TEXTSEARCH 1
#define CONFIG_ADC_RK30 1
#define CONFIG_USB_SUPPORT 1
#define <API key> 1
#define CONFIG_RK_HDMI 1
#define CONFIG_PL330 1
#define CONFIG_LIGHT_DEVICE 1
#define CONFIG_STAGING 1
#define CONFIG_MTD_CHAR 1
#define <API key> 1
#define CONFIG_VT_CONSOLE 1
#define CONFIG_HID_UCLOGIC 1
#define CONFIG_LEDS_GPIO 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_USB20_OTG 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_PREEMPT 1
#define <API key> 1
#define <API key> 1
#define CONFIG_RK_SRAM_DMA 1
#define <API key> 1
#define CONFIG_VIDEOBUF_GEN 1
#define CONFIG_VIDEO_V4L2 1
#define CONFIG_HID_NTRIG 1
#define <API key> 336
#define <API key> 1
#define CONFIG_SDMMC_RK29 1
#define CONFIG_LLC 1
#define <API key> ""
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_USB_USBNET 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_TPS65910_RTC 1
#define CONFIG_NEW_LEDS 1
#define CONFIG_SWAP 1
#define CONFIG_CRC_CCITT 1
#define CONFIG_BLK_DEV_SD 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_USB_DWC_OTG 1
#define <API key> 1
#define CONFIG_RCU_FANOUT 32
#define CONFIG_BITREVERSE 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define CONFIG_NF_CONNTRACK 1
#define CONFIG_FILE_LOCKING 1
#define <API key> 1
#define CONFIG_FIQ 1
#define <API key> 1
#define CONFIG_NET_EMATCH 1
#define <API key> 1
#define CONFIG_LEDS_CLASS 1
#define <API key> 1
#define CONFIG_RTC_INTF_DEV 1
#define <API key> 1
#define CONFIG_HID_SUPPORT 1
#define <API key> 1
#define CONFIG_NLS_DEFAULT "iso8859-1"
#define <API key> 1
#define CONFIG_ION_ROCKCHIP 1
#define <API key> 1
#define CONFIG_CRYPTO_AEAD2 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 0x0
#define <API key> 1
#define CONFIG_INPUT 1
#define CONFIG_PROC_SYSCTL 1
#define CONFIG_MMU 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
#define <API key> 1
|
/**
* @file
* AAC decoder data
* @author Oded Shimon ( ods15 ods15 dyndns org )
* @author Maxim Gavrilov ( maxim.gavrilov gmail com )
*/
#ifndef AVCODEC_AACDECTAB_H
#define AVCODEC_AACDECTAB_H
#include "libavutil/audioconvert.h"
#include "aac.h"
#include <stdint.h>
/* @name ltp_coef
* Table of the LTP coefficients
*/
static const float ltp_coef[8] = {
0.570829, 0.696616, 0.813004, 0.911304,
0.984900, 1.067894, 1.194601, 1.369533,
};
/* @name tns_tmp2_map
* Tables of the tmp2[] arrays of LPC coefficients used for TNS.
* The suffix _M_N[] indicate the values of coef_compress and coef_res
* respectively.
* @{
*/
static const float tns_tmp2_map_1_3[4] = {
0.00000000, -0.43388373, 0.64278758, 0.34202015,
};
static const float tns_tmp2_map_0_3[8] = {
0.00000000, -0.43388373, -0.78183150, -0.97492790,
0.98480773, 0.86602539, 0.64278758, 0.34202015,
};
static const float tns_tmp2_map_1_4[8] = {
0.00000000, -0.20791170, -0.40673664, -0.58778524,
0.67369562, 0.52643216, 0.36124167, 0.18374951,
};
static const float tns_tmp2_map_0_4[16] = {
0.00000000, -0.20791170, -0.40673664, -0.58778524,
-0.74314481, -0.86602539, -0.95105654, -0.99452192,
0.99573416, 0.96182561, 0.89516330, 0.79801720,
0.67369562, 0.52643216, 0.36124167, 0.18374951,
};
static const float * const tns_tmp2_map[4] = {
tns_tmp2_map_0_3,
tns_tmp2_map_0_4,
tns_tmp2_map_1_3,
tns_tmp2_map_1_4
};
static const int8_t tags_per_config[16] = { 0, 1, 1, 2, 3, 3, 4, 5, 0, 0, 0, 0, 0, 0, 0, 0 };
static const uint8_t <API key>[7][5][2] = {
{ { TYPE_SCE, 0 }, },
{ { TYPE_CPE, 0 }, },
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, },
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_SCE, 1 }, },
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_CPE, 1 }, },
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 1 }, },
{ { TYPE_CPE, 0 }, { TYPE_SCE, 0 }, { TYPE_LFE, 0 }, { TYPE_CPE, 2 }, { TYPE_CPE, 1 }, },
};
static const int64_t aac_channel_layout[8] = {
AV_CH_LAYOUT_MONO,
AV_CH_LAYOUT_STEREO,
<API key>,
<API key>,
<API key>,
<API key>,
<API key>,
0,
};
#endif /* AVCODEC_AACDECTAB_H */
|
template <typename Item>
void mergesort(Item a[], int l, int r)
{
if (r <= 1) return ;
int m = (r+1)/2;
mergesort(a, l, m);
mergesort(a, m+1, r);
merge(a, l, m, r);
}
|
#include <dcopclient.h>
#include <kapplication.h>
#include <kprocess.h>
#include <kstaticdeleter.h>
#include "watcher_stub.h"
#include "mrml_utils.h"
// after 100 of no use, terminate the mrmld
#define TIMEOUT 100
// how often to restart the mrmld in case of failure
#define NUM_RESTARTS 5
using namespace KMrml;
KStaticDeleter<Util> utils_sd;
Util *Util::s_self = 0L;
Util::Util()
{
// we need our own dcopclient, when used in kio_mrml
if ( !DCOPClient::mainClient() )
{
DCOPClient::setMainClient( new DCOPClient() );
if ( !DCOPClient::mainClient()->attach() )
qWarning( "kio_mrml: Can't attach to DCOP Server.");
}
}
Util::~Util()
{
if ( this == s_self )
s_self = 0L;
}
Util *Util::self()
{
if ( !s_self )
s_self = utils_sd.setObject( new Util() );
return s_self;
}
bool Util::<API key>( const KURL& url )
{
return url.host().isEmpty() || url.host() == "localhost";
}
bool Util::startLocalServer( const Config& config )
{
if ( config.<API key>() )
return true;
DCOPClient *client = DCOPClient::mainClient();
// ### check if it's already running (add dcop method to Watcher)
Watcher_stub watcher( client, "kded", "daemonwatcher");
return ( watcher.requireDaemon( client->appId(),
"mrmld", config.mrmldCommandline(),
TIMEOUT, NUM_RESTARTS )
&& watcher.ok() );
}
void Util::<API key>()
{
DCOPClient *client = DCOPClient::mainClient();
Watcher_stub watcher( client, "kded", "daemonwatcher");
watcher.unrequireDaemon( client->appId(), "mrmld" );
}
|
# -*- coding: utf-8 -*-
## This file is part of Invenio.
## Invenio is free software; you can redistribute it and/or
## published by the Free Software Foundation; either version 2 of the
## Invenio is distributed in the hope that it will be useful, but
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## along with Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
"""Unit tests for the ranking engine."""
__revision__ = "$Id$"
from invenio.importutils import lazy_import
from invenio.testutils import make_test_suite, run_test_suite, InvenioTestCase
<API key> = lazy_import('invenio.<API key>')
split_ranges = lazy_import('invenio.bibrank:split_ranges')
class <API key>(InvenioTestCase):
"""Test list set operations."""
def test_union_dicts(self):
"""bibrank tag based indexer - union dicts"""
self.assertEqual({1: 5, 2: 6, 3: 9, 4: 10, 10: 1}, <API key>.union_dicts({1: 5, 2: 6, 3: 9}, {3:9, 4:10, 10: 1}))
def test_split_ranges(self):
"""bibrank tag based indexer - split ranges"""
self.assertEqual([[0, 500], [600, 1000]], split_ranges("0-500,600-1000"))
TEST_SUITE = make_test_suite(<API key>,)
if __name__ == "__main__":
run_test_suite(TEST_SUITE)
|
layout: post
title: For Rusty - 1988 - 2004
author: Chris Metcalf
date: 2004/04/21
slug: for-rusty-1988-2004
category:
tags: [ dogs, family, me ]
Today we had to say goodbye to a loyal friend.
<img src="/images/posts/rusty.jpg" alt="an old friend" />
Today we had to put one of our family's favorite pets to sleep. As he approached the ripe old age of 16, age had simply taken too much of a toll on him. He had a long, full life of deer and bunny chasing, and we're all sure he's much happier now.
I decided I'd blog the occasion to make sure I always remembered him. The most loyal of friends deserve that.
|
#include "system.h"
#include "conf.h"
#include "connection.h"
#include "logger.h"
#include "net.h"
#include "netutl.h"
#include "node.h"
#include "protocol.h"
#include "subnet.h"
#include "utils.h"
#include "xalloc.h"
bool send_add_subnet(connection_t *c, const subnet_t *subnet) {
char netstr[MAXNETSTR];
if(!net2str(netstr, sizeof netstr, subnet))
return false;
return send_request(c, "%d %x %s %s", ADD_SUBNET, rand(), subnet->owner->name, netstr);
}
bool add_subnet_h(connection_t *c, const char *request) {
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
node_t *owner;
subnet_t s, *new, *old;
memset(&s, 0x0, sizeof(subnet_t));
if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "ADD_SUBNET", c->name,
c->hostname);
return false;
}
/* Check if owner name is valid */
if(!check_id(name)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name,
c->hostname, "invalid name");
return false;
}
/* Check if subnet string is valid */
if(!str2net(&s, subnetstr)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "ADD_SUBNET", c->name,
c->hostname, "invalid subnet string");
return false;
}
if(seen_request(request))
return true;
/* Check if the owner of the new subnet is in the connection list */
owner = lookup_node(name);
if(tunnelserver && owner != myself && owner != c->node) {
/* in case of tunnelserver, ignore indirect subnet registrations */
logger(DEBUG_PROTOCOL, LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s",
"ADD_SUBNET", c->name, c->hostname, subnetstr);
return true;
}
if(!owner) {
owner = new_node();
owner->name = xstrdup(name);
node_add(owner);
}
/* Check if we already know this subnet */
if(lookup_subnet(owner, &s))
return true;
/* If we don't know this subnet, but we are the owner, retaliate with a DEL_SUBNET */
if(owner == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself",
"ADD_SUBNET", c->name, c->hostname);
s.owner = myself;
send_del_subnet(c, &s);
return true;
}
/* In tunnel server mode, we should already know all allowed subnets */
if(tunnelserver) {
logger(DEBUG_ALWAYS, LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s",
"ADD_SUBNET", c->name, c->hostname, subnetstr);
return true;
}
/* Ignore if strictsubnets is true, but forward it to others */
if(strictsubnets) {
logger(DEBUG_ALWAYS, LOG_WARNING, "Ignoring unauthorized %s from %s (%s): %s",
"ADD_SUBNET", c->name, c->hostname, subnetstr);
if ((!owner->status.reachable) && ((now.tv_sec - owner->last_state_change) >= keylifetime*2)) {
logger(DEBUG_CONNECTIONS, LOG_INFO, "Not forwarding informations about %s to ALL (%lf / %d)", owner->name, difftime(now.tv_sec, owner->last_state_change), keylifetime);
} else {
forward_request(c, request);
}
return true;
}
/* If everything is correct, add the subnet to the list of the owner */
*(new = new_subnet()) = s;
subnet_add(owner, new);
if(owner->status.reachable)
subnet_update(owner, new, true);
/* Tell the rest */
if(!tunnelserver)
forward_request(c, request);
/* Fast handoff of roaming MAC addresses */
if(s.type == SUBNET_MAC && owner != myself && (old = lookup_subnet(myself, &s)) && old->expires)
old->expires = 1;
return true;
}
bool send_del_subnet(connection_t *c, const subnet_t *s) {
char netstr[MAXNETSTR];
if(!net2str(netstr, sizeof netstr, s))
return false;
return send_request(c, "%d %x %s %s", DEL_SUBNET, rand(), s->owner->name, netstr);
}
bool del_subnet_h(connection_t *c, const char *request) {
char subnetstr[MAX_STRING_SIZE];
char name[MAX_STRING_SIZE];
node_t *owner;
subnet_t s, *find;
memset(&s, 0x0, sizeof(subnet_t));
if(sscanf(request, "%*d %*x " MAX_STRING " " MAX_STRING, name, subnetstr) != 2) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s)", "DEL_SUBNET", c->name,
c->hostname);
return false;
}
/* Check if owner name is valid */
if(!check_id(name)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name,
c->hostname, "invalid name");
return false;
}
/* Check if subnet string is valid */
if(!str2net(&s, subnetstr)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Got bad %s from %s (%s): %s", "DEL_SUBNET", c->name,
c->hostname, "invalid subnet string");
return false;
}
if(seen_request(request))
return true;
/* Check if the owner of the subnet being deleted is in the connection list */
owner = lookup_node(name);
if(tunnelserver && owner != myself && owner != c->node) {
/* in case of tunnelserver, ignore indirect subnet deletion */
logger(DEBUG_PROTOCOL, LOG_WARNING, "Ignoring indirect %s from %s (%s) for %s",
"DEL_SUBNET", c->name, c->hostname, subnetstr);
return true;
}
if(!owner) {
logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for %s which is not in our node tree",
"DEL_SUBNET", c->name, c->hostname, name);
return true;
}
/* If everything is correct, delete the subnet from the list of the owner */
s.owner = owner;
find = lookup_subnet(owner, &s);
if(!find) {
logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for %s which does not appear in his subnet tree",
"DEL_SUBNET", c->name, c->hostname, name);
if(strictsubnets)
forward_request(c, request);
return true;
}
/* If we are the owner of this subnet, retaliate with an ADD_SUBNET */
if(owner == myself) {
logger(DEBUG_PROTOCOL, LOG_WARNING, "Got %s from %s (%s) for ourself",
"DEL_SUBNET", c->name, c->hostname);
send_add_subnet(c, find);
return true;
}
if(tunnelserver)
return true;
/* Tell the rest */
if(!tunnelserver)
forward_request(c, request);
if(strictsubnets)
return true;
/* Finally, delete it. */
if(owner->status.reachable)
subnet_update(owner, find, false);
subnet_del(owner, find);
return true;
}
|
#pragma once
#include "il2cpp-config.h"
#ifndef _MSC_VER
# include <alloca.h>
#else
# include <malloc.h>
#endif
#include <stdint.h>
#include <assert.h>
#include <exception>
// System.Reflection.Emit.ModuleBuilder
struct ModuleBuilder_t973;
// System.Object
struct Object_t;
// System.Type[]
struct TypeU5BU5D_t194;
// System.Reflection.MemberInfo
struct MemberInfo_t;
// System.Reflection.Emit.TokenGenerator
struct TokenGenerator_t970;
#include "codegen/il2cpp-codegen.h"
// System.Void System.Reflection.Emit.ModuleBuilder::.cctor()
extern "C" void <API key> (Object_t * __this /* static, unused */, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 System.Reflection.Emit.ModuleBuilder::<API key>(System.Object,System.Int32,System.Boolean)
extern "C" int32_t <API key> (ModuleBuilder_t973 * __this, Object_t * ___obj, int32_t ___table, bool ___inc, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Type[] System.Reflection.Emit.ModuleBuilder::GetTypes()
extern "C" TypeU5BU5D_t194* <API key> (ModuleBuilder_t973 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 System.Reflection.Emit.ModuleBuilder::getToken(System.Reflection.Emit.ModuleBuilder,System.Object)
extern "C" int32_t <API key> (Object_t * __this /* static, unused */, ModuleBuilder_t973 * ___mb, Object_t * ___obj, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Int32 System.Reflection.Emit.ModuleBuilder::GetToken(System.Reflection.MemberInfo)
extern "C" int32_t <API key> (ModuleBuilder_t973 * __this, MemberInfo_t * ___member, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Void System.Reflection.Emit.ModuleBuilder::RegisterToken(System.Object,System.Int32)
extern "C" void <API key> (ModuleBuilder_t973 * __this, Object_t * ___obj, int32_t ___token, const MethodInfo* method) IL2CPP_METHOD_ATTR;
// System.Reflection.Emit.TokenGenerator System.Reflection.Emit.ModuleBuilder::GetTokenGenerator()
extern "C" Object_t * <API key> (ModuleBuilder_t973 * __this, const MethodInfo* method) IL2CPP_METHOD_ATTR;
|
<?php
class <API key> extends <API key> implements <API key>
{
/**
* Initializes the options for the object
*
* Called from {@link __construct()} as a first step of object instantiation.
*
* @param object An optional KConfig object with configuration options
* @return void
*/
protected function _initialize(KConfig $config)
{
$config->append(array(
'priority' => KCommand::PRIORITY_LOW,
));
parent::_initialize($config);
}
/**
* Find any <module></module> elements and inject them into the JDocument object
*
* @param string Block of text to parse
*
* @return void
*/
public function write(&$text)
{
$matches = array();
if(preg_match_all('#<module([^>]*)>(.*)</module>#siU', $text, $matches))
{
$modules = array();
foreach($matches[0] as $key => $match)
{
$text = str_replace($match, '', $text);
$attributes = array(
'style' => 'default',
'params' => '',
'title' => '',
'class' => '',
'prepend' => true
);
$attributes = array_merge($attributes, $this->_parseAttributes($matches[1][$key]));
if ( !empty($attributes['class']) ) {
$attributes['params'] .= ' moduleclass_sfx= '.$attributes['class'];
}
$module = new KObject();
$module->id = uniqid();
$module->content = $matches[2][$key];
$module->position = $attributes['position'];
$module->params = $attributes['params'];
$module->showtitle = !empty($attributes['title']);
$module->title = $attributes['title'];
$module->name = $attributes['position'];
$module->attribs = $attributes;
$module->user = 0;
$module->module = 'mod_dynamic';
$modules[] = $module;
}
$mods =& JModuleHelper::_load();
$mods = array_merge($modules, $mods);
}
return $this;
}
}
|
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Joomla! Debug plugin
*
* @author Johan Janssens <johan.janssens@joomla.org>
* @package Joomla
* @subpackage System
*/
class plgSystemLegacy extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function plgSystemLegacy(& $subject, $config)
{
parent::__construct($subject, $config);
global $mainframe;
// Define the 1.0 legacy mode constant
define('_JLEGACY', '1.0');
// Set global configuration var for legacy mode
$config = &JFactory::getConfig();
$config->setValue('config.legacy', 1);
// Import library dependencies
require_once(dirname(__FILE__).DS.'legacy'.DS.'classes.php');
require_once(dirname(__FILE__).DS.'legacy'.DS.'functions.php');
// Register legacy classes for autoloading
JLoader::register('mosAdminMenus' , dirname(__FILE__).DS.'legacy'.DS.'adminmenus.php');
JLoader::register('mosCache' , dirname(__FILE__).DS.'legacy'.DS.'cache.php');
JLoader::register('mosCategory' , dirname(__FILE__).DS.'legacy'.DS.'category.php');
JLoader::register('mosCommonHTML' , dirname(__FILE__).DS.'legacy'.DS.'commonhtml.php');
JLoader::register('mosComponent' , dirname(__FILE__).DS.'legacy'.DS.'component.php');
JLoader::register('mosContent' , dirname(__FILE__).DS.'legacy'.DS.'content.php');
JLoader::register('mosDBTable' , dirname(__FILE__).DS.'legacy'.DS.'dbtable.php');
JLoader::register('mosHTML' , dirname(__FILE__).DS.'legacy'.DS.'html.php');
JLoader::register('mosInstaller' , dirname(__FILE__).DS.'legacy'.DS.'installer.php');
JLoader::register('mosMainFrame' , dirname(__FILE__).DS.'legacy'.DS.'mainframe.php');
JLoader::register('mosMambot' , dirname(__FILE__).DS.'legacy'.DS.'mambot.php');
JLoader::register('mosMambotHandler', dirname(__FILE__).DS.'legacy'.DS.'mambothandler.php');
JLoader::register('mosMenu' , dirname(__FILE__).DS.'legacy'.DS.'menu.php');
JLoader::register('mosMenuBar' , dirname(__FILE__).DS.'legacy'.DS.'menubar.php');
JLoader::register('mosModule' , dirname(__FILE__).DS.'legacy'.DS.'module.php');
//JLoader::register('mosPageNav' , dirname(__FILE__).DS.'legacy'.DS.'pagination.php');
JLoader::register('mosParameters' , dirname(__FILE__).DS.'legacy'.DS.'parameters.php');
JLoader::register('patFactory' , dirname(__FILE__).DS.'legacy'.DS.'patfactory.php');
JLoader::register('mosProfiler' , dirname(__FILE__).DS.'legacy'.DS.'profiler.php');
JLoader::register('mosSection' , dirname(__FILE__).DS.'legacy'.DS.'section.php');
JLoader::register('mosSession' , dirname(__FILE__).DS.'legacy'.DS.'session.php');
JLoader::register('mosToolbar' , dirname(__FILE__).DS.'legacy'.DS.'toolbar.php');
JLoader::register('mosUser' , dirname(__FILE__).DS.'legacy'.DS.'user.php');
// Register class for the database, depends on which db type has been selected for use
$dbtype = $config->getValue('config.dbtype', 'mysql');
JLoader::register('database' , dirname(__FILE__).DS.'legacy'.DS.$dbtype.'.php');
/**
* Legacy define, _ISO define not used anymore. All output is forced as utf-8.
* @deprecated As of version 1.5
*/
define('_ISO','charset=utf-8');
/**
* Legacy constant, use _JEXEC instead
* @deprecated As of version 1.5
*/
define( '_VALID_MOS', 1 );
/**
* Legacy constant, use _JEXEC instead
* @deprecated As of version 1.5
*/
define( '_MOS_MAMBO_INCLUDED', 1 );
/**
* Legacy constant, use DATE_FORMAT_LC instead
* @deprecated As of version 1.5
*/
DEFINE('_DATE_FORMAT_LC', JText::_('DATE_FORMAT_LC1') ); //Uses PHP's strftime Command Format
/**
* Legacy constant, use DATE_FORMAT_LC2 instead
* @deprecated As of version 1.5
*/
DEFINE('_DATE_FORMAT_LC2', JText::_('DATE_FORMAT_LC2'));
/**
* Legacy constant, use JFilterInput instead
* @deprecated As of version 1.5
*/
DEFINE( "_MOS_NOTRIM", 0x0001 );
/**
* Legacy constant, use JFilterInput instead
* @deprecated As of version 1.5
*/
DEFINE( "_MOS_ALLOWHTML", 0x0002 );
/**
* Legacy constant, use JFilterInput instead
* @deprecated As of version 1.5
*/
DEFINE( "_MOS_ALLOWRAW", 0x0004 );
/**
* Legacy global, use JVersion->getLongVersion() instead
* @name $_VERSION
* @deprecated As of version 1.5
*/
$GLOBALS['_VERSION'] = new JVersion();
$version = $GLOBALS['_VERSION']->getLongVersion();
/**
* Legacy global, use JFactory::getDBO() instead
* @name $database
* @deprecated As of version 1.5
*/
$conf =& JFactory::getConfig();
$GLOBALS['database'] = new database($conf->getValue('config.host'), $conf->getValue('config.user'), $conf->getValue('config.password'), $conf->getValue('config.db'), $conf->getValue('config.dbprefix'));
$GLOBALS['database']->debug($conf->getValue('config.debug'));
/**
* Legacy global, use JFactory::getUser() [JUser object] instead
* @name $my
* @deprecated As of version 1.5
*/
$user =& JFactory::getUser();
$GLOBALS['my'] = (object)$user->getProperties();
$GLOBALS['my']->gid = $user->get('aid', 0);
/**
* Insert configuration values into global scope (for backwards compatibility)
* @deprecated As of version 1.5
*/
$temp = new JConfig;
foreach (get_object_vars($temp) as $k => $v) {
$name = 'mosConfig_'.$k;
$GLOBALS[$name] = $v;
}
$GLOBALS['mosConfig_live_site'] = substr_replace(JURI::root(), '', -1, 1);
$GLOBALS['<API key>'] = JPATH_SITE;
$GLOBALS['mosConfig_cachepath'] = JPATH_BASE.DS.'cache';
$GLOBALS['<API key>'] = 0;
$lang =& JFactory::getLanguage();
$GLOBALS['mosConfig_lang'] = $lang->getBackwardLang();
$config->setValue('config.live_site', $GLOBALS['mosConfig_live_site']);
$config->setValue('config.absolute_path', $GLOBALS['<API key>']);
$config->setValue('config.lang', $GLOBALS['mosConfig_lang']);
/**
* Legacy global, use JFactory::getUser() instead
* @name $acl
* @deprecated As of version 1.5
*/
$acl =& JFactory::getACL();
// Legacy ACL's for backward compat
$acl->addACL( 'administration', 'edit', 'users', 'super administrator', 'components', 'all' );
$acl->addACL( 'administration', 'edit', 'users', 'administrator', 'components', 'all' );
$acl->addACL( 'administration', 'edit', 'users', 'super administrator', 'user properties', 'block_user' );
$acl->addACL( 'administration', 'manage', 'users', 'super administrator', 'components', 'com_users' );
$acl->addACL( 'administration', 'manage', 'users', 'administrator', 'components', 'com_users' );
$acl->addACL( 'administration', 'config', 'users', 'super administrator' );
//$acl->addACL( 'administration', 'config', 'users', 'administrator' );
$acl->addACL( 'action', 'add', 'users', 'author', 'content', 'all' );
$acl->addACL( 'action', 'add', 'users', 'editor', 'content', 'all' );
$acl->addACL( 'action', 'add', 'users', 'publisher', 'content', 'all' );
$acl->addACL( 'action', 'edit', 'users', 'author', 'content', 'own' );
$acl->addACL( 'action', 'edit', 'users', 'editor', 'content', 'all' );
$acl->addACL( 'action', 'edit', 'users', 'publisher', 'content', 'all' );
$acl->addACL( 'action', 'publish', 'users', 'publisher', 'content', 'all' );
$acl->addACL( 'action', 'add', 'users', 'manager', 'content', 'all' );
$acl->addACL( 'action', 'edit', 'users', 'manager', 'content', 'all' );
$acl->addACL( 'action', 'publish', 'users', 'manager', 'content', 'all' );
$acl->addACL( 'action', 'add', 'users', 'administrator', 'content', 'all' );
$acl->addACL( 'action', 'edit', 'users', 'administrator', 'content', 'all' );
$acl->addACL( 'action', 'publish', 'users', 'administrator', 'content', 'all' );
$acl->addACL( 'action', 'add', 'users', 'super administrator', 'content', 'all' );
$acl->addACL( 'action', 'edit', 'users', 'super administrator', 'content', 'all' );
$acl->addACL( 'action', 'publish', 'users', 'super administrator', 'content', 'all' );
$acl->addACL( 'com_syndicate', 'manage', 'users', 'super administrator' );
$acl->addACL( 'com_syndicate', 'manage', 'users', 'administrator' );
$acl->addACL( 'com_syndicate', 'manage', 'users', 'manager' );
$GLOBALS['acl'] =& $acl;
/**
* Legacy global
* @name $task
* @deprecated As of version 1.5
*/
$GLOBALS['task'] = JRequest::getString('task');
/**
* Load the site language file (the old way - to be deprecated)
* @deprecated As of version 1.5
*/
global $mosConfig_lang;
$mosConfig_lang = JFilterInput::clean($mosConfig_lang, 'cmd');
$file = JPATH_SITE.DS.'language'.DS.$mosConfig_lang.'.php';
if (file_exists( $file )) {
require_once( $file);
} else {
$file = JPATH_SITE.DS.'language'.DS.'english.php';
if (file_exists( $file )) {
require_once( $file );
}
}
/**
* Legacy global
* use JApplicaiton->registerEvent and JApplication->triggerEvent for event handling
* use JPlugingHelper::importPlugin to load bot code
* @deprecated As of version 1.5
*/
$GLOBALS['_MAMBOTS'] = new mosMambotHandler();
}
function onAfterRoute()
{
global $mainframe;
if ($mainframe->isAdmin()) {
return;
}
switch(JRequest::getCmd('option'))
{
case 'com_content' :
$this->routeContent();
break;
case 'com_newsfeeds' :
$this->routeNewsfeeds();
break;
case 'com_weblinks' :
$this->routeWeblinks();
break;
case 'com_frontpage' :
JRequest::setVar('option', 'com_content');
JRequest::setVar('view', 'frontpage');
break;
case 'com_login' :
JRequest::setVar('option', 'com_user');
JRequest::setVar('view', 'login');
break;
case 'com_registration' :
JRequest::setVar('option', 'com_user');
JRequest::setVar('view', 'register');
break;
}
/**
* Legacy global, use JApplication::getTemplate() instead
* @name $cur_template
* @deprecated As of version 1.5
*/
$GLOBALS['cur_template'] = $mainframe->getTemplate();
}
function routeContent()
{
$viewName = JRequest::getCmd( 'view', 'article' );
$layout = JRequest::getCmd( 'layout', 'default' );
// interceptors to support legacy urls
switch( JRequest::getCmd('task'))
{
//index.php?option=com_content&task=x&id=x&Itemid=x
case 'blogsection':
$viewName = 'section';
$layout = 'blog';
break;
case 'section':
$viewName = 'section';
break;
case 'category':
$viewName = 'category';
break;
case 'blogcategory':
$viewName = 'category';
$layout = 'blog';
break;
case 'archivesection':
case 'archivecategory':
$viewName = 'archive';
break;
case 'frontpage' :
$viewName = 'frontpage';
break;
case 'view':
$viewName = 'article';
break;
}
JRequest::setVar('layout', $layout);
JRequest::setVar('view', $viewName);
}
function routeNewsfeeds()
{
$viewName = JRequest::getCmd( 'view', 'categories' );
// interceptors to support legacy urls
switch( JRequest::getCmd('task'))
{
//index.php?option=com_newsfeeds&task=x&catid=xid=x&Itemid=x
case 'view':
$viewName = 'newsfeed';
break;
default:
{
if(JRequest::getInt('catid') && !JRequest::getCmd('view')) {
$viewName = 'category';
}
}
}
JRequest::setVar('view', $viewName);
}
function routeWeblinks()
{
$viewName = JRequest::getCmd( 'view', 'categories' );
// interceptors to support legacy urls
switch( JRequest::getCmd('task'))
{
//index.php?option=com_weblinks&task=x&catid=xid=x
case 'view':
$viewName = 'weblink';
break;
default:
{
if(($catid = JRequest::getInt('catid')) && !JRequest::getCmd('view')) {
$viewName = 'category';
JRequest::setVar('id', $catid);
}
}
}
JRequest::setVar('view', $viewName);
}
}
|
def spaceship_building(cans):
total_cans = 0
for week in range(1,53):
total_cans = total_cans + cans
print('Week %s = %s cans' % (week, total_cans))
spaceship_building(2)
spaceship_building(13)
|
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2015-12-24 15:28
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('emailer', '<API key>'),
]
operations = [
migrations.AlterField(
model_name='email',
name='recipient',
field=models.EmailField(db_index=True, max_length=254),
),
]
|
<html>
<head>
<title>Stożek</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../books.css" />
</head>
<body align="left">
<h1>Stożek</h1>
<center><img src="../images/cone.png" /></center>
<br />
<div align="left">
<a href="file:#V=(1/3)*pi*r%5e2*h">V = (1/3) * pi * r^2 * h</a><br />
<br />
<a href="file:#A=(pi*r%5e2)+(pi*r*s)">A = (pi * r^2) + (pi * r * s)</a><br />
<a href="file:#A=(pi*r%5e2)+(pi*r*sqrt(r%5e2+h%5e2))">A = (pi * r^2) + (pi * r * sqrt(r^2 + h^2))</a><br />
</div>
</body>
</html>
|
#include "cache.h"
#include "commit.h"
#include "refs.h"
#include "quote.h"
#include "builtin.h"
#include "parse-options.h"
#include "diff.h"
#include "revision.h"
#include "split-index.h"
#define DO_REVS 1
#define DO_NOREV 2
#define DO_FLAGS 4
#define DO_NONFLAGS 8
static int filter = ~0;
static const char *def;
#define NORMAL 0
#define REVERSED 1
static int show_type = NORMAL;
#define SHOW_SYMBOLIC_ASIS 1
#define SHOW_SYMBOLIC_FULL 2
static int symbolic;
static int abbrev;
static int abbrev_ref;
static int abbrev_ref_strict;
static int output_sq;
static int stuck_long;
static struct string_list *ref_excludes;
/*
* Some arguments are relevant "revision" arguments,
* others are about output format or other details.
* This sorts it all out.
*/
static int is_rev_argument(const char *arg)
{
static const char *rev_args[] = {
"--all",
"--bisect",
"--dense",
"--branches=",
"--branches",
"--header",
"--ignore-missing",
"--max-age=",
"--max-count=",
"--min-age=",
"--no-merges",
"--min-parents=",
"--no-min-parents",
"--max-parents=",
"--no-max-parents",
"--objects",
"--objects-edge",
"--parents",
"--pretty",
"--remotes=",
"--remotes",
"--glob=",
"--sparse",
"--tags=",
"--tags",
"--topo-order",
"--date-order",
"--unpacked",
NULL
};
const char **p = rev_args;
/* accept -<digit>, like traditional "head" */
if ((*arg == '-') && isdigit(arg[1]))
return 1;
for (;;) {
const char *str = *p++;
int len;
if (!str)
return 0;
len = strlen(str);
if (!strcmp(arg, str) ||
(str[len-1] == '=' && !strncmp(arg, str, len)))
return 1;
}
}
/* Output argument as a string, either SQ or normal */
static void show(const char *arg)
{
if (output_sq) {
int sq = '\'', ch;
putchar(sq);
while ((ch = *arg++)) {
if (ch == sq)
fputs("'\\'", stdout);
putchar(ch);
}
putchar(sq);
putchar(' ');
}
else
puts(arg);
}
/* Like show(), but with a negation prefix according to type */
static void show_with_type(int type, const char *arg)
{
if (type != show_type)
putchar('^');
show(arg);
}
/* Output a revision, only if filter allows it */
static void show_rev(int type, const unsigned char *sha1, const char *name)
{
if (!(filter & DO_REVS))
return;
def = NULL;
if ((symbolic || abbrev_ref) && name) {
if (symbolic == SHOW_SYMBOLIC_FULL || abbrev_ref) {
unsigned char discard[20];
char *full;
switch (dwim_ref(name, strlen(name), discard, &full)) {
case 0:
/*
* Not found -- not a ref. We could
* emit "name" here, but symbolic-full
* users are interested in finding the
* refs spelled in full, and they would
* need to filter non-refs if we did so.
*/
break;
case 1: /* happy */
if (abbrev_ref)
full = <API key>(full,
abbrev_ref_strict);
show_with_type(type, full);
break;
default: /* ambiguous */
error("refname '%s' is ambiguous", name);
break;
}
free(full);
} else {
show_with_type(type, name);
}
}
else if (abbrev)
show_with_type(type, find_unique_abbrev(sha1, abbrev));
else
show_with_type(type, sha1_to_hex(sha1));
}
/* Output a flag, only if filter allows it. */
static int show_flag(const char *arg)
{
if (!(filter & DO_FLAGS))
return 0;
if (filter & (is_rev_argument(arg) ? DO_REVS : DO_NOREV)) {
show(arg);
return 1;
}
return 0;
}
static int show_default(void)
{
const char *s = def;
if (s) {
unsigned char sha1[20];
def = NULL;
if (!get_sha1(s, sha1)) {
show_rev(NORMAL, sha1, s);
return 1;
}
}
return 0;
}
static int show_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
{
if (ref_excluded(ref_excludes, refname))
return 0;
show_rev(NORMAL, oid->hash, refname);
return 0;
}
static int anti_reference(const char *refname, const struct object_id *oid, int flag, void *cb_data)
{
show_rev(REVERSED, oid->hash, refname);
return 0;
}
static int show_abbrev(const unsigned char *sha1, void *cb_data)
{
show_rev(NORMAL, sha1, NULL);
return 0;
}
static void show_datestring(const char *flag, const char *datestr)
{
static char buffer[100];
/* date handling requires both flags and revs */
if ((filter & (DO_FLAGS | DO_REVS)) != (DO_FLAGS | DO_REVS))
return;
snprintf(buffer, sizeof(buffer), "%s%lu", flag, approxidate(datestr));
show(buffer);
}
static int show_file(const char *arg, int output_prefix)
{
show_default();
if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
if (output_prefix) {
const char *prefix = startup_info->prefix;
show(prefix_filename(prefix,
prefix ? strlen(prefix) : 0,
arg));
} else
show(arg);
return 1;
}
return 0;
}
static int try_difference(const char *arg)
{
char *dotdot;
unsigned char sha1[20];
unsigned char end[20];
const char *next;
const char *this;
int symmetric;
static const char head_by_default[] = "HEAD";
if (!(dotdot = strstr(arg, "..")))
return 0;
next = dotdot + 2;
this = arg;
symmetric = (*next == '.');
*dotdot = 0;
next += symmetric;
if (!*next)
next = head_by_default;
if (dotdot == arg)
this = head_by_default;
if (this == head_by_default && next == head_by_default &&
!symmetric) {
/*
* Just ".."? That is not a range but the
* pathspec for the parent directory.
*/
*dotdot = '.';
return 0;
}
if (!get_sha1_committish(this, sha1) && !get_sha1_committish(next, end)) {
show_rev(NORMAL, end, next);
show_rev(symmetric ? NORMAL : REVERSED, sha1, this);
if (symmetric) {
struct commit_list *exclude;
struct commit *a, *b;
a = <API key>(sha1);
b = <API key>(end);
exclude = get_merge_bases(a, b);
while (exclude) {
struct commit *commit = pop_commit(&exclude);
show_rev(REVERSED, commit->object.oid.hash, NULL);
}
}
*dotdot = '.';
return 1;
}
*dotdot = '.';
return 0;
}
static int <API key>(const char *arg)
{
char *dotdot;
unsigned char sha1[20];
struct commit *commit;
struct commit_list *parents;
int parents_only;
if ((dotdot = strstr(arg, "^!")))
parents_only = 0;
else if ((dotdot = strstr(arg, "^@")))
parents_only = 1;
if (!dotdot || dotdot[2])
return 0;
*dotdot = 0;
if (get_sha1_committish(arg, sha1)) {
*dotdot = '^';
return 0;
}
if (!parents_only)
show_rev(NORMAL, sha1, arg);
commit = <API key>(sha1);
for (parents = commit->parents; parents; parents = parents->next)
show_rev(parents_only ? NORMAL : REVERSED,
parents->item->object.oid.hash, arg);
*dotdot = '^';
return 1;
}
static int parseopt_dump(const struct option *o, const char *arg, int unset)
{
struct strbuf *parsed = o->value;
if (unset)
strbuf_addf(parsed, " --no-%s", o->long_name);
else if (o->short_name && (o->long_name == NULL || !stuck_long))
strbuf_addf(parsed, " -%c", o->short_name);
else
strbuf_addf(parsed, " --%s", o->long_name);
if (arg) {
if (!stuck_long)
strbuf_addch(parsed, ' ');
else if (o->long_name)
strbuf_addch(parsed, '=');
sq_quote_buf(parsed, arg);
}
return 0;
}
static const char *skipspaces(const char *s)
{
while (isspace(*s))
s++;
return s;
}
static int cmd_parseopt(int argc, const char **argv, const char *prefix)
{
static int keep_dashdash = 0, stop_at_non_option = 0;
static char const * const parseopt_usage[] = {
N_("git rev-parse --parseopt [<options>] -- [<args>...]"),
NULL
};
static struct option parseopt_opts[] = {
OPT_BOOL(0, "keep-dashdash", &keep_dashdash,
N_("keep the `--` passed as an arg")),
OPT_BOOL(0, "stop-at-non-option", &stop_at_non_option,
N_("stop parsing after the "
"first non-option argument")),
OPT_BOOL(0, "stuck-long", &stuck_long,
N_("output in stuck long form")),
OPT_END(),
};
static const char * const flag_chars = "*=?!";
struct strbuf sb = STRBUF_INIT, parsed = STRBUF_INIT;
const char **usage = NULL;
struct option *opts = NULL;
int onb = 0, osz = 0, unb = 0, usz = 0;
strbuf_addstr(&parsed, "set
argc = parse_options(argc, argv, prefix, parseopt_opts, parseopt_usage,
<API key>);
if (argc < 1 || strcmp(argv[0], "
usage_with_options(parseopt_usage, parseopt_opts);
/* get the usage up to the first line with a -- on it */
for (;;) {
if (strbuf_getline(&sb, stdin) == EOF)
die("premature end of input");
ALLOC_GROW(usage, unb + 1, usz);
if (!strcmp("--", sb.buf)) {
if (unb < 1)
die("no usage string given before the `--' separator");
usage[unb] = NULL;
break;
}
usage[unb++] = strbuf_detach(&sb, NULL);
}
/* parse: (<short>|<short>,<long>|<long>)[*=?!]*<arghint>? SP+ <help> */
while (strbuf_getline(&sb, stdin) != EOF) {
const char *s;
const char *help;
struct option *o;
if (!sb.len)
continue;
ALLOC_GROW(opts, onb + 1, osz);
memset(opts + onb, 0, sizeof(opts[onb]));
o = &opts[onb++];
help = strchr(sb.buf, ' ');
if (!help || *sb.buf == ' ') {
o->type = OPTION_GROUP;
o->help = xstrdup(skipspaces(sb.buf));
continue;
}
o->type = OPTION_CALLBACK;
o->help = xstrdup(skipspaces(help));
o->value = &parsed;
o->flags = PARSE_OPT_NOARG;
o->callback = &parseopt_dump;
/* name(s) */
s = strpbrk(sb.buf, flag_chars);
if (s == NULL)
s = help;
if (s - sb.buf == 1) /* short option only */
o->short_name = *sb.buf;
else if (sb.buf[1] != ',') /* long option only */
o->long_name = xmemdupz(sb.buf, s - sb.buf);
else {
o->short_name = *sb.buf;
o->long_name = xmemdupz(sb.buf + 2, s - sb.buf - 2);
}
/* flags */
while (s < help) {
switch (*s++) {
case '=':
o->flags &= ~PARSE_OPT_NOARG;
continue;
case '?':
o->flags &= ~PARSE_OPT_NOARG;
o->flags |= PARSE_OPT_OPTARG;
continue;
case '!':
o->flags |= PARSE_OPT_NONEG;
continue;
case '*':
o->flags |= PARSE_OPT_HIDDEN;
continue;
}
s
break;
}
if (s < help)
o->argh = xmemdupz(s, help - s);
}
strbuf_release(&sb);
/* put an OPT_END() */
ALLOC_GROW(opts, onb + 1, osz);
memset(opts + onb, 0, sizeof(opts[onb]));
argc = parse_options(argc, argv, prefix, opts, usage,
(keep_dashdash ? <API key> : 0) |
(stop_at_non_option ? <API key> : 0) |
<API key>);
strbuf_addstr(&parsed, "
sq_quote_argv(&parsed, argv, 0);
puts(parsed.buf);
return 0;
}
static int cmd_sq_quote(int argc, const char **argv)
{
struct strbuf buf = STRBUF_INIT;
if (argc)
sq_quote_argv(&buf, argv, 0);
printf("%s\n", buf.buf);
strbuf_release(&buf);
return 0;
}
static void die_no_single_rev(int quiet)
{
if (quiet)
exit(1);
else
die("Needed a single revision");
}
static const char <API key>[] =
N_("git rev-parse --parseopt [<options>] -- [<args>...]\n"
" or: git rev-parse --sq-quote [<arg>...]\n"
" or: git rev-parse [<options>] [<arg>...]\n"
"\n"
"Run \"git rev-parse --parseopt -h\" for more information on the first usage.");
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
{
int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
int did_repo_setup = 0;
int has_dashdash = 0;
int output_prefix = 0;
unsigned char sha1[20];
unsigned int flags = 0;
const char *name = NULL;
struct object_context unused;
if (argc > 1 && !strcmp("--parseopt", argv[1]))
return cmd_parseopt(argc - 1, argv + 1, prefix);
if (argc > 1 && !strcmp("--sq-quote", argv[1]))
return cmd_sq_quote(argc - 2, argv + 2);
if (argc > 1 && !strcmp("-h", argv[1]))
usage(<API key>);
for (i = 1; i < argc; i++) {
if (!strcmp(argv[i], "
has_dashdash = 1;
break;
}
}
/* No options; just report on whether we're in a git repo or not. */
if (argc == 1) {
setup_git_directory();
git_config(git_default_config, NULL);
return 0;
}
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (!strcmp(arg, "--local-env-vars")) {
int i;
for (i = 0; local_repo_env[i]; i++)
printf("%s\n", local_repo_env[i]);
continue;
}
if (!strcmp(arg, "--resolve-git-dir")) {
const char *gitdir = argv[++i];
if (!gitdir)
die("--resolve-git-dir requires an argument");
gitdir = resolve_gitdir(gitdir);
if (!gitdir)
die("not a gitdir '%s'", argv[i]);
puts(gitdir);
continue;
}
/* The rest of the options require a git repository. */
if (!did_repo_setup) {
prefix = setup_git_directory();
git_config(git_default_config, NULL);
did_repo_setup = 1;
}
if (!strcmp(arg, "--git-path")) {
if (!argv[i + 1])
die("--git-path requires an argument");
puts(git_path("%s", argv[i + 1]));
i++;
continue;
}
if (as_is) {
if (show_file(arg, output_prefix) && as_is < 2)
verify_filename(prefix, arg, 0);
continue;
}
if (!strcmp(arg,"-n")) {
if (++i >= argc)
die("-n requires an argument");
if ((filter & DO_FLAGS) && (filter & DO_REVS)) {
show(arg);
show(argv[i]);
}
continue;
}
if (starts_with(arg, "-n")) {
if ((filter & DO_FLAGS) && (filter & DO_REVS))
show(arg);
continue;
}
if (*arg == '-') {
if (!strcmp(arg, "
as_is = 2;
/* Pass on the "--" if we show anything but files.. */
if (filter & (DO_FLAGS | DO_REVS))
show_file(arg, 0);
continue;
}
if (!strcmp(arg, "--default")) {
def = argv[++i];
if (!def)
die("--default requires an argument");
continue;
}
if (!strcmp(arg, "--prefix")) {
prefix = argv[++i];
if (!prefix)
die("--prefix requires an argument");
startup_info->prefix = prefix;
output_prefix = 1;
continue;
}
if (!strcmp(arg, "--revs-only")) {
filter &= ~DO_NOREV;
continue;
}
if (!strcmp(arg, "--no-revs")) {
filter &= ~DO_REVS;
continue;
}
if (!strcmp(arg, "--flags")) {
filter &= ~DO_NONFLAGS;
continue;
}
if (!strcmp(arg, "--no-flags")) {
filter &= ~DO_FLAGS;
continue;
}
if (!strcmp(arg, "--verify")) {
filter &= ~(DO_FLAGS|DO_NOREV);
verify = 1;
continue;
}
if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
quiet = 1;
flags |= GET_SHA1_QUIETLY;
continue;
}
if (!strcmp(arg, "--short") ||
starts_with(arg, "--short=")) {
filter &= ~(DO_FLAGS|DO_NOREV);
verify = 1;
abbrev = DEFAULT_ABBREV;
if (arg[7] == '=')
abbrev = strtoul(arg + 8, NULL, 10);
if (abbrev < MINIMUM_ABBREV)
abbrev = MINIMUM_ABBREV;
else if (40 <= abbrev)
abbrev = 40;
continue;
}
if (!strcmp(arg, "--sq")) {
output_sq = 1;
continue;
}
if (!strcmp(arg, "--not")) {
show_type ^= REVERSED;
continue;
}
if (!strcmp(arg, "--symbolic")) {
symbolic = SHOW_SYMBOLIC_ASIS;
continue;
}
if (!strcmp(arg, "--symbolic-full-name")) {
symbolic = SHOW_SYMBOLIC_FULL;
continue;
}
if (starts_with(arg, "--abbrev-ref") &&
(!arg[12] || arg[12] == '=')) {
abbrev_ref = 1;
abbrev_ref_strict = warn_ambiguous_refs;
if (arg[12] == '=') {
if (!strcmp(arg + 13, "strict"))
abbrev_ref_strict = 1;
else if (!strcmp(arg + 13, "loose"))
abbrev_ref_strict = 0;
else
die("unknown mode for %s", arg);
}
continue;
}
if (!strcmp(arg, "--all")) {
for_each_ref(show_reference, NULL);
continue;
}
if (starts_with(arg, "--disambiguate=")) {
for_each_abbrev(arg + 15, show_abbrev, NULL);
continue;
}
if (!strcmp(arg, "--bisect")) {
for_each_ref_in("refs/bisect/bad", show_reference, NULL);
for_each_ref_in("refs/bisect/good", anti_reference, NULL);
continue;
}
if (starts_with(arg, "--branches=")) {
<API key>(show_reference, arg + 11,
"refs/heads/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--branches")) {
for_each_branch_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--tags=")) {
<API key>(show_reference, arg + 7,
"refs/tags/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--tags")) {
for_each_tag_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--glob=")) {
for_each_glob_ref(show_reference, arg + 7, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--remotes=")) {
<API key>(show_reference, arg + 10,
"refs/remotes/", NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (!strcmp(arg, "--remotes")) {
for_each_remote_ref(show_reference, NULL);
clear_ref_exclusion(&ref_excludes);
continue;
}
if (starts_with(arg, "--exclude=")) {
add_ref_exclusion(&ref_excludes, arg + 10);
continue;
}
if (!strcmp(arg, "--show-toplevel")) {
const char *work_tree = get_git_work_tree();
if (work_tree)
puts(work_tree);
continue;
}
if (!strcmp(arg, "--show-prefix")) {
if (prefix)
puts(prefix);
else
putchar('\n');
continue;
}
if (!strcmp(arg, "--show-cdup")) {
const char *pfx = prefix;
if (!is_inside_work_tree()) {
const char *work_tree =
get_git_work_tree();
if (work_tree)
printf("%s\n", work_tree);
continue;
}
while (pfx) {
pfx = strchr(pfx, '/');
if (pfx) {
pfx++;
printf("../");
}
}
putchar('\n');
continue;
}
if (!strcmp(arg, "--git-dir")) {
const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
char *cwd;
int len;
if (gitdir) {
puts(gitdir);
continue;
}
if (!prefix) {
puts(".git");
continue;
}
cwd = xgetcwd();
len = strlen(cwd);
printf("%s%s.git\n", cwd, len && cwd[len-1] != '/' ? "/" : "");
free(cwd);
continue;
}
if (!strcmp(arg, "--git-common-dir")) {
const char *pfx = prefix ? prefix : "";
puts(prefix_filename(pfx, strlen(pfx), get_git_common_dir()));
continue;
}
if (!strcmp(arg, "--is-inside-git-dir")) {
printf("%s\n", is_inside_git_dir() ? "true"
: "false");
continue;
}
if (!strcmp(arg, "--is-inside-work-tree")) {
printf("%s\n", is_inside_work_tree() ? "true"
: "false");
continue;
}
if (!strcmp(arg, "--is-bare-repository")) {
printf("%s\n", is_bare_repository() ? "true"
: "false");
continue;
}
if (!strcmp(arg, "--shared-index-path")) {
if (read_cache() < 0)
die(_("Could not read the index"));
if (the_index.split_index) {
const unsigned char *sha1 = the_index.split_index->base_sha1;
puts(git_path("sharedindex.%s", sha1_to_hex(sha1)));
}
continue;
}
if (starts_with(arg, "--since=")) {
show_datestring("--max-age=", arg+8);
continue;
}
if (starts_with(arg, "--after=")) {
show_datestring("--max-age=", arg+8);
continue;
}
if (starts_with(arg, "--before=")) {
show_datestring("--min-age=", arg+9);
continue;
}
if (starts_with(arg, "--until=")) {
show_datestring("--min-age=", arg+8);
continue;
}
if (show_flag(arg) && verify)
die_no_single_rev(quiet);
continue;
}
/* Not a flag argument */
if (try_difference(arg))
continue;
if (<API key>(arg))
continue;
name = arg;
type = NORMAL;
if (*arg == '^') {
name++;
type = REVERSED;
}
if (!<API key>(name, flags, sha1, &unused)) {
if (verify)
revs_count++;
else
show_rev(type, sha1, name);
continue;
}
if (verify)
die_no_single_rev(quiet);
if (has_dashdash)
die("bad revision '%s'", arg);
as_is = 1;
if (!show_file(arg, output_prefix))
continue;
verify_filename(prefix, arg, 1);
}
if (verify) {
if (revs_count == 1) {
show_rev(type, sha1, name);
return 0;
} else if (revs_count == 0 && show_default())
return 0;
die_no_single_rev(quiet);
} else
show_default();
return 0;
}
|
#ifndef JULIUSRECOGNIZER_H
#define JULIUSRECOGNIZER_H
#include "recognizer.h"
#include <QMutex>
#include <QString>
#include "<API key>.h"
class KProcess;
class <API key> JuliusRecognizer : public Recognizer
{
private:
KProcess *m_juliusProcess;
bool isBeingKilled;
QMutex recognitionLock;
QMutex initializationLock;
private:
bool blockTillPrompt(QByteArray *data=0);
QByteArray readData();
bool startProcess();
public:
JuliusRecognizer();
bool init(<API key>* config);
QList<RecognitionResult> recognize(const QString& file);
bool uninitialize();
virtual ~JuliusRecognizer();
};
#endif // JULIUSRECOGNIZER_H
|
#pragma once
#include <OpenEXR/ImathVec.h>
#include <string>
struct RenderSettings
{
// maximum path length allowed in the path tracer (1 = direct
// illumination only).
int <API key>;
// Max number of accumulated samples before the render finishes
int <API key>;
// rendered image resolution in pixels
Imath::V2i m_imageResolution;
// Viewport within which to render the image. This may not match the
// resolution of the rendered image, in which case stretching or squashing
// will occur.
int m_viewport[4];
float m_wireframeOpacity;
float <API key>;
std::string m_backgroundImage;
Imath::V3f m_backgroundColor[2]; // gradient (top/bottom)
int <API key>;
};
|
/* $Id: VBoxGuest-win.cpp $ */
/** @file
* VBoxGuest - Windows specifics.
*/
#define LOG_GROUP LOG_GROUP_SUP_DRV
#include "VBoxGuest-win.h"
#include "VBoxGuestInternal.h"
#include <iprt/asm.h>
#include <iprt/asm-amd64-x86.h>
#include <VBox/log.h>
#include <VBox/VBoxGuestLib.h>
#include <iprt/string.h>
/*
* XP DDK #defines ExFreePool to ExFreePoolWithTag. The latter does not exist
* on NT4, so... The same for ExAllocatePool.
*/
#ifdef TARGET_NT4
# undef ExAllocatePool
# undef ExFreePool
#endif
RT_C_DECLS_BEGIN
static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj);
static void vbgdNtUnload(PDRIVER_OBJECT pDrvObj);
static NTSTATUS vbgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS vbgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS vbgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS vbgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS <API key>(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue);
static NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp);
static NTSTATUS <API key>(PDEVICE_OBJECT pDevObj, PIRP pIrp);
#ifdef DEBUG
static void vbgdNtDoTests(void);
#endif
RT_C_DECLS_END
RT_C_DECLS_BEGIN
ULONG DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath);
RT_C_DECLS_END
#ifdef ALLOC_PRAGMA
# pragma alloc_text(INIT, DriverEntry)
# pragma alloc_text(PAGE, vbgdNtAddDevice)
# pragma alloc_text(PAGE, vbgdNtUnload)
# pragma alloc_text(PAGE, vbgdNtCreate)
# pragma alloc_text(PAGE, vbgdNtClose)
# pragma alloc_text(PAGE, vbgdNtShutdown)
# pragma alloc_text(PAGE, <API key>)
# pragma alloc_text(PAGE, <API key>)
#endif
/** The detected NT (windows) version. */
VBGDNTVER g_enmVbgdNtVer = VBGDNTVER_INVALID;
/**
* Driver entry point.
*
* @returns appropriate status code.
* @param pDrvObj Pointer to driver object.
* @param pRegPath Registry base path.
*/
ULONG DriverEntry(PDRIVER_OBJECT pDrvObj, PUNICODE_STRING pRegPath)
{
NTSTATUS rc = STATUS_SUCCESS;
LogFunc(("Driver built: %s %s\n", __DATE__, __TIME__));
/*
* Check if the the NT version is supported and initializing
* g_enmVbgdNtVer in the process.
*/
ULONG ulMajorVer;
ULONG ulMinorVer;
ULONG ulBuildNo;
BOOLEAN fCheckedBuild = PsGetVersion(&ulMajorVer, &ulMinorVer, &ulBuildNo, NULL);
/* Use RTLogBackdoorPrintf to make sure that this goes to VBox.log */
RTLogBackdoorPrintf("VBoxGuest: Windows version %u.%u, build %u\n", ulMajorVer, ulMinorVer, ulBuildNo);
if (fCheckedBuild)
RTLogBackdoorPrintf("VBoxGuest: Windows checked build\n");
#ifdef DEBUG
vbgdNtDoTests();
#endif
switch (ulMajorVer)
{
case 10:
switch (ulMinorVer)
{
case 0:
/* Windows 10 Preview builds starting with 9926. */
default:
/* Also everything newer. */
g_enmVbgdNtVer = VBGDNTVER_WIN10;
break;
}
break;
case 6: /* Windows Vista or Windows 7 (based on minor ver) */
switch (ulMinorVer)
{
case 0: /* Note: Also could be Windows 2008 Server! */
g_enmVbgdNtVer = VBGDNTVER_WINVISTA;
break;
case 1: /* Note: Also could be Windows 2008 Server R2! */
g_enmVbgdNtVer = VBGDNTVER_WIN7;
break;
case 2:
g_enmVbgdNtVer = VBGDNTVER_WIN8;
break;
case 3:
g_enmVbgdNtVer = VBGDNTVER_WIN81;
break;
case 4:
/* Windows 10 Preview builds. */
default:
/* Also everything newer. */
g_enmVbgdNtVer = VBGDNTVER_WIN10;
break;
}
break;
case 5:
switch (ulMinorVer)
{
default:
case 2:
g_enmVbgdNtVer = VBGDNTVER_WIN2K3;
break;
case 1:
g_enmVbgdNtVer = VBGDNTVER_WINXP;
break;
case 0:
g_enmVbgdNtVer = VBGDNTVER_WIN2K;
break;
}
break;
case 4:
g_enmVbgdNtVer = VBGDNTVER_WINNT4;
break;
default:
if (ulMajorVer > 6)
{
/* "Windows 10 mode" for Windows 8.1+. */
g_enmVbgdNtVer = VBGDNTVER_WIN10;
}
else
{
if (ulMajorVer < 4)
LogRelFunc(("At least Windows NT4 required! (%u.%u)\n", ulMajorVer, ulMinorVer));
else
LogRelFunc(("Unknown version %u.%u!\n", ulMajorVer, ulMinorVer));
rc = <API key>;
}
break;
}
if (NT_SUCCESS(rc))
{
/*
* Setup the driver entry points in pDrvObj.
*/
pDrvObj->DriverUnload = vbgdNtUnload;
pDrvObj->MajorFunction[IRP_MJ_CREATE] = vbgdNtCreate;
pDrvObj->MajorFunction[IRP_MJ_CLOSE] = vbgdNtClose;
pDrvObj->MajorFunction[<API key>] = vbgdNtIOCtl;
pDrvObj->MajorFunction[<API key>] = vbgdNtInternalIOCtl;
pDrvObj->MajorFunction[IRP_MJ_SHUTDOWN] = vbgdNtShutdown;
pDrvObj->MajorFunction[IRP_MJ_READ] = <API key>;
pDrvObj->MajorFunction[IRP_MJ_WRITE] = <API key>;
#ifdef TARGET_NT4
rc = vbgdNt4CreateDevice(pDrvObj, NULL /* pDevObj */, pRegPath);
#else
pDrvObj->MajorFunction[IRP_MJ_PNP] = vbgdNtPnP;
pDrvObj->MajorFunction[IRP_MJ_POWER] = vbgdNtPower;
pDrvObj->MajorFunction[<API key>] = vbgdNtSystemControl;
pDrvObj->DriverExtension->AddDevice = (PDRIVER_ADD_DEVICE)vbgdNtAddDevice;
#endif
}
LogFlowFunc(("Returning %#x\n", rc));
return rc;
}
#ifndef TARGET_NT4
/**
* Handle request from the Plug & Play subsystem.
*
* @returns NT status code
* @param pDrvObj Driver object
* @param pDevObj Device object
*/
static NTSTATUS vbgdNtAddDevice(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj)
{
NTSTATUS rc;
LogFlowFuncEnter();
/*
* Create device.
*/
UNICODE_STRING DevName;
<API key>(&DevName, <API key>);
PDEVICE_OBJECT pDeviceObject = NULL;
rc = IoCreateDevice(pDrvObj, sizeof(VBOXGUESTDEVEXTWIN), &DevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDeviceObject);
if (NT_SUCCESS(rc))
{
/*
* Create symbolic link (DOS devices).
*/
UNICODE_STRING DosName;
<API key>(&DosName, <API key>);
rc = <API key>(&DosName, &DevName);
if (NT_SUCCESS(rc))
{
/*
* Setup the device extension.
*/
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDeviceObject->DeviceExtension;
RT_ZERO(*pDevExt);
<API key>(&pDevExt-><API key>);
pDevExt->pDeviceObject = pDeviceObject;
pDevExt->prevDevState = STOPPED;
pDevExt->devState = STOPPED;
pDevExt->pNextLowerDriver = <API key>(pDeviceObject, pDevObj);
if (pDevExt->pNextLowerDriver != NULL)
{
/*
* If we reached this point we're fine with the basic driver setup,
* so continue to init our own things.
*/
#ifdef <API key>
<API key>(pDevExt); /* Ignore failure! */
#endif
if (NT_SUCCESS(rc))
{
/* VBoxGuestPower is pageable; ensure we are not called at elevated IRQL */
pDeviceObject->Flags |= DO_POWER_PAGABLE;
/* Driver is ready now. */
pDeviceObject->Flags &= ~<API key>;
LogFlowFunc(("Returning with rc=0x%x (success)\n", rc));
return rc;
}
IoDetachDevice(pDevExt->pNextLowerDriver);
}
else
{
LogFunc(("<API key> did not give a nextLowerDriver!\n"));
rc = <API key>;
}
/* bail out */
<API key>(&DosName);
}
else
LogFunc(("<API key> failed with rc=%#x!\n", rc));
IoDeleteDevice(pDeviceObject);
}
else
LogFunc(("IoCreateDevice failed with rc=%#x!\n", rc));
LogFunc(("Returning with rc=0x%x\n", rc));
return rc;
}
#endif
/**
* Debug helper to dump a device resource list.
*
* @param pResourceList list of device resources.
*/
static void <API key>(<API key> pResourceList)
{
#ifdef LOG_ENABLED
<API key> pResource = pResourceList->PartialDescriptors;
ULONG cResources = pResourceList->Count;
for (ULONG i = 0; i < cResources; ++i, ++pResource)
{
ULONG uType = pResource->Type;
static char const * const s_apszName[] =
{
"CmResourceTypeNull",
"CmResourceTypePort",
"<API key>",
"<API key>",
"CmResourceTypeDma",
"<API key>",
"<API key>",
"<API key>",
"<API key>",
"<API key>",
};
LogFunc(("Type=%s", uType < RT_ELEMENTS(s_apszName) ? s_apszName[uType] : "Unknown"));
switch (uType)
{
case CmResourceTypePort:
case <API key>:
LogFunc(("Start %8X%8.8lX, length=%X\n",
pResource->u.Port.Start.HighPart, pResource->u.Port.Start.LowPart,
pResource->u.Port.Length));
break;
case <API key>:
LogFunc(("Level=%X, vector=%X, affinity=%X\n",
pResource->u.Interrupt.Level, pResource->u.Interrupt.Vector,
pResource->u.Interrupt.Affinity));
break;
case CmResourceTypeDma:
LogFunc(("Channel %d, Port %X\n",
pResource->u.Dma.Channel, pResource->u.Dma.Port));
break;
default:
LogFunc(("\n"));
break;
}
}
#endif
}
/**
* Global initialisation stuff (PnP + NT4 legacy).
*
* @param pDevObj Device object.
* @param pIrp Request packet.
*/
#ifndef TARGET_NT4
NTSTATUS vbgdNtInit(PDEVICE_OBJECT pDevObj, PIRP pIrp)
#else
NTSTATUS vbgdNtInit(PDRIVER_OBJECT pDrvObj, PDEVICE_OBJECT pDevObj, PUNICODE_STRING pRegPath)
#endif
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
#ifndef TARGET_NT4
PIO_STACK_LOCATION pStack = <API key>(pIrp);
#endif
LogFlowFuncEnter();
int rc = STATUS_SUCCESS; /** @todo r=bird: s/rc/rcNt/ and s/int/NTSTATUS/. gee. */
#ifdef TARGET_NT4
/*
* Let's have a look at what our PCI adapter offers.
*/
LogFlowFunc(("Starting to scan PCI resources of VBoxGuest ...\n"));
/* Assign the PCI resources. */
PCM_RESOURCE_LIST pResourceList = NULL;
UNICODE_STRING classNameString;
<API key>(&classNameString, L"VBoxGuestAdapter");
rc = <API key>(pRegPath, &classNameString,
pDrvObj, pDevObj,
PCIBus, pDevExt->busNumber, pDevExt->slotNumber,
&pResourceList);
if (pResourceList && pResourceList->Count > 0)
<API key>(&pResourceList->List[0].PartialResourceList);
if (NT_SUCCESS(rc))
rc = <API key>(pResourceList, pDevExt);
#else
if (pStack->Parameters.StartDevice.AllocatedResources->Count > 0)
<API key>(&pStack->Parameters.StartDevice.AllocatedResources->List[0].PartialResourceList);
if (NT_SUCCESS(rc))
rc = <API key>(pStack->Parameters.StartDevice.<API key>, pDevExt);
#endif
if (NT_SUCCESS(rc))
{
/*
* Map physical address of VMMDev memory into MMIO region
* and init the common device extension bits.
*/
void *pvMMIOBase = NULL;
uint32_t cbMMIO = 0;
rc = <API key>(pDevExt,
pDevExt-><API key>,
pDevExt-><API key>,
&pvMMIOBase,
&cbMMIO);
if (NT_SUCCESS(rc))
{
pDevExt->Core.pVMMDevMemory = (VMMDevMemory *)pvMMIOBase;
LogFunc(("pvMMIOBase=0x%p, pDevExt=0x%p, pDevExt->Core.pVMMDevMemory=0x%p\n",
pvMMIOBase, pDevExt, pDevExt ? pDevExt->Core.pVMMDevMemory : NULL));
int vrc = <API key>(&pDevExt->Core,
pDevExt->Core.IOPortBase,
pvMMIOBase, cbMMIO,
<API key>(g_enmVbgdNtVer),
<API key>);
if (RT_FAILURE(vrc))
{
LogFunc(("Could not init device extension, rc=%Rrc\n", vrc));
rc = <API key>;
}
}
else
LogFunc(("Could not map physical address of VMMDev, rc=0x%x\n", rc));
}
if (NT_SUCCESS(rc))
{
int vrc = VbglGRAlloc((VMMDevRequestHeader **)&pDevExt->pPowerStateRequest,
sizeof(<API key>), <API key>);
if (RT_FAILURE(vrc))
{
LogFunc(("Alloc for pPowerStateRequest failed, rc=%Rrc\n", vrc));
rc = STATUS_UNSUCCESSFUL;
}
}
if (NT_SUCCESS(rc))
{
/*
* Register DPC and ISR.
*/
LogFlowFunc(("Initializing DPC/ISR ...\n"));
<API key>(pDevExt->pDeviceObject, vbgdNtDpcHandler);
#ifdef TARGET_NT4
ULONG uInterruptVector;
KIRQL irqLevel;
/* Get an interrupt vector. */
/* Only proceed if the device provides an interrupt. */
if ( pDevExt->interruptLevel
|| pDevExt->interruptVector)
{
LogFlowFunc(("Getting interrupt vector (HAL): Bus=%u, IRQL=%u, Vector=%u\n",
pDevExt->busNumber, pDevExt->interruptLevel, pDevExt->interruptVector));
uInterruptVector = <API key>(PCIBus,
pDevExt->busNumber,
pDevExt->interruptLevel,
pDevExt->interruptVector,
&irqLevel,
&pDevExt->interruptAffinity);
LogFlowFunc(("<API key> returns vector=%u\n", uInterruptVector));
if (uInterruptVector == 0)
LogFunc(("No interrupt vector found!\n"));
}
else
LogFunc(("Device does not provide an interrupt!\n"));
#endif
if (pDevExt->interruptVector)
{
LogFlowFunc(("Connecting interrupt ...\n"));
rc = IoConnectInterrupt(&pDevExt->pInterruptObject, /* Out: interrupt object. */
(PKSERVICE_ROUTINE)vbgdNtIsrHandler, /* Our ISR handler. */
pDevExt, /* Device context. */
NULL, /* Optional spinlock. */
#ifdef TARGET_NT4
uInterruptVector, /* Interrupt vector. */
irqLevel, /* Interrupt level. */
irqLevel, /* Interrupt level. */
#else
pDevExt->interruptVector, /* Interrupt vector. */
(KIRQL)pDevExt->interruptLevel, /* Interrupt level. */
(KIRQL)pDevExt->interruptLevel, /* Interrupt level. */
#endif
pDevExt->interruptMode, /* LevelSensitive or Latched. */
TRUE, /* Shareable interrupt. */
pDevExt->interruptAffinity, /* CPU affinity. */
FALSE); /* Don't save FPU stack. */
if (NT_ERROR(rc))
LogFunc(("Could not connect interrupt, rc=0x%x\n", rc));
}
else
LogFunc(("No interrupt vector found!\n"));
}
#ifdef VBOX_WITH_HGCM
LogFunc(("Allocating kernel session data ...\n"));
int vrc = <API key>(&pDevExt->Core, &pDevExt->pKernelSession);
if (RT_FAILURE(vrc))
{
LogFunc(("Failed to allocated kernel session data, rc=%Rrc\n", rc));
rc = STATUS_UNSUCCESSFUL;
}
#endif
if (RT_SUCCESS(rc))
{
ULONG ulValue = 0;
NTSTATUS rcNt = <API key>(<API key>,
L"VBoxGuest", L"LoggingEnabled", &ulValue);
if (NT_SUCCESS(rcNt))
{
pDevExt->Core.fLoggingEnabled = ulValue >= 0xFF;
if (pDevExt->Core.fLoggingEnabled)
LogRelFunc(("Logging to host log enabled (0x%x)", ulValue));
}
/* Ready to rumble! */
LogRelFunc(("Device is ready!\n"));
<API key>(pDevExt, WORKING);
}
else
pDevExt->pInterruptObject = NULL;
/** @todo r=bird: The error cleanup here is completely missing. We'll leak a
* whole bunch of things... */
LogFunc(("Returned with rc=0x%x\n", rc));
return rc;
}
/**
* Cleans up hardware resources.
* Do not delete DevExt here.
*
* @param pDrvObj Driver object.
*/
NTSTATUS vbgdNtCleanup(PDEVICE_OBJECT pDevObj)
{
LogFlowFuncEnter();
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
if (pDevExt)
{
#if 0 /* @todo: test & enable cleaning global session data */
#ifdef VBOX_WITH_HGCM
if (pDevExt->pKernelSession)
{
<API key>(pDevExt, pDevExt->pKernelSession);
pDevExt->pKernelSession = NULL;
}
#endif
#endif
if (pDevExt->pInterruptObject)
{
<API key>(pDevExt->pInterruptObject);
pDevExt->pInterruptObject = NULL;
}
/** @todo: cleanup the rest stuff */
#ifdef <API key>
<API key>(pDevExt); /* ignore failure! */
#endif
/* According to MSDN we have to unmap previously mapped memory. */
<API key>(pDevExt);
}
return STATUS_SUCCESS;
}
/**
* Unload the driver.
*
* @param pDrvObj Driver object.
*/
static void vbgdNtUnload(PDRIVER_OBJECT pDrvObj)
{
LogFlowFuncEnter();
#ifdef TARGET_NT4
vbgdNtCleanup(pDrvObj->DeviceObject);
/* Destroy device extension and clean up everything else. */
if (pDrvObj->DeviceObject && pDrvObj->DeviceObject->DeviceExtension)
<API key>((PVBOXGUESTDEVEXT)pDrvObj->DeviceObject->DeviceExtension);
/*
* I don't think it's possible to unload a driver which processes have
* opened, at least we'll blindly assume that here.
*/
UNICODE_STRING DosName;
<API key>(&DosName, <API key>);
NTSTATUS rc = <API key>(&DosName);
IoDeleteDevice(pDrvObj->DeviceObject);
#else /* !TARGET_NT4 */
/* On a PnP driver this routine will be called after
* <API key> (where we already did the cleanup),
* so don't do anything here (yet). */
#endif /* !TARGET_NT4 */
LogFlowFunc(("Returning\n"));
}
/**
* Create (i.e. Open) file entry point.
*
* @param pDevObj Device object.
* @param pIrp Request packet.
*/
static NTSTATUS vbgdNtCreate(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
/** @todo AssertPtrReturn(pIrp); */
PIO_STACK_LOCATION pStack = <API key>(pIrp);
/** @todo AssertPtrReturn(pStack); */
PFILE_OBJECT pFileObj = pStack->FileObject;
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
NTSTATUS rc = STATUS_SUCCESS;
if (pDevExt->devState != WORKING)
{
LogFunc(("Device is not working currently, state=%d\n", pDevExt->devState));
rc = STATUS_UNSUCCESSFUL;
}
else if (pStack->Parameters.Create.Options & FILE_DIRECTORY_FILE)
{
/*
* We are not remotely similar to a directory...
* (But this is possible.)
*/
LogFlowFunc(("Uhm, we're not a directory!\n"));
rc = <API key>;
}
else
{
#ifdef VBOX_WITH_HGCM
if (pFileObj)
{
LogFlowFunc(("File object type=%d\n", pFileObj->Type));
int vrc;
PVBOXGUESTSESSION pSession;
if (pFileObj->Type == 5 /* File Object */)
{
/*
* Create a session object if we have a valid file object. This session object
* exists for every R3 process.
*/
vrc = <API key>(&pDevExt->Core, &pSession);
}
else
{
/* ... otherwise we've been called from R0! */
vrc = <API key>(&pDevExt->Core, &pSession);
}
if (RT_SUCCESS(vrc))
pFileObj->FsContext = pSession;
}
#endif
}
/* Complete the request! */
pIrp->IoStatus.Information = 0;
pIrp->IoStatus.Status = rc;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
LogFlowFunc(("Returning rc=0x%x\n", rc));
return rc;
}
/**
* Close file entry point.
*
* @param pDevObj Device object.
* @param pIrp Request packet.
*/
static NTSTATUS vbgdNtClose(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
PIO_STACK_LOCATION pStack = <API key>(pIrp);
PFILE_OBJECT pFileObj = pStack->FileObject;
LogFlowFunc(("pDevExt=0x%p, pFileObj=0x%p, FsContext=0x%p\n",
pDevExt, pFileObj, pFileObj->FsContext));
#ifdef VBOX_WITH_HGCM
/* Close both, R0 and R3 sessions. */
PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pFileObj->FsContext;
if (pSession)
<API key>(&pDevExt->Core, pSession);
#endif
pFileObj->FsContext = NULL;
pIrp->IoStatus.Information = 0;
pIrp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}
/**
* Device I/O Control entry point.
*
* @param pDevObj Device object.
* @param pIrp Request packet.
*/
static NTSTATUS vbgdNtIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
NTSTATUS Status = STATUS_SUCCESS;
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
PIO_STACK_LOCATION pStack = <API key>(pIrp);
unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
char *pBuf = (char *)pIrp->AssociatedIrp.SystemBuffer; /* All requests are buffered. */
size_t cbData = pStack->Parameters.DeviceIoControl.InputBufferLength;
size_t cbOut = 0;
/* Do we have a file object associated?*/
PFILE_OBJECT pFileObj = pStack->FileObject;
PVBOXGUESTSESSION pSession = NULL;
if (pFileObj) /* ... then we might have a session object as well! */
pSession = (PVBOXGUESTSESSION)pFileObj->FsContext;
LogFlowFunc(("uCmd=%u, pDevExt=0x%p, pSession=0x%p\n",
uCmd, pDevExt, pSession));
/* We don't have a session associated with the file object? So this seems
* to be a kernel call then. */
/** @todo r=bird: What on earth is this supposed to be? Each kernel session
* shall have its own context of course, no hacks, pleeease. */
if (pSession == NULL)
{
LogFunc(("XXX: BUGBUG: FIXME: Using ugly kernel session data hack ...\n"));
#ifdef DEBUG_andy
RTLogBackdoorPrintf("XXX: BUGBUG: FIXME: Using ugly kernel session data hack ... Please don't forget to fix this one, Andy!\n");
#endif
pSession = pDevExt->pKernelSession;
}
/* Verify that it's a buffered CTL. */
if ((pStack->Parameters.DeviceIoControl.IoControlCode & 0x3) == METHOD_BUFFERED)
{
/*
* Process the common IOCtls.
*/
size_t cbDataReturned;
int vrc = VbgdCommonIoCtl(uCmd, &pDevExt->Core, pSession, pBuf, cbData, &cbDataReturned);
LogFlowFunc(("rc=%Rrc, pBuf=0x%p, cbData=%u, cbDataReturned=%u\n",
vrc, pBuf, cbData, cbDataReturned));
if (RT_SUCCESS(vrc))
{
if (RT_UNLIKELY( cbDataReturned > cbData
|| cbDataReturned > pStack->Parameters.DeviceIoControl.OutputBufferLength))
{
LogFunc(("Too much output data %u - expected %u!\n", cbDataReturned, cbData));
cbDataReturned = cbData;
Status = <API key>;
}
if (cbDataReturned > 0)
cbOut = cbDataReturned;
}
else
{
if ( vrc == VERR_NOT_SUPPORTED
|| vrc == <API key>)
Status = <API key>;
else if (vrc == VERR_OUT_OF_RANGE)
Status = <API key>;
else
Status = STATUS_UNSUCCESSFUL;
}
}
else
{
LogFunc(("Not buffered request (%#x) - not supported\n", pStack->Parameters.DeviceIoControl.IoControlCode));
Status = <API key>;
}
pIrp->IoStatus.Status = Status;
pIrp->IoStatus.Information = cbOut;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
//LogFlowFunc(("Returned cbOut=%d rc=%#x\n", cbOut, Status));
return Status;
}
/**
* Internal Device I/O Control entry point.
*
* @param pDevObj Device object.
* @param pIrp Request packet.
*/
static NTSTATUS vbgdNtInternalIOCtl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
NTSTATUS Status = STATUS_SUCCESS;
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
PIO_STACK_LOCATION pStack = <API key>(pIrp);
unsigned int uCmd = (unsigned int)pStack->Parameters.DeviceIoControl.IoControlCode;
bool fProcessed = false;
unsigned Info = 0;
/*
* Override common behavior of some operations.
*/
/** @todo r=bird: Better to add dedicated worker functions for this! */
switch (uCmd)
{
case <API key>:
{
PVOID pvBuf = pStack->Parameters.Others.Argument1;
size_t cbData = (size_t)pStack->Parameters.Others.Argument2;
fProcessed = true;
if (cbData != sizeof(<API key>))
{
AssertFailed();
Status = <API key>;
break;
}
<API key> *pInfo = (<API key>*)pvBuf;
/* we need a lock here to avoid concurrency with the set event functionality */
KIRQL OldIrql;
KeAcquireSpinLock(&pDevExt-><API key>, &OldIrql);
pDevExt->Core.MouseNotifyCallback = *pInfo;
KeReleaseSpinLock(&pDevExt-><API key>, OldIrql);
Status = STATUS_SUCCESS;
break;
}
default:
break;
}
if (fProcessed)
{
pIrp->IoStatus.Status = Status;
pIrp->IoStatus.Information = Info;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return Status;
}
/*
* No override, go to common code.
*/
return vbgdNtIOCtl(pDevObj, pIrp);
}
/**
* <API key> handler.
*
* @returns NT status code
* @param pDevObj Device object.
* @param pIrp IRP.
*/
NTSTATUS vbgdNtSystemControl(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
LogFlowFuncEnter();
/* Always pass it on to the next driver. */
<API key>(pIrp);
return IoCallDriver(pDevExt->pNextLowerDriver, pIrp);
}
/**
* IRP_MJ_SHUTDOWN handler.
*
* @returns NT status code
* @param pDevObj Device object.
* @param pIrp IRP.
*/
NTSTATUS vbgdNtShutdown(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
LogFlowFuncEnter();
<API key> *pReq = pDevExt->pPowerStateRequest;
if (pReq)
{
pReq->header.requestType = <API key>;
pReq->powerState = <API key>;
int rc = VbglGRPerform(&pReq->header);
if (RT_FAILURE(rc))
LogFunc(("Error performing request to VMMDev, rc=%Rrc\n", rc));
}
return STATUS_SUCCESS;
}
/**
* Stub function for functions we don't implemented.
*
* @returns <API key>
* @param pDevObj Device object.
* @param pIrp IRP.
*/
NTSTATUS <API key>(PDEVICE_OBJECT pDevObj, PIRP pIrp)
{
LogFlowFuncEnter();
pIrp->IoStatus.Information = 0;
pIrp->IoStatus.Status = <API key>;
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return <API key>;
}
/**
* DPC handler.
*
* @param pDPC DPC descriptor.
* @param pDevObj Device object.
* @param pIrp Interrupt request packet.
* @param pContext Context specific pointer.
*/
void vbgdNtDpcHandler(PKDPC pDPC, PDEVICE_OBJECT pDevObj, PIRP pIrp, PVOID pContext)
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pDevObj->DeviceExtension;
Log3Func(("pDevExt=0x%p\n", pDevExt));
/* Test & reset the counter. */
if (ASMAtomicXchgU32(&pDevExt->Core.<API key>, 0))
{
/* we need a lock here to avoid concurrency with the set event ioctl handler thread,
* i.e. to prevent the event from destroyed while we're using it */
Assert(KeGetCurrentIrql() == DISPATCH_LEVEL);
<API key>(&pDevExt-><API key>);
if (pDevExt->Core.MouseNotifyCallback.pfnNotify)
pDevExt->Core.MouseNotifyCallback.pfnNotify(pDevExt->Core.MouseNotifyCallback.pvUser);
<API key>(&pDevExt-><API key>);
}
/* Process the wake-up list we were asked by the scheduling a DPC
* in vbgdNtIsrHandler(). */
<API key>(&pDevExt->Core);
}
/**
* ISR handler.
*
* @return BOOLEAN Indicates whether the IRQ came from us (TRUE) or not (FALSE).
* @param pInterrupt Interrupt that was triggered.
* @param pServiceContext Context specific pointer.
*/
BOOLEAN vbgdNtIsrHandler(PKINTERRUPT pInterrupt, PVOID pServiceContext)
{
PVBOXGUESTDEVEXTWIN pDevExt = (PVBOXGUESTDEVEXTWIN)pServiceContext;
if (pDevExt == NULL)
return FALSE;
/*Log3Func(("pDevExt=0x%p, pVMMDevMemory=0x%p\n", pDevExt, pDevExt ? pDevExt->pVMMDevMemory : NULL));*/
/* Enter the common ISR routine and do the actual work. */
BOOLEAN fIRQTaken = VbgdCommonISR(&pDevExt->Core);
/* If we need to wake up some events we do that in a DPC to make
* sure we're called at the right IRQL. */
if (fIRQTaken)
{
Log3Func(("IRQ was taken! pInterrupt=0x%p, pDevExt=0x%p\n", pInterrupt, pDevExt));
if (ASMAtomicUoReadU32( &pDevExt->Core.<API key>)
|| !RTListIsEmpty(&pDevExt->Core.WakeUpList))
{
Log3Func(("Requesting DPC ...\n"));
IoRequestDpc(pDevExt->pDeviceObject, pDevExt->pCurrentIrp, NULL);
}
}
return fIRQTaken;
}
/**
* Overridden routine for mouse polling events.
*
* @param pDevExt Device extension structure.
*/
void <API key>(PVBOXGUESTDEVEXT pDevExt)
{
NOREF(pDevExt);
/* nothing to do here - i.e. since we can not KeSetEvent from ISR level,
* we rely on the pDevExt-><API key> to be set to a non-zero value on a mouse event
* and queue the DPC in our ISR routine in that case doing KeSetEvent from the DPC routine */
}
/**
* Queries (gets) a DWORD value from the registry.
*
* @return NTSTATUS
* @param ulRoot Relative path root. See <API key> or <API key>.
* @param pwszPath Path inside path root.
* @param pwszName Actual value name to look up.
* @param puValue On input this can specify the default value (if <API key> is
* not specified in ulRoot), on output this will retrieve the looked up
* registry value if found.
*/
NTSTATUS <API key>(ULONG ulRoot, PCWSTR pwszPath, PWSTR pwszName, PULONG puValue)
{
if (!pwszPath || !pwszName || !puValue)
return <API key>;
ULONG ulDefault = *puValue;
<API key> tblQuery[2];
RtlZeroMemory(tblQuery, sizeof(tblQuery));
/** @todo Add <API key>! */
tblQuery[0].Flags = <API key>;
tblQuery[0].Name = pwszName;
tblQuery[0].EntryContext = puValue;
tblQuery[0].DefaultType = REG_DWORD;
tblQuery[0].DefaultData = &ulDefault;
tblQuery[0].DefaultLength = sizeof(ULONG);
return <API key>(ulRoot,
pwszPath,
&tblQuery[0],
NULL /* Context */,
NULL /* Environment */);
}
/**
* Helper to scan the PCI resource list and remember stuff.
*
* @param pResList Resource list
* @param pDevExt Device extension
*/
NTSTATUS <API key>(PCM_RESOURCE_LIST pResList, PVBOXGUESTDEVEXTWIN pDevExt)
{
/* Enumerate the resource list. */
LogFlowFunc(("Found %d resources\n",
pResList->List->PartialResourceList.Count));
NTSTATUS rc = STATUS_SUCCESS;
<API key> pPartialData = NULL;
ULONG rangeCount = 0;
ULONG cMMIORange = 0;
<API key> pBaseAddress = pDevExt->pciBaseAddress;
for (ULONG i = 0; i < pResList->List->PartialResourceList.Count; i++)
{
pPartialData = &pResList->List->PartialResourceList.PartialDescriptors[i];
switch (pPartialData->Type)
{
case CmResourceTypePort:
{
/* Overflow protection. */
if (rangeCount < PCI_TYPE0_ADDRESSES)
{
LogFlowFunc(("I/O range: Base=%08x:%08x, length=%08x\n",
pPartialData->u.Port.Start.HighPart,
pPartialData->u.Port.Start.LowPart,
pPartialData->u.Port.Length));
/* Save the IO port base. */
/** @todo Not so good.
* Update/bird: What is not so good? That we just consider the last range? */
pDevExt->Core.IOPortBase = (RTIOPORT)pPartialData->u.Port.Start.LowPart;
/* Save resource information. */
pBaseAddress->RangeStart = pPartialData->u.Port.Start;
pBaseAddress->RangeLength = pPartialData->u.Port.Length;
pBaseAddress->RangeInMemory = FALSE;
pBaseAddress->ResourceMapped = FALSE;
LogFunc(("I/O range for VMMDev found! Base=%08x:%08x, length=%08x\n",
pPartialData->u.Port.Start.HighPart,
pPartialData->u.Port.Start.LowPart,
pPartialData->u.Port.Length));
/* Next item ... */
rangeCount++; pBaseAddress++;
}
break;
}
case <API key>:
{
LogFunc(("Interrupt: Level=%x, vector=%x, mode=%x\n",
pPartialData->u.Interrupt.Level,
pPartialData->u.Interrupt.Vector,
pPartialData->Flags));
/* Save information. */
pDevExt->interruptLevel = pPartialData->u.Interrupt.Level;
pDevExt->interruptVector = pPartialData->u.Interrupt.Vector;
pDevExt->interruptAffinity = pPartialData->u.Interrupt.Affinity;
/* Check interrupt mode. */
if (pPartialData->Flags & <API key>)
pDevExt->interruptMode = Latched;
else
pDevExt->interruptMode = LevelSensitive;
break;
}
case <API key>:
{
/* Overflow protection. */
if (rangeCount < PCI_TYPE0_ADDRESSES)
{
LogFlowFunc(("Memory range: Base=%08x:%08x, length=%08x\n",
pPartialData->u.Memory.Start.HighPart,
pPartialData->u.Memory.Start.LowPart,
pPartialData->u.Memory.Length));
/* We only care about read/write memory. */
/** @todo Reconsider memory type. */
if ( cMMIORange == 0 /* Only care about the first MMIO range (!!!). */
&& (pPartialData->Flags & <API key>) == <API key>)
{
/* Save physical MMIO base + length for VMMDev. */
pDevExt-><API key> = pPartialData->u.Memory.Start;
pDevExt-><API key> = (ULONG)pPartialData->u.Memory.Length;
/* Save resource information. */
pBaseAddress->RangeStart = pPartialData->u.Memory.Start;
pBaseAddress->RangeLength = pPartialData->u.Memory.Length;
pBaseAddress->RangeInMemory = TRUE;
pBaseAddress->ResourceMapped = FALSE;
LogFunc(("Memory range for VMMDev found! Base = %08x:%08x, Length = %08x\n",
pPartialData->u.Memory.Start.HighPart,
pPartialData->u.Memory.Start.LowPart,
pPartialData->u.Memory.Length));
/* Next item ... */
rangeCount++; pBaseAddress++; cMMIORange++;
}
else
LogFunc(("Ignoring memory: Flags=%08x\n", pPartialData->Flags));
}
break;
}
default:
{
LogFunc(("Unhandled resource found, type=%d\n", pPartialData->Type));
break;
}
}
}
/* Memorize the number of resources found. */
pDevExt->pciAddressCount = rangeCount;
return rc;
}
/**
* Maps the I/O space from VMMDev to virtual kernel address space.
*
* @return NTSTATUS
*
* @param pDevExt The device extension.
* @param PhysAddr Physical address to map.
* @param cbToMap Number of bytes to map.
* @param ppvMMIOBase Pointer of mapped I/O base.
* @param pcbMMIO Length of mapped I/O base.
*/
NTSTATUS <API key>(PVBOXGUESTDEVEXTWIN pDevExt, PHYSICAL_ADDRESS PhysAddr, ULONG cbToMap,
void **ppvMMIOBase, uint32_t *pcbMMIO)
{
AssertPtrReturn(pDevExt, <API key>);
AssertPtrReturn(ppvMMIOBase, <API key>);
/* pcbMMIO is optional. */
NTSTATUS rc = STATUS_SUCCESS;
if (PhysAddr.LowPart > 0) /* We're mapping below 4GB. */
{
VMMDevMemory *pVMMDevMemory = (VMMDevMemory *)MmMapIoSpace(PhysAddr, cbToMap, MmNonCached);
LogFlowFunc(("pVMMDevMemory = 0x%x\n", pVMMDevMemory));
if (pVMMDevMemory)
{
LogFunc(("VMMDevMemory: Version = 0x%x, Size = %d\n", pVMMDevMemory->u32Version, pVMMDevMemory->u32Size));
/* Check version of the structure; do we have the right memory version? */
if (pVMMDevMemory->u32Version == <API key>)
{
/* Save results. */
*ppvMMIOBase = pVMMDevMemory;
if (pcbMMIO) /* Optional. */
*pcbMMIO = pVMMDevMemory->u32Size;
LogFlowFunc(("VMMDevMemory found and mapped! pvMMIOBase = 0x%p\n", *ppvMMIOBase));
}
else
{
/* Not our version, refuse operation and unmap the memory. */
LogFunc(("Wrong version (%u), refusing operation!\n", pVMMDevMemory->u32Version));
<API key>(pDevExt);
rc = STATUS_UNSUCCESSFUL;
}
}
else
rc = STATUS_UNSUCCESSFUL;
}
return rc;
}
/**
* Unmaps the VMMDev I/O range from kernel space.
*
* @param pDevExt The device extension.
*/
void <API key>(PVBOXGUESTDEVEXTWIN pDevExt)
{
LogFlowFunc(("pVMMDevMemory = 0x%x\n", pDevExt->Core.pVMMDevMemory));
if (pDevExt->Core.pVMMDevMemory)
{
MmUnmapIoSpace((void*)pDevExt->Core.pVMMDevMemory, pDevExt-><API key>);
pDevExt->Core.pVMMDevMemory = NULL;
}
pDevExt-><API key>.QuadPart = 0;
pDevExt-><API key> = 0;
}
VBOXOSTYPE <API key>(VBGDNTVER enmNtVer)
{
VBOXOSTYPE enmOsType;
switch (enmNtVer)
{
case VBGDNTVER_WINNT4:
enmOsType = VBOXOSTYPE_WinNT4;
break;
case VBGDNTVER_WIN2K:
enmOsType = VBOXOSTYPE_Win2k;
break;
case VBGDNTVER_WINXP:
#if ARCH_BITS == 64
enmOsType = <API key>;
#else
enmOsType = VBOXOSTYPE_WinXP;
#endif
break;
case VBGDNTVER_WIN2K3:
#if ARCH_BITS == 64
enmOsType = <API key>;
#else
enmOsType = VBOXOSTYPE_Win2k3;
#endif
break;
case VBGDNTVER_WINVISTA:
#if ARCH_BITS == 64
enmOsType = <API key>;
#else
enmOsType = VBOXOSTYPE_WinVista;
#endif
break;
case VBGDNTVER_WIN7:
#if ARCH_BITS == 64
enmOsType = VBOXOSTYPE_Win7_x64;
#else
enmOsType = VBOXOSTYPE_Win7;
#endif
break;
case VBGDNTVER_WIN8:
#if ARCH_BITS == 64
enmOsType = VBOXOSTYPE_Win8_x64;
#else
enmOsType = VBOXOSTYPE_Win8;
#endif
break;
case VBGDNTVER_WIN81:
#if ARCH_BITS == 64
enmOsType = <API key>;
#else
enmOsType = VBOXOSTYPE_Win81;
#endif
break;
case VBGDNTVER_WIN10:
#if ARCH_BITS == 64
enmOsType = <API key>;
#else
enmOsType = VBOXOSTYPE_Win10;
#endif
break;
default:
/* We don't know, therefore NT family. */
enmOsType = VBOXOSTYPE_WinNT;
break;
}
return enmOsType;
}
#ifdef DEBUG
/**
* A quick implementation of AtomicTestAndClear for uint32_t and multiple bits.
*/
static uint32_t <API key>(void *pu32Bits, uint32_t u32Mask)
{
AssertPtrReturn(pu32Bits, 0);
LogFlowFunc(("*pu32Bits=0x%x, u32Mask=0x%x\n", *(uint32_t *)pu32Bits, u32Mask));
uint32_t u32Result = 0;
uint32_t u32WorkingMask = u32Mask;
int iBitOffset = ASMBitFirstSetU32 (u32WorkingMask);
while (iBitOffset > 0)
{
bool fSet = <API key>(pu32Bits, iBitOffset - 1);
if (fSet)
u32Result |= 1 << (iBitOffset - 1);
u32WorkingMask &= ~(1 << (iBitOffset - 1));
iBitOffset = ASMBitFirstSetU32 (u32WorkingMask);
}
LogFlowFunc(("Returning 0x%x\n", u32Result));
return u32Result;
}
static void <API key>(uint32_t u32Mask, uint32_t u32Bits, uint32_t u32Exp)
{
ULONG u32Bits2 = u32Bits;
uint32_t u32Result = <API key>(&u32Bits2, u32Mask);
if ( u32Result != u32Exp
|| (u32Bits2 & u32Mask)
|| (u32Bits2 & u32Result)
|| ((u32Bits2 | u32Result) != u32Bits)
)
<API key>(("%s: TEST FAILED: u32Mask=0x%x, u32Bits (before)=0x%x, u32Bits (after)=0x%x, u32Result=0x%x, u32Exp=ox%x\n",
__PRETTY_FUNCTION__, u32Mask, u32Bits, u32Bits2,
u32Result));
}
static void vbgdNtDoTests(void)
{
<API key>(0x00, 0x23, 0);
<API key>(0x11, 0, 0);
<API key>(0x11, 0x22, 0);
<API key>(0x11, 0x23, 0x1);
<API key>(0x11, 0x32, 0x10);
<API key>(0x22, 0x23, 0x22);
}
#endif /* DEBUG */
#ifdef <API key>
/*
* DPC latency checker.
*/
/**
* One DPC latency sample.
*/
typedef struct DPCSAMPLE
{
LARGE_INTEGER PerfDelta;
LARGE_INTEGER PerfCounter;
LARGE_INTEGER PerfFrequency;
uint64_t u64TSC;
} DPCSAMPLE;
AssertCompileSize(DPCSAMPLE, 4*8);
/**
* The DPC latency measurement workset.
*/
typedef struct DPCDATA
{
KDPC Dpc;
KTIMER Timer;
KSPIN_LOCK SpinLock;
ULONG ulTimerRes;
bool volatile fFinished;
/** The timer interval (relative). */
LARGE_INTEGER DueTime;
LARGE_INTEGER PerfCounterPrev;
/** Align the sample array on a 64 byte boundrary just for the off chance
* that we'll get cache line aligned memory backing this structure. */
uint32_t auPadding[ARCH_BITS == 32 ? 5 : 7];
int cSamples;
DPCSAMPLE aSamples[8192];
} DPCDATA;
<API key>(DPCDATA, aSamples, 64);
# define VBOXGUEST_DPC_TAG 'DPCS'
/**
* DPC callback routine for the DPC latency measurement code.
*
* @param pDpc The DPC, not used.
* @param pvDeferredContext Pointer to the DPCDATA.
* @param SystemArgument1 System use, ignored.
* @param SystemArgument2 System use, ignored.
*/
static VOID <API key>(PKDPC pDpc, PVOID pvDeferredContext, PVOID SystemArgument1, PVOID SystemArgument2)
{
DPCDATA *pData = (DPCDATA *)pvDeferredContext;
<API key>(&pData->SpinLock);
if (pData->cSamples >= RT_ELEMENTS(pData->aSamples))
pData->fFinished = true;
else
{
DPCSAMPLE *pSample = &pData->aSamples[pData->cSamples++];
pSample->u64TSC = ASMReadTSC();
pSample->PerfCounter = <API key>(&pSample->PerfFrequency);
pSample->PerfDelta.QuadPart = pSample->PerfCounter.QuadPart - pData->PerfCounterPrev.QuadPart;
pData->PerfCounterPrev.QuadPart = pSample->PerfCounter.QuadPart;
KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc);
}
<API key>(&pData->SpinLock);
}
/**
* Handles the DPC latency checker request.
*
* @returns VBox status code.
*/
int <API key>(void)
{
/*
* Allocate a block of non paged memory for samples and related data.
*/
DPCDATA *pData = (DPCDATA *)<API key>(NonPagedPool, sizeof(DPCDATA), VBOXGUEST_DPC_TAG);
if (!pData)
{
RTLogBackdoorPrintf("VBoxGuest: DPC: DPCDATA allocation failed.\n");
return VERR_NO_MEMORY;
}
/*
* Initialize the data.
*/
KeInitializeDpc(&pData->Dpc, <API key>, pData);
KeInitializeTimer(&pData->Timer);
<API key>(&pData->SpinLock);
pData->fFinished = false;
pData->cSamples = 0;
pData->PerfCounterPrev.QuadPart = 0;
pData->ulTimerRes = <API key>(1000 * 10, 1);
pData->DueTime.QuadPart = -(int64_t)pData->ulTimerRes / 10;
/*
* Start the DPC measurements and wait for a full set.
*/
KeSetTimer(&pData->Timer, pData->DueTime, &pData->Dpc);
while (!pData->fFinished)
{
LARGE_INTEGER Interval;
Interval.QuadPart = -100 * 1000 * 10;
<API key>(KernelMode, TRUE, &Interval);
}
<API key>(0, 0);
/*
* Log everything to the host.
*/
RTLogBackdoorPrintf("DPC: ulTimerRes = %d\n", pData->ulTimerRes);
for (int i = 0; i < pData->cSamples; i++)
{
DPCSAMPLE *pSample = &pData->aSamples[i];
RTLogBackdoorPrintf("[%d] pd %lld pc %lld pf %lld t %lld\n",
i,
pSample->PerfDelta.QuadPart,
pSample->PerfCounter.QuadPart,
pSample->PerfFrequency.QuadPart,
pSample->u64TSC);
}
ExFreePoolWithTag(pData, VBOXGUEST_DPC_TAG);
return VINF_SUCCESS;
}
#endif /* <API key> */
|
#ifndef <API key>
#define <API key>
#include <memory>
#include "backup/backup_coordinator.h"
#include "<API key>/sync_count_handler.h"
#include "block_device/block_device.h"
#include "block_device/<API key>.h"
#include "<API key>/<API key>.h"
namespace datto_linux_client {
// Existance of this class allows for easier mocking in unit tests
// The real work is done in DeviceSynchronizer
class <API key> {
public:
// Precondition: source_device must be both traced and mounted
virtual void DoSync(std::shared_ptr<BackupCoordinator> coordinator,
std::shared_ptr<SyncCountHandler> count_handler) = 0;
virtual std::shared_ptr<const <API key>>
source_device() const = 0;
virtual std::shared_ptr<const <API key>>
sector_manager() const = 0;
virtual std::shared_ptr<const BlockDevice> destination_device() const = 0;
virtual ~<API key>() {}
<API key>(const <API key> &) = delete;
<API key>&
operator=(const <API key> &) = delete;
protected:
<API key>() {}
};
}
#endif // <API key>
|
#ifndef _SOCK_H
#define _SOCK_H
#include <linux/config.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/cache.h>
#include <linux/module.h>
#include <linux/netdevice.h>
#include <linux/skbuff.h> /* struct sk_buff */
#include <linux/security.h>
#include <linux/filter.h>
#include <asm/atomic.h>
#include <net/dst.h>
#include <net/checksum.h>
/*
* This structure really needs to be cleaned up.
* Most of it is for TCP, and not used by any of
* the other protocols.
*/
/* Define this to get the SOCK_DBG debugging facility. */
#define SOCK_DEBUGGING
#ifdef SOCK_DEBUGGING
#define SOCK_DEBUG(sk, msg...) do { if ((sk) && sock_flag((sk), SOCK_DBG)) \
printk(KERN_DEBUG msg); } while (0)
#else
#define SOCK_DEBUG(sk, msg...) do { } while (0)
#endif
/* This is the per-socket lock. The spinlock provides a synchronization
* between user contexts and software interrupt processing, whereas the
* mini-semaphore synchronizes multiple users amongst themselves.
*/
struct sock_iocb;
typedef struct {
spinlock_t slock;
struct sock_iocb *owner;
wait_queue_head_t wq;
} socket_lock_t;
#define sock_lock_init(__sk) \
do { spin_lock_init(&((__sk)->sk_lock.slock)); \
(__sk)->sk_lock.owner = NULL; \
init_waitqueue_head(&((__sk)->sk_lock.wq)); \
} while(0)
struct sock;
/**
* struct sock_common - minimal network layer representation of sockets
* @skc_family: network address family
* @skc_state: Connection state
* @skc_reuse: %SO_REUSEADDR setting
* @skc_bound_dev_if: bound device index if != 0
* @skc_node: main hash linkage for various protocol lookup tables
* @skc_bind_node: bind hash linkage for various protocol lookup tables
* @skc_refcnt: reference count
*
* This is the minimal network layer representation of sockets, the header
* for struct sock and struct tcp_tw_bucket.
*/
struct sock_common {
unsigned short skc_family;
volatile unsigned char skc_state;
unsigned char skc_reuse;
int skc_bound_dev_if;
struct hlist_node skc_node;
struct hlist_node skc_bind_node;
atomic_t skc_refcnt;
};
/**
* struct sock - network layer representation of sockets
* @__sk_common: shared layout with tcp_tw_bucket
* @sk_shutdown: mask of %SEND_SHUTDOWN and/or %RCV_SHUTDOWN
* @sk_userlocks: %SO_SNDBUF and %SO_RCVBUF settings
* @sk_lock: synchronizer
* @sk_rcvbuf: size of receive buffer in bytes
* @sk_sleep: sock wait queue
* @sk_dst_cache: destination cache
* @sk_dst_lock: destination cache lock
* @sk_policy: flow policy
* @sk_rmem_alloc: receive queue bytes committed
* @sk_receive_queue: incoming packets
* @sk_wmem_alloc: transmit queue bytes committed
* @sk_write_queue: Packet sending queue
* @sk_omem_alloc: "o" is "option" or "other"
* @sk_wmem_queued: persistent queue size
* @sk_forward_alloc: space allocated forward
* @sk_allocation: allocation mode
* @sk_sndbuf: size of send buffer in bytes
* @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, %SO_OOBINLINE settings
* @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets
* @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
* @sk_lingertime: %SO_LINGER l_linger setting
* @sk_hashent: hash entry in several tables (e.g. tcp_ehash)
* @sk_backlog: always used with the per-socket spinlock held
* @sk_callback_lock: used with the callbacks in the end of this struct
* @sk_error_queue: rarely used
* @sk_prot: protocol handlers inside a network family
* @sk_prot_creator: sk_prot of original sock creator (see ipv6_setsockopt, IPV6_ADDRFORM for instance)
* @sk_err: last error
* @sk_err_soft: errors that don't cause failure but are the cause of a persistent failure not just 'timed out'
* @sk_ack_backlog: current listen backlog
* @sk_max_ack_backlog: listen backlog set in listen()
* @sk_priority: %SO_PRIORITY setting
* @sk_type: socket type (%SOCK_STREAM, etc)
* @sk_protocol: which protocol this socket belongs in this network family
* @sk_peercred: %SO_PEERCRED setting
* @sk_rcvlowat: %SO_RCVLOWAT setting
* @sk_rcvtimeo: %SO_RCVTIMEO setting
* @sk_sndtimeo: %SO_SNDTIMEO setting
* @sk_filter: socket filtering instructions
* @sk_protinfo: private area, net family specific, when not using slab
* @sk_timer: sock cleanup timer
* @sk_stamp: time stamp of last packet received
* @sk_socket: Identd and reporting IO signals
* @sk_user_data: RPC layer private data
* @sk_sndmsg_page: cached page for sendmsg
* @sk_sndmsg_off: cached offset for sendmsg
* @sk_send_head: front of stuff to transmit
* @sk_security: used by security modules
* @sk_write_pending: a write to stream socket waits to start
* @sk_state_change: callback to indicate change in the state of the sock
* @sk_data_ready: callback to indicate there is data to be processed
* @sk_write_space: callback to indicate there is bf sending space available
* @sk_error_report: callback to indicate errors (e.g. %MSG_ERRQUEUE)
* @sk_backlog_rcv: callback to process the backlog
* @sk_destruct: called at sock freeing time, i.e. when all refcnt == 0
*/
struct sock {
/*
* Now struct tcp_tw_bucket also uses sock_common, so please just
* don't add nothing before this first member (__sk_common) --acme
*/
struct sock_common __sk_common;
#define sk_family __sk_common.skc_family
#define sk_state __sk_common.skc_state
#define sk_reuse __sk_common.skc_reuse
#define sk_bound_dev_if __sk_common.skc_bound_dev_if
#define sk_node __sk_common.skc_node
#define sk_bind_node __sk_common.skc_bind_node
#define sk_refcnt __sk_common.skc_refcnt
unsigned char sk_shutdown : 2,
sk_no_check : 2,
sk_userlocks : 4;
unsigned char sk_protocol;
unsigned short sk_type;
int sk_rcvbuf;
socket_lock_t sk_lock;
wait_queue_head_t *sk_sleep;
struct dst_entry *sk_dst_cache;
struct xfrm_policy *sk_policy[2];
rwlock_t sk_dst_lock;
atomic_t sk_rmem_alloc;
atomic_t sk_wmem_alloc;
atomic_t sk_omem_alloc;
struct sk_buff_head sk_receive_queue;
struct sk_buff_head sk_write_queue;
int sk_wmem_queued;
int sk_forward_alloc;
unsigned int sk_allocation;
int sk_sndbuf;
int sk_route_caps;
int sk_hashent;
unsigned long sk_flags;
unsigned long sk_lingertime;
/*
* The backlog queue is special, it is always used with
* the per-socket spinlock held and requires low latency
* access. Therefore we special case it's implementation.
*/
struct {
struct sk_buff *head;
struct sk_buff *tail;
} sk_backlog;
struct sk_buff_head sk_error_queue;
struct proto *sk_prot;
struct proto *sk_prot_creator;
rwlock_t sk_callback_lock;
int sk_err,
sk_err_soft;
unsigned short sk_ack_backlog;
unsigned short sk_max_ack_backlog;
__u32 sk_priority;
struct ucred sk_peercred;
int sk_rcvlowat;
long sk_rcvtimeo;
long sk_sndtimeo;
struct sk_filter *sk_filter;
void *sk_protinfo;
struct timer_list sk_timer;
struct timeval sk_stamp;
struct socket *sk_socket;
void *sk_user_data;
struct page *sk_sndmsg_page;
struct sk_buff *sk_send_head;
__u32 sk_sndmsg_off;
int sk_write_pending;
void *sk_security;
void (*sk_state_change)(struct sock *sk);
void (*sk_data_ready)(struct sock *sk, int bytes);
void (*sk_write_space)(struct sock *sk);
void (*sk_error_report)(struct sock *sk);
int (*sk_backlog_rcv)(struct sock *sk,
struct sk_buff *skb);
void (*sk_destruct)(struct sock *sk);
};
/*
* Hashed lists helper routines
*/
static inline struct sock *__sk_head(struct hlist_head *head)
{
return hlist_entry(head->first, struct sock, sk_node);
}
static inline struct sock *sk_head(struct hlist_head *head)
{
return hlist_empty(head) ? NULL : __sk_head(head);
}
static inline struct sock *sk_next(struct sock *sk)
{
return sk->sk_node.next ?
hlist_entry(sk->sk_node.next, struct sock, sk_node) : NULL;
}
static inline int sk_unhashed(struct sock *sk)
{
return hlist_unhashed(&sk->sk_node);
}
static inline int sk_hashed(struct sock *sk)
{
return sk->sk_node.pprev != NULL;
}
static __inline__ void sk_node_init(struct hlist_node *node)
{
node->pprev = NULL;
}
static __inline__ void __sk_del_node(struct sock *sk)
{
__hlist_del(&sk->sk_node);
}
static __inline__ int __sk_del_node_init(struct sock *sk)
{
if (sk_hashed(sk)) {
__sk_del_node(sk);
sk_node_init(&sk->sk_node);
return 1;
}
return 0;
}
/* Grab socket reference count. This operation is valid only
when sk is ALREADY grabbed f.e. it is found in hash table
or a list and the lookup is made under lock preventing hash table
modifications.
*/
static inline void sock_hold(struct sock *sk)
{
atomic_inc(&sk->sk_refcnt);
}
/* Ungrab socket in the context, which assumes that socket refcnt
cannot hit zero, f.e. it is true in context of any socketcall.
*/
static inline void __sock_put(struct sock *sk)
{
atomic_dec(&sk->sk_refcnt);
}
static __inline__ int sk_del_node_init(struct sock *sk)
{
int rc = __sk_del_node_init(sk);
if (rc) {
/* paranoid for a while -acme */
WARN_ON(atomic_read(&sk->sk_refcnt) == 1);
__sock_put(sk);
}
return rc;
}
static __inline__ void __sk_add_node(struct sock *sk, struct hlist_head *list)
{
hlist_add_head(&sk->sk_node, list);
}
static __inline__ void sk_add_node(struct sock *sk, struct hlist_head *list)
{
sock_hold(sk);
__sk_add_node(sk, list);
}
static __inline__ void __sk_del_bind_node(struct sock *sk)
{
__hlist_del(&sk->sk_bind_node);
}
static __inline__ void sk_add_bind_node(struct sock *sk,
struct hlist_head *list)
{
hlist_add_head(&sk->sk_bind_node, list);
}
#define sk_for_each(__sk, node, list) \
<API key>(__sk, node, list, sk_node)
#define sk_for_each_from(__sk, node) \
if (__sk && ({ node = &(__sk)->sk_node; 1; })) \
<API key>(__sk, node, sk_node)
#define <API key>(__sk, node) \
if (__sk && ({ node = &(__sk)->sk_node; 1; })) \
<API key>(__sk, node, sk_node)
#define sk_for_each_safe(__sk, node, tmp, list) \
<API key>(__sk, node, tmp, list, sk_node)
#define sk_for_each_bound(__sk, node, list) \
<API key>(__sk, node, list, sk_bind_node)
/* Sock flags */
enum sock_flags {
SOCK_DEAD,
SOCK_DONE,
SOCK_URGINLINE,
SOCK_KEEPOPEN,
SOCK_LINGER,
SOCK_DESTROY,
SOCK_BROADCAST,
SOCK_TIMESTAMP,
SOCK_ZAPPED,
<API key>, /* whether to call sk->sk_write_space in sock_wfree */
SOCK_DBG, /* %SO_DEBUG setting */
SOCK_RCVTSTAMP, /* %SO_TIMESTAMP setting */
SOCK_NO_LARGESEND, /* whether to sent large segments or not */
SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */
SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */
};
static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
{
nsk->sk_flags = osk->sk_flags;
}
static inline void sock_set_flag(struct sock *sk, enum sock_flags flag)
{
__set_bit(flag, &sk->sk_flags);
}
static inline void sock_reset_flag(struct sock *sk, enum sock_flags flag)
{
__clear_bit(flag, &sk->sk_flags);
}
static inline int sock_flag(struct sock *sk, enum sock_flags flag)
{
return test_bit(flag, &sk->sk_flags);
}
static inline void sk_acceptq_removed(struct sock *sk)
{
sk->sk_ack_backlog
}
static inline void sk_acceptq_added(struct sock *sk)
{
sk->sk_ack_backlog++;
}
static inline int sk_acceptq_is_full(struct sock *sk)
{
return sk->sk_ack_backlog > sk->sk_max_ack_backlog;
}
/*
* Compute minimal free write space needed to queue new packets.
*/
static inline int <API key>(struct sock *sk)
{
return sk->sk_wmem_queued / 2;
}
static inline int sk_stream_wspace(struct sock *sk)
{
return sk->sk_sndbuf - sk->sk_wmem_queued;
}
extern void <API key>(struct sock *sk);
static inline int <API key>(struct sock *sk)
{
return sk->sk_wmem_queued < sk->sk_sndbuf;
}
extern void sk_stream_rfree(struct sk_buff *skb);
static inline void <API key>(struct sk_buff *skb, struct sock *sk)
{
skb->sk = sk;
skb->destructor = sk_stream_rfree;
atomic_add(skb->truesize, &sk->sk_rmem_alloc);
sk->sk_forward_alloc -= skb->truesize;
}
static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb)
{
sock_set_flag(sk, SOCK_QUEUE_SHRUNK);
sk->sk_wmem_queued -= skb->truesize;
sk->sk_forward_alloc += skb->truesize;
__kfree_skb(skb);
}
/* The per-socket spinlock must be held here. */
#define sk_add_backlog(__sk, __skb) \
do { if (!(__sk)->sk_backlog.tail) { \
(__sk)->sk_backlog.head = \
(__sk)->sk_backlog.tail = (__skb); \
} else { \
((__sk)->sk_backlog.tail)->next = (__skb); \
(__sk)->sk_backlog.tail = (__skb); \
} \
(__skb)->next = NULL; \
} while(0)
#define sk_wait_event(__sk, __timeo, __condition) \
({ int rc; \
release_sock(__sk); \
rc = __condition; \
if (!rc) { \
*(__timeo) = schedule_timeout(*(__timeo)); \
rc = __condition; \
} \
lock_sock(__sk); \
rc; \
})
extern int <API key>(struct sock *sk, long *timeo_p);
extern int <API key>(struct sock *sk, long *timeo_p);
extern void <API key>(struct sock *sk, long timeo_p);
extern int sk_stream_error(struct sock *sk, int flags, int err);
extern void <API key>(struct sock *sk);
extern int sk_wait_data(struct sock *sk, long *timeo);
struct request_sock_ops;
/* Networking protocol blocks we attach to sockets.
* socket layer -> transport layer interface
* transport -> network interface is defined by struct inet_proto
*/
struct proto {
void (*close)(struct sock *sk,
long timeout);
int (*connect)(struct sock *sk,
struct sockaddr *uaddr,
int addr_len);
int (*disconnect)(struct sock *sk, int flags);
struct sock * (*accept) (struct sock *sk, int flags, int *err);
int (*ioctl)(struct sock *sk, int cmd,
unsigned long arg);
int (*init)(struct sock *sk);
int (*destroy)(struct sock *sk);
void (*shutdown)(struct sock *sk, int how);
int (*setsockopt)(struct sock *sk, int level,
int optname, char __user *optval,
int optlen);
int (*getsockopt)(struct sock *sk, int level,
int optname, char __user *optval,
int __user *option);
int (*sendmsg)(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg, size_t len);
int (*recvmsg)(struct kiocb *iocb, struct sock *sk,
struct msghdr *msg,
size_t len, int noblock, int flags,
int *addr_len);
int (*sendpage)(struct sock *sk, struct page *page,
int offset, size_t size, int flags);
int (*bind)(struct sock *sk,
struct sockaddr *uaddr, int addr_len);
int (*backlog_rcv) (struct sock *sk,
struct sk_buff *skb);
/* Keeping track of sk's, looking them up, and port selection methods. */
void (*hash)(struct sock *sk);
void (*unhash)(struct sock *sk);
int (*get_port)(struct sock *sk, unsigned short snum);
/* Memory pressure */
void (*<API key>)(void);
atomic_t *memory_allocated; /* Current allocated memory. */
atomic_t *sockets_allocated; /* Current number of sockets. */
/*
* Pressure flag: try to collapse.
* Technical note: it is used by multiple contexts non atomically.
* All the <API key>() is of this nature: accounting
* is strict, actions are advisory and have some latency.
*/
int *memory_pressure;
int *sysctl_mem;
int *sysctl_wmem;
int *sysctl_rmem;
int max_header;
kmem_cache_t *slab;
unsigned int obj_size;
struct request_sock_ops *rsk_prot;
struct module *owner;
char name[32];
struct list_head node;
struct {
int inuse;
u8 __pad[SMP_CACHE_BYTES - sizeof(int)];
} stats[NR_CPUS];
};
extern int proto_register(struct proto *prot, int alloc_slab);
extern void proto_unregister(struct proto *prot);
/* Called with local bh disabled */
static __inline__ void sock_prot_inc_use(struct proto *prot)
{
prot->stats[smp_processor_id()].inuse++;
}
static __inline__ void sock_prot_dec_use(struct proto *prot)
{
prot->stats[smp_processor_id()].inuse
}
/* About 10 seconds */
#define SOCK_DESTROY_TIME (10*HZ)
/* Sockets 0-1023 can't be bound to unless you are superuser */
#define PROT_SOCK 1024
#define SHUTDOWN_MASK 3
#define RCV_SHUTDOWN 1
#define SEND_SHUTDOWN 2
#define SOCK_SNDBUF_LOCK 1
#define SOCK_RCVBUF_LOCK 2
#define SOCK_BINDADDR_LOCK 4
#define SOCK_BINDPORT_LOCK 8
/* sock_iocb: used to kick off async processing of socket ios */
struct sock_iocb {
struct list_head list;
int flags;
int size;
struct socket *sock;
struct sock *sk;
struct scm_cookie *scm;
struct msghdr *msg, async_msg;
struct iovec async_iov;
struct kiocb *kiocb;
};
static inline struct sock_iocb *kiocb_to_siocb(struct kiocb *iocb)
{
return (struct sock_iocb *)iocb->private;
}
static inline struct kiocb *siocb_to_kiocb(struct sock_iocb *si)
{
return si->kiocb;
}
struct socket_alloc {
struct socket socket;
struct inode vfs_inode;
};
static inline struct socket *SOCKET_I(struct inode *inode)
{
return &container_of(inode, struct socket_alloc, vfs_inode)->socket;
}
static inline struct inode *SOCK_INODE(struct socket *socket)
{
return &container_of(socket, struct socket_alloc, socket)->vfs_inode;
}
extern void <API key>(struct sock *sk);
extern int <API key>(struct sock *sk, int size, int kind);
#define <API key> ((int)PAGE_SIZE)
static inline int sk_stream_pages(int amt)
{
return (amt + <API key> - 1) / <API key>;
}
static inline void <API key>(struct sock *sk)
{
if (sk->sk_forward_alloc >= <API key>)
<API key>(sk);
}
static inline void <API key>(struct sock *sk)
{
struct sk_buff *skb;
while ((skb = __skb_dequeue(&sk->sk_write_queue)) != NULL)
sk_stream_free_skb(sk, skb);
<API key>(sk);
}
static inline int <API key>(struct sock *sk, struct sk_buff *skb)
{
return (int)skb->truesize <= sk->sk_forward_alloc ||
<API key>(sk, skb->truesize, 1);
}
/* Used by processes to "lock" a socket state, so that
* interrupts and bottom half handlers won't change it
* from under us. It essentially blocks any incoming
* packets, so that we won't get any new data or any
* packets that change the state of the socket.
*
* While locked, BH processing will add new packets to
* the backlog queue. This queue is processed by the
* owner of the socket lock right before it is released.
*
* Since ~2.3.5 it is also exclusive sleep lock serializing
* accesses from user process context.
*/
#define sock_owned_by_user(sk) ((sk)->sk_lock.owner)
extern void FASTCALL(lock_sock(struct sock *sk));
extern void FASTCALL(release_sock(struct sock *sk));
/* BH context may only use the following locking interface. */
#define bh_lock_sock(__sk) spin_lock(&((__sk)->sk_lock.slock))
#define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock))
extern struct sock *sk_alloc(int family,
unsigned int __nocast priority,
struct proto *prot, int zero_it);
extern void sk_free(struct sock *sk);
extern struct sk_buff *sock_wmalloc(struct sock *sk,
unsigned long size, int force,
unsigned int __nocast priority);
extern struct sk_buff *sock_rmalloc(struct sock *sk,
unsigned long size, int force,
unsigned int __nocast priority);
extern void sock_wfree(struct sk_buff *skb);
extern void sock_rfree(struct sk_buff *skb);
extern int sock_setsockopt(struct socket *sock, int level,
int op, char __user *optval,
int optlen);
extern int sock_getsockopt(struct socket *sock, int level,
int op, char __user *optval,
int __user *optlen);
extern struct sk_buff *sock_alloc_send_skb(struct sock *sk,
unsigned long size,
int noblock,
int *errcode);
extern void *sock_kmalloc(struct sock *sk, int size,
unsigned int __nocast priority);
extern void sock_kfree_s(struct sock *sk, void *mem, int size);
extern void sk_send_sigurg(struct sock *sk);
/*
* Functions to fill in entries in struct proto_ops when a protocol
* does not implement a particular function.
*/
extern int sock_no_bind(struct socket *,
struct sockaddr *, int);
extern int sock_no_connect(struct socket *,
struct sockaddr *, int, int);
extern int sock_no_socketpair(struct socket *,
struct socket *);
extern int sock_no_accept(struct socket *,
struct socket *, int);
extern int sock_no_getname(struct socket *,
struct sockaddr *, int *, int);
extern unsigned int sock_no_poll(struct file *, struct socket *,
struct poll_table_struct *);
extern int sock_no_ioctl(struct socket *, unsigned int,
unsigned long);
extern int sock_no_listen(struct socket *, int);
extern int sock_no_shutdown(struct socket *, int);
extern int sock_no_getsockopt(struct socket *, int , int,
char __user *, int __user *);
extern int sock_no_setsockopt(struct socket *, int, int,
char __user *, int);
extern int sock_no_sendmsg(struct kiocb *, struct socket *,
struct msghdr *, size_t);
extern int sock_no_recvmsg(struct kiocb *, struct socket *,
struct msghdr *, size_t, int);
extern int sock_no_mmap(struct file *file,
struct socket *sock,
struct vm_area_struct *vma);
extern ssize_t sock_no_sendpage(struct socket *sock,
struct page *page,
int offset, size_t size,
int flags);
/*
* Functions to fill in entries in struct proto_ops when a protocol
* uses the inet style.
*/
extern int <API key>(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen);
extern int sock_common_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size, int flags);
extern int <API key>(struct socket *sock, int level, int optname,
char __user *optval, int optlen);
extern void sk_common_release(struct sock *sk);
/*
* Default socket callbacks and setup code
*/
/* Initialise core socket variables */
extern void sock_init_data(struct socket *sock, struct sock *sk);
/**
* sk_filter - run a packet through a socket filter
* @sk: sock associated with &sk_buff
* @skb: buffer to filter
* @needlock: set to 1 if the sock is not locked by caller.
*
* Run the filter code and then cut skb->data to correct size returned by
* sk_run_filter. If pkt_len is 0 we toss packet. If skb->len is smaller
* than pkt_len we keep whole skb->data. This is the socket level
* wrapper to sk_run_filter. It returns 0 if the packet should
* be accepted or -EPERM if the packet should be tossed.
*
*/
static inline int sk_filter(struct sock *sk, struct sk_buff *skb, int needlock)
{
int err;
err = <API key>(sk, skb);
if (err)
return err;
if (sk->sk_filter) {
struct sk_filter *filter;
if (needlock)
bh_lock_sock(sk);
filter = sk->sk_filter;
if (filter) {
int pkt_len = sk_run_filter(skb, filter->insns,
filter->len);
if (!pkt_len)
err = -EPERM;
else
skb_trim(skb, pkt_len);
}
if (needlock)
bh_unlock_sock(sk);
}
return err;
}
/**
* sk_filter_release: Release a socket filter
* @sk: socket
* @fp: filter to remove
*
* Remove a filter from a socket and release its resources.
*/
static inline void sk_filter_release(struct sock *sk, struct sk_filter *fp)
{
unsigned int size = sk_filter_len(fp);
atomic_sub(size, &sk->sk_omem_alloc);
if (atomic_dec_and_test(&fp->refcnt))
kfree(fp);
}
static inline void sk_filter_charge(struct sock *sk, struct sk_filter *fp)
{
atomic_inc(&fp->refcnt);
atomic_add(sk_filter_len(fp), &sk->sk_omem_alloc);
}
/*
* Socket reference counting postulates.
*
* * Each user of socket SHOULD hold a reference count.
* * Each access point to socket (an hash table bucket, reference from a list,
* running timer, skb in flight MUST hold a reference count.
* * When reference count hits 0, it means it will never increase back.
* * When reference count hits 0, it means that no references from
* outside exist to this socket and current process on current CPU
* is last user and may/should destroy this socket.
* * sk_free is called from any context: process, BH, IRQ. When
* it is called, socket has no references from outside -> sk_free
* may release descendant resources allocated by the socket, but
* to the time when it is called, socket is NOT referenced by any
* hash tables, lists etc.
* * Packets, delivered from outside (from network or from another process)
* and enqueued on receive/error queues SHOULD NOT grab reference count,
* when they sit in queue. Otherwise, packets will leak to hole, when
* socket is looked up by one cpu and unhasing is made by another CPU.
* It is true for udp/raw, netlink (leak to receive and error queues), tcp
* (leak to backlog). Packet socket does all the processing inside
* BR_NETPROTO_LOCK, so that it has not this race condition. UNIX sockets
* use separate SMP lock, so that they are prone too.
*/
/* Ungrab socket and destroy it, if it was the last reference. */
static inline void sock_put(struct sock *sk)
{
if (atomic_dec_and_test(&sk->sk_refcnt))
sk_free(sk);
}
/* Detach socket from process context.
* Announce socket dead, detach it from wait queue and inode.
* Note that parent inode held reference count on this struct sock,
* we do not release it in this function, because protocol
* probably wants some additional cleanups or even continuing
* to work with this socket (TCP).
*/
static inline void sock_orphan(struct sock *sk)
{
write_lock_bh(&sk->sk_callback_lock);
sock_set_flag(sk, SOCK_DEAD);
sk->sk_socket = NULL;
sk->sk_sleep = NULL;
write_unlock_bh(&sk->sk_callback_lock);
}
static inline void sock_graft(struct sock *sk, struct socket *parent)
{
write_lock_bh(&sk->sk_callback_lock);
sk->sk_sleep = &parent->wait;
parent->sk = sk;
sk->sk_socket = parent;
write_unlock_bh(&sk->sk_callback_lock);
}
extern int sock_i_uid(struct sock *sk);
extern unsigned long sock_i_ino(struct sock *sk);
static inline struct dst_entry *
__sk_dst_get(struct sock *sk)
{
return sk->sk_dst_cache;
}
static inline struct dst_entry *
sk_dst_get(struct sock *sk)
{
struct dst_entry *dst;
read_lock(&sk->sk_dst_lock);
dst = sk->sk_dst_cache;
if (dst)
dst_hold(dst);
read_unlock(&sk->sk_dst_lock);
return dst;
}
static inline void
__sk_dst_set(struct sock *sk, struct dst_entry *dst)
{
struct dst_entry *old_dst;
old_dst = sk->sk_dst_cache;
sk->sk_dst_cache = dst;
dst_release(old_dst);
}
static inline void
sk_dst_set(struct sock *sk, struct dst_entry *dst)
{
write_lock(&sk->sk_dst_lock);
__sk_dst_set(sk, dst);
write_unlock(&sk->sk_dst_lock);
}
static inline void
__sk_dst_reset(struct sock *sk)
{
struct dst_entry *old_dst;
old_dst = sk->sk_dst_cache;
sk->sk_dst_cache = NULL;
dst_release(old_dst);
}
static inline void
sk_dst_reset(struct sock *sk)
{
write_lock(&sk->sk_dst_lock);
__sk_dst_reset(sk);
write_unlock(&sk->sk_dst_lock);
}
static inline struct dst_entry *
__sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk->sk_dst_cache;
if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk->sk_dst_cache = NULL;
dst_release(dst);
return NULL;
}
return dst;
}
static inline struct dst_entry *
sk_dst_check(struct sock *sk, u32 cookie)
{
struct dst_entry *dst = sk_dst_get(sk);
if (dst && dst->obsolete && dst->ops->check(dst, cookie) == NULL) {
sk_dst_reset(sk);
dst_release(dst);
return NULL;
}
return dst;
}
static inline void sk_charge_skb(struct sock *sk, struct sk_buff *skb)
{
sk->sk_wmem_queued += skb->truesize;
sk->sk_forward_alloc -= skb->truesize;
}
static inline int skb_copy_to_page(struct sock *sk, char __user *from,
struct sk_buff *skb, struct page *page,
int off, int copy)
{
if (skb->ip_summed == CHECKSUM_NONE) {
int err = 0;
unsigned int csum = <API key>(from,
page_address(page) + off,
copy, 0, &err);
if (err)
return err;
skb->csum = csum_block_add(skb->csum, csum, skb->len);
} else if (copy_from_user(page_address(page) + off, from, copy))
return -EFAULT;
skb->len += copy;
skb->data_len += copy;
skb->truesize += copy;
sk->sk_wmem_queued += copy;
sk->sk_forward_alloc -= copy;
return 0;
}
/*
* Queue a received datagram if it will fit. Stream and sequenced
* protocols can't normally use this as they need to fit buffers in
* and play with them.
*
* Inlined as it's very short and called for pretty much every
* packet ever received.
*/
static inline void skb_set_owner_w(struct sk_buff *skb, struct sock *sk)
{
sock_hold(sk);
skb->sk = sk;
skb->destructor = sock_wfree;
atomic_add(skb->truesize, &sk->sk_wmem_alloc);
}
static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
{
skb->sk = sk;
skb->destructor = sock_rfree;
atomic_add(skb->truesize, &sk->sk_rmem_alloc);
}
extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
unsigned long expires);
extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);
static inline int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
{
int err = 0;
int skb_len;
/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
number of warnings when compiling with -W --ANK
*/
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf) {
err = -ENOMEM;
goto out;
}
/* It would be deadlock, if sock_queue_rcv_skb is used
with socket lock! We assume that users of this
function are lock free.
*/
err = sk_filter(sk, skb, 1);
if (err)
goto out;
skb->dev = NULL;
skb_set_owner_r(skb, sk);
/* Cache the SKB length before we tack it onto the receive
* queue. Once it is added it no longer belongs to us and
* may be freed by other threads of control pulling packets
* from the queue.
*/
skb_len = skb->len;
skb_queue_tail(&sk->sk_receive_queue, skb);
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb_len);
out:
return err;
}
static inline int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb)
{
/* Cast skb->rcvbuf to unsigned... It's pointless, but reduces
number of warnings when compiling with -W --ANK
*/
if (atomic_read(&sk->sk_rmem_alloc) + skb->truesize >=
(unsigned)sk->sk_rcvbuf)
return -ENOMEM;
skb_set_owner_r(skb, sk);
skb_queue_tail(&sk->sk_error_queue, skb);
if (!sock_flag(sk, SOCK_DEAD))
sk->sk_data_ready(sk, skb->len);
return 0;
}
/*
* Recover an error report and clear atomically
*/
static inline int sock_error(struct sock *sk)
{
int err = xchg(&sk->sk_err, 0);
return -err;
}
static inline unsigned long sock_wspace(struct sock *sk)
{
int amt = 0;
if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
amt = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
if (amt < 0)
amt = 0;
}
return amt;
}
static inline void sk_wake_async(struct sock *sk, int how, int band)
{
if (sk->sk_socket && sk->sk_socket->fasync_list)
sock_wake_async(sk->sk_socket, how, band);
}
#define SOCK_MIN_SNDBUF 2048
#define SOCK_MIN_RCVBUF 256
static inline void <API key>(struct sock *sk)
{
if (!(sk->sk_userlocks & SOCK_SNDBUF_LOCK)) {
sk->sk_sndbuf = min(sk->sk_sndbuf, sk->sk_wmem_queued / 2);
sk->sk_sndbuf = max(sk->sk_sndbuf, SOCK_MIN_SNDBUF);
}
}
static inline struct sk_buff *<API key>(struct sock *sk,
int size, int mem,
unsigned int __nocast gfp)
{
struct sk_buff *skb;
int hdr_len;
hdr_len = SKB_DATA_ALIGN(sk->sk_prot->max_header);
skb = alloc_skb(size + hdr_len, gfp);
if (skb) {
skb->truesize += mem;
if (sk->sk_forward_alloc >= (int)skb->truesize ||
<API key>(sk, skb->truesize, 0)) {
skb_reserve(skb, hdr_len);
return skb;
}
__kfree_skb(skb);
} else {
sk->sk_prot-><API key>();
<API key>(sk);
}
return NULL;
}
static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk,
int size,
unsigned int __nocast gfp)
{
return <API key>(sk, size, 0, gfp);
}
static inline struct page *<API key>(struct sock *sk)
{
struct page *page = NULL;
if (sk->sk_forward_alloc >= (int)PAGE_SIZE ||
<API key>(sk, PAGE_SIZE, 0))
page = alloc_pages(sk->sk_allocation, 0);
else {
sk->sk_prot-><API key>();
<API key>(sk);
}
return page;
}
#define <API key>(skb, sk) \
for (skb = (sk)->sk_write_queue.next; \
(skb != (sk)->sk_send_head) && \
(skb != (struct sk_buff *)&(sk)->sk_write_queue); \
skb = skb->next)
/*
* Default write policy as shown to user space via poll/select/SIGIO
*/
static inline int sock_writeable(const struct sock *sk)
{
return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2);
}
static inline unsigned int __nocast gfp_any(void)
{
return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
}
static inline long sock_rcvtimeo(const struct sock *sk, int noblock)
{
return noblock ? 0 : sk->sk_rcvtimeo;
}
static inline long sock_sndtimeo(const struct sock *sk, int noblock)
{
return noblock ? 0 : sk->sk_sndtimeo;
}
static inline int sock_rcvlowat(const struct sock *sk, int waitall, int len)
{
return (waitall ? len : min_t(int, sk->sk_rcvlowat, len)) ? : 1;
}
/* Alas, with timeout socket operations are not restartable.
* Compare this to poll().
*/
static inline int sock_intr_errno(long timeo)
{
return timeo == <API key> ? -ERESTARTSYS : -EINTR;
}
static __inline__ void
sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
{
struct timeval *stamp = &skb->stamp;
if (sock_flag(sk, SOCK_RCVTSTAMP)) {
/* Race occurred between timestamp enabling and packet
receiving. Fill in the current time for now. */
if (stamp->tv_sec == 0)
do_gettimeofday(stamp);
put_cmsg(msg, SOL_SOCKET, SO_TIMESTAMP, sizeof(struct timeval),
stamp);
} else
sk->sk_stamp = *stamp;
}
/**
* sk_eat_skb - Release a skb if it is no longer needed
* @sk: socket to eat this skb from
* @skb: socket buffer to eat
*
* This routine must be called with interrupts disabled or with the socket
* locked so that the sk_buff queue operation is ok.
*/
static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb)
{
__skb_unlink(skb, &sk->sk_receive_queue);
__kfree_skb(skb);
}
extern void <API key>(struct sock *sk);
extern int sock_get_timestamp(struct sock *, struct timeval __user *);
/*
* Enable debug/info messages
*/
#if 0
#define NETDEBUG(x) do { } while (0)
#define LIMIT_NETDEBUG(x) do {} while(0)
#else
#define NETDEBUG(x) do { x; } while (0)
#define LIMIT_NETDEBUG(x) do { if (net_ratelimit()) { x; } } while(0)
#endif
/*
* Macros for sleeping on a socket. Use them like this:
*
* SOCK_SLEEP_PRE(sk)
* if (condition)
* schedule();
* SOCK_SLEEP_POST(sk)
*
* N.B. These are now obsolete and were, afaik, only ever used in DECnet
* and when the last use of them in DECnet has gone, I'm intending to
* remove them.
*/
#define SOCK_SLEEP_PRE(sk) { struct task_struct *tsk = current; \
DECLARE_WAITQUEUE(wait, tsk); \
tsk->state = TASK_INTERRUPTIBLE; \
add_wait_queue((sk)->sk_sleep, &wait); \
release_sock(sk);
#define SOCK_SLEEP_POST(sk) tsk->state = TASK_RUNNING; \
remove_wait_queue((sk)->sk_sleep, &wait); \
lock_sock(sk); \
}
static inline void sock_valbool_flag(struct sock *sk, int bit, int valbool)
{
if (valbool)
sock_set_flag(sk, bit);
else
sock_reset_flag(sk, bit);
}
extern __u32 sysctl_wmem_max;
extern __u32 sysctl_rmem_max;
#ifdef CONFIG_NET
int <API key>(unsigned int fd, unsigned int cmd, unsigned long arg);
#else
static inline int <API key>(unsigned int fd, unsigned int cmd, unsigned long arg)
{
return -ENODEV;
}
#endif
#endif /* _SOCK_H */
|
#include "SmoothTasks/<API key>.h"
#include <QApplication>
#include <cmath>
namespace SmoothTasks {
void <API key>::setItemsPerRow(int itemsPerRow) {
if (m_itemsPerRow != itemsPerRow) {
m_itemsPerRow = itemsPerRow;
invalidate();
}
}
int <API key>::optimumCapacity() const {
return m_itemsPerRow * maximumRows();
}
void <API key>::doLayout() {
// I think this way the loops can be optimized by the compiler.
// (lifting out the comparison and making two loops; TODO: find out whether this is true):
const bool isVertical = orientation() == Qt::Vertical;
const QList<TaskbarItem*>& items = this->items();
const int N = items.size();
// if there is nothing to layout fill in some dummy data and leave
if (N == 0) {
stopAnimation();
QRectF rect(geometry());
m_rows = 1;
if (isVertical) {
m_cellHeight = rect.width();
}
else {
m_cellHeight = rect.height();
}
QSizeF newPreferredSize(qMin(10.0, rect.width()), qMin(10.0, rect.height()));
if (newPreferredSize != m_preferredSize) {
m_preferredSize = newPreferredSize;
emit sizeHintChanged(Qt::PreferredSize);
}
return;
}
const QRectF effectiveRect(effectiveGeometry());
const qreal availableWidth = isVertical ? effectiveRect.height() : effectiveRect.width();
const qreal availableHeight = isVertical ? effectiveRect.width() : effectiveRect.height();
const qreal spacing = this->spacing();
#define CELL_HEIGHT(ROWS) (((availableHeight + spacing) / ((qreal) (ROWS))) - spacing)
int itemsPerRow = m_itemsPerRow;
int rows = maximumRows();
if (itemsPerRow * rows < N) {
itemsPerRow = std::ceil(((qreal) N) / rows);
}
else {
rows = std::ceil(((qreal) N) / itemsPerRow);
}
qreal cellHeight = CELL_HEIGHT(rows);
qreal cellWidth = cellHeight * aspectRatio();
QList<RowInfo> rowInfos;
qreal <API key> = 0;
buildRows(itemsPerRow, cellWidth, rowInfos, rows, <API key>);
cellHeight = CELL_HEIGHT(rows);
updateLayout(rows, cellWidth, cellHeight, availableWidth, <API key>, rowInfos, effectiveRect);
#undef CELL_HEIGHT
}
} // namespace SmoothTasks
|
#ifndef _HEAD_HACK_CLIENT
#define _HEAD_HACK_CLIENT
#define SOCKET_SEND_MAXLEN 1024
int init_client_connect();
int handle_send(int sock_fd, const char *msg);
#endif
|
'use strict';
var env = process.env.NODE_ENV || 'development',
config = require('./config'),
B = require('bluebird'),
_ = require('underscore'),
L = require('./logger'),
S = require('underscore.string'),
nodemailer = require('nodemailer'),
smtpTransport = require('<API key>');
var Mailer = function (options) {
var opts = _.extend({}, config.mail, options);
this.transporter = B.promisifyAll(nodemailer.createTransport(smtpTransport(opts)));
};
Mailer.prototype.send = function (options) {
var that = this;
return that.transporter.sendMailAsync(options);
};
module.exports = Mailer;
|
#include <linux/kernel.h>
#include <linux/irq.h>
#include <linux/gpio.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/bootmem.h>
#include <linux/io.h>
#ifdef CONFIG_SPI_QSD
#include <linux/spi/spi.h>
#endif
#include <linux/mfd/pmic8058.h>
#include <linux/mfd/marimba.h>
#include <linux/i2c.h>
#include <linux/input.h>
#ifdef CONFIG_SMSC911X
#include <linux/smsc911x.h>
#endif
#include <linux/ofn_atlab.h>
#include <linux/power_supply.h>
#include <linux/input/pmic8058-keypad.h>
#include <linux/i2c/isa1200.h>
#include <linux/pwm.h>
#include <linux/pmic8058-pwm.h>
#include <linux/i2c/tsc2007.h>
#include <linux/input/kp_flip_switch.h>
#include <linux/leds-pmic8058.h>
#include <linux/input/cy8c_ts.h>
#include <linux/msm_adc.h>
#include <linux/dma-mapping.h>
#ifdef <API key>
#include <linux/gpio_keys.h> // <API key>
#endif
#ifdef <API key>
#include <linux/pmic8058-vibrator.h> // <API key>
#endif
#include <linux/gps_fm_lna.h> /* AlbertYCFang, 2011.06.13, FM */
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/setup.h>
#include <mach/mpp.h>
#include <mach/board.h>
#include <mach/camera.h>
#include <mach/memory.h>
#include <mach/msm_iomap.h>
#include <mach/msm_hsusb.h>
#include <mach/rpc_hsusb.h>
#include <mach/msm_spi.h>
#include <mach/qdsp5v2/msm_lpa.h>
#include <mach/dma.h>
#include <linux/android_pmem.h>
#include <linux/input/msm_ts.h>
#include <mach/pmic.h>
#include <mach/rpc_pmapp.h>
#include <mach/qdsp5v2/aux_pcm.h>
#include <mach/qdsp5v2/mi2s.h>
#include <mach/qdsp5v2/audio_dev_ctl.h>
#ifdef CONFIG_BATTERY_MSM
#include <mach/msm_battery.h>
#endif
#include <mach/rpc_server_handset.h>
#include <mach/msm_tsif.h>
#include <mach/socinfo.h>
#include <linux/cyttsp.h>
#include <asm/mach/mmc.h>
#include <asm/mach/flash.h>
#include <mach/vreg.h>
#include "devices.h"
#include "timer.h"
#ifdef CONFIG_USB_ANDROID
#include <linux/usb/android_composite.h>
#endif
#include "pm.h"
#include "spm.h"
#include <linux/msm_kgsl.h>
#include <mach/dal_axi.h>
#include <mach/msm_serial_hs.h>
#include <mach/msm_reqs.h>
#include <mach/qdsp5v2/mi2s.h>
#include <mach/qdsp5v2/audio_dev_ctl.h>
#include <mach/sdio_al.h>
#include "smd_private.h"
#include <linux/fih_hw_info.h> //FIHTDC, Div2-SW2-BSP
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
#undef HDMI_RESET
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
#include <linux/bma150.h>
#ifdef <API key>
#include <mach/leds-fbx-pwm.h> // <API key>
#endif
//FIHTDC, Port keypad, MayLi, 2011.09.21 {+
#ifdef <API key>
#include <mach/sf8_kybd.h>
#endif
//FIHTDC, Port keypad, MayLi, 2011.09.21 -}
#ifdef CONFIG_DS2482
#include <mach/ds2482.h> // <API key>
#endif
#ifdef <API key>
#include <mach/ds2784.h> // <API key>
#endif
#ifdef <API key>
#include <mach/fih_msm_battery.h> // <API key>
#endif
#ifdef <API key>
#include <mach/bq275x0_battery.h> // <API key>
#endif
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
#include <linux/switch.h>
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
/* FIHTDC, Div2-SW2-BSP, Penho, USB_ACCESORIES { */
#ifdef <API key>
#include <linux/usb/f_accessory.h>
#endif // <API key>
/* } FIHTDC, Div2-SW2-BSP, Penho, USB_ACCESORIES */
/* FIHTDC, Div2-SW2-BSP, Ming, PMEM { */
/* Enlarge PMEM_SF to 30 MB for WVGA */
#define MSM_PMEM_SF_SIZE 0x1E00000 //0x1700000
/* } FIHTDC, Div2-SW2-BSP, Ming, PMEM */
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
#define MSM_FB_SIZE 0x500000
#else
#define MSM_FB_SIZE 0xA00000 ///0x500000
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
#define MSM_PMEM_ADSP_SIZE 0x2400000 //0x1800000 //<API key>.3_R4_FailIssue-00*
#define <API key> 0x2800000
#define <API key> 0x600000
#define MSM_PMEM_AUDIO_SIZE 0x200000
#define PMIC_GPIO_INT 27
#define <API key> 2900
#define PMIC_GPIO_SD_DET 36
#define PMIC_GPIO_SDC4_EN_N 17 /* PMIC GPIO Number 18 */
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
#define <API key> 32 /* PMIC GPIO for V3 H/W */
#define <API key> 39 /* PMIC GPIO for V2 H/W */
#define ADV7520_I2C_ADDR 0x39
#endif
#ifdef <API key>
#define <API key> 32 /* PMIC GPIO Number 33 */
#define GPIO_HDMI_5V_EN \
GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA)
#define HDMI_INT 180
static bool hdmi_init_done = false;
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
/* FIHTDC, Div2-SW2-BSP, Ming, LCM { */
#define <API key> 35 /* PMIC GPIO Number 36 */
/* } FIHTDC, Div2-SW2-BSP, Ming, LCM */
#define FPGA_SDCC_STATUS 0x8E0001A8
#define <API key> 0x8E000026
#define <API key> (0xB0 >> 1)
#define OPTNAV_IRQ 20
#define OPTNAV_CHIP_SELECT 19
/* Macros assume PMIC GPIOs start at 0 */
#define <API key>(pm_gpio) (pm_gpio + NR_GPIO_IRQS)
#define <API key>(sys_gpio) (sys_gpio - NR_GPIO_IRQS)
#define <API key> 15 /* PMIC GPIO Number 16 */
#define <API key> 16 /* PMIC GPIO Number 17 */
#define <API key> 22 /* PMIC GPIO NUMBER 23 */
#define BMA150_GPIO_INT 1
#define <API key> 24
#define <API key> 37 /* PMIC GPIO 38 */
#define PM_FLIP_MPP 5 /* PMIC MPP 06 */
/* +++ AlbertYCFang, 2011.06.13,FM +++ */
//SQ01.FC-73: Change QTR8200 WCN clock source(32M) from PMIC-D0 to PMIC-A1
#if defined(<API key>) || defined(<API key>)
#define QTR8x00_WCN_CLK PMAPP_CLOCK_ID_DO
#else
#define QTR8x00_WCN_CLK PMAPP_CLOCK_ID_A1
#endif
// <API key>+
#ifdef <API key>
#define PM_GPIO_CAMF 1
#define PM_GPIO_CAMT 2
#define PM_GPIO_VOLUP 3
#define PM_GPIO_VOLDN 4
#define KEY_NUM 4
#define KEY_FOCUS KEY_F13
#define <API key> 2
static struct gpio_keys_button gpio_buttons[KEY_NUM] = {
{
.code = KEY_VOLUMEUP,
.gpio = <API key>(PM_GPIO_VOLUP),
.active_low = 0,
.desc = "Vol Up Key",
.type = EV_KEY,
.wakeup = 0,
.debounce_interval = <API key>
},
{
.code = KEY_VOLUMEDOWN,
.gpio = <API key>(PM_GPIO_VOLDN),
.active_low = 0,
.desc = "Vol Dn Key",
.type = EV_KEY,
.wakeup = 0,
.debounce_interval = <API key>
},
{
.code = KEY_FOCUS,
.gpio = <API key>(PM_GPIO_CAMF),
.active_low = 0,
.desc = "Focus Key",
.type = EV_KEY,
.wakeup = 0,
.debounce_interval = <API key>
},
{
.code = KEY_CAMERA,
.gpio = <API key>(PM_GPIO_CAMT),
.active_low = 0,
.desc = "Camera Key",
.type = EV_KEY,
.wakeup = 0,
.debounce_interval = <API key>
},
};
static struct <API key> gpio_buttons_pdata = {
.buttons = gpio_buttons,
.nbuttons = KEY_NUM - 2,
.rep = 0
};
static struct platform_device gpio_buttons_device = {
.name = "gpio-keys",
.id = -1,
.dev = {
.platform_data = &gpio_buttons_pdata,
},
};
#endif
// <API key>-
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
bool m_HsAmpOn=false;
bool m_SpkAmpOn=false;
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
int sd_detect_pin = 0;
int sd_enable_pin = 0;
static int pm8058_gpios_init(void)
{
int rc;
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
int <API key>;
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
/* remove redundant code*/
#if 0
#ifdef <API key>
struct pm8058_gpio sdcc_det = {
.direction = PM_GPIO_DIR_IN,
.pull = PM_GPIO_PULL_UP_1P5,
.vin_sel = 2,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
};
#endif
#endif
struct pm8058_gpio sdc4_en = {
.direction = PM_GPIO_DIR_OUT,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_L5,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
.out_strength = <API key>,
.output_value = 0,
};
struct pm8058_gpio haptics_enable = {
.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,
};
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
struct pm8058_gpio hdmi_5V_en = {
.direction = PM_GPIO_DIR_OUT,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_VPH,
.function = PM_GPIO_FUNC_NORMAL,
.out_strength = <API key>,
.output_value = 0,
};
#endif
#ifdef <API key>
struct pm8058_gpio hdmi_18V_en = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = <API key>,
.output_value = 1,
.pull = PM_GPIO_PULL_NO,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_NORMAL,
};
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
/* FIHTDC, Div2-SW2-BSP, Ming, LCM { */
struct pm8058_gpio lcm_v1p8_en ={
.direction = PM_GPIO_DIR_OUT, //Let the pin be an output one.
.output_buffer = <API key>, //HW suggestion
.output_value = 1, //You also can set 0, but it seems useless.
.out_strength = <API key>, //There are three options for this, LOW, MED, and HIGH, but I don!|t know the actual effect.
.function = PM_GPIO_FUNC_NORMAL, //Let the pin be a general GPIO.
};
/* } FIHTDC, Div2-SW2-BSP, Ming, LCM */
struct pm8058_gpio flash_boost_enable = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = <API key>,
.output_value = 0,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_S3,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_2,
};
struct pm8058_gpio gpio23 = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = <API key>,
.output_value = 0,
.pull = PM_GPIO_PULL_NO,
.vin_sel = 2,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_NORMAL,
};
// <API key>+
#ifdef <API key>
struct pm8058_gpio <API key> = {
.direction = PM_GPIO_DIR_IN,
.pull = PM_GPIO_PULL_DN,
.vin_sel = 2,
.out_strength = PM_GPIO_STRENGTH_NO,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
};
#endif
// <API key>-
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
if (<API key>() || <API key>() ||
<API key>())
<API key> = <API key> ;
else
<API key> = <API key> ;
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
if (<API key>()) {
rc = pm8058_gpio_config(<API key>, &haptics_enable);
if (rc) {
pr_err("%s: PMIC GPIO %d write failed\n", __func__,
(<API key> + 1));
return rc;
}
rc = pm8058_gpio_config(<API key>,
&flash_boost_enable);
if (rc) {
pr_err("%s: PMIC GPIO %d write failed\n", __func__,
(<API key> + 1));
return rc;
}
}
/*remove redundant code*/
#if 0
#ifdef <API key>
if (<API key>())
sdcc_det.inv_int_pol = 1;
rc = pm8058_gpio_config(PMIC_GPIO_SD_DET - 1, &sdcc_det);
if (rc) {
pr_err("%s PMIC_GPIO_SD_DET config failed\n", __func__);
return rc;
}
#endif
#endif
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
rc = pm8058_gpio_config(<API key>, &hdmi_5V_en);
if (rc) {
pr_err("%s <API key> config failed\n", __func__);
return rc;
}
#endif
#ifdef <API key>
rc = pm8058_gpio_config(<API key>, &hdmi_18V_en);
if (rc) {
pr_err("%s PMIC_GPIO_HDMI_1.8V_EN config failed\n", __func__);
return rc;
}
rc = gpio_request(<API key>(<API key>),
"hdmi_18V_en");
if (rc) {
pr_err("%s PMIC_GPIO_HDMI_1.8V_EN gpio_request failed\n",
__func__);
return rc;
}
<API key>(
<API key>(<API key>), 1);
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
/* Deassert GPIO#23 (source for Ext_POR on WLAN-Volans) */
rc = pm8058_gpio_config(<API key>, &gpio23);
if (rc) {
pr_err("%s <API key> config failed\n", __func__);
return rc;
}
if (<API key>()) {
rc = pm8058_gpio_config(PMIC_GPIO_SDC4_EN_N, &sdc4_en);
if (rc) {
pr_err("%s PMIC_GPIO_SDC4_EN_N config failed\n",
__func__);
return rc;
}
rc = gpio_request(<API key>(PMIC_GPIO_SDC4_EN_N),
"sdc4_en");
if (rc) {
pr_err("%s PMIC_GPIO_SDC4_EN_N gpio_request failed\n",
__func__);
return rc;
}
<API key>(
<API key>(PMIC_GPIO_SDC4_EN_N), 0);
}
/* FIHTDC, Div2-SW2-BSP, Ming, LCM { */
rc = pm8058_gpio_config(<API key>, &lcm_v1p8_en);
if (rc) {
pr_err("%s <API key> config failed\n",
__func__);
return rc;
}
/* } FIHTDC, Div2-SW2-BSP, Ming, LCM */
// <API key>+
#ifdef <API key>
rc = pm8058_gpio_config(PM_GPIO_VOLUP, &<API key>);
if (rc < 0) {
printk(KERN_INFO "gpio %d configured failed\n", PM_GPIO_VOLUP);
return rc;
}
rc = pm8058_gpio_config(PM_GPIO_VOLDN, &<API key>);
if (rc < 0) {
printk(KERN_INFO "gpio %d configured failed\n", PM_GPIO_VOLDN);
return rc;
}
if (<API key>() == Product_PR1 || <API key>() == Product_EVB) {
rc = pm8058_gpio_config(PM_GPIO_CAMF, &<API key>);
if (rc < 0) {
printk(KERN_INFO "gpio %d configured failed\n", PM_GPIO_CAMF);
return rc;
}
rc = pm8058_gpio_config(PM_GPIO_CAMT, &<API key>);
if (rc < 0) {
printk(KERN_INFO "gpio %d configured failed\n", PM_GPIO_CAMT);
return rc;
}
gpio_buttons_pdata.nbuttons = KEY_NUM;
}
#endif
// <API key>-
return 0;
}
/*virtual key support */
static ssize_t tma300_vkeys_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
return sprintf(buf,
__stringify(EV_KEY) ":" __stringify(KEY_BACK) ":50:842:80:100"
":" __stringify(EV_KEY) ":" __stringify(KEY_MENU) ":170:842:80:100"
":" __stringify(EV_KEY) ":" __stringify(KEY_HOME) ":290:842:80:100"
":" __stringify(EV_KEY) ":" __stringify(KEY_SEARCH) ":410:842:80:100"
"\n");
}
static struct kobj_attribute tma300_vkeys_attr = {
.attr = {
.mode = S_IRUGO,
},
.show = &tma300_vkeys_show,
};
static struct attribute *<API key>[] = {
&tma300_vkeys_attr.attr,
NULL
};
static struct attribute_group <API key> = {
.attrs = <API key>,
};
static struct kobject *properties_kobj;
#define CYTTSP_TS_GPIO_IRQ 150
static int <API key>(struct i2c_client *client)
{
int rc = -EINVAL;
struct vreg *vreg_ldo8, *vreg_ldo15;
vreg_ldo8 = vreg_get(NULL, "gp7");
if (!vreg_ldo8) {
pr_err("%s: VREG L8 get failed\n", __func__);
return rc;
}
rc = vreg_set_level(vreg_ldo8, 1800);
if (rc) {
pr_err("%s: VREG L8 set failed\n", __func__);
goto l8_put;
}
rc = vreg_enable(vreg_ldo8);
if (rc) {
pr_err("%s: VREG L8 enable failed\n", __func__);
goto l8_put;
}
vreg_ldo15 = vreg_get(NULL, "gp6");
if (!vreg_ldo15) {
pr_err("%s: VREG L15 get failed\n", __func__);
goto l8_disable;
}
rc = vreg_set_level(vreg_ldo15, 3050);
if (rc) {
pr_err("%s: VREG L15 set failed\n", __func__);
goto l8_disable;
}
rc = vreg_enable(vreg_ldo15);
if (rc) {
pr_err("%s: VREG L15 enable failed\n", __func__);
goto l8_disable;
}
/* check this device active by reading first byte/register */
rc = <API key>(client, 0x01);
if (rc < 0) {
pr_err("%s: i2c sanity check failed\n", __func__);
goto l8_disable;
}
rc = gpio_tlmm_config(GPIO_CFG(CYTTSP_TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, CYTTSP_TS_GPIO_IRQ);
goto l8_disable;
}
rc = gpio_request(CYTTSP_TS_GPIO_IRQ, "ts_irq");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, CYTTSP_TS_GPIO_IRQ, rc);
goto l8_disable;
}
/* virtual keys */
tma300_vkeys_attr.attr.name = "virtualkeys.cyttsp-i2c";
properties_kobj = <API key>("board_properties",
NULL);
if (properties_kobj)
rc = sysfs_create_group(properties_kobj,
&<API key>);
if (!properties_kobj || rc)
pr_err("%s: failed to create board_properties\n",
__func__);
return CY_OK;
l8_disable:
vreg_disable(vreg_ldo8);
l8_put:
vreg_put(vreg_ldo8);
return rc;
}
static int <API key>(struct i2c_client *client)
{
/* add any special code to strobe a wakeup pin or chip reset */
mdelay(10);
return CY_OK;
}
static struct <API key> cyttsp_data = {
.panel_maxx = 479,
.panel_maxy = 799,
.disp_maxx = 469,
.disp_maxy = 799,
.disp_minx = 10,
.disp_miny = 0,
.flags = 0,
.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 = CY_USE_SLEEP,
.use_gestures = CY_USE_GESTURES,
/* 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,
/* change act_intrvl to customize the Active power state
* scanning/processing refresh interval for Operating mode
*/
.act_intrvl = CY_ACT_INTRVL_DFLT,
/* change tch_tmout to customize the touch timeout for the
* Active power state for Operating mode
*/
.tch_tmout = CY_TCH_TMOUT_DFLT,
/* change lp_intrvl to customize the Low Power power state
* scanning/processing refresh interval for Operating mode
*/
.lp_intrvl = CY_LP_INTRVL_DFLT,
.resume = <API key>,
.init = <API key>,
};
static int pm8058_pwm_config(struct pwm_device *pwm, int ch, int on)
{
struct pm8058_gpio pwm_gpio_config = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = <API key>,
.output_value = 0,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_S3,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_2,
};
int rc = -EINVAL;
int id, mode, max_mA;
id = mode = max_mA = 0;
switch (ch) {
case 0:
case 1:
case 2:
if (on) {
id = 24 + ch;
rc = pm8058_gpio_config(id - 1, &pwm_gpio_config);
if (rc)
pr_err("%s: pm8058_gpio_config(%d): rc=%d\n",
__func__, id, rc);
}
break;
case 3:
id = PM_PWM_LED_KPD;
mode = PM_PWM_CONF_DTEST3;
max_mA = 200;
break;
case 4:
id = PM_PWM_LED_0;
mode = PM_PWM_CONF_PWM1;
max_mA = 40;
break;
// <API key>+
#ifdef <API key>
case 5:
id = PM_PWM_LED_1;
mode = PM_PWM_CONF_PWM2;
max_mA = 40;
break;
case 6:
id = PM_PWM_LED_2;
mode = PM_PWM_CONF_PWM3;
max_mA = 40;
break;
#else
#ifdef <API key> //OwenHung Add+
case 5:
id = PM_PWM_LED_1;
mode = PM_PWM_CONF_PWM2;
max_mA = 10;
break;
case 6:
id = PM_PWM_LED_2;
mode = PM_PWM_CONF_PWM3;
max_mA = 10;
break;
#else
case 5:
id = PM_PWM_LED_2;
mode = PM_PWM_CONF_PWM2;
max_mA = 40;
break;
case 6:
id = PM_PWM_LED_FLASH;
mode = PM_PWM_CONF_DTEST3;
max_mA = 200;
break;
#endif
#endif
// <API key>-
default:
break;
}
if (ch >= 3 && ch <= 6) {
if (!on) {
mode = PM_PWM_CONF_NONE;
max_mA = 0;
}
rc = <API key>(pwm, id, mode, max_mA);
if (rc)
pr_err("%s: <API key>(ch=%d): rc=%d\n",
__func__, ch, rc);
}
return rc;
}
static int pm8058_pwm_enable(struct pwm_device *pwm, int ch, int on)
{
int rc;
switch (ch) {
case 7:
rc = <API key>(pwm, on);
if (rc)
pr_err("%s: pwm_set_dtest(%d): rc=%d\n",
__func__, on, rc);
break;
default:
rc = -EINVAL;
break;
}
return rc;
}
#ifdef <API key>
static const unsigned int fluid_keymap[] = {
KEY(0, 0, KEY_7),
KEY(0, 1, KEY_ENTER),
KEY(0, 2, KEY_UP),
/* drop (0,3) as it always shows up in pair with(0,2) */
KEY(0, 4, KEY_DOWN),
KEY(1, 0, KEY_CAMERA_SNAPSHOT),
KEY(1, 1, KEY_SELECT),
KEY(1, 2, KEY_1),
KEY(1, 3, KEY_VOLUMEUP),
KEY(1, 4, KEY_VOLUMEDOWN),
};
static const unsigned int surf_keymap[] = {
KEY(0, 0, KEY_7),
KEY(0, 1, KEY_DOWN),
KEY(0, 2, KEY_UP),
KEY(0, 3, KEY_RIGHT),
KEY(0, 4, KEY_ENTER),
KEY(0, 5, KEY_L),
KEY(0, 6, KEY_BACK),
KEY(0, 7, KEY_M),
KEY(1, 0, KEY_LEFT),
KEY(1, 1, KEY_SEND),
KEY(1, 2, KEY_1),
KEY(1, 3, KEY_4),
KEY(1, 4, KEY_CLEAR),
KEY(1, 5, KEY_MSDOS),
KEY(1, 6, KEY_SPACE),
KEY(1, 7, KEY_COMMA),
KEY(2, 0, KEY_6),
KEY(2, 1, KEY_5),
KEY(2, 2, KEY_8),
KEY(2, 3, KEY_3),
KEY(2, 4, KEY_NUMERIC_STAR),
KEY(2, 5, KEY_UP),
KEY(2, 6, KEY_DOWN), /* SYN */
KEY(2, 7, KEY_LEFTSHIFT),
KEY(3, 0, KEY_9),
KEY(3, 1, KEY_NUMERIC_POUND),
KEY(3, 2, KEY_0),
KEY(3, 3, KEY_2),
KEY(3, 4, KEY_SLEEP),
KEY(3, 5, KEY_F1),
KEY(3, 6, KEY_F2),
KEY(3, 7, KEY_F3),
KEY(4, 0, KEY_BACK),
KEY(4, 1, KEY_HOME),
KEY(4, 2, KEY_MENU),
KEY(4, 3, KEY_VOLUMEUP),
KEY(4, 4, KEY_VOLUMEDOWN),
KEY(4, 5, KEY_F4),
KEY(4, 6, KEY_F5),
KEY(4, 7, KEY_F6),
KEY(5, 0, KEY_R),
KEY(5, 1, KEY_T),
KEY(5, 2, KEY_Y),
KEY(5, 3, KEY_LEFTALT),
KEY(5, 4, KEY_KPENTER),
KEY(5, 5, KEY_Q),
KEY(5, 6, KEY_W),
KEY(5, 7, KEY_E),
KEY(6, 0, KEY_F),
KEY(6, 1, KEY_G),
KEY(6, 2, KEY_H),
KEY(6, 3, KEY_CAPSLOCK),
KEY(6, 4, KEY_PAGEUP),
KEY(6, 5, KEY_A),
KEY(6, 6, KEY_S),
KEY(6, 7, KEY_D),
KEY(7, 0, KEY_V),
KEY(7, 1, KEY_B),
KEY(7, 2, KEY_N),
KEY(7, 3, KEY_MENU), /* REVISIT - SYM */
KEY(7, 4, KEY_PAGEDOWN),
KEY(7, 5, KEY_Z),
KEY(7, 6, KEY_X),
KEY(7, 7, KEY_C),
KEY(8, 0, KEY_P),
KEY(8, 1, KEY_J),
KEY(8, 2, KEY_K),
KEY(8, 3, KEY_INSERT),
KEY(8, 4, KEY_LINEFEED),
KEY(8, 5, KEY_U),
KEY(8, 6, KEY_I),
KEY(8, 7, KEY_O),
KEY(9, 0, KEY_4),
KEY(9, 1, KEY_5),
KEY(9, 2, KEY_6),
KEY(9, 3, KEY_7),
KEY(9, 4, KEY_8),
KEY(9, 5, KEY_1),
KEY(9, 6, KEY_2),
KEY(9, 7, KEY_3),
KEY(10, 0, KEY_F7),
KEY(10, 1, KEY_F8),
KEY(10, 2, KEY_F9),
KEY(10, 3, KEY_F10),
KEY(10, 4, KEY_FN),
KEY(10, 5, KEY_9),
KEY(10, 6, KEY_0),
KEY(10, 7, KEY_DOT),
KEY(11, 0, KEY_LEFTCTRL),
KEY(11, 1, KEY_F11), /* START */
KEY(11, 2, KEY_ENTER),
KEY(11, 3, KEY_SEARCH),
KEY(11, 4, KEY_DELETE),
KEY(11, 5, KEY_RIGHT),
KEY(11, 6, KEY_LEFT),
KEY(11, 7, KEY_RIGHTSHIFT),
};
static struct resource resources_keypad[] = {
{
.start = PM8058_KEYPAD_IRQ(PMIC8058_IRQ_BASE),
.end = PM8058_KEYPAD_IRQ(PMIC8058_IRQ_BASE),
.flags = IORESOURCE_IRQ,
},
{
.start = PM8058_KEYSTUCK_IRQ(PMIC8058_IRQ_BASE),
.end = PM8058_KEYSTUCK_IRQ(PMIC8058_IRQ_BASE),
.flags = IORESOURCE_IRQ,
},
};
static struct matrix_keymap_data surf_keymap_data = {
.keymap_size = ARRAY_SIZE(surf_keymap),
.keymap = surf_keymap,
};
static struct <API key> surf_keypad_data = {
.input_name = "surf_keypad",
.input_phys_device = "surf_keypad/input0",
.num_rows = 12,
.num_cols = 8,
.rows_gpio_start = 8,
.cols_gpio_start = 0,
.debounce_ms = {8, 10},
.scan_delay_ms = 32,
.row_hold_ns = 91500,
.wakeup = 1,
.keymap_data = &surf_keymap_data,
};
static struct matrix_keymap_data fluid_keymap_data = {
.keymap_size = ARRAY_SIZE(fluid_keymap),
.keymap = fluid_keymap,
};
static struct <API key> fluid_keypad_data = {
.input_name = "fluid-keypad",
.input_phys_device = "fluid-keypad/input0",
.num_rows = 5,
.num_cols = 5,
.rows_gpio_start = 8,
.cols_gpio_start = 0,
.debounce_ms = {8, 10},
.scan_delay_ms = 32,
.row_hold_ns = 91500,
.wakeup = 1,
.keymap_data = &fluid_keymap_data,
};
#endif
static struct pm8058_pwm_pdata pm8058_pwm_data = {
.config = pm8058_pwm_config,
.enable = pm8058_pwm_enable,
};
/* Put sub devices with fixed location first in sub_devices array */
#define PM8058_SUBDEV_KPD 0
#define PM8058_SUBDEV_LED 1
static struct <API key> pm8058_gpio_data = {
.gpio_base = <API key>(0),
.irq_base = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, 0),
.init = pm8058_gpios_init,
};
static struct <API key> pm8058_mpp_data = {
.gpio_base = <API key>(PM8058_GPIOS),
.irq_base = PM8058_MPP_IRQ(PMIC8058_IRQ_BASE, 0),
};
#ifdef CONFIG_LEDS_PM8058
static struct pmic8058_led pmic8058_ffa_leds[] = {
[0] = {
.name = "keyboard-backlight",
.max_brightness = 15,
.id = <API key>,
},
};
static struct <API key> <API key> = {
.num_leds = ARRAY_SIZE(pmic8058_ffa_leds),
.leds = pmic8058_ffa_leds,
};
static struct pmic8058_led pmic8058_surf_leds[] = {
[0] = {
.name = "keyboard-backlight",
.max_brightness = 15,
.id = <API key>,
},
[1] = {
.name = "voice:red",
.max_brightness = 20,
.id = PMIC8058_ID_LED_0,
},
[2] = {
.name = "wlan:green",
.max_brightness = 20,
.id = PMIC8058_ID_LED_2,
},
};
#endif
// <API key>+
#ifdef <API key>
static struct <API key> pmic_vib_pdata = {
.initial_vibrate_ms = 0,
.level_mV = 3000,
.max_timeout_ms = 15000,
};
#endif
// <API key>-
static struct mfd_cell pm8058_subdevs[] = {
#ifdef <API key>
{ .name = "pm8058-keypad",
.id = -1,
.num_resources = ARRAY_SIZE(resources_keypad),
.resources = resources_keypad,
},
#endif
#ifdef <API key>
{ .name = "pm8058-led",
.id = -1,
},
#endif
{ .name = "pm8058-gpio",
.id = -1,
.platform_data = &pm8058_gpio_data,
.data_size = sizeof(pm8058_gpio_data),
},
{ .name = "pm8058-mpp",
.id = -1,
.platform_data = &pm8058_mpp_data,
.data_size = sizeof(pm8058_mpp_data),
},
{ .name = "pm8058-pwm",
.id = -1,
.platform_data = &pm8058_pwm_data,
.data_size = sizeof(pm8058_pwm_data),
},
{ .name = "pm8058-nfc",
.id = -1,
},
{ .name = "pm8058-upl",
.id = -1,
},
// <API key>+
#ifdef <API key>
{ .name = "pm8058-vib",
.id = -1,
.platform_data = &pmic_vib_pdata,
.data_size = sizeof(pmic_vib_pdata),
},
#endif
// <API key>-
};
#ifdef CONFIG_LEDS_PM8058
static struct <API key> <API key> = {
.num_leds = ARRAY_SIZE(pmic8058_surf_leds),
.leds = pmic8058_surf_leds,
};
static struct pmic8058_led pmic8058_fluid_leds[] = {
[0] = {
.name = "keyboard-backlight",
.max_brightness = 15,
.id = <API key>,
},
[1] = {
.name = "flash:led_0",
.max_brightness = 15,
.id = <API key>,
},
[2] = {
.name = "flash:led_1",
.max_brightness = 15,
.id = <API key>,
},
};
static struct <API key> <API key> = {
.num_leds = ARRAY_SIZE(pmic8058_fluid_leds),
.leds = pmic8058_fluid_leds,
};
#endif
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
static struct <API key> <API key> = {
.name = "headset_sensor",
.gpio = 26,
.name_on = "",
.name_off = "",
.state_on = "",
.state_off = "",
};
static struct platform_device <API key> = {
.name = "switch_gpio",
.id = -1,
.dev = { .platform_data = &<API key> },
};
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
static struct <API key> pm8058_7x30_data = {
.irq_base = PMIC8058_IRQ_BASE,
.num_subdevs = ARRAY_SIZE(pm8058_subdevs),
.sub_devices = pm8058_subdevs,
.irq_trigger_flags = IRQF_TRIGGER_LOW,
};
static struct i2c_board_info pm8058_boardinfo[] __initdata = {
{
I2C_BOARD_INFO("pm8058-core", 0x55),
.irq = MSM_GPIO_TO_INT(PMIC_GPIO_INT),
.platform_data = &pm8058_7x30_data,
},
};
static struct i2c_board_info cy8info[] __initdata = {
{
I2C_BOARD_INFO(CY_I2C_NAME, 0x24),
.platform_data = &cyttsp_data,
#ifndef CY_USE_TIMER
.irq = MSM_GPIO_TO_INT(CYTTSP_TS_GPIO_IRQ),
#endif /* CY_USE_TIMER */
},
};
static struct i2c_board_info <API key>[] __initdata = {
#ifdef CONFIG_FIH_MT9P111
{
I2C_BOARD_INFO("mt9p111", 0x78 >> 1),
},
#endif
#ifdef CONFIG_FIH_HM0356
{
I2C_BOARD_INFO("hm0356", 0x68 >> 1),
},
#endif
#ifdef CONFIG_FIH_HM0357
{
I2C_BOARD_INFO("hm0357", 0x60 >> 1),
},
#endif
#ifdef <API key>
{
I2C_BOARD_INFO("tcm9001md", 0x7C >> 1),
},
#endif
#ifdef CONFIG_MT9D112
{
I2C_BOARD_INFO("mt9d112", 0x78 >> 1),
},
#endif
#ifdef CONFIG_S5K3E2FX
{
I2C_BOARD_INFO("s5k3e2fx", 0x20 >> 1),
},
#endif
#ifdef CONFIG_MT9P012
{
I2C_BOARD_INFO("mt9p012", 0x6C >> 1),
},
#endif
#ifdef CONFIG_VX6953
{
I2C_BOARD_INFO("vx6953", 0x20),
},
#endif
#ifdef CONFIG_MT9E013
{
I2C_BOARD_INFO("mt9e013", 0x6C >> 2),
},
#endif
#ifdef CONFIG_SN12M0PZ
{
I2C_BOARD_INFO("sn12m0pz", 0x34 >> 1),
},
#endif
#if defined(CONFIG_MT9T013) || defined(<API key>)
{
I2C_BOARD_INFO("mt9t013", 0x6C),
},
#endif
};
#ifdef CONFIG_MSM_CAMERA
#define CAM_STNDBY 143
static uint32_t <API key>[] = {
//GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VCM */
};
static uint32_t <API key>[] = {
/* parallel CAMERA interfaces */
//GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
//GPIO_CFG(2, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
//GPIO_CFG(3, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
GPIO_CFG(4, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
GPIO_CFG(5, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
GPIO_CFG(6, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
GPIO_CFG(7, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
GPIO_CFG(8, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
GPIO_CFG(9, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
GPIO_CFG(10, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
GPIO_CFG(11, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
GPIO_CFG(12, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
GPIO_CFG(13, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
GPIO_CFG(14, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
GPIO_CFG(15, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
#ifdef CONFIG_FIH_AAT1272
#ifdef <API key>
GPIO_CFG(30, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* FLASHLED_DRV_EN PIN*/
#else
GPIO_CFG(39, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* FLASHLED_DRV_EN PIN*/
#endif
#endif
//GPIO_CFG(50, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* SWITCH PIN*/
};
static uint32_t <API key>[] = {
//GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), /* VCM */
};
static uint32_t <API key>[] = {
/* parallel CAMERA interfaces */
//GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* RST */
//GPIO_CFG(2, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT2 */
//GPIO_CFG(3, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT3 */
GPIO_CFG(0, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
//GPIO_CFG(1, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
//GPIO_CFG(2, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
GPIO_CFG(4, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT4 */
GPIO_CFG(5, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT5 */
GPIO_CFG(6, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT6 */
GPIO_CFG(7, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT7 */
GPIO_CFG(8, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT8 */
GPIO_CFG(9, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT9 */
GPIO_CFG(10, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT10 */
GPIO_CFG(11, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* DAT11 */
GPIO_CFG(12, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* PCLK */
GPIO_CFG(13, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* HSYNC_IN */
GPIO_CFG(14, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* VSYNC_IN */
GPIO_CFG(15, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* MCLK */
#ifdef CONFIG_FIH_AAT1272
#ifdef <API key>
GPIO_CFG(30, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* FLASHLED_DRV_EN PIN*/
#else
GPIO_CFG(39, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* FLASHLED_DRV_EN PIN*/
#endif
#endif
//GPIO_CFG(50, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), /* SWITCH PIN*/
};
static uint32_t <API key>[] = {
/* FLUID: CAM_VGA_RST_N */
GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
/* FLUID: CAMIF_STANDBY */
GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
};
static uint32_t <API key>[] = {
/* FLUID: CAM_VGA_RST_N */
GPIO_CFG(31, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
/* FLUID: CAMIF_STANDBY */
GPIO_CFG(CAM_STNDBY, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
};
static void config_gpio_table(uint32_t *table, int len)
{
int n, rc;
for (n = 0; n < len; n++) {
rc = gpio_tlmm_config(table[n], GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, table[n], rc);
break;
}
}
}
static int <API key>(void)
{
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
if (<API key>() != TIMPANI_ID)
/* GPIO1 is shared also used in Timpani RF card so
only configure it for non-Timpani RF card */
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
if (<API key>()) {
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
/* FLUID: turn on 5V booster */
gpio_set_value(
<API key>(<API key>), 1);
/* FLUID: drive high to put secondary sensor to STANDBY */
gpio_set_value(CAM_STNDBY, 1);
}
return 0;
}
static void <API key>(void)
{
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
if (<API key>() != TIMPANI_ID)
/* GPIO1 is shared also used in Timpani RF card so
only configure it for non-Timpani RF card */
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
if (<API key>()) {
config_gpio_table(<API key>,
ARRAY_SIZE(<API key>));
/* FLUID: turn off 5V booster */
gpio_set_value(
<API key>(<API key>), 0);
}
}
struct resource <API key>[] = {
{
.start = 0xA6000000,
.end = 0xA6000000 + SZ_1M - 1,
.flags = IORESOURCE_MEM,
},
{
.start = INT_VFE,
.end = INT_VFE,
.flags = IORESOURCE_IRQ,
},
{
.flags = IORESOURCE_DMA,
}
};
struct <API key> <API key> = {
.camera_gpio_on = <API key>,
.camera_gpio_off = <API key>,
.ioext.camifpadphy = 0xAB000000,
.ioext.camifpadsz = 0x00000400,
.ioext.csiphy = 0xA6100000,
.ioext.csisz = 0x00000400,
.ioext.csiirq = INT_CSI,
.ioclk.mclk_clk_rate = 24000000,
.ioclk.vfe_clk_rate = 122880000,
};
static struct <API key> msm_flash_src_pwm = {
.flash_sr_type = <API key>,
._fsrc.pwm_src.freq = 1000,
._fsrc.pwm_src.max_load = 300,
._fsrc.pwm_src.low_load = 30,
._fsrc.pwm_src.high_load = 100,
._fsrc.pwm_src.channel = 7,
};
#ifdef CONFIG_FIH_MT9P111
static struct <API key> flash_mt9p111 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct msm_parameters_data parameters_mt9p111 = {
};
static struct <API key> <API key> = {
.sensor_name = "mt9p111",
.sensor_reset = 1,
.sensor_pwd = 2,
.sensor_Orientation = <API key>,
.vcm_pwd = 0,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_mt9p111,
.parameters_data = ¶meters_mt9p111,
.csi_if = 0,
/* Declare for camea pins */
.MCLK_PIN =15 ,
.mclk_sw_pin = 0xffff,
.pwdn_pin = 0xffff,
.rst_pin = 0xffff,
.vga_pwdn_pin = 0xffff,
.vga_rst_pin = 0xffff,
.vga_power_en_pin = 0xffff,
.standby_pin = 0xffff,
.GPIO_FLASHLED = 0xffff,
.<API key> = 0xffff,
/* Declare for camera power */
.AF_pmic_en_pin= 0xffff,
.cam_v2p8_en_pin = 0xffff,
.cam_vreg_vddio_id = "NoVreg",
.cam_vreg_acore_id = "NoVreg",
/* Flash LED setting */
.flash_target_addr = 0xffff,
.flash_target = 0xffff,
.flash_bright = 0xffff,
.flash_main_waittime = 0,
.<API key> = 0,
.<API key> = 0,
.preflash_light = 0x31,
.torch_light = 0x34,
.<API key> = 0xffff
};
static struct platform_device <API key> = {
.name = "msm_camera_mt9p111",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_FIH_HM0356
static struct <API key> flash_hm0356 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct msm_parameters_data parameters_hm0356 = {
};
static struct <API key> <API key> = {
.sensor_name = "hm0356",
.sensor_pwd = 0,
.sensor_Orientation = <API key>,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_hm0356,
.parameters_data = ¶meters_hm0356,
.csi_if = 0,
/* Declare for camea pins */
.MCLK_PIN =15 ,
.mclk_sw_pin = 0xffff,
.pwdn_pin = 0xffff,
.rst_pin = 0xffff,
.vga_pwdn_pin = 0xffff,
.vga_rst_pin = 0xffff,
.vga_power_en_pin = 0xffff,
.standby_pin = 0xffff,
.GPIO_FLASHLED = 0xffff,
.<API key> = 0xffff,
/* Declare for camera power */
.AF_pmic_en_pin= 0xffff,
.cam_v2p8_en_pin = 0xffff,
.cam_vreg_vddio_id = "NoVreg",
.cam_vreg_acore_id = "NoVreg"
};
static struct platform_device <API key> = {
.name = "msm_camera_hm0356",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_FIH_HM0357
static struct <API key> flash_hm0357 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct msm_parameters_data parameters_hm0357 = {
};
static struct <API key> <API key> = {
.sensor_name = "hm0357",
.sensor_pwd = 0,
.sensor_Orientation = <API key>,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_hm0357,
.parameters_data = ¶meters_hm0357,
.csi_if = 0,
/* Declare for camea pins */
.MCLK_PIN =15 ,
.mclk_sw_pin = 0xffff,
.pwdn_pin = 0xffff,
.rst_pin = 0xffff,
.vga_pwdn_pin = 0xffff,
.vga_rst_pin = 0xffff,
.vga_power_en_pin = 0xffff,
.standby_pin = 0xffff,
.GPIO_FLASHLED = 0xffff,
.<API key> = 0xffff,
/* Declare for camera power */
.AF_pmic_en_pin= 0xffff,
.cam_v2p8_en_pin = 0xffff,
.cam_vreg_vddio_id = "NoVreg",
.cam_vreg_acore_id = "NoVreg"
};
static struct platform_device <API key> = {
.name = "msm_camera_hm0357",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef <API key>
static struct <API key> flash_tcm9001md = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct msm_parameters_data <API key> = {
};
static struct <API key> <API key> = {
.sensor_name = "tcm9001md",
.sensor_reset = 19,
.sensor_pwd = 0,
.sensor_Orientation = <API key>,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_tcm9001md,
.parameters_data = &<API key>,
.csi_if = 0,
/* Declare for camea pins */
.MCLK_PIN =15 ,
.mclk_sw_pin = 0xffff,
.pwdn_pin = 0xffff,
.rst_pin = 0xffff,
.vga_pwdn_pin = 0xffff,
.vga_rst_pin = 0xffff,
.vga_power_en_pin = 0xffff,
.standby_pin = 0xffff,
.GPIO_FLASHLED = 0xffff,
.<API key> = 0xffff,
/* Declare for camera power */
.AF_pmic_en_pin= 0xffff,
.cam_v2p8_en_pin = 0xffff,
.cam_vreg_vddio_id = "NoVreg",
.cam_vreg_acore_id = "NoVreg"
};
static struct platform_device <API key> = {
.name = "<API key>",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_MT9D112
static struct <API key> flash_mt9d112 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct <API key> <API key> = {
.sensor_name = "mt9d112",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 0,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_mt9d112,
.csi_if = 0
};
static struct platform_device <API key> = {
.name = "msm_camera_mt9d112",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_S5K3E2FX
static struct <API key> flash_s5k3e2fx = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm,
};
static struct <API key> <API key> = {
.sensor_name = "s5k3e2fx",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 0,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_s5k3e2fx,
.csi_if = 0
};
static struct platform_device <API key> = {
.name = "msm_camera_s5k3e2fx",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_MT9P012
static struct <API key> flash_mt9p012 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct <API key> <API key> = {
.sensor_name = "mt9p012",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 1,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_mt9p012,
.csi_if = 0
};
static struct platform_device <API key> = {
.name = "msm_camera_mt9p012",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_MT9E013
static struct <API key> flash_mt9e013 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct <API key> <API key> = {
.sensor_name = "mt9e013",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 1,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_mt9e013,
.csi_if = 1
};
static struct platform_device <API key> = {
.name = "msm_camera_mt9e013",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_VX6953
static struct <API key> flash_vx6953 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct <API key> <API key> = {
.sensor_name = "vx6953",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 0,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_vx6953,
.csi_if = 1
};
static struct platform_device <API key> = {
.name = "msm_camera_vx6953",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_SN12M0PZ
static struct <API key> <API key> = {
.flash_sr_type = <API key>,
._fsrc.current_driver_src.low_current = 210,
._fsrc.current_driver_src.high_current = 700,
#ifdef <API key>
._fsrc.current_driver_src.driver_channel = &<API key>,
#endif
};
static struct <API key> flash_sn12m0pz = {
.flash_type = <API key>,
.flash_src = &<API key>
};
static struct <API key> <API key> = {
.sensor_name = "sn12m0pz",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 1,
.pdata = &<API key>,
.flash_data = &flash_sn12m0pz,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.csi_if = 0
};
static struct platform_device <API key> = {
.name = "msm_camera_sn12m0pz",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_MT9T013
static struct <API key> flash_mt9t013 = {
.flash_type = <API key>,
.flash_src = &msm_flash_src_pwm
};
static struct <API key> <API key> = {
.sensor_name = "mt9t013",
.sensor_reset = 0,
.sensor_pwd = 85,
.vcm_pwd = 1,
.vcm_enable = 0,
.pdata = &<API key>,
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
.flash_data = &flash_mt9t013,
.csi_if = 1
};
static struct platform_device <API key> = {
.name = "msm_camera_mt9t013",
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_MSM_GEMINI
static struct resource <API key>[] = {
{
.start = 0xA3A00000,
.end = 0xA3A00000 + 0x0150 - 1,
.flags = IORESOURCE_MEM,
},
{
.start = INT_JPEG,
.end = INT_JPEG,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device msm_gemini_device = {
.name = "msm_gemini",
.resource = <API key>,
.num_resources = ARRAY_SIZE(<API key>),
};
#endif
#ifdef CONFIG_MSM_VPE
static struct resource msm_vpe_resources[] = {
{
.start = 0xAD200000,
.end = 0xAD200000 + SZ_1M - 1,
.flags = IORESOURCE_MEM,
},
{
.start = INT_VPE,
.end = INT_VPE,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device msm_vpe_device = {
.name = "msm_vpe",
.id = 0,
.num_resources = ARRAY_SIZE(msm_vpe_resources),
.resource = msm_vpe_resources,
};
#endif
void <API key>(void)
{
int pid = 0;
int phid = 0;
pid = fih_get_product_id();
phid = <API key>();
#ifdef CONFIG_FIH_MT9P111
#if 1
if (pid == Product_SF5)
{
/* Declare for camea pins */
if (phid <= Product_PR2)
{
<API key>.rst_pin = 1;
}
else
{
<API key>.rst_pin = 120;
}
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.standby_pin=33;
<API key>.GPIO_FLASHLED = 3;
<API key>.<API key> = 39;
/* Declare for camera power */
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
/* Flash LED setting */
<API key>.flash_target_addr = 0xB80C;
<API key>.flash_target = 0x07BE;
<API key>.flash_bright = 0x20;
<API key>.flash_main_waittime = 150;
<API key>.<API key> = 150;
<API key>.<API key> = 200;
/*Fast AF*/
<API key>.<API key> = 0x2000;
}
else if (pid == Product_SF6)
{
<API key>.sensor_Orientation=<API key>;
/* Declare for camea pins */
<API key>.rst_pin = 3;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.GPIO_FLASHLED = 164;
<API key>.<API key> = 30;
/* Declare for camera power */
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
/* Flash LED setting */
<API key>.flash_target_addr = 0xB80C;
<API key>.flash_target = 0x2E00;
<API key>.flash_bright = 0x20;
<API key>.flash_main_waittime = 100;
<API key>.<API key> = 200;
<API key>.<API key> = 200;
/*Fast AF*/
<API key>.<API key> = 0x3800;
}
else if (IS_SF8_SERIES_PRJ())
{
/* Declare for camea pins */
if (pid == Product_SF8 && phid < Product_PR2)
{
<API key>.rst_pin = 1;
<API key>.vga_pwdn_pin = 0;
}
else
{
<API key>.rst_pin = 173;
<API key>.vga_pwdn_pin = 174;
}
<API key>.pwdn_pin = 2;
<API key>.GPIO_FLASHLED = 177;
<API key>.<API key> = 3;
/* Declare for camera power */
<API key>.cam_v2p8_en_pin = 120;
<API key>.cam_vreg_vddio_id = "gp10";
<API key>.cam_vreg_acore_id = "NoVreg";
/* Flash LED setting */
<API key>.flash_target_addr = 0x3012;
<API key>.flash_target = 0x9C4;
<API key>.flash_bright = 0x30;
<API key>.flash_main_waittime = 100;
<API key>.<API key> = 200;
<API key>.<API key> = 200;
/*Fast AF*/
<API key>.<API key> = 0x2000;
}
else// For FBx and FDx series project
#endif
{
/* Declare for camea pins */
<API key>.rst_pin = 1;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.standby_pin=33;
<API key>.GPIO_FLASHLED = 3;
<API key>.<API key> = 39;
<API key>.AF_pmic_en_pin=16;
<API key>.mclk_sw_pin = 50;
/* Declare for camera power */
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
/* Flash LED setting */
<API key>.flash_target_addr = 0x3012;
<API key>.flash_target = 0x7AA;
<API key>.flash_bright = 0x14;
<API key>.flash_main_waittime = 300;
<API key>.<API key> = 90;
<API key>.<API key> = 200;
/*Fast AF*/
<API key>.<API key> = 0x2000;
#if 1
if(pid ==Product_FD1 )
{
<API key>.flash_target = 0x7D0;
<API key>.<API key> = 90;
<API key>.flash_main_waittime = 700;
}
if(pid ==Product_FB3 )
{
<API key>.torch_light = 0x3E;
<API key>.preflash_light=0x3E;
}
#endif
}
#endif
#ifdef CONFIG_FIH_HM0356
/*Setting camera pins */
#if 1
if (IS_SF8_SERIES_PRJ())
{
if (pid == Product_SF8 && phid < Product_PR2)
{
<API key>.rst_pin = 1;
<API key>.vga_pwdn_pin = 0;
}
else
{
<API key>.rst_pin = 173;
<API key>.vga_pwdn_pin = 174;
}
<API key>.pwdn_pin = 2;
<API key>.mclk_sw_pin = 0xffff;
/* Declare for camera power */
<API key>.cam_v2p8_en_pin = 120;
<API key>.cam_vreg_vddio_id="gp10";
<API key>.cam_vreg_acore_id="NoVreg";
}
else if (pid == Product_SF6)
{
<API key>.sensor_Orientation = <API key>,
<API key>.rst_pin = 3;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
}
else// For FBx and FDx series project
#endif
{
<API key>.rst_pin = 1;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.mclk_sw_pin = 50;
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
}
#endif
#ifdef CONFIG_FIH_HM0357
/*Setting camera pins */
#if 1
if (IS_SF8_SERIES_PRJ())
{
if (pid == Product_SF8 && phid < Product_PR2)
{
<API key>.rst_pin = 1;
<API key>.vga_pwdn_pin = 0;
}
else
{
<API key>.rst_pin = 173;
<API key>.vga_pwdn_pin = 174;
}
<API key>.sensor_Orientation = <API key>,
<API key>.pwdn_pin = 2;
<API key>.mclk_sw_pin = 0xffff;
/* Declare for camera power */
<API key>.cam_v2p8_en_pin = 120;
<API key>.cam_vreg_vddio_id="gp10";
<API key>.cam_vreg_acore_id="NoVreg";
}
else if (pid == Product_SF6)
{
<API key>.sensor_Orientation = <API key>,
<API key>.rst_pin = 3;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
}
else if (pid == Product_SF5)
{
<API key>.rst_pin = 120;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.vga_power_en_pin = 98;
}
else// For FBx and FDx series project
#endif
{
<API key>.rst_pin = 1;
<API key>.pwdn_pin = 2;
<API key>.vga_pwdn_pin = 0;
<API key>.mclk_sw_pin = 50;
<API key>.cam_vreg_vddio_id = "gp7";
<API key>.cam_vreg_acore_id = "gp10";
}
#endif
#if 1
#ifdef <API key>
if (pid == Product_SF5)
{
/*5M sensor pins*/
if (phid <= Product_PR2)
{
<API key>.rst_pin = 1;
}
else
{
<API key>.rst_pin = 120;
}
<API key>.pwdn_pin = 2;
/*VGA sensor pins*/
<API key>.vga_rst_pin = 19;
<API key>.vga_pwdn_pin = 0;
<API key>.vga_power_en_pin = 98;
}
else
{
/*5M sensor pins*/
if (phid <= Product_PR2)
{
<API key>.rst_pin = 1;
}
else
{
<API key>.rst_pin = 120;
}
<API key>.pwdn_pin = 2;
/*VGA sensor pins*/
<API key>.vga_rst_pin = 19;
<API key>.vga_pwdn_pin = 0;
<API key>.vga_power_en_pin = 98;
}
#endif
#endif
}
#endif /*CONFIG_MSM_CAMERA*/
#ifdef <API key>
static uint32_t <API key> =
GPIO_CFG(82, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
static uint32_t <API key> =
GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
int SPK1_AMP = 36;
int SPK2_AMP = 37;
int HS_AMP = 55;
static uint32_t <API key> = 0;
static uint32_t <API key> = 0;
static uint32_t <API key> = 0;
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
static int __init <API key>(void)
{
int rc;
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
int pid =0;
pid = fih_get_product_id();
if((pid==Product_SF5)||IS_SF8_SERIES_PRJ())
{
SPK1_AMP = 36;
}
else if(pid==Product_SF6)
{
SPK1_AMP = 37;
}
else
{
SPK1_AMP = 36;
SPK2_AMP = 37;
}
<API key> =
GPIO_CFG(SPK1_AMP, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
<API key> =
GPIO_CFG(SPK2_AMP, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
<API key> =
GPIO_CFG(HS_AMP, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
pr_info("<API key> \n");
rc = gpio_tlmm_config(<API key>, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
rc = gpio_tlmm_config(<API key>, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
rc = gpio_tlmm_config(<API key>, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
pr_info("<API key> \n");
rc = gpio_tlmm_config(<API key>, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
return rc;
}
void <API key>(void)
{
int rc;
pr_debug("%s()\n", __func__);
if (<API key>()) {
rc = gpio_tlmm_config(<API key>,
GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
} else
gpio_set_value(85, 0);
}
}
void <API key>(void)
{
int rc;
pr_debug("%s()\n", __func__);
if (<API key>()) {
rc = gpio_tlmm_config(<API key>,
GPIO_CFG_DISABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
}
}
void <API key>(void)
{
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
pr_info("%s: power on amplifier\n", __func__);
m_SpkAmpOn=true; /* enable spkr poweramp */
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
}
void <API key>(void)
{
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
pr_info("%s: power off amplifier\n", __func__);
m_SpkAmpOn=false; /* disable spkr poweramp */
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
}
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
#ifndef <API key>
static struct vreg *snddev_vreg_ncp, *snddev_vreg_gp4;
#endif // <API key>
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
void <API key>(void)
{
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
#ifndef <API key>
int rc;
snddev_vreg_gp4 = vreg_get(NULL, "gp4");
if (IS_ERR(snddev_vreg_gp4)) {
pr_err("%s: vreg_get(%s) failed (%ld)\n",
__func__, "gp4", PTR_ERR(snddev_vreg_gp4));
return;
}
rc = vreg_enable(snddev_vreg_gp4);
if (rc)
pr_err("%s: vreg_enable(gp4) failed (%d)\n", __func__, rc);
snddev_vreg_ncp = vreg_get(NULL, "ncp");
if (IS_ERR(snddev_vreg_ncp)) {
pr_err("%s: vreg_get(%s) failed (%ld)\n",
__func__, "ncp", PTR_ERR(snddev_vreg_ncp));
return;
}
rc = vreg_enable(snddev_vreg_ncp);
if (rc)
pr_err("%s: vreg_enable(ncp) failed (%d)\n", __func__, rc);
#endif // <API key>
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
m_HsAmpOn=true;
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
}
void <API key>(void)
{
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
#ifndef <API key>
int rc;
if (IS_ERR(snddev_vreg_ncp)) {
pr_err("%s: vreg_get(%s) failed (%ld)\n",
__func__, "ncp", PTR_ERR(snddev_vreg_ncp));
return;
}
rc = vreg_disable(snddev_vreg_ncp);
if (rc)
pr_err("%s: vreg_disable(ncp) failed (%d)\n", __func__, rc);
vreg_put(snddev_vreg_ncp);
if (IS_ERR(snddev_vreg_gp4)) {
pr_err("%s: vreg_get(%s) failed (%ld)\n",
__func__, "gp4", PTR_ERR(snddev_vreg_gp4));
return;
}
rc = vreg_disable(snddev_vreg_gp4);
if (rc)
pr_err("%s: vreg_disable(gp4) failed (%d)\n", __func__, rc);
vreg_put(snddev_vreg_gp4);
#endif // <API key>
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
m_HsAmpOn=false;
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
}
static unsigned aux_pcm_gpio_on[] = {
GPIO_CFG(138, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DOUT */
GPIO_CFG(139, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_DIN */
GPIO_CFG(140, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_SYNC */
GPIO_CFG(141, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), /* PCM_CLK */
};
static int __init aux_pcm_gpio_init(void)
{
int pin, rc;
pr_info("aux_pcm_gpio_init \n");
for (pin = 0; pin < ARRAY_SIZE(aux_pcm_gpio_on); pin++) {
rc = gpio_tlmm_config(aux_pcm_gpio_on[pin],
GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR
"%s: gpio_tlmm_config(%#x)=%d\n",
__func__, aux_pcm_gpio_on[pin], rc);
}
}
return rc;
}
static struct msm_gpio mi2s_clk_gpios[] = {
{ GPIO_CFG(145, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_SCLK"},
{ GPIO_CFG(144, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_WS"},
};
//<API key>+{
static struct msm_gpio mi2s_mclk_gpios[] = {
{ GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_MCLK_A"},
};
//<API key>+}
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_DATA_SD0_A"},
{ GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_DATA_SD1_A"},
{ GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_DATA_SD2_A"},
{ GPIO_CFG(146, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_DATA_SD3"},
};
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(146, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"MI2S_DATA_SD3"},
};
int <API key>(void)
{
//<API key>*{
if(!IS_SF8_SERIES_PRJ()){
int rc = 0;
rc = <API key>(mi2s_clk_gpios,
ARRAY_SIZE(mi2s_clk_gpios));
if (rc) {
pr_err("%s: enable mi2s clk gpios failed\n",
__func__);
return rc;
}
//<API key>+{
if ((fih_get_product_id() != Product_SF5) || (<API key>() != Product_PCR))
{
rc = <API key>(mi2s_mclk_gpios,
ARRAY_SIZE(mi2s_mclk_gpios));
if (rc) {
pr_err("%s: enable mi2s clk gpios failed\n",
__func__);
return rc;
}
}
//<API key>+}
}
//<API key>*}
return 0;
}
int <API key>(u32 direction, u8 sd_line_mask)
{
int i, rc = 0;
//<API key>*{
if(IS_SF8_SERIES_PRJ())
return rc;
//<API key>*}
sd_line_mask &= MI2S_SD_LINE_MASK;
switch (direction) {
case DIR_TX:
<API key>(<API key>, 1);
break;
case DIR_RX:
i = 0;
while (sd_line_mask) {
if (sd_line_mask & 0x1)
<API key>(
<API key> + i , 1);
sd_line_mask = sd_line_mask >> 1;
i++;
}
break;
default:
pr_err("%s: Invaild direction direction = %u\n",
__func__, direction);
rc = -EINVAL;
break;
}
return rc;
}
int <API key>(u32 direction, u8 sd_line_mask)
{
int i , rc = 0;
u8 sd_config_done_mask = 0;
//<API key>*{
if(IS_SF8_SERIES_PRJ())
return rc;
//<API key>*}
sd_line_mask &= MI2S_SD_LINE_MASK;
switch (direction) {
case DIR_TX:
if ((sd_line_mask & MI2S_SD_0) || (sd_line_mask & MI2S_SD_1) ||
(sd_line_mask & MI2S_SD_2) || !(sd_line_mask & MI2S_SD_3)) {
pr_err("%s: can not use SD0 or SD1 or SD2 for TX"
".only can use SD3. sd_line_mask = 0x%x\n",
__func__ , sd_line_mask);
rc = -EINVAL;
} else {
rc = <API key>(<API key>,
1);
if (rc)
pr_err("%s: enable mi2s gpios for TX failed\n",
__func__);
}
break;
case DIR_RX:
i = 0;
while (sd_line_mask && (rc == 0)) {
if (sd_line_mask & 0x1) {
rc = <API key>(
<API key> + i , 1);
if (rc) {
pr_err("%s: enable mi2s gpios for"
"RX failed. SD line = %s\n",
__func__,
(<API key> + i)->label);
<API key>(DIR_RX,
sd_config_done_mask);
} else
sd_config_done_mask |= (1 << i);
}
sd_line_mask = sd_line_mask >> 1;
i++;
}
break;
default:
pr_err("%s: Invaild direction direction = %u\n",
__func__, direction);
rc = -EINVAL;
break;
}
return rc;
}
int <API key>(void)
{
//<API key>*{
if(!IS_SF8_SERIES_PRJ()){
<API key>(mi2s_clk_gpios, ARRAY_SIZE(mi2s_clk_gpios));
//<API key>+{
if ((fih_get_product_id() != Product_SF5) || (<API key>() != Product_PCR))
{
<API key>(mi2s_mclk_gpios, ARRAY_SIZE(mi2s_mclk_gpios));
}
//<API key>+}
}
//<API key>*}
return 0;
}
#endif /* <API key> */
static int __init buses_init(void)
{
if (gpio_tlmm_config(GPIO_CFG(PMIC_GPIO_INT, 1, GPIO_CFG_INPUT,
GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE))
pr_err("%s: gpio_tlmm_config (gpio=%d) failed\n",
__func__, PMIC_GPIO_INT);
#ifdef <API key>
if (<API key>()) {
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].platform_data
= &fluid_keypad_data;
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].data_size
= sizeof(fluid_keypad_data);
} else {
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].platform_data
= &surf_keypad_data;
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_KPD].data_size
= sizeof(surf_keypad_data);
}
#endif
<API key>(6 /* I2C_SSBI ID */, pm8058_boardinfo,
ARRAY_SIZE(pm8058_boardinfo));
return 0;
}
#define TIMPANI_RESET_GPIO 1
struct <API key>{
u8 reg;
u8 value;
u8 mask;
};
enum version{
VER_1_0,
VER_2_0,
VER_UNSUPPORTED = 0xFF
};
static struct vreg *vreg_marimba_1;
static struct vreg *vreg_marimba_2;
static struct vreg *vreg_marimba_3;
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(TIMPANI_RESET_GPIO, 0, GPIO_CFG_OUTPUT,
GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "timpani_reset"} };
static u8 read_bahama_ver(void)
{
int rc;
struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
u8 bahama_version;
rc = <API key>(&config, 0x00, &bahama_version, 1, 0x1F);
if (rc < 0) {
printk(KERN_ERR
"%s: version read failed: %d\n",
__func__, rc);
return rc;
} else {
printk(KERN_INFO
"%s: version read got: 0x%x\n",
__func__, bahama_version);
}
switch (bahama_version) {
case 0x08: /* varient of bahama v1 */
case 0x10:
case 0x00:
return VER_1_0;
case 0x09: /* variant of bahama v2 */
return VER_2_0;
default:
return VER_UNSUPPORTED;
}
}
static int <API key>(void)
{
int rc;
rc = <API key>(<API key>,
ARRAY_SIZE(<API key>));
if (rc < 0) {
printk(KERN_ERR
"%s: <API key> failed (%d)\n",
__func__, rc);
}
return rc;
}
static unsigned int <API key>(void)
{
int rc;
rc = <API key>();
if (rc < 0)
goto out;
rc = vreg_enable(vreg_marimba_1);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d\n",
__func__, rc);
goto out;
}
rc = vreg_enable(vreg_marimba_2);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d\n",
__func__, rc);
goto <API key>;
}
rc = <API key>(TIMPANI_RESET_GPIO, 1);
if (rc < 0) {
printk(KERN_ERR
"%s: <API key> failed (%d)\n",
__func__, rc);
msm_gpios_free(<API key>,
ARRAY_SIZE(<API key>));
vreg_disable(vreg_marimba_2);
} else
goto out;
<API key>:
vreg_disable(vreg_marimba_1);
out:
return rc;
};
static void <API key>(void)
{
int rc;
rc = vreg_disable(vreg_marimba_1);
if (rc) {
printk(KERN_ERR "%s: return val: %d\n",
__func__, rc);
}
rc = vreg_disable(vreg_marimba_2);
if (rc) {
printk(KERN_ERR "%s: return val: %d\n",
__func__, rc);
}
rc = <API key>(TIMPANI_RESET_GPIO, 0);
if (rc < 0) {
printk(KERN_ERR
"%s: <API key> failed (%d)\n",
__func__, rc);
}
msm_gpios_free(<API key>,
ARRAY_SIZE(<API key>));
};
static unsigned int <API key>(int type)
{
int rc = 0;
if (type == BAHAMA_ID) {
int i;
struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
const struct <API key> v20_init[] = {
/* reg, value, mask */
{ 0xF4, 0x84, 0xFF }, /* AREG */
{ 0xF0, 0x04, 0xFF } /* DREG */
};
if (read_bahama_ver() == VER_2_0) {
for (i = 0; i < ARRAY_SIZE(v20_init); i++) {
u8 value = v20_init[i].value;
rc = <API key>(&config,
v20_init[i].reg,
&value,
sizeof(v20_init[i].value),
v20_init[i].mask);
if (rc < 0) {
printk(KERN_ERR
"%s: reg %d write failed: %d\n",
__func__, v20_init[i].reg, rc);
return rc;
}
printk(KERN_INFO "%s: reg 0x%02x value 0x%02x"
" mask 0x%02x\n",
__func__, v20_init[i].reg,
v20_init[i].value, v20_init[i].mask);
}
}
}
printk(KERN_INFO "core type: %d\n", type);
return rc;
}
static unsigned int <API key>(void)
{
int rc;
rc = vreg_enable(vreg_marimba_3);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d\n",
__func__, rc);
}
return rc;
};
static unsigned int <API key>(int value)
{
int rc = 0;
if (value != BAHAMA_ID) {
rc = vreg_disable(vreg_marimba_3);
if (rc) {
printk(KERN_ERR "%s: return val: %d\n",
__func__, rc);
}
}
return rc;
};
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"<API key>" },
};
static unsigned int <API key>(int gpio_cfg_marimba)
{
if (<API key>() ||
<API key>()) {
if (gpio_cfg_marimba)
gpio_set_value(GPIO_PIN
(<API key>->gpio_cfg), 1);
else
gpio_set_value(GPIO_PIN
(<API key>->gpio_cfg), 0);
}
return 0;
};
static unsigned int <API key>(void)
{
int rc;
rc = vreg_enable(vreg_marimba_1);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d \n",
__func__, rc);
goto out;
}
rc = vreg_enable(vreg_marimba_2);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d \n",
__func__, rc);
goto out;
}
if (<API key>() || <API key>()) {
rc = <API key>(<API key>,
ARRAY_SIZE(<API key>));
if (rc < 0) {
printk(KERN_ERR
"%s: <API key> failed (%d)\n",
__func__, rc);
return rc;
}
rc = <API key>(GPIO_PIN
(<API key>->gpio_cfg), 0);
if (rc < 0) {
printk(KERN_ERR
"%s: <API key> failed (%d)\n",
__func__, rc);
return rc;
}
}
out:
return rc;
};
static void <API key>(void)
{
int rc;
rc = vreg_disable(vreg_marimba_1);
if (rc) {
printk(KERN_ERR "%s: return val: %d\n",
__func__, rc);
}
rc = vreg_disable(vreg_marimba_2);
if (rc) {
printk(KERN_ERR "%s: return val: %d \n",
__func__, rc);
}
};
static int bahama_present(void)
{
int id;
switch (id = <API key>()) {
case BAHAMA_ID:
return 1;
case MARIMBA_ID:
return 0;
case TIMPANI_ID:
default:
printk(KERN_ERR "%s: unexpected adie connectivity type: %d\n",
__func__, id);
return -ENODEV;
}
}
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
#ifdef CONFIG_FIH_FM_LNA
//FB0 add LNA in FM, so we need to control FM_LNA_EN and GPS_FM_LNA_2V8_EN to turn on/off FM LNA.
#define FM_LNA_EN 78
static struct msm_gpio fm_gpio_table[] = {
//{ GPIO_CFG(GPS_FM_LNA_2V8_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "gps_fm_lna_2v8_en" },
{ GPIO_CFG(FM_LNA_EN, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "fm_lna_en" },
};
#endif
struct vreg *fm_regulator;
struct vreg *fm_gp16;
static int fm_radio_setup(struct <API key> *pdata)
{
int rc;
uint32_t irqcfg;
const char *id = "FMPW";
int bahama_not_marimba = bahama_present();
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
fm_gp16 = vreg_get(NULL, "gp16");
if (IS_ERR(fm_gp16)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(fm_gp16));
return -1;
}
rc = vreg_enable(fm_gp16);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d \n",
__func__, rc);
return rc;
}
if (bahama_not_marimba == -1) {
printk(KERN_WARNING "%s: bahama_present: %d\n",
__func__, bahama_not_marimba);
return -ENODEV;
}
if (bahama_not_marimba)
fm_regulator = vreg_get(NULL, "s3");
else
fm_regulator = vreg_get(NULL, "s2");
if (IS_ERR(fm_regulator)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(fm_regulator));
return -1;
}
if (!bahama_not_marimba) {
rc = <API key>(id, PMAPP_VREG_S2, 1300);
if (rc < 0) {
printk(KERN_ERR "%s: voltage level vote failed (%d)\n",
__func__, rc);
return rc;
}
}
rc = vreg_enable(fm_regulator);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d\n",
__func__, rc);
return rc;
}
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
PMAPP_CLOCK_VOTE_ON);
}
else {
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
rc = pmapp_clock_vote(id, /*PMAPP_CLOCK_ID_DO*/QTR8x00_WCN_CLK,
PMAPP_CLOCK_VOTE_ON);
}
if (rc < 0) {
printk(KERN_ERR "%s: clock vote failed (%d)\n",
__func__, rc);
goto fm_clock_vote_fail;
}
/*Request the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
of svlte*/
if (<API key>() ||
<API key>()) {
rc = marimba_gpio_config(1);
if (rc < 0)
printk(KERN_ERR "%s: clock enable for svlte : %d\n",
__func__, rc);
}
irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL,
GPIO_CFG_2MA);
rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
__func__, irqcfg, rc);
rc = -EIO;
goto fm_gpio_config_fail;
}
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
#ifdef CONFIG_FIH_FM_LNA
//FB0 add LNA in FM, so we need to control FM_LNA_EN and GPS_FM_LNA_2V8_EN to turn LNA.
printk(KERN_INFO "%s : config and enable FM LNA control.\n", __func__);
rc = msm_gpios_enable(fm_gpio_table, ARRAY_SIZE(fm_gpio_table));
if (rc<0) goto fm_gpio_config_fail;
/* FB0.B-396 */
rc = enable_gps_fm_lna(true);
if (rc<0) goto fm_gpio_config_fail;
gpio_set_value(FM_LNA_EN, 1);
#endif
return 0;
fm_gpio_config_fail:
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
<API key>);
}
else {
pmapp_clock_vote(id, /*PMAPP_CLOCK_ID_DO*/QTR8x00_WCN_CLK,
<API key>);
}
fm_clock_vote_fail:
vreg_disable(fm_regulator);
vreg_disable(fm_gp16);
return rc;
};
static void fm_radio_shutdown(struct <API key> *pdata)
{
int rc;
const char *id = "FMPW";
uint32_t irqcfg = GPIO_CFG(147, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP,
GPIO_CFG_2MA);
int bahama_not_marimba = bahama_present();
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
#ifdef CONFIG_FIH_FM_LNA
/* FB0 add LNA in FM, so we need to control FM_LNA_EN and GPS_FM_LNA_2V8_EN to turn LNA.
FB0.B-396 */
enable_gps_fm_lna(false);
gpio_set_value(FM_LNA_EN, 0);
#endif
if (bahama_not_marimba == -1) {
printk(KERN_WARNING "%s: bahama_present: %d\n",
__func__, bahama_not_marimba);
return;
}
rc = gpio_tlmm_config(irqcfg, GPIO_CFG_ENABLE);
if (rc) {
printk(KERN_ERR "%s: gpio_tlmm_config(%#x)=%d\n",
__func__, irqcfg, rc);
}
if (fm_regulator != NULL) {
rc = vreg_disable(fm_regulator);
if (rc) {
printk(KERN_ERR "%s: return val: %d\n",
__func__, rc);
}
fm_regulator = NULL;
}
/* +++ AlbertYCFang, 2011.06.13, FM +++ */
rc = vreg_disable(fm_gp16);
if (rc) {
printk(KERN_ERR "%s: return val: %d \n",
__func__, rc);
}
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
<API key>);
}
else {
rc = pmapp_clock_vote(id, /*PMAPP_CLOCK_ID_DO*/QTR8x00_WCN_CLK,
<API key>);
}
if (rc < 0)
printk(KERN_ERR "%s: clock_vote return val: %d\n",
__func__, rc);
/*Disable the Clock Using GPIO34/AP2MDM_MRMBCK_EN in case
of svlte*/
if (<API key>() ||
<API key>()) {
rc = marimba_gpio_config(0);
if (rc < 0)
printk(KERN_ERR "%s: clock disable for svlte : %d\n",
__func__, rc);
}
if (!bahama_not_marimba) {
rc = <API key>(id, PMAPP_VREG_S2, 0);
if (rc < 0)
printk(KERN_ERR "%s: vreg level vote return val: %d\n",
__func__, rc);
}
}
static struct <API key> marimba_fm_pdata = {
.fm_setup = fm_radio_setup,
.fm_shutdown = fm_radio_shutdown,
.irq = MSM_GPIO_TO_INT(147),
.vreg_s2 = NULL,
.vreg_xo_out = NULL,
};
/* Slave id address for FM/CDC/QMEMBIST
* Values can be programmed using Marimba slave id 0
* should there be a conflict with other I2C devices
* */
#define <API key> 0x2A
#define <API key> 0x77
#define <API key> 0X66
#define <API key> 0x2A
#define <API key> 0x7B
static const char *tsadc_id = "MADC";
static const char *vregs_tsadc_name[] = {
"gp12",
"s2",
};
static struct vreg *vregs_tsadc[ARRAY_SIZE(vregs_tsadc_name)];
static const char *<API key>[] = {
"s3",
"gp12",
"gp16"
};
static struct vreg *vregs_timpani_tsadc[ARRAY_SIZE(<API key>)];
static int marimba_tsadc_power(int vreg_on)
{
int i, rc = 0;
int tsadc_adie_type = <API key>();
if (tsadc_adie_type == TIMPANI_ID) {
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
if (!vregs_timpani_tsadc[i]) {
pr_err("%s: vreg_get %s failed(%d)\n",
__func__, <API key>[i], rc);
goto vreg_fail;
}
rc = vreg_on ? vreg_enable(vregs_timpani_tsadc[i]) :
vreg_disable(vregs_timpani_tsadc[i]);
if (rc < 0) {
pr_err("%s: vreg %s %s failed(%d)\n",
__func__, <API key>[i],
vreg_on ? "enable" : "disable", rc);
goto vreg_fail;
}
}
/* Vote for D0 and D1 buffer */
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
vreg_on ? PMAPP_CLOCK_VOTE_ON : <API key>);
}
else {
rc = pmapp_clock_vote(tsadc_id, /*PMAPP_CLOCK_ID_D1*/QTR8x00_WCN_CLK,
vreg_on ? PMAPP_CLOCK_VOTE_ON : <API key>);
}
if (rc) {
pr_err("%s: unable to %svote for d1 clk\n",
__func__, vreg_on ? "" : "de-");
goto do_vote_fail;
}
rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
vreg_on ? PMAPP_CLOCK_VOTE_ON : <API key>);
if (rc) {
pr_err("%s: unable to %svote for d1 clk\n",
__func__, vreg_on ? "" : "de-");
goto do_vote_fail;
}
} else if (tsadc_adie_type == MARIMBA_ID) {
for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
if (!vregs_tsadc[i]) {
pr_err("%s: vreg_get %s failed (%d)\n",
__func__, vregs_tsadc_name[i], rc);
goto vreg_fail;
}
rc = vreg_on ? vreg_enable(vregs_tsadc[i]) :
vreg_disable(vregs_tsadc[i]);
if (rc < 0) {
pr_err("%s: vreg %s %s failed (%d)\n",
__func__, vregs_tsadc_name[i],
vreg_on ? "enable" : "disable", rc);
goto vreg_fail;
}
}
/* If marimba vote for DO buffer */
rc = pmapp_clock_vote(tsadc_id, PMAPP_CLOCK_ID_DO,
vreg_on ? PMAPP_CLOCK_VOTE_ON : <API key>);
if (rc) {
pr_err("%s: unable to %svote for d0 clk\n",
__func__, vreg_on ? "" : "de-");
goto do_vote_fail;
}
} else {
pr_err("%s:Adie %d not supported\n",
__func__, tsadc_adie_type);
return -ENODEV;
}
msleep(5); /* ensure power is stable */
return 0;
do_vote_fail:
vreg_fail:
while (i) {
if (vreg_on) {
if (tsadc_adie_type == TIMPANI_ID)
vreg_disable(vregs_timpani_tsadc[--i]);
else if (tsadc_adie_type == MARIMBA_ID)
vreg_disable(vregs_tsadc[--i]);
} else {
if (tsadc_adie_type == TIMPANI_ID)
vreg_enable(vregs_timpani_tsadc[--i]);
else if (tsadc_adie_type == MARIMBA_ID)
vreg_enable(vregs_tsadc[--i]);
}
}
return rc;
}
static int marimba_tsadc_vote(int vote_on)
{
int rc = 0;
if (<API key>() == MARIMBA_ID) {
int level = vote_on ? 1300 : 0;
rc = <API key>(tsadc_id, PMAPP_VREG_S2, level);
if (rc < 0)
pr_err("%s: vreg level %s failed (%d)\n",
__func__, vote_on ? "on" : "off", rc);
}
return rc;
}
static int marimba_tsadc_init(void)
{
int i, rc = 0;
int tsadc_adie_type = <API key>();
if (tsadc_adie_type == TIMPANI_ID) {
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
vregs_timpani_tsadc[i] = vreg_get(NULL,
<API key>[i]);
if (IS_ERR(vregs_timpani_tsadc[i])) {
pr_err("%s: vreg get %s failed (%ld)\n",
__func__, <API key>[i],
PTR_ERR(vregs_timpani_tsadc[i]));
rc = PTR_ERR(vregs_timpani_tsadc[i]);
goto vreg_get_fail;
}
}
} else if (tsadc_adie_type == MARIMBA_ID) {
for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
vregs_tsadc[i] = vreg_get(NULL, vregs_tsadc_name[i]);
if (IS_ERR(vregs_tsadc[i])) {
pr_err("%s: vreg get %s failed (%ld)\n",
__func__, vregs_tsadc_name[i],
PTR_ERR(vregs_tsadc[i]));
rc = PTR_ERR(vregs_tsadc[i]);
goto vreg_get_fail;
}
}
} else {
pr_err("%s:Adie %d not supported\n",
__func__, tsadc_adie_type);
return -ENODEV;
}
return 0;
vreg_get_fail:
while (i) {
if (tsadc_adie_type == TIMPANI_ID)
vreg_put(vregs_timpani_tsadc[--i]);
else if (tsadc_adie_type == MARIMBA_ID)
vreg_put(vregs_tsadc[--i]);
}
return rc;
}
static int marimba_tsadc_exit(void)
{
int i, rc = 0;
int tsadc_adie_type = <API key>();
if (tsadc_adie_type == TIMPANI_ID) {
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
if (vregs_tsadc[i])
vreg_put(vregs_timpani_tsadc[i]);
}
} else if (tsadc_adie_type == MARIMBA_ID) {
for (i = 0; i < ARRAY_SIZE(vregs_tsadc_name); i++) {
if (vregs_tsadc[i])
vreg_put(vregs_tsadc[i]);
}
rc = <API key>(tsadc_id, PMAPP_VREG_S2, 0);
if (rc < 0)
pr_err("%s: vreg level off failed (%d)\n",
__func__, rc);
} else {
pr_err("%s:Adie %d not supported\n",
__func__, tsadc_adie_type);
rc = -ENODEV;
}
return rc;
}
static struct <API key> msm_ts_data = {
.min_x = 0,
.max_x = 4096,
.min_y = 0,
.max_y = 4096,
.min_press = 0,
.max_press = 255,
.inv_x = 4096,
.inv_y = 4096,
.can_wakeup = false,
};
static struct <API key> marimba_tsadc_pdata = {
.marimba_tsadc_power = marimba_tsadc_power,
.init = marimba_tsadc_init,
.exit = marimba_tsadc_exit,
.level_vote = marimba_tsadc_vote,
.tsadc_prechg_en = true,
.can_wakeup = false,
.setup = {
.pen_irq_en = true,
.tsadc_en = true,
},
.params2 = {
.input_clk_khz = 2400,
.sample_prd = TSADC_CLK_3,
},
.params3 = {
.prechg_time_nsecs = 6400,
.stable_time_nsecs = 6400,
.tsadc_test_mode = 0,
},
.tssc_data = &msm_ts_data,
};
static struct vreg *vreg_codec_s4;
static int <API key>(int vreg_on)
{
int rc = 0;
if (!vreg_codec_s4) {
vreg_codec_s4 = vreg_get(NULL, "s4");
if (IS_ERR(vreg_codec_s4)) {
printk(KERN_ERR "%s: vreg_get() failed (%ld)\n",
__func__, PTR_ERR(vreg_codec_s4));
rc = PTR_ERR(vreg_codec_s4);
goto vreg_codec_s4_fail;
}
}
if (vreg_on) {
rc = vreg_enable(vreg_codec_s4);
if (rc)
printk(KERN_ERR "%s: vreg_enable() = %d \n",
__func__, rc);
goto vreg_codec_s4_fail;
} else {
rc = vreg_disable(vreg_codec_s4);
if (rc)
printk(KERN_ERR "%s: vreg_disable() = %d \n",
__func__, rc);
goto vreg_codec_s4_fail;
}
vreg_codec_s4_fail:
return rc;
}
static struct <API key> mariba_codec_pdata = {
.marimba_codec_power = <API key>,
#ifdef <API key>
.snddev_profile_init = msm_snddev_init,
#endif
};
static struct <API key> marimba_pdata = {
.slave_id[MARIMBA_SLAVE_ID_FM] = <API key>,
.slave_id[<API key>] = <API key>,
.slave_id[<API key>] = <API key>,
.slave_id[SLAVE_ID_BAHAMA_FM] = <API key>,
.slave_id[<API key>] = <API key>,
.marimba_setup = <API key>,
.marimba_shutdown = <API key>,
.bahama_setup = <API key>,
.bahama_shutdown = <API key>,
.marimba_gpio_config = <API key>,
.bahama_core_config = <API key>,
.fm = &marimba_fm_pdata,
.codec = &mariba_codec_pdata,
};
static void __init <API key>(void)
{
int rc;
vreg_marimba_1 = vreg_get(NULL, "s3");
if (IS_ERR(vreg_marimba_1)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_marimba_1));
return;
}
rc = vreg_set_level(vreg_marimba_1, 1800);
vreg_marimba_2 = vreg_get(NULL, "gp16");
if (IS_ERR(vreg_marimba_1)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_marimba_1));
return;
}
rc = vreg_set_level(vreg_marimba_2, 1200);
vreg_marimba_3 = vreg_get(NULL, "usb2");
if (IS_ERR(vreg_marimba_3)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_marimba_3));
return;
}
rc = vreg_set_level(vreg_marimba_3, 1800);
}
static struct <API key> timpani_codec_pdata = {
.marimba_codec_power = <API key>,
#ifdef <API key>
.snddev_profile_init = <API key>,
#endif
};
static struct <API key> timpani_pdata = {
.slave_id[<API key>] = <API key>,
.slave_id[<API key>] = <API key>,
.marimba_setup = <API key>,
.marimba_shutdown = <API key>,
.codec = &timpani_codec_pdata,
.tsadc = &marimba_tsadc_pdata,
};
#define <API key> 0xD
static struct i2c_board_info <API key>[] = {
{
I2C_BOARD_INFO("timpani", <API key>),
.platform_data = &timpani_pdata,
},
};
#ifdef <API key>
static struct resource msm_aictl_resources[] = {
{
.name = "aictl",
.start = 0xa5000100,
.end = 0xa5000100,
.flags = IORESOURCE_MEM,
}
};
static struct resource msm_mi2s_resources[] = {
{
.name = "hdmi",
.start = 0xac900000,
.end = 0xac900038,
.flags = IORESOURCE_MEM,
},
{
.name = "codec_rx",
.start = 0xac940040,
.end = 0xac940078,
.flags = IORESOURCE_MEM,
},
{
.name = "codec_tx",
.start = 0xac980080,
.end = 0xac9800B8,
.flags = IORESOURCE_MEM,
}
};
static struct <API key> lpa_pdata = {
.obuf_hlb_size = 0x2BFF8,
.dsp_proc_id = 0,
.app_proc_id = 2,
.nosb_config = {
.llb_min_addr = 0,
.llb_max_addr = 0x3ff8,
.sb_min_addr = 0,
.sb_max_addr = 0,
},
.sb_config = {
.llb_min_addr = 0,
.llb_max_addr = 0x37f8,
.sb_min_addr = 0x3800,
.sb_max_addr = 0x3ff8,
}
};
static struct resource msm_lpa_resources[] = {
{
.name = "lpa",
.start = 0xa5000000,
.end = 0xa50000a0,
.flags = IORESOURCE_MEM,
}
};
static struct resource <API key>[] = {
{
.name = "aux_codec_reg_addr",
.start = 0xac9c00c0,
.end = 0xac9c00c8,
.flags = IORESOURCE_MEM,
},
{
.name = "aux_pcm_dout",
.start = 138,
.end = 138,
.flags = IORESOURCE_IO,
},
{
.name = "aux_pcm_din",
.start = 139,
.end = 139,
.flags = IORESOURCE_IO,
},
{
.name = "aux_pcm_syncout",
.start = 140,
.end = 140,
.flags = IORESOURCE_IO,
},
{
.name = "aux_pcm_clkin_a",
.start = 141,
.end = 141,
.flags = IORESOURCE_IO,
},
};
static struct platform_device msm_aux_pcm_device = {
.name = "msm_aux_pcm",
.id = 0,
.num_resources = ARRAY_SIZE(<API key>),
.resource = <API key>,
};
struct platform_device msm_aictl_device = {
.name = "audio_interct",
.id = 0,
.num_resources = ARRAY_SIZE(msm_aictl_resources),
.resource = msm_aictl_resources,
};
struct platform_device msm_mi2s_device = {
.name = "mi2s",
.id = 0,
.num_resources = ARRAY_SIZE(msm_mi2s_resources),
.resource = msm_mi2s_resources,
};
struct platform_device msm_lpa_device = {
.name = "lpa",
.id = 0,
.num_resources = ARRAY_SIZE(msm_lpa_resources),
.resource = msm_lpa_resources,
.dev = {
.platform_data = &lpa_pdata,
},
};
#endif /* <API key> */
#define DEC0_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
(1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<<API key>)|(1<<MSM_ADSP_CODEC_WAV)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<MSM_ADSP_CODEC_EVRC)|(1<<<API key>))
#define DEC1_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
(1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<<API key>)|(1<<MSM_ADSP_CODEC_WAV)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<MSM_ADSP_CODEC_EVRC)|(1<<<API key>))
#define DEC2_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
(1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<<API key>)|(1<<MSM_ADSP_CODEC_WAV)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<MSM_ADSP_CODEC_EVRC)|(1<<<API key>))
#define DEC3_FORMAT ((1<<MSM_ADSP_CODEC_MP3)| \
(1<<MSM_ADSP_CODEC_AAC)|(1<<MSM_ADSP_CODEC_WMA)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<<API key>)|(1<<MSM_ADSP_CODEC_WAV)| \
(1<<<API key>)|(1<<<API key>)| \
(1<<MSM_ADSP_CODEC_EVRC)|(1<<<API key>))
#define DEC4_FORMAT (1<<MSM_ADSP_CODEC_MIDI)
static unsigned int <API key>[] = {
/* Audio LP */
0,
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_MODE_LP)|
(1<<MSM_ADSP_OP_DM)),
/* Concurrency 1 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
/* Concurrency 2 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
/* Concurrency 3 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
/* Concurrency 4 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
/* Concurrency 5 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
/* Concurrency 6 */
(DEC4_FORMAT),
(DEC3_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC2_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC1_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
(DEC0_FORMAT|(1<<<API key>)|(1<<MSM_ADSP_OP_DM)),
};
#define DEC_INFO(name, queueid, decid, nr_codec) { .module_name = name, \
.module_queueid = queueid, .module_decid = decid, \
.nr_codec_support = nr_codec}
#define DEC_INSTANCE(max_instance_same, max_instance_diff) { \
.<API key> = max_instance_same, \
.<API key> = max_instance_diff}
static struct msm_adspdec_info dec_info_list[] = {
DEC_INFO("AUDPLAY4TASK", 17, 4, 1), /* <API key> */
DEC_INFO("AUDPLAY3TASK", 16, 3, 11), /* <API key> */
DEC_INFO("AUDPLAY2TASK", 15, 2, 11), /* <API key> */
DEC_INFO("AUDPLAY1TASK", 14, 1, 11), /* <API key> */
DEC_INFO("AUDPLAY0TASK", 13, 0, 11), /* <API key> */
};
static struct dec_instance_table dec_instance_list[][MSM_MAX_DEC_CNT] = {
/* Non Turbo Mode */
{
DEC_INSTANCE(4, 3), /* WAV */
DEC_INSTANCE(4, 3), /* ADPCM */
DEC_INSTANCE(4, 2), /* MP3 */
DEC_INSTANCE(0, 0), /* Real Audio */
DEC_INSTANCE(4, 2), /* WMA */
DEC_INSTANCE(3, 2), /* AAC */
DEC_INSTANCE(0, 0), /* Reserved */
DEC_INSTANCE(0, 0), /* MIDI */
DEC_INSTANCE(4, 3), /* YADPCM */
DEC_INSTANCE(4, 3), /* QCELP */
DEC_INSTANCE(4, 3), /* AMRNB */
DEC_INSTANCE(1, 1), /* AMRWB/WB+ */
DEC_INSTANCE(4, 3), /* EVRC */
DEC_INSTANCE(1, 1), /* WMAPRO */
},
/* Turbo Mode */
{
DEC_INSTANCE(4, 3), /* WAV */
DEC_INSTANCE(4, 3), /* ADPCM */
DEC_INSTANCE(4, 3), /* MP3 */
DEC_INSTANCE(0, 0), /* Real Audio */
DEC_INSTANCE(4, 3), /* WMA */
DEC_INSTANCE(4, 3), /* AAC */
DEC_INSTANCE(0, 0), /* Reserved */
DEC_INSTANCE(0, 0), /* MIDI */
DEC_INSTANCE(4, 3), /* YADPCM */
DEC_INSTANCE(4, 3), /* QCELP */
DEC_INSTANCE(4, 3), /* AMRNB */
DEC_INSTANCE(2, 3), /* AMRWB/WB+ */
DEC_INSTANCE(4, 3), /* EVRC */
DEC_INSTANCE(1, 2), /* WMAPRO */
},
};
static struct <API key> <API key> = {
.num_dec = ARRAY_SIZE(dec_info_list),
.<API key> = (ARRAY_SIZE(<API key>) / \
ARRAY_SIZE(dec_info_list)),
.<API key> = <API key>,
.dec_info_list = dec_info_list,
.dec_instance_list = &dec_instance_list[0][0],
};
static struct platform_device msm_device_adspdec = {
.name = "msm_adspdec",
.id = -1,
.dev = {
.platform_data = &<API key>
},
};
/* Div2-SW2-BSP-FBX-OW { */
#ifdef CONFIG_SMC91X
static struct resource smc91x_resources[] = {
[0] = {
.start = 0x8A000300,
.end = 0x8A0003ff,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MSM_GPIO_TO_INT(156),
.end = MSM_GPIO_TO_INT(156),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device smc91x_device = {
.name = "smc91x",
.id = 0,
.num_resources = ARRAY_SIZE(smc91x_resources),
.resource = smc91x_resources,
};
#endif
#ifdef CONFIG_SMSC911X
static struct <API key> smsc911x_config = {
.phy_interface = <API key>,
.irq_polarity = <API key>,
.irq_type = <API key>,
.flags = SMSC911X_USE_32BIT,
};
static struct resource smsc911x_resources[] = {
[0] = {
.start = 0x8D000000,
.end = 0x8D000100,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = MSM_GPIO_TO_INT(88),
.end = MSM_GPIO_TO_INT(88),
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device smsc911x_device = {
.name = "smsc911x",
.id = -1,
.num_resources = ARRAY_SIZE(smsc911x_resources),
.resource = smsc911x_resources,
.dev = {
.platform_data = &smsc911x_config,
},
};
static struct msm_gpio smsc911x_gpios[] = {
{ GPIO_CFG(172, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr6" },
{ GPIO_CFG(173, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr5" },
{ GPIO_CFG(174, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr4" },
{ GPIO_CFG(175, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr3" },
{ GPIO_CFG(176, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr2" },
{ GPIO_CFG(177, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr1" },
{ GPIO_CFG(178, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "ebi2_addr0" },
{ GPIO_CFG(88, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "smsc911x_irq" },
};
static void <API key>(void)
{
int rc;
rc = <API key>(smsc911x_gpios,
ARRAY_SIZE(smsc911x_gpios));
if (rc)
pr_err("%s: unable to enable gpios\n", __func__);
}
#endif
/* } Div2-SW2-BSP-FBX-OW */
#ifdef CONFIG_USB_FUNCTION
static struct <API key> <API key> = {
.nluns = 0x02,
.buf_size = 16384,
.vendor = "GOOGLE",
.product = "Mass storage",
.release = 0xffff,
};
static struct platform_device mass_storage_device = {
.name = "usb_mass_storage",
.id = -1,
.dev = {
.platform_data = &<API key>,
},
};
#endif
#ifdef CONFIG_USB_ANDROID
static char *<API key>[] = {
"diag",
"modem",
"nmea",
"rmnet",
"usb_mass_storage",
};
static char *<API key>[] = {
"diag",
"adb",
"modem",
"nmea",
"rmnet",
"usb_mass_storage",
};
static char *<API key>[] = {
"diag",
"nmea",
"usb_mass_storage",
};
static char *<API key>[] = {
"diag",
"adb",
"nmea",
"usb_mass_storage",
};
static char *usb_functions_rndis[] = {
"rndis",
};
static char *<API key>[] = {
"rndis",
"adb",
};
static char *<API key>[] = {
"rndis",
"diag",
};
static char *<API key>[] = {
"rndis",
"diag",
"adb",
};
/* FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid { */
#ifdef CONFIG_FIH_FXX
static char *usb_functions_c000[] = {
"nmea",
"modem",
"adb",
"diag",
"usb_mass_storage",
};
static char *usb_functions_c001[] = {
"modem",
"adb",
"usb_mass_storage",
};
static char *usb_functions_c002[] = {
"diag",
};
static char *usb_functions_c003[] = {
"modem",
};
static char *usb_functions_c004[] = {
"usb_mass_storage",
};
static char *usb_functions_c007[] = {
"rndis",
"adb",
"diag",
};
static char *usb_functions_c008[] = {
"rndis",
"adb",
};
#ifdef <API key>
static char *<API key>[] = { "accessory" };
static char *<API key>[] = { "accessory", "adb" };
#endif // <API key>
static char *usb_functions_all[] = {
#ifdef <API key>
"rndis",
#endif
#ifdef <API key>
"accessory",
#endif // <API key>
"usb_mass_storage",
#ifdef <API key>
"diag",
#endif
"adb",
#ifdef CONFIG_USB_F_SERIAL
"modem",
"nmea",
#endif
#ifdef <API key>
"rmnet",
#endif
#ifdef <API key>
"acm",
#endif
};
#else // CONFIG_FIH_FXX
static char *usb_functions_all[] = {
#ifdef <API key>
"rndis",
#endif
#ifdef <API key>
"diag",
#endif
"adb",
#ifdef CONFIG_USB_F_SERIAL
"modem",
"nmea",
#endif
#ifdef <API key>
"rmnet",
#endif
"usb_mass_storage",
#ifdef <API key>
"acm",
#endif
};
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid */
static struct android_usb_product usb_products[] = {
/* FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid { */
#ifdef CONFIG_FIH_FXX
{
/* RNDIS + ADB */
.product_id = 0xC008,
.num_functions = ARRAY_SIZE(usb_functions_c008),
.functions = usb_functions_c008,
},
{
/* RNDIS + ADB + DIAG */
.product_id = 0xC007,
.num_functions = ARRAY_SIZE(usb_functions_c007),
.functions = usb_functions_c007,
},
{
/* USB_MASS_STORAGE */
.product_id = 0xC004,
.num_functions = ARRAY_SIZE(usb_functions_c004),
.functions = usb_functions_c004,
},
{
/* MODEM */
.product_id = 0xC003,
.num_functions = ARRAY_SIZE(usb_functions_c003),
.functions = usb_functions_c003,
},
{
/* DIAG */
.product_id = 0xC002,
.num_functions = ARRAY_SIZE(usb_functions_c002),
.functions = usb_functions_c002,
},
{
/* MODEM + ADB + USB_MASS_STORAGE */
.product_id = 0xC001,
.num_functions = ARRAY_SIZE(usb_functions_c001),
.functions = usb_functions_c001,
},
{
/* NMEA + MODEM + ADB + DIAG + USB_MASS_STORAGE */
.product_id = 0xC000,
.num_functions = ARRAY_SIZE(usb_functions_c000),
.functions = usb_functions_c000,
},
#ifdef <API key>
{
.vendor_id = <API key>,
.product_id = <API key>,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
.vendor_id = <API key>,
.product_id = <API key>,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
#endif // <API key>
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid */
{
.product_id = 0x9026,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
.product_id = 0x9025,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
/* RNDIS + DIAG */
.product_id = 0x902C,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
/* RNDIS + ADB + DIAG */
.product_id = 0x902D,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
};
/* FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized { */
#ifdef CONFIG_FIH_FXX
/*Huawei*/
static struct android_usb_product usb_products_12d1[] = {
{
.product_id = 0x1028,
.num_functions = ARRAY_SIZE(usb_functions_c008),
.functions = usb_functions_c008,
},
{
.product_id = 0x1027,
.num_functions = ARRAY_SIZE(usb_functions_c007),
.functions = usb_functions_c007,
},
{
.product_id = 0x1024,
.num_functions = ARRAY_SIZE(usb_functions_c004),
.functions = usb_functions_c004,
},
{
.product_id = 0x1023,
.num_functions = ARRAY_SIZE(usb_functions_c003),
.functions = usb_functions_c003,
},
{
.product_id = 0x1022,
.num_functions = ARRAY_SIZE(usb_functions_c002),
.functions = usb_functions_c002,
},
{
.product_id = 0x103c,
.num_functions = ARRAY_SIZE(usb_functions_c001),
.functions = usb_functions_c001,
},
{
.product_id = 0x1021,
.num_functions = ARRAY_SIZE(usb_functions_c000),
.functions = usb_functions_c000,
},
};
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized */
static struct android_usb_product fusion_usb_products[] = {
{
.product_id = 0x9028,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
.product_id = 0x9029,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
{
.product_id = 0xf00e,
.num_functions = ARRAY_SIZE(usb_functions_rndis),
.functions = usb_functions_rndis,
},
{
.product_id = 0x9024,
.num_functions = ARRAY_SIZE(<API key>),
.functions = <API key>,
},
};
static struct <API key> mass_storage_pdata = {
/* FIHTDC, Div2-SW2-BSP, Penho, PCtool { */
#ifdef CONFIG_FIH_FXX
.nluns = 2,
#else // CONFIG_FIH_FXX
.nluns = 1,
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, PCtool */
.vendor = "Qualcomm Incorporated",
.product = "Mass storage",
.release = 0x0100,
.can_stall = 1,
};
static struct platform_device <API key> = {
.name = "usb_mass_storage",
.id = -1,
.dev = {
.platform_data = &mass_storage_pdata,
},
};
static struct <API key> rndis_pdata = {
/* ethaddr is filled by <API key> */
.vendorID = 0x05C6,
.vendorDescr = "Qualcomm Incorporated",
};
static struct platform_device rndis_device = {
.name = "rndis",
.id = -1,
.dev = {
.platform_data = &rndis_pdata,
},
};
static struct <API key> android_usb_pdata = {
/* FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid { */
#ifdef CONFIG_FIH_FXX
.vendor_id = 0x0489,
.product_id = 0xC001,
#else // CONFIG_FIH_FXX
.vendor_id = 0x05C6,
.product_id = 0x9026,
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbPidVid */
.version = 0x0100,
.product_name = "Qualcomm HSUSB Device",
.manufacturer_name = "Qualcomm Incorporated",
.num_products = ARRAY_SIZE(usb_products),
.products = usb_products,
.num_functions = ARRAY_SIZE(usb_functions_all),
.functions = usb_functions_all,
.serial_number = "1234567890ABCDEF",
};
static struct platform_device android_usb_device = {
.name = "android_usb",
.id = -1,
.dev = {
.platform_data = &android_usb_pdata,
},
};
static int __init <API key>(char *serialno)
{
int i;
char *src = serialno;
/* create a fake MAC address from our serial number.
* first byte is 0x02 to signify locally administered.
*/
rndis_pdata.ethaddr[0] = 0x02;
for (i = 0; *src; i++) {
/* XOR the USB serial across the remaining bytes */
rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++;
}
android_usb_pdata.serial_number = serialno;
return 1;
}
__setup("androidboot.serialno=", <API key>);
#endif
static struct msm_gpio optnav_config_data[] = {
{ GPIO_CFG(OPTNAV_CHIP_SELECT, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA),
"optnav_chip_select" },
};
static void __iomem *virtual_optnav;
static int optnav_gpio_setup(void)
{
int rc = -ENODEV;
rc = <API key>(optnav_config_data,
ARRAY_SIZE(optnav_config_data));
/* Configure the FPGA for GPIOs */
virtual_optnav = ioremap(<API key>, 0x4);
if (!virtual_optnav) {
pr_err("%s:Could not ioremap region\n", __func__);
return -ENOMEM;
}
/*
* Configure the FPGA to set GPIO 19 as
* normal, active(enabled), output(MSM to SURF)
*/
writew(0x311E, virtual_optnav);
return rc;
}
static void optnav_gpio_release(void)
{
<API key>(optnav_config_data,
ARRAY_SIZE(optnav_config_data));
iounmap(virtual_optnav);
}
static struct vreg *vreg_gp7;
static struct vreg *vreg_gp4;
static struct vreg *vreg_gp9;
static struct vreg *vreg_usb3_3;
static int optnav_enable(void)
{
int rc;
/*
* Enable the VREGs L8(gp7), L10(gp4), L12(gp9), L6(usb)
* for I2C communication with keyboard.
*/
vreg_gp7 = vreg_get(NULL, "gp7");
rc = vreg_set_level(vreg_gp7, 1800);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_gp7;
}
rc = vreg_enable(vreg_gp7);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_gp7;
}
vreg_gp4 = vreg_get(NULL, "gp4");
rc = vreg_set_level(vreg_gp4, 2600);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_gp4;
}
rc = vreg_enable(vreg_gp4);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_gp4;
}
vreg_gp9 = vreg_get(NULL, "gp9");
rc = vreg_set_level(vreg_gp9, 1800);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_gp9;
}
rc = vreg_enable(vreg_gp9);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_gp9;
}
vreg_usb3_3 = vreg_get(NULL, "usb");
rc = vreg_set_level(vreg_usb3_3, 3300);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_3_3;
}
rc = vreg_enable(vreg_usb3_3);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_3_3;
}
/* Enable the chip select GPIO */
gpio_set_value(OPTNAV_CHIP_SELECT, 1);
gpio_set_value(OPTNAV_CHIP_SELECT, 0);
return 0;
fail_vreg_3_3:
vreg_disable(vreg_gp9);
fail_vreg_gp9:
vreg_disable(vreg_gp4);
fail_vreg_gp4:
vreg_disable(vreg_gp7);
fail_vreg_gp7:
return rc;
}
static void optnav_disable(void)
{
vreg_disable(vreg_usb3_3);
vreg_disable(vreg_gp9);
vreg_disable(vreg_gp4);
vreg_disable(vreg_gp7);
gpio_set_value(OPTNAV_CHIP_SELECT, 1);
}
static struct <API key> optnav_data = {
.gpio_setup = optnav_gpio_setup,
.gpio_release = optnav_gpio_release,
.optnav_on = optnav_enable,
.optnav_off = optnav_disable,
.rotate_xy = 0,
.function1 = {
.no_motion1_en = true,
.touch_sensor_en = true,
.ofn_en = true,
.clock_select_khz = 1500,
.cpi_selection = 1200,
},
.function2 = {
.invert_y = false,
.invert_x = true,
.swap_x_y = false,
.hold_a_b_en = true,
.motion_filter_en = true,
},
};
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
static int hdmi_comm_power(int on, int show);
static int hdmi_init_irq(void);
static int hdmi_enable_5v(int on);
static int hdmi_core_power(int on, int show);
static int hdmi_cec_power(int on);
static bool <API key>(void);
static struct <API key> adv7520_hdmi_data = {
.irq = MSM_GPIO_TO_INT(18),
.comm_power = hdmi_comm_power,
.init_irq = hdmi_init_irq,
.enable_5v = hdmi_enable_5v,
.core_power = hdmi_core_power,
.cec_power = hdmi_cec_power,
.<API key> = <API key>,
};
#endif
#ifdef <API key>
static void <API key>(int on)
{
gpio_tlmm_config(GPIO_HDMI_5V_EN, GPIO_CFG_ENABLE);
if (on)
gpio_set_value(GPIO_PIN(GPIO_HDMI_5V_EN), 1);
else
gpio_set_value(GPIO_PIN(GPIO_HDMI_5V_EN), 0);
}
static int <API key>(void)
{
return gpio_get_value(HDMI_INT);
}
static struct <API key> adv7525_hdmi_data = {
.irq = MSM_GPIO_TO_INT(HDMI_INT),
.intr_detect = <API key>,
.setup_int_power = <API key>,
};
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
#ifdef CONFIG_BOSCH_BMA150
static struct vreg *vreg_gp6;
static int sensors_ldo_enable(void)
{
int rc;
/*
* Enable the VREGs L8(gp7), L15(gp6)
* for I2C communication with sensors.
*/
pr_info("sensors_ldo_enable called!!\n");
vreg_gp7 = vreg_get(NULL, "gp7");
if (IS_ERR(vreg_gp7)) {
pr_err("%s: vreg_get gp7 failed\n", __func__);
rc = PTR_ERR(vreg_gp7);
goto fail_gp7_get;
}
rc = vreg_set_level(vreg_gp7, 1800);
if (rc) {
pr_err("%s: vreg_set_level gp7 failed\n", __func__);
goto fail_gp7_level;
}
rc = vreg_enable(vreg_gp7);
if (rc) {
pr_err("%s: vreg_enable gp7 failed\n", __func__);
goto fail_gp7_level;
}
vreg_gp6 = vreg_get(NULL, "gp6");
if (IS_ERR(vreg_gp6)) {
pr_err("%s: vreg_get gp6 failed\n", __func__);
rc = PTR_ERR(vreg_gp6);
goto fail_gp6_get;
}
rc = vreg_set_level(vreg_gp6, 2800);
if (rc) {
pr_err("%s: vreg_set_level gp6 failed\n", __func__);
goto fail_gp6_level;
}
rc = vreg_enable(vreg_gp6);
if (rc) {
pr_err("%s: vreg_enable gp6 failed\n", __func__);
goto fail_gp6_level;
}
return 0;
fail_gp6_level:
vreg_put(vreg_gp6);
fail_gp6_get:
vreg_disable(vreg_gp7);
fail_gp7_level:
vreg_put(vreg_gp7);
fail_gp7_get:
return rc;
}
static void sensors_ldo_disable(void)
{
pr_info("sensors_ldo_disable called!!\n");
vreg_disable(vreg_gp6);
vreg_put(vreg_gp6);
vreg_disable(vreg_gp7);
vreg_put(vreg_gp7);
}
static struct <API key> bma150_data = {
.power_on = sensors_ldo_enable,
.power_off = sensors_ldo_disable,
};
static struct i2c_board_info bma150_board_info[] __initdata = {
{
I2C_BOARD_INFO("bma150", 0x38),
.flags = I2C_CLIENT_WAKE,
.irq = MSM_GPIO_TO_INT(BMA150_GPIO_INT),
.platform_data = &bma150_data,
},
};
#endif
static struct i2c_board_info msm_i2c_board_info[] = {
{
I2C_BOARD_INFO("m33c01", <API key>),
.irq = MSM_GPIO_TO_INT(OPTNAV_IRQ),
.platform_data = &optnav_data,
},
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
{
I2C_BOARD_INFO("adv7520", ADV7520_I2C_ADDR),
.platform_data = &adv7520_hdmi_data,
},
#endif
#ifdef <API key>
{
I2C_BOARD_INFO("adv7525", 0x72 >> 1),
.platform_data = &adv7525_hdmi_data,
},
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
//Div2-SW2-BSP-Touch, Vincent +
#ifdef <API key>
{
I2C_BOARD_INFO("innolux_ts", 0x09),
},
#endif
#ifdef <API key>
{
I2C_BOARD_INFO("bu21018mwv", 0x5C),
},
#endif
#ifdef <API key>
{
I2C_BOARD_INFO("bi041p", 0x08),
.irq = MSM_GPIO_TO_INT(42),
},
#endif
//Div2-SW2-BSP-Touch, Vincent -
//<API key>+[
#ifdef <API key>
{
I2C_BOARD_INFO("atmel_mxt165", 0x4A),
},
#endif
//<API key>+]
#ifdef CONFIG_FIH_AAT1272
{
I2C_BOARD_INFO("aat1272", 0x37),
},
#endif
//<API key>+{
#ifdef CONFIG_INPUT_YAS529
{
I2C_BOARD_INFO("yas529", 0x2E), //yamaha yas529
},
#endif
#ifdef CONFIG_INPUT_BMA150
{
I2C_BOARD_INFO("bma150", 0x38), //bosch bma150/bosch bma023
},
#endif
//<API key>+{
#ifdef <API key>
{
#ifdef <API key>
I2C_BOARD_INFO("cm3623", 0x49),
#else
I2C_BOARD_INFO("cm3623", 0x11),
#endif
},
#endif
//<API key>+}
#ifdef <API key>
{
#ifdef <API key>
I2C_BOARD_INFO("ltr502als", 0x1c),
.irq = MSM_GPIO_TO_INT(20),
#else
I2C_BOARD_INFO("ltr502als", 0x1d),
.irq = MSM_GPIO_TO_INT(49),
#endif
},
#endif
//<API key>+}
};
static struct i2c_board_info <API key>[] = {
{
I2C_BOARD_INFO("marimba", 0xc),
.platform_data = &marimba_pdata,
}
};
#ifdef CONFIG_USB_FUNCTION
static struct usb_function_map usb_functions_map[] = {
{"diag", 0},
{"adb", 1},
{"modem", 2},
{"nmea", 3},
{"mass_storage", 4},
{"ethernet", 5},
};
static struct usb_composition <API key>[] = {
{
.product_id = 0x9012,
.functions = 0x5, /* 0101 */
},
{
.product_id = 0x9013,
.functions = 0x15, /* 10101 */
},
{
.product_id = 0x9014,
.functions = 0x30, /* 110000 */
},
{
.product_id = 0x9016,
.functions = 0xD, /* 01101 */
},
{
.product_id = 0x9017,
.functions = 0x1D, /* 11101 */
},
{
.product_id = 0xF000,
.functions = 0x10, /* 10000 */
},
{
.product_id = 0xF009,
.functions = 0x20, /* 100000 */
},
{
.product_id = 0x9018,
.functions = 0x1F, /* 011111 */
},
};
static struct <API key> msm_hsusb_pdata = {
.version = 0x0100,
.phy_info = USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM,
.vendor_id = 0x5c6,
.product_name = "Qualcomm HSUSB Device",
.serial_number = "1234567890ABCDEF",
.manufacturer_name
= "Qualcomm Incorporated",
.compositions = <API key>,
.num_compositions
= ARRAY_SIZE(<API key>),
.function_map = usb_functions_map,
.num_functions = ARRAY_SIZE(usb_functions_map),
.core_clk = 1,
};
#endif
static struct <API key> hs_platform_data = {
.hs_name = "7k_handset",
//<API key>*[
// .pwr_key_delay_ms = 500, /* 0 will disable end key */
.pwr_key_delay_ms = 0, /* 0 will disable end key */
//<API key>*]
};
static struct platform_device hs_device = {
.name = "msm-handset",
.id = -1,
.dev = {
.platform_data = &hs_platform_data,
},
};
static struct <API key> msm_pm_data[<API key>] = {
[<API key>].supported = 1,
[<API key>].suspend_enabled = 1,
[<API key>].idle_enabled = 1,
[<API key>].latency = 8594,
[<API key>].residency = 23740,
[<API key>].supported = 1,
[<API key>].suspend_enabled = 1,
[<API key>].idle_enabled = 1,
[<API key>].latency = 4594,
[<API key>].residency = 23740,
[<API key>].supported = 1,
#ifdef <API key>
[<API key>].suspend_enabled = 0,
[<API key>].idle_enabled = 1,
#else /*<API key>*/
[<API key>].suspend_enabled = 0,
[<API key>].idle_enabled = 0,
#endif /*<API key>*/
[<API key>].latency = 500,
[<API key>].residency = 6000,
[<API key>].supported = 1,
[<API key>].suspend_enabled
= 1,
[<API key>].idle_enabled = 0,
[<API key>].latency = 443,
[<API key>].residency = 1098,
[<API key>].supported = 1,
[<API key>].suspend_enabled = 1,
[<API key>].idle_enabled = 1,
[<API key>].latency = 2,
[<API key>].residency = 0,
};
static struct resource qsd_spi_resources[] = {
{
.name = "spi_irq_in",
.start = INT_SPI_INPUT,
.end = INT_SPI_INPUT,
.flags = IORESOURCE_IRQ,
},
{
.name = "spi_irq_out",
.start = INT_SPI_OUTPUT,
.end = INT_SPI_OUTPUT,
.flags = IORESOURCE_IRQ,
},
{
.name = "spi_irq_err",
.start = INT_SPI_ERROR,
.end = INT_SPI_ERROR,
.flags = IORESOURCE_IRQ,
},
{
.name = "spi_base",
.start = 0xA8000000,
.end = 0xA8000000 + SZ_4K - 1,
.flags = IORESOURCE_MEM,
},
{
.name = "spidm_channels",
.flags = IORESOURCE_DMA,
},
{
.name = "spidm_crci",
.flags = IORESOURCE_DMA,
},
};
#define AMDH0_BASE_PHYS 0xAC200000
#define ADMH0_GP_CTL (ct_adm_base + 0x3D8)
static int <API key>(void)
{
void __iomem *ct_adm_base = 0;
u32 spi_mux = 0;
int ret = 0;
ct_adm_base = ioremap(AMDH0_BASE_PHYS, PAGE_SIZE);
if (!ct_adm_base) {
pr_err("%s: Could not remap %x\n", __func__, AMDH0_BASE_PHYS);
return -ENOMEM;
}
spi_mux = (ioread32(ADMH0_GP_CTL) & (0x3 << 12)) >> 12;
qsd_spi_resources[4].start = DMOV_USB_CHAN;
qsd_spi_resources[4].end = DMOV_TSIF_CHAN;
switch (spi_mux) {
case (1):
qsd_spi_resources[5].start = <API key>;
qsd_spi_resources[5].end = <API key>;
break;
case (2):
qsd_spi_resources[5].start = <API key>;
qsd_spi_resources[5].end = <API key>;
break;
case (3):
qsd_spi_resources[5].start = DMOV_CE_OUT_CRCI;
qsd_spi_resources[5].end = DMOV_CE_IN_CRCI;
break;
default:
ret = -ENOENT;
}
iounmap(ct_adm_base);
return ret;
}
static struct platform_device qsd_device_spi = {
.name = "spi_qsd",
.id = 0,
.num_resources = ARRAY_SIZE(qsd_spi_resources),
.resource = qsd_spi_resources,
};
#ifdef CONFIG_SPI_QSD
static struct spi_board_info <API key>[] __initdata = {
{
.modalias = "<API key>",
.mode = SPI_MODE_1,
.bus_num = 0,
.chip_select = 0,
.max_speed_hz = 26331429,
}
};
static struct spi_board_info <API key>[] __initdata = {
{
.modalias = "<API key>",
.mode = SPI_MODE_3|SPI_CS_HIGH,
.bus_num = 0,
.chip_select = 0,
.max_speed_hz = 9963243,
}
};
#endif
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(45, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
{ GPIO_CFG(46, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
{ GPIO_CFG(47, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "spi_mosi" },
{ GPIO_CFG(48, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
};
static int <API key>(void)
{
return <API key>(<API key>,
ARRAY_SIZE(<API key>));
}
static void <API key>(void)
{
<API key>(<API key>,
ARRAY_SIZE(<API key>));
}
static struct <API key> qsd_spi_pdata = {
.max_clock_speed = 26331429,
.clk_name = "spi_clk",
.pclk_name = "spi_pclk",
.gpio_config = <API key>,
.gpio_release = <API key>,
.dma_config = <API key>,
};
static void __init msm_qsd_spi_init(void)
{
qsd_device_spi.dev.platform_data = &qsd_spi_pdata;
}
#ifdef CONFIG_USB_EHCI_MSM
static void <API key>(unsigned phy_info, int on)
{
int rc;
static int vbus_is_on;
struct pm8058_gpio usb_vbus = {
.direction = PM_GPIO_DIR_OUT,
.pull = PM_GPIO_PULL_NO,
.output_buffer = <API key>,
.output_value = 1,
.vin_sel = 2,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_NORMAL,
.inv_int_pol = 0,
};
/* If VBUS is already on (or off), do nothing. */
if (unlikely(on == vbus_is_on))
return;
if (on) {
rc = pm8058_gpio_config(36, &usb_vbus);
if (rc) {
pr_err("%s PMIC GPIO 36 write failed\n", __func__);
return;
}
} else {
<API key>(<API key>(36), 0);
}
vbus_is_on = on;
}
static struct <API key> msm_usb_host_pdata = {
.phy_info = (USB_PHY_INTEGRATED | USB_PHY_MODEL_45NM),
.vbus_power = <API key>,
.power_budget = 180,
};
#endif
#ifdef <API key>
static int hsusb_rpc_connect(int connect)
{
if (connect)
return <API key>();
else
return msm_hsusb_rpc_close();
}
#endif
#ifdef <API key>
static struct vreg *vreg_3p3;
static int msm_hsusb_ldo_init(int init)
{
uint32_t version = 0;
int def_vol = 3400;
version = socinfo_get_version();
if (<API key>(version) >= 2 &&
<API key>(version) >= 1) {
def_vol = 3075;
pr_debug("%s: default voltage:%d\n", __func__, def_vol);
}
if (init) {
vreg_3p3 = vreg_get(NULL, "usb");
if (IS_ERR(vreg_3p3))
return PTR_ERR(vreg_3p3);
vreg_set_level(vreg_3p3, def_vol);
} else
vreg_put(vreg_3p3);
return 0;
}
static int <API key>(int enable)
{
static int ldo_status;
if (!vreg_3p3 || IS_ERR(vreg_3p3))
return -ENODEV;
if (ldo_status == enable)
return 0;
ldo_status = enable;
if (enable)
return vreg_enable(vreg_3p3);
return vreg_disable(vreg_3p3);
}
static int <API key>(int mV)
{
static int cur_voltage = 3400;
if (!vreg_3p3 || IS_ERR(vreg_3p3))
return -ENODEV;
if (cur_voltage == mV)
return 0;
cur_voltage = mV;
pr_debug("%s: (%d)\n", __func__, mV);
return vreg_set_level(vreg_3p3, mV);
}
#endif
#ifndef CONFIG_USB_EHCI_MSM
static int <API key>(void (*callback)(int online), int init);
#endif
static struct <API key> msm_otg_pdata = {
.rpc_connect = hsusb_rpc_connect,
#ifndef CONFIG_USB_EHCI_MSM
.<API key> = <API key>,
#else
.vbus_power = <API key>,
#endif
.core_clk = 1,
.pemp_level = <API key>,
.cdr_autoreset = <API key>,
.drv_ampl = <API key>,
.se1_gating = SE1_GATING_DISABLE,
.chg_vbus_draw = hsusb_chg_vbus_draw,
.chg_connected = hsusb_chg_connected,
.chg_init = hsusb_chg_init,
.ldo_enable = <API key>,
.ldo_init = msm_hsusb_ldo_init,
.ldo_set_voltage = <API key>,
};
#ifdef CONFIG_USB_GADGET
static struct <API key> msm_gadget_pdata = {
.<API key> = 1,
};
#endif
#ifndef CONFIG_USB_EHCI_MSM
typedef void (*notify_vbus_state) (int);
notify_vbus_state <API key>;
int vbus_on_irq;
static irqreturn_t pmic_vbus_on_irq(int irq, void *data)
{
pr_info("%s: vbus notification from pmic\n", __func__);
(*<API key>) (1);
return IRQ_HANDLED;
}
static int <API key>(void (*callback)(int online), int init)
{
int ret;
if (init) {
if (!callback)
return -ENODEV;
<API key> = callback;
vbus_on_irq = <API key>(&msm_device_otg,
"vbus_on");
if (vbus_on_irq <= 0) {
pr_err("%s: unable to get vbus on irq\n", __func__);
return -ENODEV;
}
ret = <API key>(vbus_on_irq, pmic_vbus_on_irq,
IRQF_TRIGGER_RISING, "msm_otg_vbus_on", NULL);
if (ret < 0) {
pr_info("%s: request_irq for vbus_on"
"interrupt failed\n", __func__);
return ret;
}
msm_otg_pdata.pmic_vbus_irq = vbus_on_irq;
return 0;
} else {
free_irq(vbus_on_irq, 0);
<API key> = NULL;
return 0;
}
}
#endif
static struct <API key> android_pmem_pdata = {
.name = "pmem",
.allocator_type = <API key>,
.cached = 1,
};
static struct platform_device android_pmem_device = {
.name = "android_pmem",
.id = 0,
.dev = { .platform_data = &android_pmem_pdata },
};
//<API key>+
#if 0
#ifndef CONFIG_SPI_QSD
static int lcdc_gpio_array_num[] = {
45, /* spi_clk */
46, /* spi_cs */
47, /* spi_mosi */
48, /* spi_miso */
};
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
{ GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
{ GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
{ GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
};
static void lcdc_config_gpios(int enable)
{
if (enable) {
<API key>(<API key>,
ARRAY_SIZE(
<API key>));
} else
<API key>(<API key>,
ARRAY_SIZE(
<API key>));
}
#endif
static struct <API key> <API key> = {
#ifndef CONFIG_SPI_QSD
.panel_config_gpio = lcdc_config_gpios,
.gpio_num = lcdc_gpio_array_num,
#endif
.gpio = 2, /* LPG PMIC_GPIO26 channel number */
};
static struct platform_device <API key> = {
.name = "lcdc_sharp_wvga",
.id = 0,
.dev = {
.platform_data = &<API key>,
}
};
#endif
//<API key>-
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
static struct msm_gpio dtv_panel_irq_gpios[] = {
{ GPIO_CFG(18, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA),
"hdmi_int" },
};
#endif
#ifdef <API key>
static struct msm_gpio hdmi_panel_gpios[] = {
{ GPIO_CFG(34, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "hdmi_5v_en" },
{ GPIO_CFG(HDMI_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "hdmi_int" },
};
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
#if defined(<API key>) || defined(<API key>)
static struct msm_gpio dtv_panel_gpios[] = {
{ GPIO_CFG(120, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_mclk" },
{ GPIO_CFG(121, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd0" },
{ GPIO_CFG(122, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd1" },
{ GPIO_CFG(123, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "wca_sd2" },
{ GPIO_CFG(124, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA), "dtv_pclk" },
{ GPIO_CFG(125, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_en" },
{ GPIO_CFG(126, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_vsync" },
{ GPIO_CFG(127, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_hsync" },
{ GPIO_CFG(128, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data0" },
{ GPIO_CFG(129, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data1" },
{ GPIO_CFG(130, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data2" },
{ GPIO_CFG(131, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data3" },
{ GPIO_CFG(132, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data4" },
{ GPIO_CFG(160, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data5" },
{ GPIO_CFG(161, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data6" },
{ GPIO_CFG(162, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data7" },
{ GPIO_CFG(163, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data8" },
{ GPIO_CFG(164, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_data9" },
{ GPIO_CFG(165, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat10" },
{ GPIO_CFG(166, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat11" },
{ GPIO_CFG(167, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat12" },
{ GPIO_CFG(168, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat13" },
{ GPIO_CFG(169, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat14" },
{ GPIO_CFG(170, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat15" },
{ GPIO_CFG(171, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat16" },
{ GPIO_CFG(172, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat17" },
{ GPIO_CFG(173, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat18" },
{ GPIO_CFG(174, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat19" },
{ GPIO_CFG(175, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat20" },
{ GPIO_CFG(176, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat21" },
{ GPIO_CFG(177, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat22" },
{ GPIO_CFG(178, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_4MA), "dtv_dat23" },
};
#endif
#ifdef HDMI_RESET
static unsigned dtv_reset_gpio =
GPIO_CFG(37, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
#endif
#ifdef <API key>
static int gpio_set(const char *label, const char *name, int level, int on)
{
struct vreg *vreg = vreg_get(NULL, label);
int rc;
if (IS_ERR(vreg)) {
rc = PTR_ERR(vreg);
pr_err("%s: vreg %s get failed (%d)\n",
__func__, name, rc);
return rc;
}
rc = vreg_set_level(vreg, level);
if (rc) {
pr_err("%s: vreg %s set level failed (%d)\n",
__func__, name, rc);
return rc;
}
if (on)
rc = vreg_enable(vreg);
else
rc = vreg_disable(vreg);
if (rc)
pr_err("%s: vreg %s enable failed (%d)\n",
__func__, name, rc);
return rc;
}
#endif
#if defined(<API key>) || defined(CONFIG_BOSCH_BMA150)
/* there is an i2c address conflict between adv7520 and bma150 sensor after
* power up on fluid. As a solution, the default address of adv7520's packet
* memory is changed as soon as possible
*/
#ifdef <API key>
static int __init <API key>(void)
{
unsigned char wBuff[16];
unsigned char rBuff[16];
struct i2c_msg msgs[3];
int res;
int rc = -EINVAL;
struct vreg *vreg_ldo8;
struct i2c_adapter *adapter;
if (<API key>()) {
adapter = i2c_get_adapter(0);
if (!adapter) {
pr_err("%s: invalid i2c adapter\n", __func__);
return PTR_ERR(adapter);
}
/* turn on LDO8 */
vreg_ldo8 = vreg_get(NULL, "gp7");
if (!vreg_ldo8) {
pr_err("%s: VREG L8 get failed\n", __func__);
goto adapter_put;
}
rc = vreg_set_level(vreg_ldo8, 1800);
if (rc) {
pr_err("%s: VREG L8 set failed\n", __func__);
goto ldo8_put;
}
rc = vreg_enable(vreg_ldo8);
if (rc) {
pr_err("%s: VREG L8 enable failed\n", __func__);
goto ldo8_put;
}
/* change packet memory address to 0x74 */
wBuff[0] = 0x45;
wBuff[1] = 0x74;
msgs[0].addr = ADV7520_I2C_ADDR;
msgs[0].flags = 0;
msgs[0].buf = (unsigned char *) wBuff;
msgs[0].len = 2;
res = i2c_transfer(adapter, msgs, 1);
if (res != 1) {
pr_err("%s: error writing adv7520\n", __func__);
goto ldo8_disable;
}
/* powerdown adv7520 using bit 6 */
/* i2c read first */
wBuff[0] = 0x41;
msgs[0].addr = ADV7520_I2C_ADDR;
msgs[0].flags = 0;
msgs[0].buf = (unsigned char *) wBuff;
msgs[0].len = 1;
msgs[1].addr = ADV7520_I2C_ADDR;
msgs[1].flags = I2C_M_RD;
msgs[1].buf = rBuff;
msgs[1].len = 1;
res = i2c_transfer(adapter, msgs, 2);
if (res != 2) {
pr_err("%s: error reading adv7520\n", __func__);
goto ldo8_disable;
}
/* i2c write back */
wBuff[0] = 0x41;
wBuff[1] = rBuff[0] | 0x40;
msgs[0].addr = ADV7520_I2C_ADDR;
msgs[0].flags = 0;
msgs[0].buf = (unsigned char *) wBuff;
msgs[0].len = 2;
res = i2c_transfer(adapter, msgs, 1);
if (res != 1) {
pr_err("%s: error writing adv7520\n", __func__);
goto ldo8_disable;
}
/* for successful fixup, we release the i2c adapter */
/* but leave ldo8 on so that the adv7520 is not repowered */
i2c_put_adapter(adapter);
pr_info("%s: fluid i2c address conflict resolved\n", __func__);
}
return 0;
ldo8_disable:
vreg_disable(vreg_ldo8);
ldo8_put:
vreg_put(vreg_ldo8);
adapter_put:
i2c_put_adapter(adapter);
return rc;
}
<API key>(<API key>);
#endif
#ifdef <API key>
static int hdmi_comm_power(int on, int show)
{
int rc = gpio_set("gp7", "LDO8", 1800, on);
if (rc) {
pr_warning("hdmi_comm_power: LDO8 gpio failed: rc=%d\n", rc);
return rc;
}
rc = gpio_set("gp4", "LDO10", 2600, on);
if (rc)
pr_warning("hdmi_comm_power: LDO10 gpio failed: rc=%d\n", rc);
if (show)
pr_info("%s: i2c comm: %d <LDO8+LDO10>\n", __func__, on);
return rc;
}
static int hdmi_init_irq(void)
{
int rc = msm_gpios_enable(dtv_panel_irq_gpios,
ARRAY_SIZE(dtv_panel_irq_gpios));
if (rc < 0) {
pr_err("%s: gpio enable failed: %d\n", __func__, rc);
return rc;
}
pr_info("%s\n", __func__);
return 0;
}
static int hdmi_enable_5v(int on)
{
int <API key> ;
if (<API key>() || <API key>() ||
<API key>())
<API key> = <API key> ;
else
<API key> = <API key> ;
pr_info("%s: %d\n", __func__, on);
if (on) {
int rc;
rc = gpio_request(<API key>(<API key>),
"hdmi_5V_en");
if (rc) {
pr_err("%s <API key> gpio_request failed\n",
__func__);
return rc;
}
<API key>(
<API key>(<API key>), 1);
} else {
<API key>(
<API key>(<API key>), 0);
gpio_free(<API key>(<API key>));
}
return 0;
}
static int hdmi_core_power(int on, int show)
{
if (show)
pr_info("%s: %d <LDO8>\n", __func__, on);
return gpio_set("gp7", "LDO8", 1800, on);
}
static int hdmi_cec_power(int on)
{
pr_info("%s: %d <LDO17>\n", __func__, on);
return gpio_set("gp11", "LDO17", 2600, on);
}
static bool <API key>(void)
{
if (<API key>())
return false;
else
return true;
}
static int dtv_panel_power(int on)
{
int flag_on = !!on;
static int dtv_power_save_on;
int rc;
if (dtv_power_save_on == flag_on)
return 0;
dtv_power_save_on = flag_on;
pr_info("%s: %d\n", __func__, on);
#ifdef HDMI_RESET
if (on) {
/* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
rc = gpio_tlmm_config(dtv_reset_gpio, GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, dtv_reset_gpio, rc);
return rc;
}
/* bring reset line low to hold reset*/
gpio_set_value(37, 0);
}
#endif
if (on) {
rc = msm_gpios_enable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
return rc;
}
} else {
rc = msm_gpios_disable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio disable failed: %d\n",
__func__, rc);
return rc;
}
}
mdelay(5); /* ensure power is stable */
#ifdef HDMI_RESET
if (on) {
gpio_set_value(37, 1); /* bring reset line high */
mdelay(10); /* 10 msec before IO can be accessed */
}
#endif
return rc;
}
#endif
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
static int dtv_panel_power(int on)
{
int flag_on = !!on;
static int dtv_power_save_on;
int rc;
struct vreg *vreg_ldo11;
if (dtv_power_save_on == flag_on)
return 0;
dtv_power_save_on = flag_on;
pr_info("%s: %d >>\n", __func__, on);
if(!on){
rc = msm_gpios_disable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio disable failed: %d\n",
__func__, rc);
return rc;
}
printk("dtv_panel_power always turn on\n");
return 0;
}else if(hdmi_init_done){
rc = msm_gpios_enable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
return rc;
}
return 0;
}
if (on) {
rc = msm_gpios_enable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
return rc;
}
rc = msm_gpios_enable(hdmi_panel_gpios,
ARRAY_SIZE(hdmi_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
return rc;
}
} else {
rc = msm_gpios_disable(dtv_panel_gpios,
ARRAY_SIZE(dtv_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio disable failed: %d\n",
__func__, rc);
return rc;
}
}
/* VDDIO 1.8V -- LDO11*/
vreg_ldo11 = vreg_get(NULL, "gp2");
if (IS_ERR(vreg_ldo11)) {
rc = PTR_ERR(vreg_ldo11);
printk("%s: gp2 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo11, 1800);
if (rc) {
printk("%s: vreg LDO11 set level failed (%d)\n",
__func__, rc);
return rc;
}
if (on)
rc = vreg_enable(vreg_ldo11);
else
rc = vreg_disable(vreg_ldo11);
if (rc) {
printk("%s: LDO11 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
mdelay(5);
<API key>(<API key>(<API key>),
on);
gpio_tlmm_config(GPIO_HDMI_5V_EN, GPIO_CFG_ENABLE);
if (on)
gpio_set_value(GPIO_PIN(GPIO_HDMI_5V_EN), 1);
else {
printk("dtv_panel_power 5V always turn on\n");
gpio_set_value(GPIO_PIN(GPIO_HDMI_5V_EN), 0);
}
mdelay(5); /* ensure power is stable */
pr_info("%s: %d <<\n", __func__, on);
hdmi_init_done = true;
return rc;
}
#endif
#if defined(<API key>) || defined(<API key>)
static struct lcdc_platform_data dtv_pdata = {
.lcdc_power_save = dtv_panel_power,
};
#endif
#ifdef <API key>
static struct platform_device <API key> = {
.name = "adv7525",
.id = 0,
};
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
static struct <API key> msm_uart_dm1_pdata = {
.inject_rx_on_wakeup = 1,
.rx_to_inject = 0xFD,
};
static struct resource msm_fb_resources[] = {
{
.flags = IORESOURCE_DMA,
}
};
static int msm_fb_detect_panel(const char *name)
{
if (<API key>()) {
if (!strcmp(name, "lcdc_sharp_wvga_pt"))
return 0;
} else {
if (!strncmp(name, "<API key>", 20))
return -EPERM;
else if (!strncmp(name, "<API key>", 20))
return 0;
else if (!strcmp(name, "mddi_orise"))
return -EPERM;
else if (!strcmp(name, "mddi_quickvx"))
return -EPERM;
}
return -ENODEV;
}
static struct <API key> msm_fb_pdata = {
.detect_client = msm_fb_detect_panel,
.mddi_prescan = 1,
};
static struct platform_device msm_fb_device = {
.name = "msm_fb",
.id = 0,
.num_resources = ARRAY_SIZE(msm_fb_resources),
.resource = msm_fb_resources,
.dev = {
.platform_data = &msm_fb_pdata,
}
};
static struct platform_device <API key> = {
.name = "msm_migrate_pages",
.id = -1,
};
static struct <API key> <API key> = {
.name = <API key>,
/* if no allocator_type, defaults to <API key>,
* the only valid choice at this time. The board structure is
* set to all zeros by the C runtime initialization and that is now
* the enum value of <API key>, now forced to 0 in
* include/linux/android_pmem.h.
*/
.cached = 0,
};
static struct <API key> <API key> = {
.name = "pmem_adsp",
.allocator_type = <API key>,
.cached = 0,
};
static struct <API key> <API key> = {
.name = "pmem_audio",
.allocator_type = <API key>,
.cached = 0,
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 1,
.dev = { .platform_data = &<API key> },
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 2,
.dev = { .platform_data = &<API key> },
};
static struct platform_device <API key> = {
.name = "android_pmem",
.id = 4,
.dev = { .platform_data = &<API key> },
};
static struct resource kgsl_3d0_resources[] = {
{
.name = KGSL_3D0_REG_MEMORY,
.start = 0xA3500000, /* 3D GRP address */
.end = 0xA351ffff,
.flags = IORESOURCE_MEM,
},
{
.name = KGSL_3D0_IRQ,
.start = INT_GRP_3D,
.end = INT_GRP_3D,
.flags = IORESOURCE_IRQ,
},
};
static struct <API key> kgsl_3d0_pdata = {
.pwrlevel = {
{
.gpu_freq = 245760000,
.bus_freq = 192000000,
},
{
.gpu_freq = 192000000,
.bus_freq = 153000000,
},
{
.gpu_freq = 192000000,
.bus_freq = 0,
},
},
.init_level = 0,
.num_levels = 3,
.set_grp_async = set_grp3d_async,
.idle_timeout = HZ/20,
.nap_allowed = true,
.clk = {
.clk = "grp_clk",
.pclk = "grp_pclk",
},
.imem_clk_name = {
.clk = "imem_clk",
.pclk = NULL,
},
};
static struct platform_device msm_kgsl_3d0 = {
.name = "kgsl-3d0",
.id = 0,
.num_resources = ARRAY_SIZE(kgsl_3d0_resources),
.resource = kgsl_3d0_resources,
.dev = {
.platform_data = &kgsl_3d0_pdata,
},
};
#ifdef CONFIG_MSM_KGSL_2D
static struct resource kgsl_2d0_resources[] = {
{
.name = KGSL_2D0_REG_MEMORY,
.start = 0xA3900000, /* Z180 base address */
.end = 0xA3900FFF,
.flags = IORESOURCE_MEM,
},
{
.name = KGSL_2D0_IRQ,
.start = INT_GRP_2D,
.end = INT_GRP_2D,
.flags = IORESOURCE_IRQ,
},
};
static struct <API key> kgsl_2d0_pdata = {
.pwrlevel = {
{
.gpu_freq = 0,
.bus_freq = 192000000,
},
},
.init_level = 0,
.num_levels = 1,
/* HW workaround, run Z180 SYNC @ 192 MHZ */
.set_grp_async = NULL,
.idle_timeout = HZ/10,
.nap_allowed = true,
.clk = {
.clk = "grp_2d_clk",
.pclk = "grp_2d_pclk",
},
};
static struct platform_device msm_kgsl_2d0 = {
.name = "kgsl-2d0",
.id = 0,
.num_resources = ARRAY_SIZE(kgsl_2d0_resources),
.resource = kgsl_2d0_resources,
.dev = {
.platform_data = &kgsl_2d0_pdata,
},
};
#endif
//<API key>/SF4Y6 keypad backlight+
#if defined(<API key>) || defined(<API key>) || defined(<API key>)
static struct platform_device <API key> = {
.name = "pmic-leds",
.id = -1,
};
#endif
//<API key>/SF4Y6 keypad backlight-
#if defined(<API key>) || \
defined(<API key>) || \
defined(<API key>) || \
defined(<API key>)
#define QCE_SIZE 0x10000
#define QCE_0_BASE 0xA8400000
#define QCE_HW_KEY_SUPPORT 1
#define <API key> 0
#define QCE_CE_SHARED 0
static struct resource qce_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,
},
[4] = {
.name = "crypto_crci_hash",
.start = DMOV_CE_HASH_CRCI,
.end = DMOV_CE_HASH_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,
};
static struct platform_device qcrypto_device = {
.name = "qcrypto",
.id = 0,
.num_resources = ARRAY_SIZE(qce_resources),
.resource = qce_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,
};
static struct platform_device qcedev_device = {
.name = "qce",
.id = 0,
.num_resources = ARRAY_SIZE(qce_resources),
.resource = qce_resources,
.dev = {
.coherent_dma_mask = DMA_BIT_MASK(32),
.platform_data = &<API key>,
},
};
#endif
//<API key>+
#if 0
static int <API key>(int level)
{
int ret = -EPERM;
// <API key>+
#ifndef <API key>
ret = <API key>(LED_LCD, level);
#endif
// <API key>-
if (ret)
printk(KERN_WARNING "%s: can't set lcd backlight!\n",
__func__);
return ret;
}
static struct <API key> mddi_toshiba_pdata = {
.pmic_backlight = <API key>,
};
static struct platform_device mddi_toshiba_device = {
.name = "mddi_toshiba",
.id = 0,
.dev = {
.platform_data = &mddi_toshiba_pdata,
}
};
#endif
//<API key>-
#ifdef <API key>
static unsigned lcdc_reset_gpio =
GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA);
static int <API key>(int on)
{
int rc = 0, flag_on = !!on;
static int <API key> = 0;
struct vreg *vreg_ldo11, *vreg_ldo15 = NULL;
printk(KERN_INFO "[DISPLAY] %s(%d): current power status = %d.\n", __func__, on, <API key>);
if (<API key> == flag_on)
return 0;
<API key> = flag_on;
if (on) {
/* reset LCM -- toggle reset pin -- gpio_35 */
rc = gpio_tlmm_config(lcdc_reset_gpio, GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, lcdc_reset_gpio, rc);
return rc;
}
gpio_set_value(35, 0); /* bring reset line low to hold reset*/
mdelay(1); /* wait 1 ms */
}
else
{
/* Hard Reset, Reset Pin from high to low */
gpio_set_value(35, 0);
}
/* LCM power -- has 2 power source */
/* VDDIO 1.8V -- LDO11*/
vreg_ldo11 = vreg_get(NULL, "gp2");
if (IS_ERR(vreg_ldo11)) {
pr_err("%s: gp2 vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_ldo11));
return rc;
}
/* VDC 3.05V -- LDO15 */
vreg_ldo15 = vreg_get(NULL, "gp6");
if (IS_ERR(vreg_ldo15)) {
rc = PTR_ERR(vreg_ldo15);
pr_err("%s: gp6 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo11, 1800);
if (rc) {
pr_err("%s: vreg LDO11 set level failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo15, 3050);
if (rc) {
pr_err("%s: vreg LDO15 set level failed (%d)\n",
__func__, rc);
return rc;
}
if (on) {
rc = vreg_enable(vreg_ldo11);
/* PMIC GPIO VREG_LCM_V1P8_EN pull high */
<API key>(<API key>(<API key>), 1);
}
else
{
/* Use <API key> to control LCM_V1P8 when display off */
//rc = vreg_disable(vreg_ldo11);
/* PMIC GPIO VREG_LCM_V1P8_EN pull low */
<API key>(<API key>(<API key>), 0);
}
if (rc) {
pr_err("%s: LDO11 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
if (on) {
rc = vreg_enable(vreg_ldo15);
}
else
{
rc = vreg_disable(vreg_ldo15);
}
if (rc) {
pr_err("%s: LDO15 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
if (on) {
mdelay(1); /* wait 1 ms */
/* Div2-SW2-BSP,JOE HSU,Add LCM reset line hi -> lo -> hi */
gpio_set_value(35, 1); /* bring reset line high */
mdelay(5); /* 10 msec before IO can be accessed */
gpio_set_value(35, 0);
mdelay(5);
gpio_set_value(35, 1);
mdelay(5);
}
if (on) {
rc = <API key>(1);
if (rc) {
pr_err("%s <API key> rc=%d\n",
__func__, rc);
return rc;
}
} else {
rc = <API key>(0);
if (rc) {
pr_err("%s <API key> rc=%d\n",
__func__, rc);
return rc;
}
}
return rc;
}
#endif // <API key>
#if 0
static unsigned wega_reset_gpio =
GPIO_CFG(180, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(20, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "vee_reset" },
};
#endif
static unsigned char quickvx_mddi_client = 1;
#if 0
static unsigned quickvx_vlp_gpio =
GPIO_CFG(97, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA);
static struct pm8058_gpio <API key> = {
.direction = PM_GPIO_DIR_OUT,
.output_buffer = <API key>,
.output_value = 1,
.pull = PM_GPIO_PULL_NO,
.vin_sel = PM_GPIO_VIN_S3,
.out_strength = <API key>,
.function = PM_GPIO_FUNC_2,
};
#endif
#if 0
static int <API key>(int on)
{
int rc = 0, flag_on = !!on;
static int <API key>;
struct vreg *vreg_ldo12, *vreg_ldo15 = NULL;
struct vreg *vreg_ldo20, *vreg_ldo16, *vreg_ldo8 = NULL;
if (<API key> == flag_on)
return 0;
<API key> = flag_on;
if (on) {
/* reset Toshiba WeGA chip -- toggle reset pin -- gpio_180 */
rc = gpio_tlmm_config(wega_reset_gpio, GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, wega_reset_gpio, rc);
return rc;
}
/* bring reset line low to hold reset*/
gpio_set_value(180, 0);
if (quickvx_mddi_client) {
/* QuickVX chip -- VLP pin -- gpio 97 */
rc = gpio_tlmm_config(quickvx_vlp_gpio,
GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, quickvx_vlp_gpio, rc);
return rc;
}
/* bring QuickVX VLP line low */
gpio_set_value(97, 0);
rc = pm8058_gpio_config(<API key>,
&<API key>);
if (rc) {
pr_err("%s: pm8058_gpio_config(%#x)=%d\n",
__func__, <API key> + 1,
rc);
return rc;
}
<API key>(<API key>(
<API key>), 0);
}
}
/* Toshiba WeGA power -- has 3 power source */
/* 1.5V -- LDO20*/
vreg_ldo20 = vreg_get(NULL, "gp13");
if (IS_ERR(vreg_ldo20)) {
rc = PTR_ERR(vreg_ldo20);
pr_err("%s: gp13 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
/* 1.8V -- LDO12 */
vreg_ldo12 = vreg_get(NULL, "gp9");
if (IS_ERR(vreg_ldo12)) {
rc = PTR_ERR(vreg_ldo12);
pr_err("%s: gp9 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
/* 2.6V -- LDO16 */
vreg_ldo16 = vreg_get(NULL, "gp10");
if (IS_ERR(vreg_ldo16)) {
rc = PTR_ERR(vreg_ldo16);
pr_err("%s: gp10 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
if (<API key>()) {
/* 1.8V -- LDO8 */
vreg_ldo8 = vreg_get(NULL, "gp7");
if (IS_ERR(vreg_ldo8)) {
rc = PTR_ERR(vreg_ldo8);
pr_err("%s: gp7 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
} else {
/* lcd panel power */
/* 3.1V -- LDO15 */
vreg_ldo15 = vreg_get(NULL, "gp6");
if (IS_ERR(vreg_ldo15)) {
rc = PTR_ERR(vreg_ldo15);
pr_err("%s: gp6 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
}
/* For QuickLogic chip, LDO20 requires 1.8V */
/* Toshiba chip requires 1.5V, but can tolerate 1.8V since max is 3V */
if (quickvx_mddi_client)
rc = vreg_set_level(vreg_ldo20, 1800);
else
rc = vreg_set_level(vreg_ldo20, 1500);
if (rc) {
pr_err("%s: vreg LDO20 set level failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo12, 1800);
if (rc) {
pr_err("%s: vreg LDO12 set level failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo16, 2600);
if (rc) {
pr_err("%s: vreg LDO16 set level failed (%d)\n",
__func__, rc);
return rc;
}
if (<API key>()) {
rc = vreg_set_level(vreg_ldo8, 1800);
if (rc) {
pr_err("%s: vreg LDO8 set level failed (%d)\n",
__func__, rc);
return rc;
}
} else {
rc = vreg_set_level(vreg_ldo15, 3100);
if (rc) {
pr_err("%s: vreg LDO15 set level failed (%d)\n",
__func__, rc);
return rc;
}
}
if (on) {
rc = vreg_enable(vreg_ldo20);
if (rc) {
pr_err("%s: LDO20 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_enable(vreg_ldo12);
if (rc) {
pr_err("%s: LDO12 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_enable(vreg_ldo16);
if (rc) {
pr_err("%s: LDO16 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
if (<API key>()) {
rc = vreg_enable(vreg_ldo8);
if (rc) {
pr_err("%s: LDO8 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
} else {
rc = vreg_enable(vreg_ldo15);
if (rc) {
pr_err("%s: LDO15 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
}
mdelay(5); /* ensure power is stable */
if (<API key>()) {
rc = <API key>(<API key>,
ARRAY_SIZE(<API key>));
if (rc)
pr_err("%s gpio_request_enable failed rc=%d\n",
__func__, rc);
else {
/* assert vee reset_n */
gpio_set_value(20, 1);
gpio_set_value(20, 0);
mdelay(1);
gpio_set_value(20, 1);
}
}
gpio_set_value(180, 1); /* bring reset line high */
mdelay(10); /* 10 msec before IO can be accessed */
if (quickvx_mddi_client) {
gpio_set_value(97, 1);
msleep(2);
<API key>(<API key>(
<API key>), 1);
msleep(2);
}
rc = <API key>(1);
if (rc) {
pr_err("%s <API key> rc=%d\n",
__func__, rc);
return rc;
}
} else {
rc = vreg_disable(vreg_ldo20);
if (rc) {
pr_err("%s: LDO20 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_disable(vreg_ldo16);
if (rc) {
pr_err("%s: LDO16 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
gpio_set_value(180, 0); /* bring reset line low */
if (quickvx_mddi_client) {
gpio_set_value(97, 0);
<API key>(<API key>(
<API key>), 0);
}
if (<API key>()) {
rc = vreg_disable(vreg_ldo8);
if (rc) {
pr_err("%s: LDO8 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
} else {
rc = vreg_disable(vreg_ldo15);
if (rc) {
pr_err("%s: LDO15 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
}
mdelay(5); /* ensure power is stable */
rc = vreg_disable(vreg_ldo12);
if (rc) {
pr_err("%s: LDO12 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
if (<API key>()) {
<API key>(<API key>,
ARRAY_SIZE(<API key>));
}
rc = <API key>(0);
if (rc) {
pr_err("%s <API key> rc=%d\n",
__func__, rc);
return rc;
}
}
return rc;
}
#endif
static int msm_fb_mddi_sel_clk(u32 *clk_rate)
{
*clk_rate *= 2;
return 0;
}
static int <API key>(u32 client_id)
{
struct vreg *vreg_ldo20;
int rc;
printk(KERN_NOTICE "\n client_id = 0x%x", client_id);
/* Check if it is Quicklogic client */
if (client_id == 0xc5835800)
printk(KERN_NOTICE "\n Quicklogic MDDI client");
else {
printk(KERN_NOTICE "\n Non-Quicklogic MDDI client");
quickvx_mddi_client = 0;
gpio_set_value(97, 0);
<API key>(<API key>(
<API key>), 0);
vreg_ldo20 = vreg_get(NULL, "gp13");
if (IS_ERR(vreg_ldo20)) {
rc = PTR_ERR(vreg_ldo20);
pr_err("%s: gp13 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_set_level(vreg_ldo20, 1500);
if (rc) {
pr_err("%s: vreg LDO20 set level failed (%d)\n",
__func__, rc);
return rc;
}
}
return 0;
}
static struct mddi_platform_data mddi_pdata = {
#ifndef <API key>
.mddi_power_save = <API key>,
#endif
.mddi_sel_clk = msm_fb_mddi_sel_clk,
.mddi_client_power = <API key>,
};
int <API key>[] = {
122880000,
122880000,
192000000,
192000000,
};
static struct <API key> mdp_pdata = {
.hw_revision_addr = 0xac001270,
// <API key>+
#ifndef <API key>
.gpio = 30,
#endif
// <API key>-
.mdp_core_clk_rate = 122880000,
.mdp_core_clk_table = <API key>,
.num_mdp_clk = ARRAY_SIZE(<API key>),
};
/* FIHTDC, Div2-SW2-BSP, Ming, LCM { */
#ifdef <API key>
static int <API key>[] = {
45, /* spi_clk */
46, /* spi_cs */
47, /* spi_mosi */
48, /* spi_miso */
};
static struct msm_gpio lcd_panel_gpios[] = {
{ GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn0" },
{ GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn1" },
{ GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu0" },
{ GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu1" },
{ GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu2" },
{ GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red0" },
{ GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red1" },
{ GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red2" },
{ GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "spi_clk" },
{ GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA), "spi_cs0" },
{ GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "spi_mosi" },
{ GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "spi_miso" },
{ GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_4MA), "lcdc_pclk" }, // FIHTDC-Div2-SW2-BSP, Ming, 4mA
{ GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
{ GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_vsync" },
{ GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_hsync" },
{ GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn2" },
{ GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn3" },
{ GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn4" },
{ GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_grn5" },
{ GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
{ GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
{ GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu3" },
{ GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu4" },
{ GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_blu5" },
{ GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
{ GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
{ GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red3" },
{ GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red4" },
{ GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "lcdc_red5" },
{ GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
{ GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
};
#endif // <API key>
#if 0
static struct msm_gpio lcd_panel_gpios[] = {
/* Workaround, since HDMI_INT is using the same GPIO line (18), and is used as
* input. if there is a hardware revision; we should reassign this GPIO to a
* new open line; and removing it will just ensure that this will be missed in
* the future.
{ GPIO_CFG(18, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn0" },
*/
{ GPIO_CFG(19, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn1" },
{ GPIO_CFG(20, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu0" },
{ GPIO_CFG(21, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu1" },
{ GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
{ GPIO_CFG(23, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red0" },
{ GPIO_CFG(24, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red1" },
{ GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
#ifndef CONFIG_SPI_QSD
{ GPIO_CFG(45, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_clk" },
{ GPIO_CFG(46, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_cs0" },
{ GPIO_CFG(47, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_mosi" },
{ GPIO_CFG(48, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "spi_miso" },
#endif
{ GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
{ GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
{ GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
{ GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
{ GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
{ GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
{ GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
{ GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
{ GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
{ GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
{ GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
{ GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
{ GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
{ GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
{ GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
{ GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
{ GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
{ GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
{ GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
{ GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
};
#endif
//<API key>+
#if 0
static struct msm_gpio <API key>[] = {
{ GPIO_CFG(22, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu2" },
{ GPIO_CFG(25, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red2" },
{ GPIO_CFG(90, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_pclk" },
{ GPIO_CFG(91, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_en" },
{ GPIO_CFG(92, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_vsync" },
{ GPIO_CFG(93, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_hsync" },
{ GPIO_CFG(94, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn2" },
{ GPIO_CFG(95, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn3" },
{ GPIO_CFG(96, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn4" },
{ GPIO_CFG(97, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn5" },
{ GPIO_CFG(98, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn6" },
{ GPIO_CFG(99, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_grn7" },
{ GPIO_CFG(100, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu3" },
{ GPIO_CFG(101, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu4" },
{ GPIO_CFG(102, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu5" },
{ GPIO_CFG(103, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu6" },
{ GPIO_CFG(104, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_blu7" },
{ GPIO_CFG(105, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red3" },
{ GPIO_CFG(106, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red4" },
{ GPIO_CFG(107, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red5" },
{ GPIO_CFG(108, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red6" },
{ GPIO_CFG(109, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "lcdc_red7" },
};
#endif
//<API key>-
//<API key>+
#ifdef <API key>
static int <API key>(int on)
{
int rc, i;
struct msm_gpio *gp;
rc = <API key>(on);
if (rc < 0) {
printk(KERN_ERR "%s <API key> failed: %d\n",
__func__, rc);
return rc;
}
if (on) {
rc = msm_gpios_enable(lcd_panel_gpios,
ARRAY_SIZE(lcd_panel_gpios));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
}
} else { /* off */
gp = lcd_panel_gpios;
for (i = 0; i < ARRAY_SIZE(lcd_panel_gpios); i++) {
/* ouput low */
gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
gp++;
}
}
return rc;
}
#endif
//<API key>-
//<API key>+
#if 0
static int <API key>(int on)
{
int rc, i;
struct msm_gpio *gp;
rc = <API key>(on);
if (rc < 0) {
printk(KERN_ERR "%s <API key> failed: %d\n",
__func__, rc);
return rc;
}
if (on) {
rc = msm_gpios_enable(<API key>,
ARRAY_SIZE(<API key>));
if (rc < 0) {
printk(KERN_ERR "%s: gpio enable failed: %d\n",
__func__, rc);
}
} else { /* off */
gp = <API key>;
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
/* ouput low */
gpio_set_value(GPIO_PIN(gp->gpio_cfg), 0);
gp++;
}
}
return rc;
}
#endif
//<API key>-
//<API key>+
#ifdef <API key>
static int lcdc_panel_power(int on)
{
int flag_on = !!on;
static int lcdc_power_save_on;
if (lcdc_power_save_on == flag_on)
return 0;
lcdc_power_save_on = flag_on;
quickvx_mddi_client = 0;
//<API key>+
#if 0
if (<API key>())
return <API key>(on);
else
return <API key>(on);
#else
return <API key>(on);
#endif
//<API key>-
}
#endif // <API key>
//<API key>-
static struct lcdc_platform_data lcdc_pdata = {
#ifdef <API key>
.lcdc_power_save = lcdc_panel_power,
#endif
};
static int atv_dac_power(int on)
{
int rc = 0;
struct vreg *vreg_s4, *vreg_ldo9;
vreg_s4 = vreg_get(NULL, "s4");
if (IS_ERR(vreg_s4)) {
rc = PTR_ERR(vreg_s4);
pr_err("%s: s4 vreg get failed (%d)\n",
__func__, rc);
return -1;
}
vreg_ldo9 = vreg_get(NULL, "gp1");
if (IS_ERR(vreg_ldo9)) {
rc = PTR_ERR(vreg_ldo9);
pr_err("%s: ldo9 vreg get failed (%d)\n",
__func__, rc);
return rc;
}
if (on) {
rc = vreg_enable(vreg_s4);
if (rc) {
pr_err("%s: s4 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_enable(vreg_ldo9);
if (rc) {
pr_err("%s: ldo9 vreg enable failed (%d)\n",
__func__, rc);
return rc;
}
} else {
rc = vreg_disable(vreg_ldo9);
if (rc) {
pr_err("%s: ldo9 vreg disable failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_disable(vreg_s4);
if (rc) {
pr_err("%s: s4 vreg disable failed (%d)\n",
__func__, rc);
return rc;
}
}
return rc;
}
static struct tvenc_platform_data atv_pdata = {
.poll = 1,
.pm_vid_en = atv_dac_power,
};
static void __init msm_fb_add_devices(void)
{
<API key>("mdp", &mdp_pdata);
<API key>("pmdh", &mddi_pdata);
<API key>("lcdc", &lcdc_pdata);
#if defined(<API key>) || defined(<API key>)
<API key>("dtv", &dtv_pdata);
#endif
<API key>("tvenc", &atv_pdata);
#ifdef CONFIG_FB_MSM_TVOUT
<API key>("tvout_device", NULL);
#endif
}
//<API key>+
#ifdef <API key>
static struct <API key> <API key> = {
.gpio_num = <API key>,
};
static struct platform_device <API key> = {
.name = "lcdc_toshiba_wvga",
.id = 0,
.dev = {
.platform_data = &<API key>,
}
};
#endif // <API key>
//<API key>-
// <API key> BCM4329 For SF8 +[
#if defined(<API key>) && \
(defined(<API key>) || defined(<API key>))
#define BT_MASK 0x01
#define WLAN_MASK 0x02
#define FM_MASK 0x04
#define GPIO_WLAN_BT_REG_ON 168
static unsigned int <API key> = 0;
#endif
// <API key> BCM4329 For SF8 +]
// <API key> BCM4329 Bluetooth driver For SF8 +[
#ifdef <API key>
#define GPIO_BTUART_RFR 134
#define GPIO_BTUART_CTS 135
#define GPIO_BTUART_RX 136
#define GPIO_BTUART_TX 137
#define GPIO_PCM_DIN 138
#define GPIO_PCM_DOUT 139
#define GPIO_PCM_SYNC 140
#define GPIO_PCM_BCLK 141
#define GPIO_BT_RST_N 144
#define GPIO_BT_IRQ 147
#define GPIO_BT_WAKEUP 170
static struct platform_device <API key> = {
.name = "bcm4329_bt_power",
.id = -1
};
static struct msm_gpio bt_config_power_on[] = {
{ GPIO_CFG(GPIO_BTUART_RFR, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "UART1DM_RFR" },
{ GPIO_CFG(GPIO_BTUART_CTS, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "UART1DM_CTS" },
{ GPIO_CFG(GPIO_BTUART_RX, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "UART1DM_RX" },
{ GPIO_CFG(GPIO_BTUART_TX, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "UART1DM_TX" },
{ GPIO_CFG(GPIO_BT_IRQ, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "BT_HOST_WAKE" },
{ GPIO_CFG(GPIO_BT_WAKEUP, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), "BT_WAKE" }
};
static struct msm_gpio bt_config_power_off[] = {
{ GPIO_CFG(GPIO_BTUART_RFR, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART1DM_RFR" },
{ GPIO_CFG(GPIO_BTUART_CTS, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART1DM_CTS" },
{ GPIO_CFG(GPIO_BTUART_RX, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART1DM_RX" },
{ GPIO_CFG(GPIO_BTUART_TX, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART1DM_TX" },
{ GPIO_CFG(GPIO_BT_IRQ, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "BT_HOST_WAKE" },
{ GPIO_CFG(GPIO_BT_WAKEUP, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "BT_WAKE" }
};
static int bluetooth_fm_power(int on)
{
int rc;
printk("KERN_DEBUG %s: POWER %s\r\n", __FUNCTION__, on?"ON":"OFF");
if (on)
{
rc = msm_gpios_enable(bt_config_power_on, ARRAY_SIZE(bt_config_power_on));
if (rc < 0)
{
printk(KERN_DEBUG "%s: Power ON bluetooth failed.\r\n", __FUNCTION__);
return rc;
}
if (<API key> == 0)
{
printk(KERN_DEBUG "%s: PULL UP GPIO_WLAN_BT_REG_ON\r\n", __FUNCTION__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 1);
mdelay(20);
}
gpio_set_value(GPIO_BT_RST_N, 0);
mdelay(20);
gpio_set_value(GPIO_BT_RST_N, 1);
mdelay(100);
printk(KERN_DEBUG "%s: GPIO_BT_RST (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_BT_RST_N)?"HIGH":"LOW");
printk(KERN_DEBUG "%s: GPIO_WLAN_BT_REG_ON (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_BT_REG_ON)?"HIGH":"LOW");
}
else
{
rc = msm_gpios_enable(bt_config_power_off, ARRAY_SIZE(bt_config_power_off));
if (rc < 0)
{
printk(KERN_DEBUG "%s: Power OFF bluetooth failed.\r\n", __FUNCTION__);
return rc;
}
gpio_set_value(GPIO_BT_RST_N, 0);
if (<API key> == 0)
{
printk(KERN_DEBUG "%s: PULL DOWN GPIO_WLAN_BT_REG_ON\r\n", __FUNCTION__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 0);
}
mdelay(100);
printk(KERN_DEBUG "%s: GPIO_BT_RST (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_BT_RST_N)?"HIGH":"LOW");
printk(KERN_DEBUG "%s: GPIO_WLAN_BT_REG_ON (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_BT_REG_ON)?"HIGH":"LOW");
}
return 0;
}
static int bluetooth_power(int on)
{
int ret = 0;
printk("KERN_DEBUG %s: POWER %s\r\n", __FUNCTION__, on?"ON":"OFF");
if (on)
{
if ((<API key> & ~WLAN_MASK) != 0)
{
printk("KERN_DEBUG %s: FM has been enable the power\r\n", __FUNCTION__);
<API key> |= BT_MASK;
return 0;
}
ret = bluetooth_fm_power(on);
if (ret < 0)
{
printk(KERN_DEBUG "%s: Power ON bluetooth failed.\r\n", __FUNCTION__);
return ret;
}
<API key> |= BT_MASK;
}
else
{
if ((<API key> & ~(WLAN_MASK | BT_MASK)) != 0)
{
printk("KERN_DEBUG %s: FM enabled, can't turn bcm4329 bt/fm power\r\n", __FUNCTION__);
<API key> &= ~BT_MASK;
return 0;
}
<API key> &= ~BT_MASK;
ret = bluetooth_fm_power(on);
if (ret < 0)
{
printk(KERN_DEBUG "%s: Power ON bluetooth failed.\r\n", __FUNCTION__);
return ret;
}
}
return 0;
}
static void __init <API key>(void)
{
gpio_set_value(GPIO_WLAN_BT_REG_ON, 0);
gpio_set_value(GPIO_BT_RST_N, 0);
<API key>.dev.platform_data = &bluetooth_power;
}
#else
//#define bt_power_init(x) do {} while (0)
#endif
// <API key> BCM4329 Bluetooth driver For SF8 +]
#if defined(<API key>)
static struct platform_device <API key> = {
.name = "bcm4329_fm_power",
.id = -1
};
static int fm_power(int on)
{
int ret = 0;
printk("KERN_DEBUG %s: POWER %s\r\n", __FUNCTION__, on?"ON":"OFF");
if (on)
{
if ((<API key> & ~WLAN_MASK) != 0)
{
printk("KERN_DEBUG %s: Bluetooth has been enable the power\r\n", __FUNCTION__);
<API key> |= FM_MASK;
return 0;
}
ret = bluetooth_fm_power(on);
if (ret < 0)
{
printk(KERN_DEBUG "%s: Power ON FM failed.\r\n", __FUNCTION__);
return ret;
}
<API key> |= FM_MASK;
}
else
{
if ((<API key> & ~(WLAN_MASK | FM_MASK)) != 0)
{
printk("KERN_DEBUG %s: Bluetooth enabled, can't turn bcm4329 bt/fm power\r\n", __FUNCTION__);
<API key> &= ~FM_MASK;
return 0;
}
<API key> &= ~FM_MASK;
ret = bluetooth_fm_power(on);
if (ret < 0)
{
printk(KERN_DEBUG "%s: Power ON FM failed.\r\n", __FUNCTION__);
return ret;
}
}
return 0;
}
static void __init <API key>(void)
{
<API key>.dev.platform_data = &fm_power;
}
#endif
#if defined(<API key>)
static struct resource bluesleep_resources[] = {
{
.name = "gpio_host_wake",
.start = GPIO_BT_IRQ,
.end = GPIO_BT_IRQ,
.flags = IORESOURCE_IO,
},
{
.name = "gpio_ext_wake",
.start = GPIO_BT_WAKEUP,
.end = GPIO_BT_WAKEUP,
.flags = IORESOURCE_IO,
},
{
.name = "host_wake",
.start = MSM_GPIO_TO_INT(GPIO_BT_IRQ),
.end = MSM_GPIO_TO_INT(GPIO_BT_IRQ),
.flags = IORESOURCE_IO,
},
};
static struct platform_device <API key> = {
.name = "bluesleep",
.id = -1,
.num_resources = ARRAY_SIZE(bluesleep_resources),
.resource = bluesleep_resources,
};
#endif
// FihtdcCode@20110908 WeiChu add for WiFi porting begin
// <API key> BCM4329 WLAN driver For SF8 +[
#ifdef <API key>
#define GPIO_WLAN_RST_N 146
#define GPIO_WLAN_IRQ 145
#define GPIO_WLAN_WAKEUP 169
static struct platform_device <API key> = {
.name = "bcm4329_wifi_power",
.id = -1
};
int wifi_power(int on) //<API key>
{
printk(KERN_DEBUG "%s: POWER %s\r\n", __FUNCTION__, on?"ON":"OFF");
if (on)
{
if (<API key> == 0)
{
printk(KERN_DEBUG "%s: PULL UP GPIO_WLAN_BT_REG_ON\r\n", __FUNCTION__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 1);
mdelay(20);
}
gpio_set_value(GPIO_WLAN_RST_N, 1);
mdelay(20);
<API key> |= WLAN_MASK;
printk(KERN_DEBUG "%s: GPIO_WLAN_RST (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_RST_N)?"HIGH":"LOW");
printk(KERN_DEBUG "%s: GPIO_WLAN_BT_REG_ON (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_BT_REG_ON)?"HIGH":"LOW");
}
else
{
<API key> &= ~WLAN_MASK;
gpio_set_value(GPIO_WLAN_RST_N, 0);
if (<API key> == 0)
{
printk(KERN_DEBUG "%s: PULL DOWN GPIO_WLAN_BT_REG_ON\r\n", __FUNCTION__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 0);
}
printk(KERN_DEBUG "%s: GPIO_WLAN_RST (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_RST_N)?"HIGH":"LOW");
printk(KERN_DEBUG "%s: GPIO_WLAN_BT_REG_ON (%s)\r\n", __FUNCTION__, gpio_get_value(GPIO_WLAN_BT_REG_ON)?"HIGH":"LOW");
}
return 0;
}
EXPORT_SYMBOL(wifi_power); //<API key>
int bcm4329_wifi_resume(void)
{
printk(KERN_DEBUG "%s: START <API key>=0x%x\r\n", __func__, <API key>);
if (<API key> == 0) {
printk(KERN_DEBUG "%s: PULL UP GPIO_WLAN_BT_REG_ON\r\n", __func__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 1);
mdelay(45);
}
gpio_set_value(GPIO_WLAN_RST_N, 1);
mdelay(20);
<API key> |= WLAN_MASK;
return 0;
}
EXPORT_SYMBOL(bcm4329_wifi_resume);
int <API key>(void)
{
printk(KERN_DEBUG "%s: START <API key>=0x%x\r\n", __func__, <API key>);
<API key> &= ~WLAN_MASK;
gpio_set_value(GPIO_WLAN_RST_N, 0);
if (<API key> == 0) {
printk(KERN_DEBUG "%s: PULL DOWN GPIO_WLAN_BT_REG_ON\r\n", __func__);
gpio_set_value(GPIO_WLAN_BT_REG_ON, 0);
}
return 0;
}
EXPORT_SYMBOL(<API key>);
static void __init <API key>(void)
{
gpio_set_value(GPIO_WLAN_BT_REG_ON, 0);
gpio_set_value(GPIO_WLAN_RST_N, 0);
<API key>.dev.platform_data = &wifi_power;
}
#else
#define wifi_power_init(x) do {} while (0)
#endif
// <API key> BCM4329 WLAN driver For SF8 +]
// FihtdcCode@20110908 WeiChu add for WiFi porting end
#if defined(CONFIG_MARIMBA_CORE) && \
(defined(CONFIG_MSM_BT_POWER) || defined(<API key>))
static struct platform_device msm_bt_power_device = {
.name = "bt_power",
.id = -1
};
enum {
BT_RFR,
BT_CTS,
BT_RX,
BT_TX,
};
static struct msm_gpio bt_config_power_on[] = {
{ GPIO_CFG(134, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"UART1DM_RFR" },
{ GPIO_CFG(135, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"UART1DM_CTS" },
{ GPIO_CFG(136, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"UART1DM_Rx" },
{ GPIO_CFG(137, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"UART1DM_Tx" }
};
static struct msm_gpio bt_config_power_off[] = {
{ GPIO_CFG(134, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
"UART1DM_RFR" },
{ GPIO_CFG(135, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
"UART1DM_CTS" },
{ GPIO_CFG(136, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
"UART1DM_Rx" },
{ GPIO_CFG(137, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
"UART1DM_Tx" }
};
static const char *<API key>[] = {
"s3",
"s2",
"gp16",
"wlan"
};
static struct vreg *vregs_bt_marimba[ARRAY_SIZE(<API key>)];
static const char *<API key>[] = {
"s3",
"usb2",
"s2",
"wlan"
};
static struct vreg *vregs_bt_bahama[ARRAY_SIZE(<API key>)];
static u8 bahama_version;
static int marimba_bt(int on)
{
int rc;
int i;
struct marimba config = { .mod_id = <API key> };
struct <API key> {
u8 reg;
u8 value;
u8 mask;
};
struct <API key> {
const size_t size;
const struct <API key> *set;
};
const struct <API key> *p;
u8 version;
const struct <API key> v10_bt_on[] = {
{ 0xE5, 0x0B, 0x0F },
{ 0x05, 0x02, 0x07 },
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x21, 0x21 },
{ 0xE3, 0x38, 0xFF },
{ 0xE4, 0x06, 0xFF },
};
const struct <API key> v10_bt_off[] = {
{ 0xE5, 0x0B, 0x0F },
{ 0x05, 0x08, 0x0F },
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x00, 0x21 },
{ 0xE3, 0x00, 0xFF },
{ 0xE4, 0x00, 0xFF },
};
const struct <API key> v201_bt_on[] = {
{ 0x05, 0x08, 0x07 },
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x21, 0x21 },
{ 0xE3, 0x38, 0xFF },
{ 0xE4, 0x06, 0xFF },
};
const struct <API key> v201_bt_off[] = {
{ 0x05, 0x08, 0x07 },
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x00, 0x21 },
{ 0xE3, 0x00, 0xFF },
{ 0xE4, 0x00, 0xFF },
};
const struct <API key> v210_bt_on[] = {
{ 0xE9, 0x01, 0x01 },
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x21, 0x21 },
{ 0xE3, 0x38, 0xFF },
{ 0xE4, 0x06, 0xFF },
};
const struct <API key> v210_bt_off[] = {
{ 0x06, 0x88, 0xFF },
{ 0xE7, 0x00, 0x21 },
{ 0xE9, 0x00, 0x01 },
{ 0xE3, 0x00, 0xFF },
{ 0xE4, 0x00, 0xFF },
};
const struct <API key> bt_marimba[2][4] = {
{
{ ARRAY_SIZE(v10_bt_off), v10_bt_off },
{ 0, NULL },
{ ARRAY_SIZE(v201_bt_off), v201_bt_off },
{ ARRAY_SIZE(v210_bt_off), v210_bt_off }
},
{
{ ARRAY_SIZE(v10_bt_on), v10_bt_on },
{ 0, NULL },
{ ARRAY_SIZE(v201_bt_on), v201_bt_on },
{ ARRAY_SIZE(v210_bt_on), v210_bt_on }
}
};
on = on ? 1 : 0;
rc = <API key>(&config, 0x11, &version, 1, 0x1F);
if (rc < 0) {
printk(KERN_ERR
"%s: version read failed: %d\n",
__func__, rc);
return rc;
}
if ((version >= ARRAY_SIZE(bt_marimba[on])) ||
(bt_marimba[on][version].size == 0)) {
printk(KERN_ERR
"%s: unsupported version\n",
__func__);
return -EIO;
}
p = bt_marimba[on][version].set;
printk(KERN_INFO "%s: found version %d\n", __func__, version);
for (i = 0; i < bt_marimba[on][version].size; i++) {
u8 value = (p+i)->value;
rc = <API key>(&config,
(p+i)->reg,
&value,
sizeof((p+i)->value),
(p+i)->mask);
if (rc < 0) {
printk(KERN_ERR
"%s: reg %d write failed: %d\n",
__func__, (p+i)->reg, rc);
return rc;
}
printk(KERN_INFO "%s: reg 0x%02x value 0x%02x mask 0x%02x\n",
__func__, (p+i)->reg,
value, (p+i)->mask);
}
return 0;
}
static int bahama_bt(int on)
{
int rc;
int i;
struct marimba config = { .mod_id = SLAVE_ID_BAHAMA };
struct <API key> {
const size_t size;
const struct <API key> *set;
};
const struct <API key> *p;
const struct <API key> v10_bt_on[] = {
{ 0xE9, 0x00, 0xFF },
{ 0xF4, 0x80, 0xFF },
{ 0xF0, 0x06, 0xFF },
{ 0xE4, 0x00, 0xFF },
{ 0xE5, 0x00, 0x0F },
#ifdef CONFIG_WLAN
{ 0xE6, 0x38, 0x7F },
{ 0xE7, 0x06, 0xFF },
#endif
{ 0x11, 0x13, 0xFF },
{ 0xE9, 0x21, 0xFF },
{ 0x01, 0x0C, 0x1F },
{ 0x01, 0x08, 0x1F },
};
const struct <API key> v20_bt_on_fm_off[] = {
{ 0x11, 0x0C, 0xFF },
{ 0x13, 0x01, 0xFF },
{ 0xF4, 0x80, 0xFF },
{ 0xF0, 0x00, 0xFF },
{ 0xE9, 0x00, 0xFF },
#ifdef CONFIG_WLAN
{ 0x81, 0x00, 0xFF },
{ 0x82, 0x00, 0xFF },
{ 0xE6, 0x38, 0x7F },
{ 0xE7, 0x06, 0xFF },
#endif
{ 0xE9, 0x21, 0xFF }
};
const struct <API key> v20_bt_on_fm_on[] = {
{ 0x11, 0x0C, 0xFF },
{ 0x13, 0x01, 0xFF },
{ 0xF4, 0x86, 0xFF },
{ 0xF0, 0x06, 0xFF },
{ 0xE9, 0x00, 0xFF },
#ifdef CONFIG_WLAN
{ 0x81, 0x00, 0xFF },
{ 0x82, 0x00, 0xFF },
{ 0xE6, 0x38, 0x7F },
{ 0xE7, 0x06, 0xFF },
#endif
{ 0xE9, 0x21, 0xFF }
};
const struct <API key> v10_bt_off[] = {
{ 0xE9, 0x00, 0xFF },
};
const struct <API key> v20_bt_off_fm_off[] = {
{ 0xF4, 0x84, 0xFF },
{ 0xF0, 0x04, 0xFF },
{ 0xE9, 0x00, 0xFF }
};
const struct <API key> v20_bt_off_fm_on[] = {
{ 0xF4, 0x86, 0xFF },
{ 0xF0, 0x06, 0xFF },
{ 0xE9, 0x00, 0xFF }
};
const struct <API key> bt_bahama[2][3] = {
{
{ ARRAY_SIZE(v10_bt_off), v10_bt_off },
{ ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off },
{ ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on }
},
{
{ ARRAY_SIZE(v10_bt_on), v10_bt_on },
{ ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off },
{ ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on }
}
};
u8 offset = 0; /* index into bahama configs */
/* Init mutex to get/set FM/BT status respectively */
mutex_init(&config.xfer_lock);
on = on ? 1 : 0;
bahama_version = read_bahama_ver();
if (bahama_version == VER_UNSUPPORTED) {
dev_err(&msm_bt_power_device.dev,
"%s: unsupported version\n",
__func__);
return -EIO;
}
if (bahama_version == VER_2_0) {
if (<API key>(&config))
offset = 0x01;
}
p = bt_bahama[on][bahama_version + offset].set;
dev_info(&msm_bt_power_device.dev,
"%s: found version %d\n", __func__, bahama_version);
for (i = 0; i < bt_bahama[on][bahama_version + offset].size; i++) {
u8 value = (p+i)->value;
rc = <API key>(&config,
(p+i)->reg,
&value,
sizeof((p+i)->value),
(p+i)->mask);
if (rc < 0) {
dev_err(&msm_bt_power_device.dev,
"%s: reg %d write failed: %d\n",
__func__, (p+i)->reg, rc);
return rc;
}
dev_info(&msm_bt_power_device.dev,
"%s: reg 0x%02x write value 0x%02x mask 0x%02x\n",
__func__, (p+i)->reg,
value, (p+i)->mask);
}
/* Update BT status */
if (on)
<API key>(&config, true);
else
<API key>(&config, false);
/* Destory mutex */
mutex_destroy(&config.xfer_lock);
if (bahama_version == VER_2_0 && on) { /* variant of bahama v2 */
/* Disable s2 as bahama v2 uses internal LDO regulator */
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
if (!strcmp(<API key>[i], "s2")) {
rc = vreg_disable(vregs_bt_bahama[i]);
if (rc < 0) {
printk(KERN_ERR
"%s: vreg %s disable "
"failed (%d)\n",
__func__,
<API key>[i], rc);
return -EIO;
}
rc = <API key>("BTPW",
PMAPP_VREG_S2,
0);
if (rc < 0) {
printk(KERN_ERR "%s: vreg "
"level off failed (%d)\n",
__func__, rc);
return -EIO;
}
printk(KERN_INFO "%s: vreg disable & "
"level off successful (%d)\n",
__func__, rc);
}
}
}
return 0;
}
static int <API key>(int on, int bahama_not_marimba)
{
int i, rc;
const char **vregs_name;
struct vreg **vregs;
int vregs_size;
if (bahama_not_marimba) {
vregs_name = <API key>;
vregs = vregs_bt_bahama;
vregs_size = ARRAY_SIZE(<API key>);
} else {
vregs_name = <API key>;
vregs = vregs_bt_marimba;
vregs_size = ARRAY_SIZE(<API key>);
}
for (i = 0; i < vregs_size; i++) {
if (bahama_not_marimba && (bahama_version == VER_2_0) &&
!on && !strcmp(<API key>[i], "s2"))
continue;
rc = on ? vreg_enable(vregs[i]) :
vreg_disable(vregs[i]);
if (rc < 0) {
printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
__func__, vregs_name[i],
on ? "enable" : "disable", rc);
return -EIO;
}
}
return 0;
}
static int bluetooth_power(int on)
{
int rc;
const char *id = "BTPW";
int bahama_not_marimba = bahama_present();
if (bahama_not_marimba == -1) {
printk(KERN_WARNING "%s: bahama_present: %d\n",
__func__, bahama_not_marimba);
return -ENODEV;
}
if (on) {
rc = <API key>(id, PMAPP_VREG_S2, 1300);
if (rc < 0) {
printk(KERN_ERR "%s: vreg level on failed (%d)\n",
__func__, rc);
return rc;
}
rc = <API key>(on, bahama_not_marimba);
if (rc < 0)
return -EIO;
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
PMAPP_CLOCK_VOTE_ON);
}
else {
rc = pmapp_clock_vote(id, QTR8x00_WCN_CLK,
PMAPP_CLOCK_VOTE_ON);
}
if (rc < 0)
return -EIO;
if (<API key>() ||
<API key>()) {
rc = marimba_gpio_config(1);
if (rc < 0)
return -EIO;
}
rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
if (rc < 0)
return -EIO;
msleep(10);
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
<API key>);
}
else {
rc = pmapp_clock_vote(id, QTR8x00_WCN_CLK,
<API key>);
}
if (rc < 0)
return -EIO;
if (<API key>() ||
<API key>()) {
rc = marimba_gpio_config(0);
if (rc < 0)
return -EIO;
}
rc = msm_gpios_enable(bt_config_power_on,
ARRAY_SIZE(bt_config_power_on));
if (rc < 0)
return rc;
} else {
rc = msm_gpios_enable(bt_config_power_off,
ARRAY_SIZE(bt_config_power_off));
if (rc < 0)
return rc;
/* check for initial RFKILL block (power off) */
if (<API key>(&msm_bt_power_device) == NULL)
goto out;
rc = (bahama_not_marimba ? bahama_bt(on) : marimba_bt(on));
if (rc < 0)
return -EIO;
/* FIHTDC, Div2-SW2-BSP Godfrey */
if ((fih_get_product_id() == Product_FD1) && ((<API key>() != Product_PR1) &&
(<API key>() != Product_PR2p5) &&
(<API key>() != Product_PR230) &&
(<API key>() != Product_PR232) &&
(<API key>() != Product_PR3) &&
(<API key>() != Product_PR4))) {
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_DO,
<API key>);
}
else {
rc = pmapp_clock_vote(id, QTR8x00_WCN_CLK,
<API key>);
}
if (rc < 0)
return -EIO;
rc = <API key>(on, bahama_not_marimba);
if (rc < 0)
return -EIO;
if (bahama_version == VER_1_0) {
rc = <API key>(id, PMAPP_VREG_S2, 0);
if (rc < 0) {
printk(KERN_ERR "%s: vreg level off failed "
"(%d)\n", __func__, rc);
return -EIO;
}
}
}
out:
printk(KERN_DEBUG "Bluetooth power switch: %d\n", on);
return 0;
}
static void __init bt_power_init(void)
{
int i;
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
vregs_bt_marimba[i] = vreg_get(NULL, <API key>[i]);
if (IS_ERR(vregs_bt_marimba[i])) {
printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
__func__, <API key>[i],
PTR_ERR(vregs_bt_marimba[i]));
return;
}
}
for (i = 0; i < ARRAY_SIZE(<API key>); i++) {
vregs_bt_bahama[i] = vreg_get(NULL, <API key>[i]);
if (IS_ERR(vregs_bt_bahama[i])) {
printk(KERN_ERR "%s: vreg get %s failed (%ld)\n",
__func__, <API key>[i],
PTR_ERR(vregs_bt_bahama[i]));
return;
}
}
msm_bt_power_device.dev.platform_data = &bluetooth_power;
}
#else
#define bt_power_init(x) do {} while (0)
#endif
#if defined(<API key>) || defined(CONFIG_BATTERY_MSM)
static struct msm_psy_batt_pdata msm_psy_batt_data = {
.voltage_min_design = 2800,
.voltage_max_design = 4300,
.avail_chg_sources = AC_CHG | USB_CHG ,
.batt_technology = <API key>,
// <API key>+[
#ifdef <API key>
.batt_info_if = {
.get_chg_source = <API key>,
.get_batt_status = <API key>,
.get_batt_capacity = <API key>,
.get_batt_health = <API key>,
.get_batt_temp = <API key>,
.get_batt_voltage = <API key>,
},
#endif
// <API key>+]
};
static struct platform_device msm_batt_device = {
.name = "msm-battery",
.id = -1,
.dev.platform_data = &msm_psy_batt_data,
};
#endif
// <API key>+[
#ifdef <API key>
enum {
<API key>,
<API key>,
};
#ifdef CONFIG_DS2482
static struct <API key> ds2482_pdata = {
.<API key> = 31,
.<API key> = <API key>(31) - 1,
.<API key> = 88,
};
#endif
#ifdef <API key>
struct <API key> bq275x0_pdata = {
#if defined(<API key>) || defined(<API key>)
.pmic_BATLOW = 12,
#else
.pmic_BATLOW = 16,
#endif
.pmic_BATGD = 19,
};
#endif
static struct i2c_board_info <API key>[] = {
#ifdef CONFIG_DS2482
{
I2C_BOARD_INFO("ds2482", 0x30 >> 1),
.platform_data = &ds2482_pdata,
},
#endif
#ifdef <API key>
{
I2C_BOARD_INFO("bq275x0-battery", 0xAA >> 1),
.platform_data = &bq275x0_pdata,
},
#ifdef <API key>
{
I2C_BOARD_INFO("bq275x0-RomMode", 0x16 >> 1),
},
#endif
#endif
};
static int <API key>(void)
{
int product_id = fih_get_product_id();
int product_phase = <API key>();
if (product_id == Product_FB0 || product_id == Product_FD1)
if (product_phase >= Product_EVB && product_phase < Product_PR231)
return <API key>;
else
return <API key>;
else
return <API key>;
}
/*
* Assign caculate_capacity and get_battery_status function by HWID
*/
static void __init <API key>(void)
{
switch(<API key>()) {
case <API key>:
#ifdef CONFIG_DS2482
<API key>(0, &<API key>[0], 1);
#ifdef <API key>
msm_psy_batt_data.batt_info_if.get_batt_capacity = <API key>;
msm_psy_batt_data.batt_info_if.get_batt_health = <API key>;
msm_psy_batt_data.batt_info_if.get_batt_temp = <API key>;
msm_psy_batt_data.batt_info_if.get_batt_voltage = <API key>;
#endif
#endif
break;
case <API key>:
default:
#ifdef <API key>
#ifdef CONFIG_DS2482
<API key>(0, &<API key>[1], 1);
#ifdef <API key>
<API key>(0, &<API key>[2], 1);
#endif
#else
<API key>(0, &<API key>[0], 1);
#ifdef <API key>
<API key>(0, &<API key>[1], 1);
#endif
#endif
msm_psy_batt_data.batt_info_if.get_batt_capacity = bq275x0_battery_soc;
msm_psy_batt_data.batt_info_if.get_batt_health = <API key>;
msm_psy_batt_data.batt_info_if.get_batt_temp = <API key>;
msm_psy_batt_data.batt_info_if.get_batt_voltage = <API key>;
#endif
}
}
#endif
// <API key>+]
static char *<API key>[] = {
"LTC_ADC1",
"LTC_ADC2",
"LTC_ADC3",
};
static char *<API key>[] = {
"XO_ADC",
};
static struct <API key> msm_adc_pdata;
static struct platform_device msm_adc_device = {
.name = "msm_adc",
.id = -1,
.dev = {
.platform_data = &msm_adc_pdata,
},
};
#ifdef CONFIG_MSM_SDIO_AL
static struct msm_gpio mdm2ap_status = {
GPIO_CFG(77, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"mdm2ap_status"
};
static int <API key>(int on)
{
if (on)
return <API key>(&mdm2ap_status, 1);
else {
<API key>(&mdm2ap_status, 1);
return 0;
}
}
static int get_mdm2ap_status(void)
{
return gpio_get_value(GPIO_PIN(mdm2ap_status.gpio_cfg));
}
static struct <API key> sdio_al_pdata = {
.<API key> = <API key>,
.get_mdm2ap_status = get_mdm2ap_status,
.<API key> = 1,
.<API key> = 0x0001,
.<API key> = 0x0003,
.<API key> = 0x0001,
.<API key> = 0x0002,
};
struct platform_device msm_device_sdio_al = {
.name = "msm_sdio_al",
.id = -1,
.dev = {
.platform_data = &sdio_al_pdata,
},
};
#endif /* CONFIG_MSM_SDIO_AL */
// <API key>+
#ifdef <API key>
static struct <API key> fbx_leds_pwm_pdata = {
.r_led_ctl = 30
};
static struct platform_device fbx_leds_pwm_device = {
.name = "fbx-leds-pwm",
.id = -1,
.dev = {
.platform_data = &fbx_leds_pwm_pdata,
},
};
#endif
// <API key>-
//FIHTDC, Port keypad, MayLi, 2011.09.21 {+
#ifdef <API key>
static struct <API key> sf8_kybd_pdata = {
.pmic_gpio_vol_up = 0,
.pmic_gpio_vol_dn = 1,
.pmic_gpio_cover_det= 2,
.sys_gpio_vol_up = <API key>(0),
.sys_gpio_vol_dn = <API key>(1),
.sys_gpio_cover_det = <API key>(2),
};
static struct platform_device sf8_kybd_device = {
.name = "sf8_kybd",
.id = -1,
.dev = {
.platform_data = &sf8_kybd_pdata,
},
};
#endif
//FIHTDC, Port keypad, MayLi, 2011.09.21 -}
//<API key>+[
#ifdef <API key>
#define RAM_CONSOLE_PHYS 0x7A00000
#define RAM_CONSOLE_SIZE 0x00020000
static struct resource <API key>[1] = {
[0] = {
.start = RAM_CONSOLE_PHYS,
.end = RAM_CONSOLE_PHYS + RAM_CONSOLE_SIZE - 1,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device ram_console_device = {
.name = "ram_console",
.id = 0,
.num_resources = ARRAY_SIZE(<API key>),
.resource = <API key>,
};
#endif
#ifdef <API key>
#ifdef <API key>
#define <API key> (RAM_CONSOLE_PHYS + RAM_CONSOLE_SIZE)
#else
#define <API key> 0x7A20000
#endif
#define <API key> 0x00020000 //128KB
#define <API key> (<API key> + <API key>)
#define <API key> 0x00020000 //128KB
#define <API key> (<API key> + <API key>)
#define <API key> 0x00020000 //128KB
#define <API key> (<API key> + <API key>)
#define <API key> 0x00020000 //128KB
static struct resource <API key>[4] = {
[0] = {
.name = "alog_main_buffer",
.start = <API key>,
.end = <API key> + <API key> - 1,
.flags = IORESOURCE_MEM,
},
[1] = {
.name = "alog_radio_buffer",
.start = <API key>,
.end = <API key> + <API key> - 1,
.flags = IORESOURCE_MEM,
},
[2] = {
.name = "alog_events_buffer",
.start = <API key>,
.end = <API key> + <API key> - 1,
.flags = IORESOURCE_MEM,
},
[3] = {
.name = "alog_system_buffer",
.start = <API key>,
.end = <API key> + <API key> - 1,
.flags = IORESOURCE_MEM,
},
};
static struct platform_device <API key> = {
.name = "alog_ram_console",
.id = 0,
.num_resources = ARRAY_SIZE(<API key>),
.resource = <API key>,
};
#endif
//<API key>+]
static struct platform_device *devices[] __initdata = {
#if defined(CONFIG_SERIAL_MSM) || defined(<API key>)
&msm_device_uart2,
#endif
&msm_device_smd,
&msm_device_dmov,
/* Div2-SW2-BSP-FBX-OW { */
#ifdef CONFIG_SMC91X
&smc91x_device,
#endif
#ifdef CONFIG_SMSC911X
&smsc911x_device,
#endif
/* } Div2-SW2-BSP-FBX-OW */
&msm_device_nand,
#ifdef CONFIG_USB_FUNCTION
&<API key>,
&mass_storage_device,
#endif
#ifdef <API key>
&msm_device_otg,
#ifdef CONFIG_USB_GADGET
&<API key>,
#endif
#endif
#ifdef CONFIG_USB_ANDROID
&<API key>,
&rndis_device,
#ifdef <API key>
&usb_diag_device,
#endif
&android_usb_device,
#endif
&qsd_device_spi,
#ifdef CONFIG_I2C_SSBI
&msm_device_ssbi6,
&msm_device_ssbi7,
#endif
&android_pmem_device,
&msm_fb_device,
&<API key>,
//<API key>+
#if 0
&mddi_toshiba_device,
#endif
//<API key>-
//<API key>+
#ifdef <API key>
&<API key>,
#endif
//<API key>-
#ifdef CONFIG_MSM_ROTATOR
&msm_rotator_device,
#endif
//<API key>+
#if 0
&<API key>,
#endif
//<API key>-
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
#ifdef <API key>
&<API key>,
#endif
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
&<API key>,
&<API key>,
&<API key>,
&msm_device_i2c,
&msm_device_i2c_2,
&msm_device_uart_dm1,
&hs_device,
#ifdef <API key>
&msm_aictl_device,
&msm_mi2s_device,
&msm_lpa_device,
&msm_aux_pcm_device,
#endif
&msm_device_adspdec,
&qup_device_i2c,
#if defined(CONFIG_MARIMBA_CORE) && \
(defined(CONFIG_MSM_BT_POWER) || defined(<API key>))
&msm_bt_power_device,
#endif
// FihtdcCode@20110908 WeiChu add for WiFi porting begin
// <API key> BCM4329 WLAN driver For SF8 +[
#ifdef <API key>
&<API key>,
#endif
// <API key> BCM4329 WLAN driver For SF8 +]
// <API key> BCM4329 BLUETOOTH driver For SF8 +[
#ifdef <API key>
&<API key>,
&<API key>,
#endif
// <API key> BCM4329 BLUETOOTH driver For SF8 +]
// FihtdcCode@20110908 WeiChu add for WiFi porting end
&msm_kgsl_3d0,
#ifdef CONFIG_MSM_KGSL_2D
&msm_kgsl_2d0,
#endif
#ifdef CONFIG_FIH_MT9P111
&<API key>,
#endif
#ifdef CONFIG_FIH_HM0356
&<API key>,
#endif
#ifdef CONFIG_FIH_HM0357
&<API key>,
#endif
#ifdef <API key>
&<API key>,
#endif
#ifdef CONFIG_MT9T013
&<API key>,
#endif
#ifdef CONFIG_MT9D112
&<API key>,
#endif
#ifdef CONFIG_S5K3E2FX
&<API key>,
#endif
#ifdef CONFIG_MT9P012
&<API key>,
#endif
#ifdef CONFIG_MT9E013
&<API key>,
#endif
#ifdef CONFIG_VX6953
&<API key>,
#endif
#ifdef CONFIG_SN12M0PZ
&<API key>,
#endif
&<API key>,
#ifdef CONFIG_MSM_GEMINI
&msm_gemini_device,
#endif
#ifdef CONFIG_MSM_VPE
&msm_vpe_device,
#endif
#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
&msm_device_tsif,
#endif
#ifdef CONFIG_MSM_SDIO_AL
&msm_device_sdio_al,
#endif
#if defined(<API key>) || \
defined(<API key>)
&qcrypto_device,
#endif
#if defined(<API key>) || \
defined(<API key>)
&qcedev_device,
#endif
//<API key>/SF4H8 porting keypad backlight +{
#if defined(<API key>) || defined(<API key>) || defined(<API key>)
&<API key>,
#endif
//<API key>/SF4H8 porting keypad backlight +}
&msm_batt_device,
&msm_adc_device,
&msm_ebi0_thermal,
&msm_ebi1_thermal,
#ifdef <API key>
&gpio_buttons_device, // <API key>
#endif
//FIHTDC, Port keypad, MayLi, 2011.09.21 {+
#ifdef <API key>
&sf8_kybd_device,
#endif
//FIHTDC, Port keypad, MayLi, 2011.09.21 -}
#ifdef <API key>
&fbx_leds_pwm_device, // <API key>
#endif
/* FIHTDC, Div2-SW2-BSP, Peter, Audio { */
&<API key>,
/* } FIHTDC, Div2-SW2-BSP, Peter, Audio */
//<API key>+[
#ifdef <API key>
&ram_console_device,
#endif
#ifdef <API key>
&<API key>,
#endif
// FihtdcCode@20110908 WeiChu add for WiFi porting begin
#if defined(<API key>)
&<API key>,
#endif
// FihtdcCode@20110908 WeiChu add for WiFi porting end
//<API key>+]
};
static struct msm_gpio msm_i2c_gpios_hw[] = {
{ GPIO_CFG(70, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
{ GPIO_CFG(71, 1, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
};
static struct msm_gpio msm_i2c_gpios_io[] = {
{ GPIO_CFG(70, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_scl" },
{ GPIO_CFG(71, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "i2c_sda" },
};
static struct msm_gpio qup_i2c_gpios_io[] = {
{ GPIO_CFG(16, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
{ GPIO_CFG(17, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
};
static struct msm_gpio qup_i2c_gpios_hw[] = {
{ GPIO_CFG(16, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_scl" },
{ GPIO_CFG(17, 2, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "qup_sda" },
};
static void
msm_i2c_gpio_config(int adap_id, int config_type)
{
struct msm_gpio *msm_i2c_table;
/* Each adapter gets 2 lines from the table */
if (adap_id > 0)
return;
if (config_type)
msm_i2c_table = &msm_i2c_gpios_hw[adap_id*2];
else
msm_i2c_table = &msm_i2c_gpios_io[adap_id*2];
msm_gpios_enable(msm_i2c_table, 2);
}
/*This needs to be enabled only for OEMS*/
#ifndef <API key>
static struct vreg *qup_vreg;
#endif
static void
qup_i2c_gpio_config(int adap_id, int config_type)
{
int rc = 0;
struct msm_gpio *qup_i2c_table;
/* Each adapter gets 2 lines from the table */
if (adap_id != 4)
return;
if (config_type)
qup_i2c_table = qup_i2c_gpios_hw;
else
qup_i2c_table = qup_i2c_gpios_io;
rc = msm_gpios_enable(qup_i2c_table, 2);
if (rc < 0)
printk(KERN_ERR "QUP GPIO enable failed: %d\n", rc);
/*This needs to be enabled only for OEMS*/
#ifndef <API key>
if (qup_vreg) {
int rc = vreg_set_level(qup_vreg, 1800);
if (rc) {
pr_err("%s: vreg LVS1 set level failed (%d)\n",
__func__, rc);
}
rc = vreg_enable(qup_vreg);
if (rc) {
pr_err("%s: vreg_enable() = %d \n",
__func__, rc);
}
}
#endif
}
static struct <API key> msm_i2c_pdata = {
.clk_freq = 100000,
.pri_clk = 70,
.pri_dat = 71,
.rmutex = 1,
.rsl_id = "D:I2C02000021",
.msm_i2c_config_gpio = msm_i2c_gpio_config,
};
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
static void __init <API key>(void)
{
struct vreg *vreg_ldo12;
struct vreg *vreg_ldo8; ///i2c_gpio_power
//<API key>++[
//<API key>+{
#if defined(<API key>) || defined(<API key>) //<API key>* //<API key>*
struct vreg *vreg_gp7;
#endif
//<API key>+}
//<API key>++]
int rc;
/* 1.8V -- LDO12 */
vreg_ldo12 = vreg_get(NULL, "gp9");
if (IS_ERR(vreg_ldo12)) {
pr_err("%s: gp9 vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_ldo12));
return;
}
rc = vreg_set_level(vreg_ldo12, 3000);
if (rc) {
pr_err("%s: vreg LDO12 set level failed (%d)\n",
__func__, rc);
return;
}
rc = vreg_enable(vreg_ldo12);
if (rc) {
pr_err("%s: LDO12 vreg enable failed (%d)\n",
__func__, rc);
return;
}
/* VDDIO 1.8V -- LDO8*/ ///i2c_gpio_power
vreg_ldo8 = vreg_get(NULL, "gp7");
if (IS_ERR(vreg_ldo8)) {
rc = PTR_ERR(vreg_ldo8);
printk("%s: gp7 vreg get failed (%d)\n",
__func__, rc);
return;
}
rc = vreg_set_level(vreg_ldo8, 1800);
if (rc) {
printk("%s: vreg LDO8 set level failed (%d)\n",
__func__, rc);
return;
}
rc = vreg_enable(vreg_ldo8);
if (rc) {
pr_err("%s: LDO8 vreg enable failed (%d)\n",
__func__, rc);
return;
}
//<API key>++[
//<API key>+{
#if defined(<API key>) || defined(<API key>) //<API key>* //<API key>*
vreg_gp7 = vreg_get(NULL, "gp7");
if (IS_ERR(vreg_gp7)) {
pr_err("%s: gp7 vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_gp7));
return;
}
rc = vreg_set_level(vreg_gp7, 1800);
if (rc) {
pr_err("%s: vreg gp7 set level failed (%d)\n",
__func__, rc);
return;
}
//<API key>-{
/*rc = vreg_enable(vreg_gp7);
if (rc) {
pr_err("%s: gp7 vreg enable failed (%d)\n",
__func__, rc);
return;
}*/
//<API key>-}
<API key>(vreg_gp7, 1); //<API key>+
//<API key>+{
//reset again to ensure light sensor can initialize successfully
rc = vreg_disable(vreg_gp7);
if (rc)
{
pr_err("%s: gp7 vreg enable failed (%d)\n",
__func__, rc);
return;
}
printk(KERN_INFO "%s, shutdown vreg_gp7\n", __func__);
msleep(100);
printk(KERN_INFO "%s, Power-on vreg_gp7\n", __func__);
rc = vreg_enable(vreg_gp7);
if (rc)
{
pr_err("%s: gp7 vreg enable failed (%d)\n",
__func__, rc);
return;
}
//<API key>+}
vreg_gp7 = NULL;
#endif
//<API key>+}
//<API key>++]
}
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
static void __init msm_device_i2c_init(void)
{
if (msm_gpios_request(msm_i2c_gpios_hw, ARRAY_SIZE(msm_i2c_gpios_hw)))
pr_err("failed to request I2C gpios\n");
msm_device_i2c.dev.platform_data = &msm_i2c_pdata;
}
static struct <API key> msm_i2c_2_pdata = {
.clk_freq = 100000,
.rmutex = 1,
.rsl_id = "D:I2C02000022",
.msm_i2c_config_gpio = msm_i2c_gpio_config,
};
static void __init <API key>(void)
{
msm_device_i2c_2.dev.platform_data = &msm_i2c_2_pdata;
}
static struct <API key> qup_i2c_pdata = {
.clk_freq = 384000,
.pclk = "camif_pad_pclk",
.msm_i2c_config_gpio = qup_i2c_gpio_config,
};
static void __init qup_device_i2c_init(void)
{
if (msm_gpios_request(qup_i2c_gpios_hw, ARRAY_SIZE(qup_i2c_gpios_hw)))
pr_err("failed to request I2C gpios\n");
qup_device_i2c.dev.platform_data = &qup_i2c_pdata;
/*This needs to be enabled only for OEMS*/
#ifndef <API key>
qup_vreg = vreg_get(NULL, "lvsw1");
if (IS_ERR(qup_vreg)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(qup_vreg));
}
#endif
}
#ifdef CONFIG_I2C_SSBI
static struct <API key> msm_i2c_ssbi6_pdata = {
.rsl_id = "D:PMIC_SSBI",
.controller_type = MSM_SBI_CTRL_SSBI2,
};
static struct <API key> msm_i2c_ssbi7_pdata = {
.rsl_id = "D:CODEC_SSBI",
.controller_type = MSM_SBI_CTRL_SSBI,
};
#endif
static struct <API key> msm7x30_clock_data = {
.acpu_switch_time_us = 50,
.vdd_switch_time_us = 62,
};
static void __init msm7x30_init_irq(void)
{
msm_init_irq();
}
static struct msm_gpio <API key>[] = {
{GPIO_CFG(86, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_cs1"},
{GPIO_CFG(115, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "ebi2_busy1"},
};
struct vreg *vreg_s3;
struct vreg *vreg_mmc;
#if (defined(<API key>)\
|| defined(<API key>)\
|| defined(<API key>)\
|| defined(<API key>))
struct sdcc_gpio {
struct msm_gpio *cfg_data;
uint32_t size;
struct msm_gpio *sleep_cfg_data;
};
#if defined(<API key>)
static struct msm_gpio <API key>[] = {
{GPIO_CFG(35, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_16MA), "sdc1_lvlshft"},
};
#endif
static struct msm_gpio sdc1_cfg_data[] = {
{GPIO_CFG(38, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc1_clk"},
#ifndef CONFIG_FIH_AAT1272
{GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
#endif
{GPIO_CFG(39, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_cmd"},
{GPIO_CFG(40, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_3"},
{GPIO_CFG(41, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_2"},
{GPIO_CFG(42, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_1"},
{GPIO_CFG(43, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc1_dat_0"},
};
static struct msm_gpio sdc2_cfg_data[] = {
{GPIO_CFG(64, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc2_clk"},
{GPIO_CFG(65, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_cmd"},
{GPIO_CFG(66, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_3"},
{GPIO_CFG(67, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_2"},
{GPIO_CFG(68, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_1"},
{GPIO_CFG(69, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_0"},
#ifdef <API key>
{GPIO_CFG(115, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_4"},
{GPIO_CFG(114, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_5"},
{GPIO_CFG(113, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_6"},
{GPIO_CFG(112, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc2_dat_7"},
#endif
};
static struct msm_gpio sdc3_cfg_data[] = {
{GPIO_CFG(110, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc3_clk"},
{GPIO_CFG(111, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_cmd"},
{GPIO_CFG(116, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_3"},
{GPIO_CFG(117, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_2"},
{GPIO_CFG(118, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_1"},
{GPIO_CFG(119, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc3_dat_0"},
};
static struct msm_gpio sdc3_sleep_cfg_data[] = {
{GPIO_CFG(110, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_clk"},
{GPIO_CFG(111, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_cmd"},
{GPIO_CFG(116, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_dat_3"},
{GPIO_CFG(117, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_dat_2"},
{GPIO_CFG(118, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_dat_1"},
{GPIO_CFG(119, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"sdc3_dat_0"},
};
static struct msm_gpio sdc4_cfg_data[] = {
{GPIO_CFG(58, 1, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA), "sdc4_clk"},
{GPIO_CFG(59, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_cmd"},
{GPIO_CFG(60, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_3"},
{GPIO_CFG(61, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_2"},
{GPIO_CFG(62, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_1"},
{GPIO_CFG(63, 1, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA), "sdc4_dat_0"},
};
static struct sdcc_gpio sdcc_cfg_data[] = {
{
.cfg_data = sdc1_cfg_data,
.size = ARRAY_SIZE(sdc1_cfg_data),
.sleep_cfg_data = NULL,
},
{
.cfg_data = sdc2_cfg_data,
.size = ARRAY_SIZE(sdc2_cfg_data),
.sleep_cfg_data = NULL,
},
{
.cfg_data = sdc3_cfg_data,
.size = ARRAY_SIZE(sdc3_cfg_data),
.sleep_cfg_data = sdc3_sleep_cfg_data,
},
{
.cfg_data = sdc4_cfg_data,
.size = ARRAY_SIZE(sdc4_cfg_data),
.sleep_cfg_data = NULL,
},
};
struct sdcc_vreg {
struct vreg *vreg_data;
unsigned level;
};
static struct sdcc_vreg sdcc_vreg_data[4];
static unsigned long vreg_sts, gpio_sts;
static uint32_t msm_sdcc_setup_gpio(int dev_id, unsigned int enable)
{
int rc = 0;
struct sdcc_gpio *curr;
curr = &sdcc_cfg_data[dev_id - 1];
if (!(test_bit(dev_id, &gpio_sts)^enable))
return rc;
if (enable) {
set_bit(dev_id, &gpio_sts);
rc = <API key>(curr->cfg_data, curr->size);
if (rc)
printk(KERN_ERR "%s: Failed to turn on GPIOs for slot %d\n",
__func__, dev_id);
} else {
clear_bit(dev_id, &gpio_sts);
if (curr->sleep_cfg_data) {
msm_gpios_enable(curr->sleep_cfg_data, curr->size);
msm_gpios_free(curr->sleep_cfg_data, curr->size);
} else {
<API key>(curr->cfg_data, curr->size);
}
}
return rc;
}
static uint32_t msm_sdcc_setup_vreg(int dev_id, unsigned int enable)
{
int rc = 0;
struct sdcc_vreg *curr;
static int enabled_once[] = {0, 0, 0, 0};
curr = &sdcc_vreg_data[dev_id - 1];
if (!(test_bit(dev_id, &vreg_sts)^enable))
return rc;
if (!enable || enabled_once[dev_id - 1])
return 0;
if (enable) {
set_bit(dev_id, &vreg_sts);
rc = vreg_set_level(curr->vreg_data, curr->level);
if (rc) {
printk(KERN_ERR "%s: vreg_set_level() = %d \n",
__func__, rc);
}
rc = vreg_enable(curr->vreg_data);
if (rc) {
printk(KERN_ERR "%s: vreg_enable() = %d \n",
__func__, rc);
}
enabled_once[dev_id - 1] = 1;
} else {
clear_bit(dev_id, &vreg_sts);
rc = vreg_disable(curr->vreg_data);
if (rc) {
printk(KERN_ERR "%s: vreg_disable() = %d \n",
__func__, rc);
}
}
return rc;
}
static uint32_t <API key>(struct device *dv, unsigned int vdd)
{
int rc = 0;
struct platform_device *pdev;
pdev = container_of(dv, struct platform_device, dev);
rc = msm_sdcc_setup_gpio(pdev->id, (vdd ? 1 : 0));
if (rc)
goto out;
if (pdev->id == 4) /* S3 is always ON and cannot be disabled */
rc = msm_sdcc_setup_vreg(pdev->id, (vdd ? 1 : 0));
out:
return rc;
}
#if defined(<API key>) && \
defined(<API key>) && \
defined(<API key>) && \
(<API key> == 0x70 && <API key> == 0x1117)
#define MBP_ON 1
#define MBP_OFF 0
#define MBP_RESET_N \
GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_8MA)
#define MBP_INT0 \
GPIO_CFG(46, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_8MA)
#define MBP_MODE_CTRL_0 \
GPIO_CFG(35, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
#define MBP_MODE_CTRL_1 \
GPIO_CFG(36, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
#define MBP_MODE_CTRL_2 \
GPIO_CFG(34, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA)
#define TSIF_EN \
GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_DATA \
GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_CLK \
GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
static struct msm_gpio mbp_cfg_data[] = {
{GPIO_CFG(44, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
"mbp_reset"},
{GPIO_CFG(85, 0, GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL, GPIO_CFG_16MA),
"mbp_io_voltage"},
};
static int <API key>(int enable)
{
int rc = 0;
if (enable) {
rc = <API key>(mbp_cfg_data,
ARRAY_SIZE(mbp_cfg_data));
if (rc) {
printk(KERN_ERR
"%s: Failed to turnon GPIOs for mbp chip(%d)\n",
__func__, rc);
}
} else
<API key>(mbp_cfg_data, ARRAY_SIZE(mbp_cfg_data));
return rc;
}
static int mbp_setup_rf_vregs(int state)
{
struct vreg *vreg_rf = NULL;
struct vreg *vreg_rf_switch = NULL;
int rc;
vreg_rf = vreg_get(NULL, "s2");
if (IS_ERR(vreg_rf)) {
pr_err("%s: s2 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_rf));
return -EFAULT;
}
vreg_rf_switch = vreg_get(NULL, "rf");
if (IS_ERR(vreg_rf_switch)) {
pr_err("%s: rf vreg get failed (%ld)",
__func__, PTR_ERR(vreg_rf_switch));
return -EFAULT;
}
if (state) {
rc = vreg_set_level(vreg_rf, 1300);
if (rc) {
pr_err("%s: vreg s2 set level failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_enable(vreg_rf);
if (rc) {
printk(KERN_ERR "%s: vreg_enable(s2) = %d\n",
__func__, rc);
}
rc = vreg_set_level(vreg_rf_switch, 2600);
if (rc) {
pr_err("%s: vreg rf switch set level failed (%d)\n",
__func__, rc);
return rc;
}
rc = vreg_enable(vreg_rf_switch);
if (rc) {
printk(KERN_ERR "%s: vreg_enable(rf) = %d\n",
__func__, rc);
}
} else {
(void) vreg_disable(vreg_rf);
(void) vreg_disable(vreg_rf_switch);
}
return 0;
}
static int mbp_setup_vregs(int state)
{
struct vreg *vreg_analog = NULL;
struct vreg *vreg_io = NULL;
int rc;
vreg_analog = vreg_get(NULL, "gp4");
if (IS_ERR(vreg_analog)) {
pr_err("%s: gp4 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_analog));
return -EFAULT;
}
vreg_io = vreg_get(NULL, "s3");
if (IS_ERR(vreg_io)) {
pr_err("%s: s3 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_io));
return -EFAULT;
}
if (state) {
rc = vreg_set_level(vreg_analog, 2600);
if (rc) {
pr_err("%s: vreg_set_level failed (%d)",
__func__, rc);
}
rc = vreg_enable(vreg_analog);
if (rc) {
pr_err("%s: analog vreg enable failed (%d)",
__func__, rc);
}
rc = vreg_set_level(vreg_io, 1800);
if (rc) {
pr_err("%s: vreg_set_level failed (%d)",
__func__, rc);
}
rc = vreg_enable(vreg_io);
if (rc) {
pr_err("%s: io vreg enable failed (%d)",
__func__, rc);
}
} else {
rc = vreg_disable(vreg_analog);
if (rc) {
pr_err("%s: analog vreg disable failed (%d)",
__func__, rc);
}
rc = vreg_disable(vreg_io);
if (rc) {
pr_err("%s: io vreg disable failed (%d)",
__func__, rc);
}
}
return rc;
}
static int mbp_set_tcxo_en(int enable)
{
int rc;
const char *id = "UBMC";
struct vreg *vreg_analog = NULL;
rc = pmapp_clock_vote(id, PMAPP_CLOCK_ID_A1,
enable ? PMAPP_CLOCK_VOTE_ON : <API key>);
if (rc < 0) {
printk(KERN_ERR "%s: unable to %svote for a1 clk\n",
__func__, enable ? "" : "de-");
return -EIO;
}
if (!enable) {
vreg_analog = vreg_get(NULL, "gp4");
if (IS_ERR(vreg_analog)) {
pr_err("%s: gp4 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_analog));
return -EFAULT;
}
(void) vreg_disable(vreg_analog);
}
return rc;
}
static void mbp_set_freeze_io(int state)
{
if (state)
gpio_set_value(85, 0);
else
gpio_set_value(85, 1);
}
static int <API key>(int enable)
{
int rc;
struct vreg *vreg_core1p2 = NULL;
vreg_core1p2 = vreg_get(NULL, "gp16");
if (IS_ERR(vreg_core1p2)) {
pr_err("%s: gp16 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_core1p2));
return -EFAULT;
}
if (enable) {
rc = vreg_set_level(vreg_core1p2, 1200);
if (rc) {
pr_err("%s: vreg_set_level failed (%d)",
__func__, rc);
}
(void) vreg_enable(vreg_core1p2);
return 80;
} else {
gpio_set_value(85, 1);
return 0;
}
return rc;
}
static void mbp_set_reset(int state)
{
if (state)
gpio_set_value(GPIO_PIN(MBP_RESET_N), 0);
else
gpio_set_value(GPIO_PIN(MBP_RESET_N), 1);
}
static int <API key>(int state)
{
if (state) {
gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_ENABLE);
gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_ENABLE);
gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_ENABLE);
gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_0), 0);
gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_1), 1);
gpio_set_value(GPIO_PIN(MBP_MODE_CTRL_2), 0);
} else {
gpio_tlmm_config(MBP_MODE_CTRL_0, GPIO_CFG_DISABLE);
gpio_tlmm_config(MBP_MODE_CTRL_1, GPIO_CFG_DISABLE);
gpio_tlmm_config(MBP_MODE_CTRL_2, GPIO_CFG_DISABLE);
}
return 0;
}
static int mbp_setup_adc_vregs(int state)
{
struct vreg *vreg_adc = NULL;
int rc;
vreg_adc = vreg_get(NULL, "s4");
if (IS_ERR(vreg_adc)) {
pr_err("%s: s4 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_adc));
return -EFAULT;
}
if (state) {
rc = vreg_set_level(vreg_adc, 2200);
if (rc) {
pr_err("%s: vreg_set_level failed (%d)",
__func__, rc);
}
rc = vreg_enable(vreg_adc);
if (rc) {
pr_err("%s: enable vreg adc failed (%d)",
__func__, rc);
}
} else {
rc = vreg_disable(vreg_adc);
if (rc) {
pr_err("%s: disable vreg adc failed (%d)",
__func__, rc);
}
}
return rc;
}
static int mbp_power_up(void)
{
int rc;
rc = <API key>(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: <API key>() done\n", __func__);
rc = mbp_setup_vregs(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: gp4 (2.6) and s3 (1.8) done\n", __func__);
rc = mbp_set_tcxo_en(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: tcxo clock done\n", __func__);
mbp_set_freeze_io(MBP_OFF);
pr_debug("%s: set gpio 85 to 1 done\n", __func__);
udelay(100);
mbp_set_reset(MBP_ON);
udelay(300);
rc = <API key>(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: <API key>() done\n", __func__);
udelay(100 + <API key>(MBP_ON));
pr_debug("%s: power gp16 1.2V done\n", __func__);
mbp_set_freeze_io(MBP_ON);
pr_debug("%s: set gpio 85 to 0 done\n", __func__);
udelay(100);
rc = mbp_setup_rf_vregs(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: s2 1.3V and rf 2.6V done\n", __func__);
rc = mbp_setup_adc_vregs(MBP_ON);
if (rc)
goto exit;
pr_debug("%s: s4 2.2V done\n", __func__);
udelay(200);
mbp_set_reset(MBP_OFF);
pr_debug("%s: close gpio 44 done\n", __func__);
msleep(20);
exit:
return rc;
}
static int mbp_power_down(void)
{
int rc;
struct vreg *vreg_adc = NULL;
vreg_adc = vreg_get(NULL, "s4");
if (IS_ERR(vreg_adc)) {
pr_err("%s: s4 vreg get failed (%ld)",
__func__, PTR_ERR(vreg_adc));
return -EFAULT;
}
mbp_set_reset(MBP_ON);
pr_debug("%s: mbp_set_reset(MBP_ON) done\n", __func__);
udelay(100);
rc = mbp_setup_adc_vregs(MBP_OFF);
if (rc)
goto exit;
pr_debug("%s: vreg_disable(vreg_adc) done\n", __func__);
udelay(5);
rc = mbp_setup_rf_vregs(MBP_OFF);
if (rc)
goto exit;
pr_debug("%s: mbp_setup_rf_vregs(MBP_OFF) done\n", __func__);
udelay(5);
mbp_set_freeze_io(MBP_OFF);
pr_debug("%s: mbp_set_freeze_io(MBP_OFF) done\n", __func__);
udelay(100);
rc = <API key>(MBP_OFF);
if (rc)
goto exit;
pr_debug("%s: <API key>(MBP_OFF) done\n", __func__);
gpio_set_value(85, 1);
rc = mbp_set_tcxo_en(MBP_OFF);
if (rc)
goto exit;
pr_debug("%s: mbp_set_tcxo_en(MBP_OFF) done\n", __func__);
rc = <API key>(MBP_OFF);
if (rc)
goto exit;
exit:
return rc;
}
static void (*<API key>)(int card_present, void *dev_id);
static void *<API key>;
static int mbp_power_status;
static int mbp_power_init_done;
static uint32_t mbp_setup_power(struct device *dv,
unsigned int power_status)
{
int rc = 0;
struct platform_device *pdev;
pdev = container_of(dv, struct platform_device, dev);
if (power_status == mbp_power_status)
goto exit;
if (power_status) {
pr_debug("turn on power of mbp slot");
rc = mbp_power_up();
mbp_power_status = 1;
} else {
pr_debug("turn off power of mbp slot");
rc = mbp_power_down();
mbp_power_status = 0;
}
exit:
return rc;
};
int <API key>(void (*callback)(int, void *),
void *dev_id)
{
<API key> = callback;
<API key> = dev_id;
return 0;
}
static unsigned int mbp_status(struct device *dev)
{
return mbp_power_status;
}
static uint32_t <API key>(struct device *dv, unsigned int vdd)
{
struct platform_device *pdev;
uint32_t rc = 0;
pdev = container_of(dv, struct platform_device, dev);
rc = <API key>(dv, vdd);
if (rc) {
pr_err("%s: Failed to setup power (%d)\n",
__func__, rc);
goto out;
}
if (!mbp_power_init_done) {
mbp_setup_power(dv, 1);
mbp_setup_power(dv, 0);
mbp_power_init_done = 1;
}
if (vdd >= 0x8000) {
rc = mbp_setup_power(dv, (0x8000 == vdd) ? 0 : 1);
if (rc) {
pr_err("%s: Failed to config mbp chip power (%d)\n",
__func__, rc);
goto out;
}
if (<API key>) {
<API key>(mbp_power_status,
<API key>);
}
}
out:
/* should return 0 only */
return 0;
}
#endif
#endif
#ifdef <API key>
#ifdef <API key>
static unsigned int <API key>(struct device *dev)
{
return (unsigned int)!gpio_get_value(sd_detect_pin);
}
#endif
static void <API key>(struct device *dv, unsigned int active)
{
pr_debug("%s not implemented\n", __func__);
}
static int <API key>(struct device *dv)
{
void __iomem *wp_addr = 0;
uint32_t ret = 0;
struct platform_device *pdev;
if (!(<API key>()))
return -1;
pdev = container_of(dv, struct platform_device, dev);
wp_addr = ioremap(FPGA_SDCC_STATUS, 4);
if (!wp_addr) {
pr_err("%s: Could not remap %x\n", __func__, FPGA_SDCC_STATUS);
return -ENOMEM;
}
ret = (((readl(wp_addr) >> 4) >> (pdev->id-1)) & 0x01);
pr_info("%s: WP Status for Slot %d = 0x%x \n", __func__,
pdev->id, ret);
iounmap(wp_addr);
return ret;
}
#endif
#if defined(<API key>)
#if defined(<API key>) && \
defined(<API key>) && \
(<API key> == 0x70 && <API key> == 0x1117)
static struct mmc_platform_data msm7x30_sdc1_data = {
.ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28 | MMC_VDD_28_29,
.translate_vdd = <API key>,
.mmc_bus_width = MMC_CAP_4_BIT_DATA,
.status = mbp_status,
.<API key> = <API key>,
#ifdef <API key>
.dummy52_required = 1,
#endif
.msmsdcc_fmin = 144000,
.msmsdcc_fmid = 24576000,
.msmsdcc_fmax = 24576000,
.nonremovable = 0,
};
#else
static struct mmc_platform_data msm7x30_sdc1_data = {
.ocr_mask = MMC_VDD_165_195,
.translate_vdd = <API key>,
.mmc_bus_width = MMC_CAP_4_BIT_DATA,
#ifdef <API key>
.dummy52_required = 1,
#endif
.msmsdcc_fmin = 144000,
.msmsdcc_fmid = 24576000,
.msmsdcc_fmax = 49152000,
.nonremovable = 0,
};
#endif
#endif
#ifdef <API key>
static struct mmc_platform_data msm7x30_sdc2_data = {
.ocr_mask = MMC_VDD_165_195 | MMC_VDD_27_28,
.translate_vdd = <API key>,
#ifdef <API key>
.mmc_bus_width = MMC_CAP_8_BIT_DATA,
#else
.mmc_bus_width = MMC_CAP_4_BIT_DATA,
#endif
#ifdef <API key>
.dummy52_required = 1,
#endif
.msmsdcc_fmin = 144000,
.msmsdcc_fmid = 24576000,
.msmsdcc_fmax = 49152000,
.nonremovable = 1,
};
#endif
#ifdef <API key>
static struct mmc_platform_data msm7x30_sdc3_data = {
.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
.translate_vdd = <API key>,
.mmc_bus_width = MMC_CAP_4_BIT_DATA,
#ifdef <API key>
.sdiowakeup_irq = MSM_GPIO_TO_INT(118),
#endif
#ifdef <API key>
.dummy52_required = 1,
#endif
.msmsdcc_fmin = 144000,
.msmsdcc_fmid = 24576000,
.msmsdcc_fmax = 49152000,
.nonremovable = 0,
};
#endif
#ifdef <API key>
static struct mmc_platform_data msm7x30_sdc4_data = {
.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29,
.translate_vdd = <API key>,
.mmc_bus_width = MMC_CAP_4_BIT_DATA,
#ifdef <API key>
.status = <API key>,
.status_irq = PM8058_GPIO_IRQ(PMIC8058_IRQ_BASE, PMIC_GPIO_SD_DET - 1),
.irq_flags = IRQF_TRIGGER_RISING | <API key>,
#endif
.wpswitch = <API key>,
#ifdef <API key>
.dummy52_required = 1,
#endif
.msmsdcc_fmin = 144000,
.msmsdcc_fmid = 24576000,
.msmsdcc_fmax = 49152000,
.nonremovable = 0,
};
#endif
#ifdef <API key>
static void <API key>(void)
{
int rc;
/* Enable LDO5, an input to the FET that powers slot 1 */
rc = vreg_set_level(vreg_mmc, 2850);
if (rc)
printk(KERN_ERR "%s: vreg_set_level() = %d \n", __func__, rc);
rc = vreg_enable(vreg_mmc);
if (rc)
printk(KERN_ERR "%s: vreg_enable() = %d \n", __func__, rc);
/* Enable GPIO 35, to turn on the FET that powers slot 1 */
rc = <API key>(<API key>,
ARRAY_SIZE(<API key>));
if (rc)
printk(KERN_ERR "%s: Failed to enable GPIO 35\n", __func__);
rc = <API key>(GPIO_PIN(<API key>[0].gpio_cfg),
1);
if (rc)
printk(KERN_ERR "%s: Failed to turn on GPIO 35\n", __func__);
}
#endif
/* FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized { */
#ifdef CONFIG_FIH_FXX
#include <linux/ctype.h> //<API key>
#include "proc_comm.h"
#define NV_PRD_ID_I 50001
#define <API key> 50034
int fih_usb_full_func = 0xC000;
struct <API key> {
uint32_t magic_num;
uint16_t vendor_id;
uint16_t product_id;
char product_name[32];
char manufacturer_name[32];
char reserved[52];
};
static int sync_from_custom_nv(void)
{
uint32_t <API key> = PCOM_CUSTOMER_CMD1;
uint32_t <API key> = <API key>;
uint32_t <API key> = NV_PRD_ID_I;
uint32_t product_id[32];
char serial_number[32];
struct <API key> usb_product;//<API key>+
struct smem_host_oem_info *usb_type_info = NULL;
unsigned int info_size;
int len = 0;
int i;
char *src;
char *k_serial;
usb_type_info = smem_get_entry(SMEM_ID_VENDOR2, &info_size);
if(usb_type_info) {
android_usb_pdata.product_id = usb_type_info->host_usb_id;
}
if(msm_proc_comm_oem(<API key>, &<API key>, product_id, &<API key>) == 0) {
memcpy(serial_number, product_id, sizeof(serial_number));
len = strlen(serial_number);
if(len > 0) {
//strlcpy(serial_number, (char*)product_id, sizeof(serial_number));
printk(KERN_INFO"%s: read serial number (%s)\n",__func__, serial_number);
src = serial_number;
//eliminate space char from string start index
while(isspace(*src)) {
src++;
}
k_serial = (char*)kzalloc(16, GFP_KERNEL);
strlcpy(k_serial, src, 16+1);
src = k_serial;
//end of non alpha and number character
while(isalnum(*src)) {
src++;
}
*src = '\0';
if(strlen(k_serial)){
android_usb_pdata.serial_number = k_serial;
}
}
}
src = android_usb_pdata.serial_number;
rndis_pdata.ethaddr[0] = 0x02;
for (i = 0; *src; i++) {
/* XOR the USB serial across the remaining bytes */
rndis_pdata.ethaddr[i % (ETH_ALEN - 1) + 1] ^= *src++;
}
//<API key>*{
<API key> = <API key>;
if(msm_proc_comm_oem(<API key>, &<API key>, product_id, &<API key>) == 0) {
memcpy(&usb_product, product_id, sizeof(usb_product));
printk(KERN_INFO"%s: USB MAGIC NUMBER (%d)", __func__, usb_product.magic_num);
if(usb_product.magic_num == 0x12345678) {//magic number must be 0x12345678 could be effective
printk(KERN_INFO"%s: USB CUSTOMIZED VID(0X%X) PID(0X%X) PRODUCT(%s) MANUFACTURER(%s)\n",
__func__, usb_product.vendor_id, usb_product.product_id, usb_product.product_name, usb_product.manufacturer_name);
if(usb_product.vendor_id && usb_product.product_id) {
android_usb_pdata.vendor_id = usb_product.vendor_id;
if(android_usb_pdata.vendor_id == 0x12d1) {//huawei
fih_usb_full_func = 0x1021;//open all usb functions
android_usb_pdata.num_products = ARRAY_SIZE(usb_products_12d1);
android_usb_pdata.products = usb_products_12d1;
if(android_usb_pdata.product_id == 0xc002) {//recovery mode
android_usb_pdata.product_id = 0x1022;
} else if(android_usb_pdata.product_id == 0xc000) {//diag debug mode enable
android_usb_pdata.product_id = 0x1021;
} else {
android_usb_pdata.product_id = usb_product.product_id;
}
}
}
if(strlen(usb_product.product_name)) {
k_serial = (char*)kzalloc(32, GFP_KERNEL);
strlcpy(k_serial, usb_product.product_name, sizeof(usb_product.product_name));
src = k_serial;
while(isalnum(*src)||isspace(*src)) {
src++;
}
*src = '\0';
if(strlen(k_serial)) {
android_usb_pdata.product_name = k_serial;
}
}
if(strlen(usb_product.manufacturer_name)) {
k_serial = (char*)kzalloc(32, GFP_KERNEL);
strlcpy(k_serial, usb_product.manufacturer_name, sizeof(usb_product.manufacturer_name));
src = k_serial;
while(isalnum(*src)||isspace(*src)) {
src++;
}
*src = '\0';
if(strlen(k_serial)) {
android_usb_pdata.manufacturer_name = k_serial;
rndis_pdata.vendorDescr = k_serial;
mass_storage_pdata.vendor = k_serial;
}
}
}
}
#ifdef CONFIG_FIH_FTM
if(android_usb_pdata.vendor_id == 0x12d1) {//Huawei
android_usb_pdata.product_id = 0x1023;
} else if(android_usb_pdata.vendor_id == 0x489) {//FIH
android_usb_pdata.product_id = 0xc003;
}
android_usb_pdata.serial_number = 0; //set serial number NULL
#endif
printk(KERN_INFO"%s: USB VID(0x%X) PID(0x%X) PRODUCT(%s) MANUFACTURER(%s) SN(%s)\n",
__func__, android_usb_pdata.vendor_id, android_usb_pdata.product_id, android_usb_pdata.product_name, android_usb_pdata.manufacturer_name, android_usb_pdata.serial_number);
//<API key>*}
return 1;
}
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized */
static void __init msm7x30_init_mmc(void)
{
vreg_s3 = vreg_get(NULL, "s3");
if (IS_ERR(vreg_s3)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_s3));
return;
}
vreg_mmc = vreg_get(NULL, "mmc");
if (IS_ERR(vreg_mmc)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_mmc));
return;
}
#ifdef <API key>
if (<API key>()) {
msm7x30_sdc1_data.ocr_mask = MMC_VDD_27_28 | MMC_VDD_28_29;
<API key>();
}
sdcc_vreg_data[0].vreg_data = vreg_s3;
sdcc_vreg_data[0].level = 1800;
msm_add_sdcc(1, &msm7x30_sdc1_data);
#endif
#ifdef <API key>
if (<API key>())
msm7x30_sdc2_data.msmsdcc_fmax = 24576000;
if (<API key>() ||
<API key>()) {
msm7x30_sdc2_data.sdio_lpm_gpio_setup = <API key>;
#ifdef <API key>
msm7x30_sdc2_data.sdiowakeup_irq = MSM_GPIO_TO_INT(68);
#ifdef CONFIG_MSM_SDIO_AL
msm7x30_sdc2_data.is_sdio_al_client = 1;
#endif
#endif
}
sdcc_vreg_data[1].vreg_data = vreg_s3;
sdcc_vreg_data[1].level = 1800;
msm_add_sdcc(2, &msm7x30_sdc2_data);
#endif
#ifdef <API key>
sdcc_vreg_data[2].vreg_data = vreg_s3;
sdcc_vreg_data[2].level = 1800;
msm_sdcc_setup_gpio(3, 1);
msm_add_sdcc(3, &msm7x30_sdc3_data);
#endif
#ifdef <API key>
sdcc_vreg_data[3].vreg_data = vreg_mmc;
sdcc_vreg_data[3].level = 2850;
#ifdef <API key>
switch(fih_get_product_id())
{
case Product_FB0:
{
if(<API key>() ==Product_PR1)
sd_detect_pin = 38;
else
sd_detect_pin = 142;
}
break;
case Product_FB1:
case Product_FB3:
case Product_FD1:
{
sd_detect_pin = 142;
}
break;
case Product_SF6:
{
if(<API key>() ==Product_PR3 || <API key>() == Product_PCR)
sd_detect_pin = 143;
else
sd_detect_pin = 142;
}
break;
case Product_SFH:
{
sd_detect_pin = 142;
}
break;
case Product_SF8:
case Product_SH8:
case Product_SFC:
{
sd_detect_pin = 0;
}
break;
default:
sd_detect_pin = 142;
break;
}
if(sd_detect_pin)
{
gpio_tlmm_config(GPIO_CFG(sd_detect_pin, 0, GPIO_CFG_INPUT, GPIO_CFG_PULL_UP, GPIO_CFG_2MA),
GPIO_CFG_ENABLE);
msm7x30_sdc4_data.status_irq = MSM_GPIO_TO_INT(sd_detect_pin);
}
else
{
msm7x30_sdc4_data.status = NULL;
msm7x30_sdc4_data.status_irq = 0;
}
#endif
switch(fih_get_product_id())
{
case Product_FB0:
case Product_FB1:
case Product_FB3:
case Product_SF6:
case Product_FD1:
{
sd_enable_pin = 85;
}
break;
case Product_SF5:
{
sd_enable_pin = 100;
}
break;
case Product_SF8:
case Product_SFH:
case Product_SH8:
case Product_SFC:
{
sd_enable_pin = 175;
}
break;
default:
sd_enable_pin = 85;
break;
}
gpio_tlmm_config(GPIO_CFG(sd_enable_pin, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
GPIO_CFG_ENABLE);
printk("[SD] id:%d, phase:%d, sd_enable_pin:%d, sd_detect_pin:%d\n", fih_get_product_id(), <API key>(), sd_enable_pin, sd_detect_pin);
msm_add_sdcc(4, &msm7x30_sdc4_data);
#endif
}
static void __init msm7x30_init_nand(void)
{
char *build_id;
struct flash_platform_data *plat_data;
build_id = <API key>();
if (build_id == NULL) {
pr_err("%s: Build ID not available from socinfo\n", __func__);
return;
}
if (build_id[8] == 'C' &&
!<API key>(<API key>,
ARRAY_SIZE(<API key>))) {
plat_data = msm_device_nand.dev.platform_data;
plat_data->interleave = 1;
printk(KERN_INFO "%s: Interleave mode Build ID found\n",
__func__);
}
}
#ifdef <API key>
static struct msm_gpio uart2_config_data[] = {
{ GPIO_CFG(49, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_RFR"},
//{ GPIO_CFG(50, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_CTS"},
{ GPIO_CFG(51, 2, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Rx"},
{ GPIO_CFG(52, 2, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), "UART2_Tx"},
};
static void msm7x30_init_uart2(void)
{
<API key>(uart2_config_data,
ARRAY_SIZE(uart2_config_data));
}
#endif
/* TSIF begin */
#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
#define TSIF_B_SYNC GPIO_CFG(37, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_B_DATA GPIO_CFG(36, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_B_EN GPIO_CFG(35, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
#define TSIF_B_CLK GPIO_CFG(34, 1, GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA)
static const struct msm_gpio tsif_gpios[] = {
{ .gpio_cfg = TSIF_B_CLK, .label = "tsif_clk", },
{ .gpio_cfg = TSIF_B_EN, .label = "tsif_en", },
{ .gpio_cfg = TSIF_B_DATA, .label = "tsif_data", },
{ .gpio_cfg = TSIF_B_SYNC, .label = "tsif_sync", },
};
static struct <API key> tsif_platform_data = {
.num_gpios = ARRAY_SIZE(tsif_gpios),
.gpios = tsif_gpios,
.tsif_pclk = "tsif_pclk",
.tsif_ref_clk = "tsif_ref_clk",
};
#endif /* defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE) */
/* TSIF end */
#ifdef CONFIG_LEDS_PM8058
static void __init pmic8058_leds_init(void)
{
if (<API key>()) {
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
= &<API key>;
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].data_size
= sizeof(<API key>);
} else if (!<API key>()) {
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
= &<API key>;
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].data_size
= sizeof(<API key>);
} else if (<API key>()) {
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].platform_data
= &<API key>;
pm8058_7x30_data.sub_devices[PM8058_SUBDEV_LED].data_size
= sizeof(<API key>);
}
}
#endif
static struct <API key> msm_spm_data __initdata = {
.reg_base_addr = MSM_SAW_BASE,
.reg_init_values[MSM_SPM_REG_SAW_CFG] = 0x05,
.reg_init_values[<API key>] = 0x18,
.reg_init_values[<API key>] = 0x00006666,
.reg_init_values[<API key>] = 0xFF000666,
.reg_init_values[<API key>] = 0x01,
.reg_init_values[<API key>] = 0x03,
.reg_init_values[<API key>] = 0x00,
.reg_init_values[<API key>] = 0x01,
.reg_init_values[<API key>] = 0x00,
.reg_init_values[<API key>] = 0x00,
.awake_vlevel = 0xF2,
.retention_vlevel = 0xE0,
.collapse_vlevel = 0x72,
.<API key> = 0xE0,
.collapse_mid_vlevel = 0xE0,
.vctl_timeout_us = 50,
};
//Div2-SW2-BSP,JOE HSU,+++
//#ifdef <API key>
extern void fxx_info_init(void);
//#endif
#if defined(<API key>) || \
defined(<API key>)
#define TSC2007_TS_PEN_INT 20
static struct msm_gpio tsc2007_config_data[] = {
{ GPIO_CFG(TSC2007_TS_PEN_INT, 0, GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA),
"tsc2007_irq" },
};
static struct vreg *vreg_tsc_s3;
static struct vreg *vreg_tsc_s2;
static int tsc2007_init(void)
{
int rc;
vreg_tsc_s3 = vreg_get(NULL, "s3");
if (IS_ERR(vreg_tsc_s3)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_tsc_s3));
return -ENODEV;
}
rc = vreg_set_level(vreg_tsc_s3, 1800);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_set_level;
}
rc = vreg_enable(vreg_tsc_s3);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_set_level;
}
vreg_tsc_s2 = vreg_get(NULL, "s2");
if (IS_ERR(vreg_tsc_s2)) {
printk(KERN_ERR "%s: vreg get failed (%ld)\n",
__func__, PTR_ERR(vreg_tsc_s2));
goto fail_vreg_get;
}
rc = vreg_set_level(vreg_tsc_s2, 1300);
if (rc) {
pr_err("%s: vreg_set_level failed \n", __func__);
goto fail_vreg_s2_level;
}
rc = vreg_enable(vreg_tsc_s2);
if (rc) {
pr_err("%s: vreg_enable failed \n", __func__);
goto fail_vreg_s2_level;
}
rc = <API key>(tsc2007_config_data,
ARRAY_SIZE(tsc2007_config_data));
if (rc) {
pr_err("%s: Unable to request gpios\n", __func__);
goto fail_gpio_req;
}
return 0;
fail_gpio_req:
vreg_disable(vreg_tsc_s2);
fail_vreg_s2_level:
vreg_put(vreg_tsc_s2);
fail_vreg_get:
vreg_disable(vreg_tsc_s3);
fail_vreg_set_level:
vreg_put(vreg_tsc_s3);
return rc;
}
static int <API key>(void)
{
int rc;
rc = gpio_get_value(TSC2007_TS_PEN_INT);
if (rc < 0) {
pr_err("%s: MSM GPIO %d read failed\n", __func__,
TSC2007_TS_PEN_INT);
return rc;
}
return (rc == 0 ? 1 : 0);
}
static void tsc2007_exit(void)
{
vreg_disable(vreg_tsc_s3);
vreg_put(vreg_tsc_s3);
vreg_disable(vreg_tsc_s2);
vreg_put(vreg_tsc_s2);
<API key>(tsc2007_config_data,
ARRAY_SIZE(tsc2007_config_data));
}
static int <API key>(bool enable)
{
int rc;
if (enable == false) {
rc = vreg_enable(vreg_tsc_s2);
if (rc) {
pr_err("%s: vreg_enable failed\n", __func__);
return rc;
}
rc = vreg_enable(vreg_tsc_s3);
if (rc) {
pr_err("%s: vreg_enable failed\n", __func__);
vreg_disable(vreg_tsc_s2);
return rc;
}
/* Voltage settling delay */
msleep(20);
} else {
rc = vreg_disable(vreg_tsc_s2);
if (rc) {
pr_err("%s: vreg_disable failed\n", __func__);
return rc;
}
rc = vreg_disable(vreg_tsc_s3);
if (rc) {
pr_err("%s: vreg_disable failed\n", __func__);
vreg_enable(vreg_tsc_s2);
return rc;
}
}
return rc;
}
static struct <API key> tsc2007_ts_data = {
.model = 2007,
.x_plate_ohms = 300,
.irq_flags = IRQF_TRIGGER_LOW,
.init_platform_hw = tsc2007_init,
.exit_platform_hw = tsc2007_exit,
.power_shutdown = <API key>,
.invert_x = true,
.invert_y = true,
/* REVISIT: Temporary fix for reversed pressure */
.invert_z1 = true,
.invert_z2 = true,
.get_pendown_state = <API key>,
};
static struct i2c_board_info tsc_i2c_board_info[] = {
{
I2C_BOARD_INFO("tsc2007", 0x48),
.irq = MSM_GPIO_TO_INT(TSC2007_TS_PEN_INT),
.platform_data = &tsc2007_ts_data,
},
};
#endif
static const char *vregs_isa1200_name[] = {
"gp7",
"gp10",
};
static const int vregs_isa1200_val[] = {
1800,
2600,
};
static struct vreg *vregs_isa1200[ARRAY_SIZE(vregs_isa1200_name)];
static int isa1200_power(int vreg_on)
{
int i, rc = 0;
for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
if (!vregs_isa1200[i]) {
pr_err("%s: vreg_get %s failed (%d)\n",
__func__, vregs_isa1200_name[i], rc);
goto vreg_fail;
}
rc = vreg_on ? vreg_enable(vregs_isa1200[i]) :
vreg_disable(vregs_isa1200[i]);
if (rc < 0) {
pr_err("%s: vreg %s %s failed (%d)\n",
__func__, vregs_isa1200_name[i],
vreg_on ? "enable" : "disable", rc);
goto vreg_fail;
}
}
return 0;
vreg_fail:
while (i)
vreg_disable(vregs_isa1200[--i]);
return rc;
}
static int isa1200_dev_setup(bool enable)
{
int i, rc;
if (enable == true) {
for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++) {
vregs_isa1200[i] = vreg_get(NULL,
vregs_isa1200_name[i]);
if (IS_ERR(vregs_isa1200[i])) {
pr_err("%s: vreg get %s failed (%ld)\n",
__func__, vregs_isa1200_name[i],
PTR_ERR(vregs_isa1200[i]));
rc = PTR_ERR(vregs_isa1200[i]);
goto vreg_get_fail;
}
rc = vreg_set_level(vregs_isa1200[i],
vregs_isa1200_val[i]);
if (rc) {
pr_err("%s: vreg_set_level() = %d\n",
__func__, rc);
goto vreg_get_fail;
}
}
rc = gpio_tlmm_config(GPIO_CFG(<API key>, 0,
GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
GPIO_CFG_2MA), GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, <API key>);
goto vreg_get_fail;
}
rc = gpio_request(<API key>, "haptics_shft_lvl_oe");
if (rc) {
pr_err("%s: unable to request gpio %d (%d)\n",
__func__, <API key>, rc);
goto vreg_get_fail;
}
gpio_set_value(<API key>, 1);
} else {
for (i = 0; i < ARRAY_SIZE(vregs_isa1200_name); i++)
vreg_put(vregs_isa1200[i]);
gpio_free(<API key>);
}
return 0;
vreg_get_fail:
while (i)
vreg_put(vregs_isa1200[--i]);
return rc;
}
static struct <API key> isa1200_1_pdata = {
.name = "vibrator",
.power_on = isa1200_power,
.dev_setup = isa1200_dev_setup,
.pwm_ch_id = 1, /*channel id*/
/*gpio to enable haptic*/
.hap_en_gpio = <API key>(<API key>),
.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,
};
static struct i2c_board_info <API key>[] = {
{
I2C_BOARD_INFO("isa1200_1", 0x90>>1),
.platform_data = &isa1200_1_pdata,
},
};
static int kp_flip_mpp_config(void)
{
return <API key>(PM_FLIP_MPP,
<API key>, PM_MPP_DIN_TO_INT);
}
static struct flip_switch_pdata flip_switch_data = {
.name = "kp_flip_switch",
.flip_gpio = <API key>(PM8058_GPIOS) + PM_FLIP_MPP,
.left_key = KEY_OPEN,
.right_key = KEY_CLOSE,
.active_low = 0,
.wakeup = 1,
.flip_mpp_config = kp_flip_mpp_config,
};
static struct platform_device flip_switch_device = {
.name = "kp_flip_switch",
.id = -1,
.dev = {
.platform_data = &flip_switch_data,
}
};
static const char *vregs_tma300_name[] = {
"gp6",
"gp7",
};
static const int vregs_tma300_val[] = {
3050,
1800,
};
static struct vreg *vregs_tma300[ARRAY_SIZE(vregs_tma300_name)];
static int tma300_power(int vreg_on)
{
int i, rc = -EINVAL;
for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
/* Never disable gp6 for fluid as lcd has a problem with it */
if (!i && !vreg_on)
continue;
if (!vregs_tma300[i]) {
printk(KERN_ERR "%s: vreg_get %s failed (%d)\n",
__func__, vregs_tma300_name[i], rc);
return rc;
}
rc = vreg_on ? vreg_enable(vregs_tma300[i]) :
vreg_disable(vregs_tma300[i]);
if (rc < 0) {
printk(KERN_ERR "%s: vreg %s %s failed (%d)\n",
__func__, vregs_tma300_name[i],
vreg_on ? "enable" : "disable", rc);
return rc;
}
}
return 0;
}
#define TS_GPIO_IRQ 150
static int tma300_dev_setup(bool enable)
{
int i, rc;
if (enable) {
/* get voltage sources */
for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++) {
vregs_tma300[i] = vreg_get(NULL, vregs_tma300_name[i]);
if (IS_ERR(vregs_tma300[i])) {
pr_err("%s: vreg get %s failed (%ld)\n",
__func__, vregs_tma300_name[i],
PTR_ERR(vregs_tma300[i]));
rc = PTR_ERR(vregs_tma300[i]);
goto vreg_get_fail;
}
rc = vreg_set_level(vregs_tma300[i],
vregs_tma300_val[i]);
if (rc) {
pr_err("%s: vreg_set_level() = %d\n",
__func__, rc);
i++;
goto vreg_get_fail;
}
}
/* enable interrupt gpio */
rc = gpio_tlmm_config(GPIO_CFG(TS_GPIO_IRQ, 0, GPIO_CFG_INPUT,
GPIO_CFG_PULL_UP, GPIO_CFG_6MA), GPIO_CFG_ENABLE);
if (rc) {
pr_err("%s: Could not configure gpio %d\n",
__func__, TS_GPIO_IRQ);
goto vreg_get_fail;
}
/* virtual keys */
tma300_vkeys_attr.attr.name = "virtualkeys.msm_tma300_ts";
properties_kobj = <API key>("board_properties",
NULL);
if (!properties_kobj) {
pr_err("%s: failed to create a kobject"
"for board_properites\n", __func__);
rc = -ENOMEM;
goto vreg_get_fail;
}
rc = sysfs_create_group(properties_kobj,
&<API key>);
if (rc) {
pr_err("%s: failed to create a sysfs entry %s\n",
__func__, tma300_vkeys_attr.attr.name);
kobject_put(properties_kobj);
goto vreg_get_fail;
}
} else {
/* put voltage sources */
for (i = 0; i < ARRAY_SIZE(vregs_tma300_name); i++)
vreg_put(vregs_tma300[i]);
/* destroy virtual keys */
if (properties_kobj) {
sysfs_remove_group(properties_kobj,
&<API key>);
kobject_put(properties_kobj);
}
}
return 0;
vreg_get_fail:
while (i)
vreg_put(vregs_tma300[--i]);
return rc;
}
static struct <API key> cy8ctma300_pdata = {
.power_on = tma300_power,
.dev_setup = tma300_dev_setup,
.ts_name = "msm_tma300_ts",
.dis_min_x = 0,
.dis_max_x = 479,
.dis_min_y = 0,
.dis_max_y = 799,
.res_x = 479,
.res_y = 1009,
.min_tid = 1,
.max_tid = 255,
.min_touch = 0,
.max_touch = 255,
.min_width = 0,
.max_width = 255,
.invert_y = 1,
.nfingers = 4,
.irq_gpio = TS_GPIO_IRQ,
.resout_gpio = -1,
};
static struct i2c_board_info <API key>[] = {
{
I2C_BOARD_INFO("cy8ctma300", 0x2),
.platform_data = &cy8ctma300_pdata,
}
};
static void __init msm7x30_init(void)
{
int rc;
//<API key>+{
int pid = Product_FB0;
int cnt = 0;
int camera_num = 0;
//<API key>+}
unsigned smem_size;
uint32_t <API key> = GPIO_CFG(56,
0,
GPIO_CFG_OUTPUT,
GPIO_CFG_NO_PULL,
GPIO_CFG_2MA);
uint32_t soc_version = 0;
if (socinfo_init() < 0)
printk(KERN_ERR "%s: socinfo_init() failed!\n",
__func__);
soc_version = socinfo_get_version();
//Div2-SW2-BSP,JOE HSU
fih_get_oem_info();
<API key>(); // <API key>+
msm_clock_init(msm_clocks_7x30, msm_num_clocks_7x30);
#ifdef <API key>
msm7x30_init_uart2();
#endif
msm_spm_init(&msm_spm_data, 1);
msm_acpu_clock_init(&msm7x30_clock_data);
/* Div2-SW2-BSP-FBX-OW { */
#ifdef CONFIG_SMSC911X
if (<API key>() || <API key>())
<API key>();
#endif
/* } Div2-SW2-BSP-FBX-OW */
#ifdef CONFIG_USB_FUNCTION
msm_hsusb_pdata.swfi_latency =
msm_pm_data
[<API key>].latency;
<API key>.dev.platform_data = &msm_hsusb_pdata;
#endif
#ifdef <API key>
if (<API key>(soc_version) >= 2 &&
<API key>(soc_version) >= 1) {
pr_debug("%s: SOC Version:2.(1 or more)\n", __func__);
msm_otg_pdata.ldo_set_voltage = 0;
}
msm_device_otg.dev.platform_data = &msm_otg_pdata;
#ifdef CONFIG_USB_GADGET
msm_otg_pdata.swfi_latency =
msm_pm_data
[<API key>].latency;
<API key>.dev.platform_data = &msm_gadget_pdata;
#endif
#endif
msm_uart_dm1_pdata.wakeup_irq = gpio_to_irq(136);
msm_device_uart_dm1.dev.platform_data = &msm_uart_dm1_pdata;
<API key>();
#if defined(CONFIG_TSIF) || defined(CONFIG_TSIF_MODULE)
msm_device_tsif.dev.platform_data = &tsif_platform_data;
#endif
if (<API key>()) {
msm_adc_pdata.dev_names = <API key>;
msm_adc_pdata.num_adc = ARRAY_SIZE(<API key>);
} else {
msm_adc_pdata.dev_names = <API key>;
msm_adc_pdata.num_adc = ARRAY_SIZE(<API key>);
}
#ifdef CONFIG_USB_ANDROID
if (<API key>() ||
<API key>()) {
android_usb_pdata.product_id = 0x9028;
android_usb_pdata.num_products =
ARRAY_SIZE(fusion_usb_products);
android_usb_pdata.products = fusion_usb_products;
}
#endif
<API key>(devices, ARRAY_SIZE(devices));
#ifdef CONFIG_USB_EHCI_MSM
msm_add_host(0, &msm_usb_host_pdata);
#endif
/* FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized { */
#ifdef CONFIG_FIH_FXX
sync_from_custom_nv(); //<API key>+
#endif // CONFIG_FIH_FXX
/* } FIHTDC, Div2-SW2-BSP, Penho, UsbCustomized */
msm7x30_init_mmc();
msm7x30_init_nand();
msm_qsd_spi_init();
#ifdef CONFIG_SPI_QSD
if (<API key>())
<API key>(<API key>,
ARRAY_SIZE(<API key>));
else
<API key>(<API key>,
ARRAY_SIZE(<API key>));
#endif
msm_fb_add_devices();
<API key>(msm_pm_data, ARRAY_SIZE(msm_pm_data));
/* FIHTDC, Div2-SW2-BSP SungSCLee, HDMI { */
<API key>();
/* } FIHTDC, Div2-SW2-BSP SungSCLee, HDMI */
msm_device_i2c_init();
<API key>();
qup_device_i2c_init();
buses_init();
<API key>();
#ifdef <API key>
<API key>();
aux_pcm_gpio_init();
#endif
#ifdef <API key>
<API key>(); // <API key>
#endif
<API key>(0, msm_i2c_board_info,
ARRAY_SIZE(msm_i2c_board_info));
if (!<API key>())
marimba_pdata.tsadc = &marimba_tsadc_pdata;
if (<API key>())
<API key>(0, cy8info,
ARRAY_SIZE(cy8info));
#ifdef CONFIG_BOSCH_BMA150
if (<API key>())
<API key>(0, bma150_board_info,
ARRAY_SIZE(bma150_board_info));
#endif
<API key>(2, <API key>,
ARRAY_SIZE(<API key>));
//<API key>+{
pid = fih_get_product_id();
camera_num = ARRAY_SIZE(<API key>);
if (pid == Product_SF6 || IS_SF8_SERIES_PRJ())//<API key>*
{
for (cnt = 0; cnt < camera_num; cnt++)
{
if(strncasecmp(<API key>[cnt].type, "mt9p111", 7) == 0)
{
printk(KERN_INFO "%s: Old camera slave address = %x .\n", __func__, <API key>[cnt].addr);
<API key>[cnt].addr = (0x7A >> 1);
printk(KERN_INFO "%s: New camera slave address = %x .\n", __func__, <API key>[cnt].addr);
}
}
if (IS_SF8_SERIES_PRJ())
printk(KERN_INFO "%s: This is SF8 series project.....\n", __func__);
}
//<API key>+}
<API key>(2, <API key>,
ARRAY_SIZE(<API key>));
<API key>(4 /* QUP ID */, <API key>,
ARRAY_SIZE(<API key>));
bt_power_init();
// FihtdcCode@20110908 WeiChu add for WiFi porting begin
// <API key> BCM4329 WLAN driver For SF8 +[
#ifdef <API key>
<API key>();
#endif
// <API key> BCM4329 WLAN driver For SF8 +]
// <API key> BCM4329 BLUETOOTH driver For SF8 +[
#ifdef <API key>
<API key>();
<API key>();
#endif
// <API key> BCM4329 BLUETOOTH driver For SF8 +]
// FihtdcCode@20110908 WeiChu add for WiFi porting end
#ifdef CONFIG_I2C_SSBI
msm_device_ssbi6.dev.platform_data = &msm_i2c_ssbi6_pdata;
msm_device_ssbi7.dev.platform_data = &msm_i2c_ssbi7_pdata;
#endif
if (<API key>())
<API key>(0, <API key>,
ARRAY_SIZE(<API key>));
#if defined(<API key>) || \
defined(<API key>)
if (<API key>())
<API key>(2, tsc_i2c_board_info,
ARRAY_SIZE(tsc_i2c_board_info));
#endif
if (<API key>())
<API key>(&flip_switch_device);
#ifdef CONFIG_LEDS_PM8058
pmic8058_leds_init();
#endif
if (<API key>()) {
/* Initialize platform data for fluid v2 hardware */
if (<API key>(
<API key>()) == 2) {
cy8ctma300_pdata.res_y = 920;
cy8ctma300_pdata.invert_y = 0;
}
<API key>(0, <API key>,
ARRAY_SIZE(<API key>));
}
if (<API key>() || <API key>()) {
rc = gpio_tlmm_config(<API key>, GPIO_CFG_ENABLE);
if (rc)
pr_err("%s: gpio_tlmm_config(%#x)=%d\n",
__func__, <API key>, rc);
}
boot_reason = *(unsigned int *)
(smem_get_entry(<API key>, &smem_size));
printk(KERN_NOTICE "Boot Reason = 0x%02x\n", boot_reason);
//Div2-SW2-BSP,JOE HSU,+++
//#ifdef <API key>
/*call product id functions for init verification*/
fih_get_product_id();
<API key>();
fih_get_band_id();
fxx_info_init();
//#endif
}
static unsigned pmem_sf_size = MSM_PMEM_SF_SIZE;
static int __init pmem_sf_size_setup(char *p)
{
pmem_sf_size = memparse(p, NULL);
return 0;
}
early_param("pmem_sf_size", pmem_sf_size_setup);
static unsigned fb_size = MSM_FB_SIZE;
static int __init fb_size_setup(char *p)
{
fb_size = memparse(p, NULL);
return 0;
}
early_param("fb_size", fb_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 <API key> = <API key>;
static int __init <API key>(char *p)
{
<API key> = memparse(p, NULL);
return 0;
}
early_param("<API key>", <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>);
static unsigned <API key> = <API key>;
static int __init <API key>(char *p)
{
<API key> = memparse(p, NULL);
return 0;
}
early_param("<API key>", <API key>);
static void __init <API key>(void)
{
void *addr;
unsigned long size;
/*
Request allocation of Hardware accessible PMEM regions
at the beginning to make sure they are allocated in EBI-0.
This will allow 7x30 with two mem banks enter the second
mem bank into Self-Refresh State during Idle Power Collapse.
The current HW accessible PMEM regions are
1. Frame Buffer.
LCDC HW can access msm_fb_resources during Idle-PC.
2. Audio
LPA HW can access <API key> during Idle-PC.
*/
size = fb_size ? : MSM_FB_SIZE;
addr = alloc_bootmem(size);
msm_fb_resources[0].start = __pa(addr);
msm_fb_resources[0].end = msm_fb_resources[0].start + size - 1;
pr_info("allocating %lu bytes at %p (%lx physical) for fb\n",
size, addr, __pa(addr));
size = pmem_audio_size;
if (size) {
addr = alloc_bootmem(size);
<API key>.start = __pa(addr);
<API key>.size = size;
pr_info("allocating %lu bytes at %p (%lx physical) for audio "
"pmem arena\n", size, addr, __pa(addr));
}
size = <API key>;
if (size) {
addr = <API key>(size, 0x100000);
<API key>.start = __pa(addr);
<API key>.size = size;
pr_info("allocating %lu bytes at %p (%lx physical) for kernel"
" ebi1 pmem arena\n", size, addr, __pa(addr));
}
size = pmem_sf_size;
if (size) {
addr = alloc_bootmem(size);
android_pmem_pdata.start = __pa(addr);
android_pmem_pdata.size = size;
pr_info("allocating %lu bytes at %p (%lx physical) for sf "
"pmem arena\n", size, addr, __pa(addr));
}
if <API key>()
size = <API key>;
else
size = pmem_adsp_size;
if (size) {
addr = alloc_bootmem(size);
<API key>.start = __pa(addr);
<API key>.size = size;
pr_info("allocating %lu bytes at %p (%lx physical) for adsp "
"pmem arena\n", size, addr, __pa(addr));
}
}
static void __init msm7x30_map_io(void)
{
msm_shared_ram_phys = 0x00100000;
msm_map_msm7x30_io();
<API key>();
}
MACHINE_START(MSM7X30_SURF, "QCT MSM7X30 SURF")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM7X30_FFA, "QCT MSM7X30 FFA")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM7X30_FLUID, "QCT MSM7X30 FLUID")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM8X55_SURF, "QCT MSM8X55 SURF")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM8X55_FFA, "FB0")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM8X55_SVLTE_SURF, "QCT MSM8X55 SVLTE SURF")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
MACHINE_START(MSM8X55_SVLTE_FFA, "QCT MSM8X55 SVLTE FFA")
#ifdef <API key>
.phys_io = MSM_DEBUG_UART_PHYS,
.io_pg_offst = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
#endif
.boot_params = PHYS_OFFSET + 0x100,
.map_io = msm7x30_map_io,
.init_irq = msm7x30_init_irq,
.init_machine = msm7x30_init,
.timer = &msm_timer,
MACHINE_END
|
import MySQLdb
class DatabaseHandler:
def __init__(self):
pass
def is_delete(self, tableName):
<API key> = ["mantis_user_table", "mantis_tokens_table", "mantis_config_table"]
isDeleteFlag = 1
for name in <API key>:
isIdentical = cmp(tableName, name)
if isIdentical == 0:
isDeleteFlag = 0
break
return isDeleteFlag
def Clean_Database(self, hostUrl, account, password, databaseName):
print 'clean database1'
db = MySQLdb.connect(host=hostUrl, user=account, passwd=password, db=databaseName)
cursor = db.cursor()
cursor.execute("Show Tables from " + databaseName)
result = cursor.fetchall()
for record in result:
tableName = record[0]
isDelete = self.is_delete(tableName)
if isDelete == 0:
print "Reserve " + tableName
else :
print "TRUNCATE TABLE `" + tableName + "`"
cursor.execute("TRUNCATE TABLE `" + tableName + "`")
print 'Add admin'
cursor.execute("INSERT INTO `account` VALUES (1, 'admin', 'admin', 'example@ezScrum.tw', '<API key>', 1, 1379910191599, 1379910191599)")
cursor.execute("INSERT INTO `system` VALUES (1, 1)")
db.commit()
#if __name__ == '__main__':
# databaseHandler = DatabaseHandler()
# databaseHandler.clean_database("localhost", "spark", "spark", "robottest")
|
#!/usr/bin/ruby
require File.expand_path(ENV['MOSYNCDIR']+'/rules/mosync_exe.rb')
work = PipeExeWork.new
work.instance_eval do
@SOURCES = ["."]
@LIBRARIES = ["mautil"]
@NAME = "Stylus"
end
work.invoke
|
<!DOCTYPE HTML PUBLIC "-
<!--NewPage
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_06) on Wed Dec 28 15:03:50 CET 2005 -->
<TITLE>
SimpleTextGUI01
</TITLE>
<META NAME="keywords" CONTENT="jmatlink.ui.SimpleTextGUI01 class">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="SimpleTextGUI01";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<A NAME="navbar_top"></A>
<A HREF="#skip-navbar_top" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SimpleTextGUI01.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../jmatlink/ui/SimpleTestGui02.html" title="class in jmatlink.ui"><B>PREV CLASS</B></A>
<A HREF="../../jmatlink/ui/SimpleTextGUI02.html" title="class in jmatlink.ui"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="SimpleTextGUI01.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
</SCRIPT>
<NOSCRIPT>
<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A>
<HR>
<H2>
<FONT SIZE="-1">
jmatlink.ui</FONT>
<BR>
Class SimpleTextGUI01</H2>
<PRE>
java.lang.Object
<IMG SRC="../../resources/inherit.gif" ALT="extended by"><B>jmatlink.ui.SimpleTextGUI01</B>
</PRE>
<HR>
<DL>
<DT>public class <B>SimpleTextGUI01</B><DT>extends java.lang.Object</DL>
<P>
<HR>
<P>
<A NAME="constructor_summary"></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Constructor Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE><B><A HREF="../../jmatlink/ui/SimpleTextGUI01.html#SimpleTextGUI01()">SimpleTextGUI01</A></B>()</CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="method_summary"></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=2><FONT SIZE="+2">
<B>Method Summary</B></FONT></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1">
<CODE>static void</CODE></FONT></TD>
<TD><CODE><B><A HREF="../../jmatlink/ui/SimpleTextGUI01.html#main(java.lang.String[])">main</A></B>(java.lang.String[] args)</CODE>
<BR>
</TD>
</TR>
</TABLE>
<A NAME="<API key>.lang.Object"></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#EEEEFF" CLASS="<API key>">
<TD><B>Methods inherited from class java.lang.Object</B></TD>
</TR>
<TR BGCOLOR="white" CLASS="TableRowColor">
<TD><CODE>clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait</CODE></TD>
</TR>
</TABLE>
<P>
<A NAME="constructor_detail"></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Constructor Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="SimpleTextGUI01()"></A><H3>
SimpleTextGUI01</H3>
<PRE>
public <B>SimpleTextGUI01</B>()</PRE>
<DL>
</DL>
<A NAME="method_detail"></A>
<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY="">
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<TD COLSPAN=1><FONT SIZE="+2">
<B>Method Detail</B></FONT></TD>
</TR>
</TABLE>
<A NAME="main(java.lang.String[])"></A><H3>
main</H3>
<PRE>
public static void <B>main</B>(java.lang.String[] args)</PRE>
<DL>
<DD><DL>
</DL>
</DD>
</DL>
<HR>
<A NAME="navbar_bottom"></A>
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="<API key>"></A>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/SimpleTextGUI01.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../index-files/index-1.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../jmatlink/ui/SimpleTestGui02.html" title="class in jmatlink.ui"><B>PREV CLASS</B></A>
<A HREF="../../jmatlink/ui/SimpleTextGUI02.html" title="class in jmatlink.ui"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="SimpleTextGUI01.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!
if(window==top) {
document.writeln('<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>');
}
</SCRIPT>
<NOSCRIPT>
<A HREF="../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_bottom"></A>
<HR>
</BODY>
</HTML>
|
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
#include <errno.h>
#include <sys/mount.h>
#include <string.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sched.h>
#include <sys/syscall.h>
#include <limits.h>
#include <linux/fs.h>
#include "strv.h"
#include "util.h"
#include "path-util.h"
#include "namespace.h"
#include "missing.h"
#include "execute.h"
typedef enum MountMode {
/* This is ordered by priority! */
INACCESSIBLE,
READONLY,
PRIVATE_TMP,
PRIVATE_VAR_TMP,
READWRITE
} MountMode;
typedef struct BindMount {
const char *path;
MountMode mode;
bool done;
bool ignore;
} BindMount;
static int append_mounts(BindMount **p, char **strv, MountMode mode) {
char **i;
STRV_FOREACH(i, strv) {
(*p)->ignore = false;
if ((mode == INACCESSIBLE || mode == READONLY) && (*i)[0] == '-') {
(*p)->ignore = true;
(*i)++;
}
if (!path_is_absolute(*i))
return -EINVAL;
(*p)->path = *i;
(*p)->mode = mode;
(*p)++;
}
return 0;
}
static int mount_path_compare(const void *a, const void *b) {
const BindMount *p = a, *q = b;
if (path_equal(p->path, q->path)) {
/* If the paths are equal, check the mode */
if (p->mode < q->mode)
return -1;
if (p->mode > q->mode)
return 1;
return 0;
}
/* If the paths are not equal, then order prefixes first */
if (path_startswith(p->path, q->path))
return 1;
if (path_startswith(q->path, p->path))
return -1;
return 0;
}
static void drop_duplicates(BindMount *m, unsigned *n) {
BindMount *f, *t, *previous;
assert(m);
assert(n);
for (f = m, t = m, previous = NULL; f < m+*n; f++) {
/* The first one wins */
if (previous && path_equal(f->path, previous->path))
continue;
t->path = f->path;
t->mode = f->mode;
previous = t;
t++;
}
*n = t - m;
}
static int apply_mount(
BindMount *m,
const char *tmp_dir,
const char *var_tmp_dir) {
const char *what;
int r;
assert(m);
switch (m->mode) {
case INACCESSIBLE:
what = "/run/systemd/inaccessible";
break;
case READONLY:
case READWRITE:
what = m->path;
break;
case PRIVATE_TMP:
what = tmp_dir;
break;
case PRIVATE_VAR_TMP:
what = var_tmp_dir;
break;
default:
assert_not_reached("Unknown mode");
}
assert(what);
r = mount(what, m->path, NULL, MS_BIND|MS_REC, NULL);
if (r >= 0)
log_debug("Successfully mounted %s to %s", what, m->path);
else if (m->ignore && errno == ENOENT)
r = 0;
return r;
}
static int make_read_only(BindMount *m) {
int r;
assert(m);
if (m->mode != INACCESSIBLE && m->mode != READONLY)
return 0;
r = mount(NULL, m->path, NULL, MS_BIND|MS_REMOUNT|MS_RDONLY|MS_REC, NULL);
if (r < 0 && !(m->ignore && errno == ENOENT))
return -errno;
return 0;
}
int setup_tmpdirs(const char *unit_id,
char **tmp_dir,
char **var_tmp_dir) {
int r = 0;
_cleanup_free_ char *tmp = NULL, *var = NULL;
assert(tmp_dir);
assert(var_tmp_dir);
tmp = strjoin("/tmp/systemd-", unit_id, "-XXXXXXX", NULL);
var = strjoin("/var/tmp/systemd-", unit_id, "-XXXXXXX", NULL);
r = create_tmp_dir(tmp, tmp_dir);
if (r < 0)
return r;
r = create_tmp_dir(var, var_tmp_dir);
if (r == 0)
return 0;
/* failure */
rmdir(*tmp_dir);
rmdir(tmp);
free(*tmp_dir);
*tmp_dir = NULL;
return r;
}
int setup_namespace(char** read_write_dirs,
char** read_only_dirs,
char** inaccessible_dirs,
char* tmp_dir,
char* var_tmp_dir,
bool private_tmp,
unsigned mount_flags) {
unsigned n = strv_length(read_write_dirs) +
strv_length(read_only_dirs) +
strv_length(inaccessible_dirs) +
(private_tmp ? 2 : 0);
BindMount *m, *mounts = NULL;
int r = 0;
if (!mount_flags)
mount_flags = MS_SHARED;
if (unshare(CLONE_NEWNS) < 0)
return -errno;
if (n) {
m = mounts = (BindMount *) alloca(n * sizeof(BindMount));
if ((r = append_mounts(&m, read_write_dirs, READWRITE)) < 0 ||
(r = append_mounts(&m, read_only_dirs, READONLY)) < 0 ||
(r = append_mounts(&m, inaccessible_dirs, INACCESSIBLE)) < 0)
return r;
if (private_tmp) {
m->path = "/tmp";
m->mode = PRIVATE_TMP;
m++;
m->path = "/var/tmp";
m->mode = PRIVATE_VAR_TMP;
m++;
}
assert(mounts + n == m);
qsort(mounts, n, sizeof(BindMount), mount_path_compare);
drop_duplicates(mounts, &n);
}
/* Remount / as SLAVE so that nothing now mounted in the namespace
shows up in the parent */
if (mount(NULL, "/", NULL, MS_SLAVE|MS_REC, NULL) < 0)
return -errno;
for (m = mounts; m < mounts + n; ++m) {
r = apply_mount(m, tmp_dir, var_tmp_dir);
if (r < 0)
goto undo_mounts;
}
for (m = mounts; m < mounts + n; ++m) {
r = make_read_only(m);
if (r < 0)
goto undo_mounts;
}
/* Remount / as the desired mode */
if (mount(NULL, "/", NULL, mount_flags | MS_REC, NULL) < 0) {
r = -errno;
goto undo_mounts;
}
return 0;
undo_mounts:
for (m = mounts; m < mounts + n; ++m) {
if (m->done)
umount2(m->path, MNT_DETACH);
}
return r;
}
|
import com.oracle.java.testlibrary.Asserts;
import java.lang.management.MemoryType;
import sun.hotspot.code.BlobType;
public class BeanTypeTest {
public static void main(String args[]) {
for (BlobType bt : BlobType.getAvailable()) {
Asserts.assertEQ(MemoryType.NON_HEAP, bt.getMemoryPool().getType());
}
}
}
|
#include "EOSProjectData.h"
EOSProjectData::EOSProjectData()
{
}
EOSProjectData::~EOSProjectData()
{
}
|
#include <glib/gstdio.h>
#include "prpltwtr.h"
typedef struct {
PurpleAccount *account;
gchar *username;
} <TwitterConsumerkey>;
static GHashTable *o<API key>(const gchar * txt);
static void <API key>(<TwitterConsumerkey> * change, gint action_id);
static void <API key>(<TwitterConsumerkey> * change, gint action_id);
static void <API key>(PurpleAccount * account, const gchar * username);
static void <API key>(TwitterRequestor * r, xmlnode * node, gpointer user_data);
static void <API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data);
static void o<API key>(TwitterRequestor * r, const gchar * response, gpointer user_data);
static void o<API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data);
static const gchar *<API key>(PurpleAccount * account);
static void <API key>(PurpleAccount * account, const gchar * oauth_token);
static const gchar *account_get_o<API key>(PurpleAccount * account);
static void account_set_o<API key>(PurpleAccount * account, const gchar * oauth_token);
static void <API key>(PurpleAccount * account, const gchar * pin);
static void o<API key>(PurpleAccount * account, const gchar * pin);
static void o<API key>(TwitterRequestor * r, const gchar * response, gpointer user_data);
static void o<API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data);
static const gchar *<TwitterConsumerkey>(PurpleAccount * account);
static const gchar *<TwitterConsumerkey>(PurpleAccount * account);
static const gchar *<TwitterConsumerkey>(PurpleAccount * account);
static const gchar *<TwitterConsumerkey>(PurpleAccount * account, const gchar * endpoint);
void prpltwtr_<API key>(PurpleAccount * account)
{
<API key>(account, NULL);
account_set_o<API key>(account, NULL);
}
void prpltwtr_<API key>(TwitterRequestor * r, gboolean * post, const char **url, <TwitterConsumerkey> ** params, gchar *** header_fields, gpointer * requestor_data)
{
const char *pass = <API key>(<API key>(r->account));
char **userparts = g_strsplit(<API key>(r->account), "@", 2);
const char *sn = userparts[0];
char *auth_text = g_strdup_printf("%s:%s", sn, pass);
char *auth_text_b64 = <API key>((guchar *) auth_text, strlen(auth_text));
*header_fields = g_new(gchar *, 2);
(*header_fields)[0] = g_strdup_printf("Authorization: Basic %s", auth_text_b64);
(*header_fields)[1] = NULL;
g_strfreev(userparts);
g_free(auth_text);
g_free(auth_text_b64);
}
void prpltwtr_<API key>(TwitterRequestor * r, gboolean * post, const char **url, <TwitterConsumerkey> ** params, gchar *** header_fields, gpointer * requestor_data)
{
g_strfreev(*header_fields);
}
const gchar *<API key>(PurpleAccount * account)
{
if (!strcmp(<API key>(account), <TwitterConsumerkey>)) {
return <TwitterConsumerkey>;
} else {
const gchar *key = <API key>(account, <TwitterConsumerkey>, "");
if (!strcmp(key, "")) {
purple_debug_error(<API key>(account), "No Consumer key specified!\n");
}
return key;
}
}
const gchar *prpltwtr_<API key>(PurpleAccount * account)
{
if (!strcmp(<API key>(account), <TwitterConsumerkey>)) {
return <TwitterConsumerkey>;
} else {
const gchar *<API key>(account, <TwitterConsumerkey>, "");
if (!strcmp(secret, "")) {
purple_debug_error(<API key>(account), "No Consumer secret specified!\n");
}
return secret;
}
}
void <API key>(TwitterRequestor * r, gboolean * post, const char **url, <TwitterConsumerkey> ** params, gchar *** header_fields, gpointer * requestor_data)
{
PurpleAccount *account = r->account;
PurpleConnection *gc = <API key>(account);
<TwitterConsumerkey> *twitter = gc->proto_data;
gchar *signing_key = g_strdup_printf("%s&%s",
prpltwtr_<API key>(account),
twitter->oauth_token_secret ? twitter->oauth_token_secret : "");
<TwitterConsumerkey> *oauth_params = <TwitterConsumerkey>(account, *post, *url,
*params, twitter->oauth_token, signing_key);
if (oauth_params == NULL) {
<TwitterConsumerkey> *error = g_new0(<TwitterConsumerkey>, 1);
gchar *error_msg = g_strdup(_("Could not sign request"));
error->type = <TwitterConsumerkey>;
error->message = error_msg;
g_free(error_msg);
g_free(error);
g_free(signing_key);
//TODO: error if couldn't sign
return;
}
g_free(signing_key);
*requestor_data = *params;
*params = oauth_params;
}
void <API key>(PurpleAccount * account, <TwitterConsumerkey> * twitter)
{
const gchar *oauth_token;
const gchar *oauth_token_secret;
oauth_<API key>(account);
oauth_token_<API key>(account);
if (oauth_token && oauth_token_secret) {
twitter->oauth_token = g_strdup(oauth_token);
twitter->oauth_token_secret = g_strdup(oauth_token_secret);
<TwitterConsumerkey>(<API key>(account), <API key>, <API key>, NULL);
} else {
<TwitterConsumerkey>(<API key>(account), FALSE, <TwitterConsumerkey>(account), NULL, o<API key>, o<API key>, NULL);
}
}
void prpltwtr_<API key>(TwitterRequestor * r, gboolean * post, const char **url, <TwitterConsumerkey> ** params, gchar *** header_fields, gpointer * requestor_data)
{
<TwitterConsumerkey>(*params);
*params = (<TwitterConsumerkey> *) * requestor_data;
}
static void o<API key>(TwitterRequestor * r, const gchar * response, gpointer user_data)
{
PurpleAccount *account = r->account;
PurpleConnection *gc = <API key>(account);
<TwitterConsumerkey> *twitter = gc->proto_data;
GHashTable *results = o<API key>(response);
const gchar *oauth_<API key>(results, "oauth_token");
const gchar *oauth_token_<API key>(results, "oauth_token_secret");
const gchar *<API key> = g_hash_table_lookup(results, "screen_name");
if (oauth_token && oauth_token_secret) {
if (twitter->oauth_token)
g_free(twitter->oauth_token);
if (twitter->oauth_token_secret)
g_free(twitter->oauth_token_secret);
twitter->oauth_token = g_strdup(oauth_token);
twitter->oauth_token_secret = g_strdup(oauth_token_secret);
<API key>(account, oauth_token);
account_set_o<API key>(account, oauth_token_secret);
//FIXME: set this to be case insensitive
{
char **userparts = g_strsplit(<API key>(r->account), "@", 2);
const char *username = userparts[0];
if (<API key> && !<TwitterConsumerkey>(account, <API key>, username)) {
<API key>(account, <API key>);
} else {
<API key>(account);
}
g_strfreev(userparts);
}
} else {
purple_debug_error(<API key>(account), "Unknown error receiving access token: %s\n", response);
prpltwtr_disconnect(account, _("Unknown response getting access token"));
}
}
static void o<API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data)
{
gchar *error = g_strdup_printf(_("Error verifying PIN: %s"), error_data->message ? error_data->message : _("unknown error"));
prpltwtr_disconnect(r->account, error);
g_free(error);
}
static GHashTable *o<API key>(const gchar * txt)
{
gchar **pieces = g_strsplit(txt, "&", 0);
GHashTable *results = <API key>(g_str_hash, g_str_equal, g_free, g_free);
gchar **p;
for (p = pieces; *p; p++) {
gchar *equalpos = strchr(*p, '=');
if (equalpos) {
equalpos[0] = '\0';
<API key>(results, g_strdup(*p), g_strdup(equalpos + 1));
}
}
g_strfreev(pieces);
return results;
}
static void <API key>(<TwitterConsumerkey> * change, gint action_id)
{
PurpleAccount *account = change->account;
prpltwtr_<API key>(account);
g_free(change->username);
g_free(change);
prpltwtr_disconnect(account, _("Username mismatch"));
}
static void <API key>(<TwitterConsumerkey> * change, gint action_id)
{
PurpleAccount *account = change->account;
<API key>(account, change->username);
g_free(change->username);
g_free(change);
<API key>(account);
}
static void <API key>(PurpleAccount * account, const gchar * username)
{
PurpleConnection *gc = <API key>(account);
gchar *secondary = g_strdup_printf(_("Do you wish to change the name on this account to %s?"), username);
<TwitterConsumerkey> *change_data = (<TwitterConsumerkey> *) g_new0(<TwitterConsumerkey> *, 1);
change_data->account = account;
change_data->username = g_strdup(username);
<API key>(gc, _("Mismatched Screen Names"), _("Authorized screen name does not match with account screen name"), secondary, 0, account, NULL, NULL, change_data, 2, _("Cancel"), <API key>, _("Yes"), <API key>, NULL);
g_free(secondary);
}
static void <API key>(TwitterRequestor * r, xmlnode * node, gpointer user_data)
{
PurpleAccount *account = r->account;
TwitterUserTweet *user_tweet = <TwitterConsumerkey>(node);
char **userparts = g_strsplit(<API key>(r->account), "@", 2);
const char *username = userparts[0];
if (!user_tweet || !user_tweet->screen_name) {
prpltwtr_disconnect(account, _("Could not verify credentials"));
} else if (!<TwitterConsumerkey>(account, user_tweet->screen_name, username)) {
<API key>(account, user_tweet->screen_name);
} else {
<API key>(account);
}
g_strfreev(userparts);
<TwitterConsumerkey>(user_tweet);
}
static void <API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data)
{
gchar *error = g_strdup_printf(_("Error verifying credentials: %s"), error_data->message ? error_data->message : _("unknown error"));
switch (error_data->type) {
case <TwitterConsumerkey>:
case <TwitterConsumerkey>:
<API key>(r->account, error);
break;
case <TwitterConsumerkey>:
case <TwitterConsumerkey>:
case <TwitterConsumerkey>:
case <TwitterConsumerkey>:
case <TwitterConsumerkey>:
default:
prpltwtr_disconnect(r->account, error);
break;
}
g_free(error);
}
static void o<API key>(TwitterRequestor * r, const gchar * response, gpointer user_data)
{
PurpleAccount *account = r->account;
PurpleConnection *gc = <API key>(account);
<TwitterConsumerkey> *twitter = gc->proto_data;
GHashTable *results = o<API key>(response);
const gchar *oauth_<API key>(results, "oauth_token");
const gchar *oauth_token_<API key>(results, "oauth_token_secret");
if (oauth_token && oauth_token_secret) {
gchar *msg = g_strdup_printf("http://%s?oauth_token=%s",
<TwitterConsumerkey>(account),
purple_url_encode(oauth_token));
gchar *prompt = g_strdup_printf("%s %s", _("Please enter PIN for"), <API key>(account));
twitter->oauth_token = g_strdup(oauth_token);
twitter->oauth_token_secret = g_strdup(oauth_token_secret);
purple_notify_uri(twitter, msg);
<API key>(twitter, _("OAuth Authentication"), //title
prompt, //primary
msg, //secondary
NULL, //default
FALSE, //multiline,
FALSE, //password
NULL, //hint
_("Submit"), //ok text
G_CALLBACK(<API key>), _("Cancel"), G_CALLBACK(o<API key>), account, NULL, NULL, account);
g_free(msg);
g_free(prompt);
} else {
purple_debug_error(<API key>(account), "Unknown error receiving request token: %s\n", response);
prpltwtr_disconnect(account, _("Invalid response receiving request token"));
}
<API key>(results);
}
static void o<API key>(TwitterRequestor * r, const <TwitterConsumerkey> * error_data, gpointer user_data)
{
gchar *error = g_strdup_printf(_("Error receiving request token: %s"), error_data->message ? error_data->message : _("unknown error"));
prpltwtr_disconnect(r->account, error);
g_free(error);
}
static const gchar *<API key>(PurpleAccount * account)
{
return <API key>(account, "oauth_token", NULL);
}
static void <API key>(PurpleAccount * account, const gchar * oauth_token)
{
<API key>(account, "oauth_token", oauth_token);
}
static const gchar *account_get_o<API key>(PurpleAccount * account)
{
return <API key>(account, "oauth_token_secret", NULL);
}
static void account_set_o<API key>(PurpleAccount * account, const gchar * oauth_token)
{
<API key>(account, "oauth_token_secret", oauth_token);
}
static void <API key>(PurpleAccount * account, const gchar * pin)
{
<TwitterConsumerkey> *params = <TwitterConsumerkey>();
<TwitterConsumerkey>(params, <TwitterConsumerkey>("oauth_verifier", pin));
<TwitterConsumerkey>(<API key>(account), FALSE, <TwitterConsumerkey>(account), params, o<API key>, o<API key>, NULL);
<TwitterConsumerkey>(params);
}
static void o<API key>(PurpleAccount * account, const gchar * pin)
{
prpltwtr_disconnect(account, _("Canceled PIN entry"));
}
static const gchar *<TwitterConsumerkey>(PurpleAccount * account)
{
return <TwitterConsumerkey>(account, "/authorize");
}
static const gchar *<TwitterConsumerkey>(PurpleAccount * account)
{
return <TwitterConsumerkey>(account, "/request_token");
}
static const gchar *<TwitterConsumerkey>(PurpleAccount * account)
{
return <TwitterConsumerkey>(account, "/access_token");
}
static const gchar *<TwitterConsumerkey>(PurpleAccount * account, const gchar * endpoint)
{
static char url[1024];
char host[256];
<API key>(endpoint != NULL && endpoint[0] != '\0', NULL);
if (!strcmp(<API key>(account), <TwitterConsumerkey>)) {
snprintf(host, 255, "api.twitter.com/oauth");
} else {
snprintf(host, 255, "%s/oauth", <API key>(account, <TwitterConsumerkey>, <API key>));
}
snprintf(url, 1023, "%s%s%s", host, host[strlen(host) - 1] == '/' || endpoint[0] == '/' ? "" : "/", host[strlen(host) - 1] == '/' && endpoint[0] == '/' ? endpoint + 1 : endpoint);
return url;
}
|
/*
* Definitions for akm8975 compass chip.
*/
#ifndef AKM8975_H
#define AKM8975_H
#include <linux/ioctl.h>
#define AKM8975_I2C_NAME "akm8975"
/*! \name AK8975 operation mode
\anchor AK8975_Mode
Defines an operation mode of the AK8975.*/
#define <API key> 0x01
#define <API key> 0x08
#define <API key> 0x0F
#define <API key> 0x00
#define SENSOR_DATA_SIZE 8
#define RWBUF_SIZE 16
/*! \name AK8975 register address
\anchor AK8975_REG
Defines a register address of the AK8975.*/
#define AK8975_REG_WIA 0x00
#define AK8975_REG_INFO 0x01
#define AK8975_REG_ST1 0x02
#define AK8975_REG_HXL 0x03
#define AK8975_REG_HXH 0x04
#define AK8975_REG_HYL 0x05
#define AK8975_REG_HYH 0x06
#define AK8975_REG_HZL 0x07
#define AK8975_REG_HZH 0x08
#define AK8975_REG_ST2 0x09
#define AK8975_REG_CNTL 0x0A
#define AK8975_REG_RSV 0x0B
#define AK8975_REG_ASTC 0x0C
#define AK8975_REG_TS1 0x0D
#define AK8975_REG_TS2 0x0E
#define AK8975_REG_I2CDIS 0x0F
/*! \name AK8975 fuse-rom address
\anchor AK8975_FUSE
Defines a read-only address of the fuse ROM of the AK8975.*/
#define AK8975_FUSE_ASAX 0x10
#define AK8975_FUSE_ASAY 0x11
#define AK8975_FUSE_ASAZ 0x12
#define AKMIO 0xA1
/* IOCTLs for AKM library */
#define ECS_IOCTL_WRITE _IOW(AKMIO, 0x01, char*)
#define ECS_IOCTL_READ _IOWR(AKMIO, 0x02, char*)
#define ECS_IOCTL_RESET _IO(AKMIO, 0x03)
#define ECS_IOCTL_SET_MODE _IOW(AKMIO, 0x04, short)
#define ECS_IOCTL_GETDATA _IOR(AKMIO, 0x05, char[SENSOR_DATA_SIZE])
#define ECS_IOCTL_SET_YPR _IOW(AKMIO, 0x06, short[12])
#define <API key> _IOR(AKMIO, 0x07, int)
#define <API key> _IOR(AKMIO, 0x08, int)
#define ECS_IOCTL_GET_DELAY _IOR(AKMIO, 0x30, short)
#define <API key> _IOR(AKMIO, 0x0D, char[64])
#define <API key> _IOR(AKMIO, 0x0E, short [4][3][3])
/* IOCTLs for APPs */
#define <API key> _IOW(AKMIO, 0x10, short)/* NOT use */
#define <API key> _IOW(AKMIO, 0x11, short)
#define <API key> _IOW(AKMIO, 0x12, short)
#define <API key> _IOW(AKMIO, 0x13, short)
#define <API key> _IOR(AKMIO, 0x14, short)
#define <API key> _IOR(AKMIO, 0x15, short)/* NOT use */
#define <API key> _IOR(AKMIO, 0x16, short)/* NOT use */
#define <API key> _IO(AKMIO, 0x17) /* NOT use */
#define <API key> _IOW(AKMIO, 0x18, short)
#define <API key> ECS_IOCTL_GET_DELAY
#define <API key> _IOW(AKMIO, 0x19, short)
#define <API key> _IOR(AKMIO, 0x1A, short)
#define <API key> _IOR(AKMIO, 0x1B, short) /* Get proximity flag */
#define <API key> _IOR(AKMIO, 0x1C, short) /* Set proximity flag */
#define <API key> _IOR(AKMIO, 0x20, char[30])
#define <API key> _IOR(AKMIO, 0x21, int[7])
#define <API key> _IOR(AKMIO, 0x22, signed short[18])
#define <API key> _IOR(AKMIO, 0x23, signed short[18])
#define <API key> _IOWR(AKMIO, 0x31, int)
#define <API key> _IOWR(AKMIO, 0x32, int)
/* original source
struct <API key> {
char layouts[3][3];
char project_name[64];
int gpio_DRDY;
};
*/
#endif
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http:
<html>
<head>
<title>Swift Kanban Webinar Series</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="robots" content="noindex,nofollow"/>
</head>
<body>
<table align="center"
style="float:none;width:500px; background-color:#FFFFFF; border: none; border-width: 0px; font-family: Arial;">
<tbody>
<!
<td style="width:5px;"></td>
<td colspan="2" style="width:540px; text-align:center;">
<span style='font-size:9px;'>If you are not able to view the email properly click
<a href='http:
</td>
<td style="width:5px;"></td>
</tr>
<tr style="vertical-align: middle;">
<td style="width:5px;"></td>
<td style="width:120px; text-align: left;">
<a href="http:
<img
src="http://app.streamsend.com/public_images/266321/images/kanban.JPG" border="0"
alt="Swift kanban Logo"/>
</a>
</td>
<td style="width:370px; text-align: right;font-family: Arial; font-size: 13px; font-weight: bold; vertical-align: bottom;">
Dr. Masa Maeda Webinar
</td>
<td style="width:5px;"></td>
</tr>
<tr>
<td style="width:5px;"></td>
<td colspan="2" style="width:540px; text-align: left;font-size: 8px;">
<hr style="border: none;background-color:#d3d3d3;height: 3px;"/>
</td>
<td style="width:5px;"></td>
</tr>
<tr>
<td style="width:5px;"></td>
<td colspan="2" style="width:540px; text-align: left;font-family: Arial;font-weight: bold;line-height: 24px;">
<span style="font-size: 13px; color: #000000;">Webinar: Jun 06, 2012; 10 AM - 11 AM Pacific</span><br/>
</td>
<td style="width:5px;"></td>
</tr>
<tr>
<td style="width:5px;"></td>
<td colspan="2" style="width:500px; text-align: center;">
<center><a
href="http:
<img src="http:
style="width: 500px;height:101px;"/>
</a></center>
</td>
<td style="width:5px;"></td>
</tr>
<tr style="height: 0px; font-size: 5px;">
<td colspan="3" style="height: 0px"> </td>
</tr>
<tr>
<td style="width:5px;"></td>
<td colspan="2"
style="width:540px; text-align: justify;font-family: Arial; font-size: 13px; line-height: 20px;">
<b style="line-height: 30px;">Kanban - Beyond IT and Software!</b><br/>
One of the important contributors to the success of several organizations is alignment of IT strategy with
Business for achieving Corporate Goals. If <strong><em>Reduced Waste</em></strong> and <strong><em>Smooth Flow</em></strong> (or streamlined processes)
throughout the enterprise are part of your corporate strategy, then you should look at Kanban. While Kanban
is making waves in IT operations and Software development, it is also proving invaluable for a number of
forward-thinking business functions such as HR, sales, marketing, insurance claims and more! <br/>
<br/>
Come hear Dr. Masa K Maeda, renowned thought leader, consultant and coach for Lean Value Innovation, discuss
the tremendous benefits of Kanban not only in IT but also for other divisions or BUs of your organization
like Sales. <u>Invite your business colleagues</u> to collaboratively use Kanban for improving throughput, quality
and other business benefits throughout the enterprise.
<br/>
<br/>
<b style="font-size: 15px;">Click <a href="http:
here</a> to Register for the webinar</b><br/>
Date: Jun 06, 2012; 10 AM - 11 AM Pacific
<br/>
<br/>
Thank you and we hope that you will join us!
<br/>
<br/>
Swift-Kanban Team
<br/>
<a href="http:
</td>
<td style="width:5px;"></td>
</tr>
<tr>
<td style="width:5px;"></td>
<td colspan="2" style="width:540px;height:5px;">
</td>
<td style="width:5px;"></td>
</tr>
<!-- Social Media starts here-->
<tr style="background-color: #99FFFF;">
<td colspan="3" style="width:540px;height:20px;">
<table>
<tr>
<td style="text-align: left;">
<table style="float: left;">
<tr>
<td align="right" valign="middle" style='color: #000000;
font-family: "Arial";
font-size:14px;'>
Follow us:
</td>
<td align="center" valign="middle"
style='color: #000000; font-family: "Arial";font-size:14px;'>
<a style="text-decoration: none; border: medium none;" target="_blank"
href="http:
src="http://cache.addthis.com/icons/v1/thumbs/facebook.gif"
width="16px" border="0" alt=" f" title="Facebook"/></a>
</td>
<td align="center" valign="middle"
style='color: #000000; font-family: "Arial";font-size:14px;'>
<a style="text-decoration: none;" target="_blank"
href="http://twitter.com/swiftkanban"><img
src="http://cache.addthis.com/icons/v1/thumbs/twitter.gif"
width="16px" hspace="0" border="0" alt=" t" title="Twitter"></a>
</td>
<td align="center" valign="middle"
style='color: #000000; font-family: "Arial";font-size:14px;'>
<a target="_blank" href="http:
src="http://cache.addthiscdn.com/icons/v1/thumbs/blogger.gif"
width="16px" border="0" alt=" B" title="Blog"></a>
</td>
<td align="center" valign="middle"
style='color:#000000; font-family: "Arial";font-size:14px;'></a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<!-- Social Media ends here -->
<tr>
<td colspan="3" style="width:540px; text-align: justify;font-family: Arial; font-size: 11px;">
Digite, Inc. is a leading provider of Lean/ Agile ALM and PPM products and solutions, based out of Mountain
View, CA.
Digite products and solutions have helped thousands of users around the world manage and deliver large and
complex projects
and applications executed by distributed teams, both
in-house and outsourced. To learn more, please visit
<a href="http:
style="text-decoration: none;">www.swift-kanban.com</a> or
<a href="http:
<br/>
</a><em>Copyright © 2012 Digite, Inc. All rights reserved.</em> <br/>
You are receiving this email as you signed up with Digite or one of our media partners.
If you have any questions, please contact us at <a href="mailto:marketing@digite.com"
style="text-decoration: none;">marketing@digite.com
</a>
<br/>
<br/>
Our mailing address is: Digite, Inc., 82 Pioneer Way, Suite 102, Mountain View, CA 94041
<br/><br/>
<!-- To manage your communication preferences/subscription with us <a href="{{{unsubscribe}}}">click here</a> -->
</td>
</tr>
</tbody>
</table>
</body>
</html>
|
package org.opennms.protocols.jmx.connectors;
import javax.management.<API key>;
/**
* <p>ConnectionWrapper interface.</p>
*
* @author ranger
* @version $Id: $
*/
public interface ConnectionWrapper {
/**
* <p>getMBeanServer</p>
*
* @return a {@link javax.management.<API key>} object.
*/
public <API key> getMBeanServer();
/**
* <p>close</p>
*/
public void close();
}
|
/* $Id: UIMachineDefs.h $ */
/** @file
* VBox Qt GUI - Defines for Virtual Machine classes.
*/
#ifndef __UIMachineDefs_h__
#define __UIMachineDefs_h__
/* Global includes */
#include <iprt/cdefs.h>
/* Machine elements enum: */
enum UIVisualElement
{
<API key> = RT_BIT(0),
<API key> = RT_BIT(1),
<API key> = RT_BIT(2),
<API key> = RT_BIT(3),
<API key> = RT_BIT(4),
<API key> = RT_BIT(5),
<API key> = RT_BIT(6),
<API key> = RT_BIT(7),
<API key> = RT_BIT(8),
<API key> = RT_BIT(9),
<API key> = RT_BIT(10),
<API key> = RT_BIT(11),
#ifndef Q_WS_MAC
<API key> = RT_BIT(12),
#endif /* !Q_WS_MAC */
<API key> = 0xFFFF
};
/* Mouse states enum: */
enum UIMouseStateType
{
<API key> = RT_BIT(0),
<API key> = RT_BIT(1),
<API key> = RT_BIT(2),
<API key> = RT_BIT(3)
};
/* Machine View states enum: */
enum UIViewStateType
{
<API key> = RT_BIT(0),
<API key> = RT_BIT(1)
};
#endif // __UIMachineDefs_h__
|
#include <linux/dccp.h>
#include <linux/icmp.h>
#include <linux/module.h>
#include <linux/skbuff.h>
#include <linux/random.h>
#include <net/icmp.h>
#include <net/inet_common.h>
#include <net/inet_hashtables.h>
#include <net/inet_sock.h>
#include <net/protocol.h>
#include <net/sock.h>
#include <net/timewait_sock.h>
#include <net/tcp_states.h>
#include <net/xfrm.h>
#include "ackvec.h"
#include "ccid.h"
#include "dccp.h"
#include "feat.h"
/*
* This is the global socket data structure used for responding to
* the Out-of-the-blue (OOTB) packets. A control sock will be created
* for this socket at the initialization time.
*/
static struct socket *dccp_v4_ctl_socket;
static int dccp_v4_get_port(struct sock *sk, const unsigned short snum)
{
return inet_csk_get_port(&dccp_hashinfo, sk, snum,
<API key>);
}
int dccp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
{
struct inet_sock *inet = inet_sk(sk);
struct dccp_sock *dp = dccp_sk(sk);
const struct sockaddr_in *usin = (struct sockaddr_in *)uaddr;
struct rtable *rt;
__be32 daddr, nexthop;
int tmp;
int err;
dp->dccps_role = DCCP_ROLE_CLIENT;
if (addr_len < sizeof(struct sockaddr_in))
return -EINVAL;
if (usin->sin_family != AF_INET)
return -EAFNOSUPPORT;
nexthop = daddr = usin->sin_addr.s_addr;
if (inet->opt != NULL && inet->opt->srr) {
if (daddr == 0)
return -EINVAL;
nexthop = inet->opt->faddr;
}
tmp = ip_route_connect(&rt, nexthop, inet->saddr,
RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
IPPROTO_DCCP,
inet->sport, usin->sin_port, sk);
if (tmp < 0)
return tmp;
if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
ip_rt_put(rt);
return -ENETUNREACH;
}
if (inet->opt == NULL || !inet->opt->srr)
daddr = rt->rt_dst;
if (inet->saddr == 0)
inet->saddr = rt->rt_src;
inet->rcv_saddr = inet->saddr;
inet->dport = usin->sin_port;
inet->daddr = daddr;
inet_csk(sk)->icsk_ext_hdr_len = 0;
if (inet->opt != NULL)
inet_csk(sk)->icsk_ext_hdr_len = inet->opt->optlen;
/*
* Socket identity is still unknown (sport may be zero).
* However we set state to DCCP_REQUESTING and not releasing socket
* lock select source port, enter ourselves into the hash tables and
* complete initialization after this.
*/
dccp_set_state(sk, DCCP_REQUESTING);
err = inet_hash_connect(&dccp_death_row, sk);
if (err != 0)
goto failure;
err = ip_route_newports(&rt, IPPROTO_DCCP, inet->sport, inet->dport,
sk);
if (err != 0)
goto failure;
/* OK, now commit destination to socket. */
sk_setup_caps(sk, &rt->u.dst);
dp->dccps_iss = <API key>(inet->saddr, inet->daddr,
inet->sport, inet->dport);
inet->id = dp->dccps_iss ^ jiffies;
err = dccp_connect(sk);
rt = NULL;
if (err != 0)
goto failure;
out:
return err;
failure:
/*
* This unhashes the socket and releases the local port, if necessary.
*/
dccp_set_state(sk, DCCP_CLOSED);
ip_rt_put(rt);
sk->sk_route_caps = 0;
inet->dport = 0;
goto out;
}
EXPORT_SYMBOL_GPL(dccp_v4_connect);
/*
* This routine does path mtu discovery as defined in RFC1191.
*/
static inline void <API key>(struct sock *sk,
const struct iphdr *iph,
u32 mtu)
{
struct dst_entry *dst;
const struct inet_sock *inet = inet_sk(sk);
const struct dccp_sock *dp = dccp_sk(sk);
/* We are not interested in DCCP_LISTEN and request_socks (RESPONSEs
* send out by Linux are always < 576bytes so they should go through
* unfragmented).
*/
if (sk->sk_state == DCCP_LISTEN)
return;
/* We don't check in the destentry if pmtu discovery is forbidden
* on this route. We just assume that no packet_to_big packets
* are send back when pmtu discovery is not active.
* There is a small race when the user changes this flag in the
* route, but I think that's acceptable.
*/
if ((dst = __sk_dst_check(sk, 0)) == NULL)
return;
dst->ops->update_pmtu(dst, mtu);
/* Something is about to be wrong... Remember soft error
* for the case, if this connection will not able to recover.
*/
if (mtu < dst_mtu(dst) && ip_dont_fragment(sk, dst))
sk->sk_err_soft = EMSGSIZE;
mtu = dst_mtu(dst);
if (inet->pmtudisc != IP_PMTUDISC_DONT &&
inet_csk(sk)->icsk_pmtu_cookie > mtu) {
dccp_sync_mss(sk, mtu);
/*
* From RFC 4340, sec. 14.1:
*
* DCCP-Sync packets are the best choice for upward
* probing, since DCCP-Sync probes do not risk application
* data loss.
*/
dccp_send_sync(sk, dp->dccps_gsr, DCCP_PKT_SYNC);
} /* else let the usual retransmit timer handle it */
}
/*
* This routine is called by the ICMP module when it gets some sort of error
* condition. If err < 0 then the socket should be closed and the error
* returned to the user. If err > 0 it's just the icmp type << 8 | icmp code.
* After adjustment header points to the first 8 bytes of the tcp header. We
* need to find the appropriate port.
*
* The locking strategy used here is very "optimistic". When someone else
* accesses the socket the ICMP is just dropped and for some paths there is no
* check at all. A more general error queue to queue errors for later handling
* is probably better.
*/
static void dccp_v4_err(struct sk_buff *skb, u32 info)
{
const struct iphdr *iph = (struct iphdr *)skb->data;
const struct dccp_hdr *dh = (struct dccp_hdr *)(skb->data +
(iph->ihl << 2));
struct dccp_sock *dp;
struct inet_sock *inet;
const int type = skb->h.icmph->type;
const int code = skb->h.icmph->code;
struct sock *sk;
__u64 seq;
int err;
if (skb->len < (iph->ihl << 2) + 8) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
return;
}
sk = inet_lookup(&dccp_hashinfo, iph->daddr, dh->dccph_dport,
iph->saddr, dh->dccph_sport, inet_iif(skb));
if (sk == NULL) {
ICMP_INC_STATS_BH(ICMP_MIB_INERRORS);
return;
}
if (sk->sk_state == DCCP_TIME_WAIT) {
inet_twsk_put(inet_twsk(sk));
return;
}
bh_lock_sock(sk);
/* If too many ICMPs get dropped on busy
* servers this needs to be solved differently.
*/
if (sock_owned_by_user(sk))
NET_INC_STATS_BH(<API key>);
if (sk->sk_state == DCCP_CLOSED)
goto out;
dp = dccp_sk(sk);
seq = dccp_hdr_seq(skb);
if (sk->sk_state != DCCP_LISTEN &&
!between48(seq, dp->dccps_swl, dp->dccps_swh)) {
NET_INC_STATS_BH(<API key>);
goto out;
}
switch (type) {
case ICMP_SOURCE_QUENCH:
/* Just silently ignore these. */
goto out;
case ICMP_PARAMETERPROB:
err = EPROTO;
break;
case ICMP_DEST_UNREACH:
if (code > NR_ICMP_UNREACH)
goto out;
if (code == ICMP_FRAG_NEEDED) { /* PMTU discovery (RFC1191) */
if (!sock_owned_by_user(sk))
<API key>(sk, iph, info);
goto out;
}
err = icmp_err_convert[code].errno;
break;
case ICMP_TIME_EXCEEDED:
err = EHOSTUNREACH;
break;
default:
goto out;
}
switch (sk->sk_state) {
struct request_sock *req , **prev;
case DCCP_LISTEN:
if (sock_owned_by_user(sk))
goto out;
req = inet_csk_search_req(sk, &prev, dh->dccph_dport,
iph->daddr, iph->saddr);
if (!req)
goto out;
/*
* ICMPs are not backlogged, hence we cannot get an established
* socket here.
*/
BUG_TRAP(!req->sk);
if (seq != dccp_rsk(req)->dreq_iss) {
NET_INC_STATS_BH(<API key>);
goto out;
}
/*
* Still in RESPOND, just remove it silently.
* There is no good way to pass the error to the newly
* created socket, and POSIX does not want network
* errors returned from accept().
*/
<API key>(sk, req, prev);
goto out;
case DCCP_REQUESTING:
case DCCP_RESPOND:
if (!sock_owned_by_user(sk)) {
DCCP_INC_STATS_BH(<API key>);
sk->sk_err = err;
sk->sk_error_report(sk);
dccp_done(sk);
} else
sk->sk_err_soft = err;
goto out;
}
/* If we've already connected we will keep trying
* until we time out, or the user gives up.
*
* rfc1122 4.2.3.9 allows to consider as hard errors
* only PROTO_UNREACH and PORT_UNREACH (well, FRAG_FAILED too,
* but it is obsoleted by pmtu discovery).
*
* Note, that in modern internet, where routing is unreliable
* and in each dark corner broken firewalls sit, sending random
* errors ordered by their masters even this two messages finally lose
* their original sense (even Linux sends invalid PORT_UNREACHs)
*
* Now we are in compliance with RFCs.
* --ANK (980905)
*/
inet = inet_sk(sk);
if (!sock_owned_by_user(sk) && inet->recverr) {
sk->sk_err = err;
sk->sk_error_report(sk);
} else /* Only an error on timeout */
sk->sk_err_soft = err;
out:
bh_unlock_sock(sk);
sock_put(sk);
}
static inline __sum16 dccp_v4_csum_finish(struct sk_buff *skb,
__be32 src, __be32 dst)
{
return csum_tcpudp_magic(src, dst, skb->len, IPPROTO_DCCP, skb->csum);
}
void dccp_v4_send_check(struct sock *sk, int unused, struct sk_buff *skb)
{
const struct inet_sock *inet = inet_sk(sk);
struct dccp_hdr *dh = dccp_hdr(skb);
dccp_csum_outgoing(skb);
dh->dccph_checksum = dccp_v4_csum_finish(skb, inet->saddr, inet->daddr);
}
EXPORT_SYMBOL_GPL(dccp_v4_send_check);
static inline u64 <API key>(const struct sk_buff *skb)
{
return <API key>(skb->nh.iph->daddr,
skb->nh.iph->saddr,
dccp_hdr(skb)->dccph_dport,
dccp_hdr(skb)->dccph_sport);
}
/*
* The three way handshake has completed - we got a valid ACK or DATAACK -
* now create the new socket.
*
* This is the equivalent of TCP's <API key>
*/
struct sock *<API key>(struct sock *sk, struct sk_buff *skb,
struct request_sock *req,
struct dst_entry *dst)
{
struct inet_request_sock *ireq;
struct inet_sock *newinet;
struct dccp_sock *newdp;
struct sock *newsk;
if (sk_acceptq_is_full(sk))
goto exit_overflow;
if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
goto exit;
newsk = <API key>(sk, req, skb);
if (newsk == NULL)
goto exit;
sk_setup_caps(newsk, dst);
newdp = dccp_sk(newsk);
newinet = inet_sk(newsk);
ireq = inet_rsk(req);
newinet->daddr = ireq->rmt_addr;
newinet->rcv_saddr = ireq->loc_addr;
newinet->saddr = ireq->loc_addr;
newinet->opt = ireq->opt;
ireq->opt = NULL;
newinet->mc_index = inet_iif(skb);
newinet->mc_ttl = skb->nh.iph->ttl;
newinet->id = jiffies;
dccp_sync_mss(newsk, dst_mtu(dst));
__inet_hash(&dccp_hashinfo, newsk, 0);
__inet_inherit_port(&dccp_hashinfo, sk, newsk);
return newsk;
exit_overflow:
NET_INC_STATS_BH(<API key>);
exit:
NET_INC_STATS_BH(<API key>);
dst_release(dst);
return NULL;
}
EXPORT_SYMBOL_GPL(<API key>);
static struct sock *dccp_v4_hnd_req(struct sock *sk, struct sk_buff *skb)
{
const struct dccp_hdr *dh = dccp_hdr(skb);
const struct iphdr *iph = skb->nh.iph;
struct sock *nsk;
struct request_sock **prev;
/* Find possible connection requests. */
struct request_sock *req = inet_csk_search_req(sk, &prev,
dh->dccph_sport,
iph->saddr, iph->daddr);
if (req != NULL)
return dccp_check_req(sk, skb, req, prev);
nsk = <API key>(&dccp_hashinfo,
iph->saddr, dh->dccph_sport,
iph->daddr, dh->dccph_dport,
inet_iif(skb));
if (nsk != NULL) {
if (nsk->sk_state != DCCP_TIME_WAIT) {
bh_lock_sock(nsk);
return nsk;
}
inet_twsk_put(inet_twsk(nsk));
return NULL;
}
return sk;
}
static struct dst_entry* dccp_v4_route_skb(struct sock *sk,
struct sk_buff *skb)
{
struct rtable *rt;
struct flowi fl = { .oif = ((struct rtable *)skb->dst)->rt_iif,
.nl_u = { .ip4_u =
{ .daddr = skb->nh.iph->saddr,
.saddr = skb->nh.iph->daddr,
.tos = RT_CONN_FLAGS(sk) } },
.proto = sk->sk_protocol,
.uli_u = { .ports =
{ .sport = dccp_hdr(skb)->dccph_dport,
.dport = dccp_hdr(skb)->dccph_sport }
}
};
<API key>(skb, &fl);
if (<API key>(&rt, &fl, sk, 0)) {
IP_INC_STATS_BH(<API key>);
return NULL;
}
return &rt->u.dst;
}
static int <API key>(struct sock *sk, struct request_sock *req,
struct dst_entry *dst)
{
int err = -1;
struct sk_buff *skb;
/* First, grab a route. */
if (dst == NULL && (dst = inet_csk_route_req(sk, req)) == NULL)
goto out;
skb = dccp_make_response(sk, dst, req);
if (skb != NULL) {
const struct inet_request_sock *ireq = inet_rsk(req);
struct dccp_hdr *dh = dccp_hdr(skb);
dh->dccph_checksum = dccp_v4_csum_finish(skb, ireq->loc_addr,
ireq->rmt_addr);
memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
err = <API key>(skb, sk, ireq->loc_addr,
ireq->rmt_addr,
ireq->opt);
err = net_xmit_eval(err);
}
out:
dst_release(dst);
return err;
}
static void <API key>(struct sock *sk, struct sk_buff *rxskb)
{
int err;
struct dccp_hdr *rxdh = dccp_hdr(rxskb), *dh;
const int dccp_hdr_reset_len = sizeof(struct dccp_hdr) +
sizeof(struct dccp_hdr_ext) +
sizeof(struct dccp_hdr_reset);
struct sk_buff *skb;
struct dst_entry *dst;
u64 seqno = 0;
/* Never send a reset in response to a reset. */
if (rxdh->dccph_type == DCCP_PKT_RESET)
return;
if (((struct rtable *)rxskb->dst)->rt_type != RTN_LOCAL)
return;
dst = dccp_v4_route_skb(dccp_v4_ctl_socket->sk, rxskb);
if (dst == NULL)
return;
skb = alloc_skb(dccp_v4_ctl_socket->sk->sk_prot->max_header,
GFP_ATOMIC);
if (skb == NULL)
goto out;
/* Reserve space for headers. */
skb_reserve(skb, dccp_v4_ctl_socket->sk->sk_prot->max_header);
skb->dst = dst_clone(dst);
dh = dccp_zeroed_hdr(skb, dccp_hdr_reset_len);
/* Build DCCP header and checksum it. */
dh->dccph_type = DCCP_PKT_RESET;
dh->dccph_sport = rxdh->dccph_dport;
dh->dccph_dport = rxdh->dccph_sport;
dh->dccph_doff = dccp_hdr_reset_len / 4;
dh->dccph_x = 1;
dccp_hdr_reset(skb)->dccph_reset_code =
DCCP_SKB_CB(rxskb)->dccpd_reset_code;
/* See "8.3.1. Abnormal Termination" in RFC 4340 */
if (DCCP_SKB_CB(rxskb)->dccpd_ack_seq != <API key>)
dccp_set_seqno(&seqno, DCCP_SKB_CB(rxskb)->dccpd_ack_seq + 1);
dccp_hdr_set_seq(dh, seqno);
dccp_hdr_set_ack(dccp_hdr_ack_bits(skb), DCCP_SKB_CB(rxskb)->dccpd_seq);
dccp_csum_outgoing(skb);
dh->dccph_checksum = dccp_v4_csum_finish(skb, rxskb->nh.iph->saddr,
rxskb->nh.iph->daddr);
bh_lock_sock(dccp_v4_ctl_socket->sk);
err = <API key>(skb, dccp_v4_ctl_socket->sk,
rxskb->nh.iph->daddr,
rxskb->nh.iph->saddr, NULL);
bh_unlock_sock(dccp_v4_ctl_socket->sk);
if (net_xmit_eval(err) == 0) {
DCCP_INC_STATS_BH(DCCP_MIB_OUTSEGS);
DCCP_INC_STATS_BH(DCCP_MIB_OUTRSTS);
}
out:
dst_release(dst);
}
static void <API key>(struct request_sock *req)
{
kfree(inet_rsk(req)->opt);
}
static struct request_sock_ops <API key> __read_mostly = {
.family = PF_INET,
.obj_size = sizeof(struct dccp_request_sock),
.rtx_syn_ack = <API key>,
.send_ack = dccp_reqsk_send_ack,
.destructor = <API key>,
.send_reset = <API key>,
};
int <API key>(struct sock *sk, struct sk_buff *skb)
{
struct inet_request_sock *ireq;
struct request_sock *req;
struct dccp_request_sock *dreq;
const __be32 service = dccp_hdr_request(skb)->dccph_req_service;
struct dccp_skb_cb *dcb = DCCP_SKB_CB(skb);
__u8 reset_code = <API key>;
/* Never answer to DCCP_PKT_REQUESTs send to broadcast or multicast */
if (((struct rtable *)skb->dst)->rt_flags &
(RTCF_BROADCAST | RTCF_MULTICAST)) {
reset_code = <API key>;
goto drop;
}
if (<API key>(sk, service)) {
reset_code = <API key>;
goto drop;
}
/*
* TW buckets are converted to open requests without
* limitations, they conserve resources and peer is
* evidently real one.
*/
if (<API key>(sk))
goto drop;
/*
* Accept backlog is full. If we have already queued enough
* of warm entries in syn queue, drop request. It is better than
* clogging syn queue with openreqs with exponentially increasing
* timeout.
*/
if (sk_acceptq_is_full(sk) && <API key>(sk) > 1)
goto drop;
req = reqsk_alloc(&<API key>);
if (req == NULL)
goto drop;
if (dccp_parse_options(sk, skb))
goto drop_and_free;
dccp_reqsk_init(req, skb);
if (<API key>(sk, skb, req))
goto drop_and_free;
ireq = inet_rsk(req);
ireq->loc_addr = skb->nh.iph->daddr;
ireq->rmt_addr = skb->nh.iph->saddr;
ireq->opt = NULL;
/*
* Step 3: Process LISTEN state
*
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookie
*
* In fact we defer setting S.GSR, S.SWL, S.SWH to
* <API key>.
*/
dreq = dccp_rsk(req);
dreq->dreq_isr = dcb->dccpd_seq;
dreq->dreq_iss = <API key>(skb);
dreq->dreq_service = service;
if (<API key>(sk, req, NULL))
goto drop_and_free;
<API key>(sk, req, DCCP_TIMEOUT_INIT);
return 0;
drop_and_free:
reqsk_free(req);
drop:
DCCP_INC_STATS_BH(<API key>);
dcb->dccpd_reset_code = reset_code;
return -1;
}
EXPORT_SYMBOL_GPL(<API key>);
int dccp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
{
struct dccp_hdr *dh = dccp_hdr(skb);
if (sk->sk_state == DCCP_OPEN) { /* Fast path */
if (<API key>(sk, skb, dh, skb->len))
goto reset;
return 0;
}
/*
* Step 3: Process LISTEN state
* If P.type == Request or P contains a valid Init Cookie option,
* (* Must scan the packet's options to check for Init
* Cookies. Only Init Cookies are processed here,
* however; other options are processed in Step 8. This
* scan need only be performed if the endpoint uses Init
* Cookies *)
* (* Generate a new socket and switch to that socket *)
* Set S := new socket for this port pair
* S.state = RESPOND
* Choose S.ISS (initial seqno) or set from Init Cookies
* Initialize S.GAR := S.ISS
* Set S.ISR, S.GSR, S.SWL, S.SWH from packet or Init Cookies
* Continue with S.state == RESPOND
* (* A Response packet will be generated in Step 11 *)
* Otherwise,
* Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return
*
* NOTE: the check for the packet types is done in
* <API key>
*/
if (sk->sk_state == DCCP_LISTEN) {
struct sock *nsk = dccp_v4_hnd_req(sk, skb);
if (nsk == NULL)
goto discard;
if (nsk != sk) {
if (dccp_child_process(sk, nsk, skb))
goto reset;
return 0;
}
}
if (<API key>(sk, skb, dh, skb->len))
goto reset;
return 0;
reset:
<API key>(sk, skb);
discard:
kfree_skb(skb);
return 0;
}
EXPORT_SYMBOL_GPL(dccp_v4_do_rcv);
/**
* dccp_invalid_packet - check for malformed packets
* Implements RFC 4340, 8.5: Step 1: Check header basics
* Packets that fail these checks are ignored and do not receive Resets.
*/
int dccp_invalid_packet(struct sk_buff *skb)
{
const struct dccp_hdr *dh;
unsigned int cscov;
if (skb->pkt_type != PACKET_HOST)
return 1;
/* If the packet is shorter than 12 bytes, drop packet and return */
if (!pskb_may_pull(skb, sizeof(struct dccp_hdr))) {
DCCP_WARN("pskb_may_pull failed\n");
return 1;
}
dh = dccp_hdr(skb);
/* If P.type is not understood, drop packet and return */
if (dh->dccph_type >= DCCP_PKT_INVALID) {
DCCP_WARN("invalid packet type\n");
return 1;
}
/*
* If P.Data Offset is too small for packet type, drop packet and return
*/
if (dh->dccph_doff < dccp_hdr_len(skb) / sizeof(u32)) {
DCCP_WARN("P.Data Offset(%u) too small\n", dh->dccph_doff);
return 1;
}
/*
* If P.Data Offset is too too large for packet, drop packet and return
*/
if (!pskb_may_pull(skb, dh->dccph_doff * sizeof(u32))) {
DCCP_WARN("P.Data Offset(%u) too large\n", dh->dccph_doff);
return 1;
}
/*
* If P.type is not Data, Ack, or DataAck and P.X == 0 (the packet
* has short sequence numbers), drop packet and return
*/
if (dh->dccph_type >= DCCP_PKT_DATA &&
dh->dccph_type <= DCCP_PKT_DATAACK && dh->dccph_x == 0) {
DCCP_WARN("P.type (%s) not Data || [Data]Ack, while P.X == 0\n",
dccp_packet_name(dh->dccph_type));
return 1;
}
/*
* If P.CsCov is too large for the packet size, drop packet and return.
* This must come _before_ checksumming (not as RFC 4340 suggests).
*/
cscov = dccp_csum_coverage(skb);
if (cscov > skb->len) {
DCCP_WARN("P.CsCov %u exceeds packet length %d\n",
dh->dccph_cscov, skb->len);
return 1;
}
/* If header checksum is incorrect, drop packet and return.
* (This step is completed in the AF-dependent functions.) */
skb->csum = skb_checksum(skb, 0, cscov, 0);
return 0;
}
EXPORT_SYMBOL_GPL(dccp_invalid_packet);
/* this is called when real data arrives */
static int dccp_v4_rcv(struct sk_buff *skb)
{
const struct dccp_hdr *dh;
struct sock *sk;
int min_cov;
/* Step 1: Check header basics */
if (dccp_invalid_packet(skb))
goto discard_it;
/* Step 1: If header checksum is incorrect, drop packet and return */
if (dccp_v4_csum_finish(skb, skb->nh.iph->saddr, skb->nh.iph->daddr)) {
DCCP_WARN("dropped packet with invalid checksum\n");
goto discard_it;
}
dh = dccp_hdr(skb);
DCCP_SKB_CB(skb)->dccpd_seq = dccp_hdr_seq(skb);
DCCP_SKB_CB(skb)->dccpd_type = dh->dccph_type;
dccp_pr_debug("%8.8s "
"src=%u.%u.%u.%u@%-5d "
"dst=%u.%u.%u.%u@%-5d seq=%llu",
dccp_packet_name(dh->dccph_type),
NIPQUAD(skb->nh.iph->saddr), ntohs(dh->dccph_sport),
NIPQUAD(skb->nh.iph->daddr), ntohs(dh->dccph_dport),
(unsigned long long) DCCP_SKB_CB(skb)->dccpd_seq);
if (<API key>(skb)) {
DCCP_SKB_CB(skb)->dccpd_ack_seq = <API key>;
dccp_pr_debug_cat("\n");
} else {
DCCP_SKB_CB(skb)->dccpd_ack_seq = dccp_hdr_ack_seq(skb);
dccp_pr_debug_cat(", ack=%llu\n", (unsigned long long)
DCCP_SKB_CB(skb)->dccpd_ack_seq);
}
/* Step 2:
* Look up flow ID in table and get corresponding socket */
sk = __inet_lookup(&dccp_hashinfo,
skb->nh.iph->saddr, dh->dccph_sport,
skb->nh.iph->daddr, dh->dccph_dport,
inet_iif(skb));
/*
* Step 2:
* If no socket ...
*/
if (sk == NULL) {
dccp_pr_debug("failed to look up flow ID in table and "
"get corresponding socket\n");
goto no_dccp_socket;
}
/*
* Step 2:
* ... or S.state == TIMEWAIT,
* Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return
*/
if (sk->sk_state == DCCP_TIME_WAIT) {
dccp_pr_debug("sk->sk_state == DCCP_TIME_WAIT: do_time_wait\n");
inet_twsk_put(inet_twsk(sk));
goto no_dccp_socket;
}
/*
* RFC 4340, sec. 9.2.1: Minimum Checksum Coverage
* o if MinCsCov = 0, only packets with CsCov = 0 are accepted
* o if MinCsCov > 0, also accept packets with CsCov >= MinCsCov
*/
min_cov = dccp_sk(sk)->dccps_pcrlen;
if (dh->dccph_cscov && (min_cov == 0 || dh->dccph_cscov < min_cov)) {
dccp_pr_debug("Packet CsCov %d does not satisfy MinCsCov %d\n",
dh->dccph_cscov, min_cov);
/* FIXME: "Such packets SHOULD be reported using Data Dropped
* options (Section 11.7) with Drop Code 0, Protocol
* Constraints." */
goto discard_and_relse;
}
if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb))
goto discard_and_relse;
nf_reset(skb);
return sk_receive_skb(sk, skb, 1);
no_dccp_socket:
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb))
goto discard_it;
/*
* Step 2:
* If no socket ...
* Generate Reset(No Connection) unless P.type == Reset
* Drop packet and return
*/
if (dh->dccph_type != DCCP_PKT_RESET) {
DCCP_SKB_CB(skb)->dccpd_reset_code =
<API key>;
<API key>(sk, skb);
}
discard_it:
kfree_skb(skb);
return 0;
discard_and_relse:
sock_put(sk);
goto discard_it;
}
static struct <API key> dccp_ipv4_af_ops = {
.queue_xmit = ip_queue_xmit,
.send_check = dccp_v4_send_check,
.rebuild_header = <API key>,
.conn_request = <API key>,
.syn_recv_sock = <API key>,
.net_header_len = sizeof(struct iphdr),
.setsockopt = ip_setsockopt,
.getsockopt = ip_getsockopt,
.addr2sockaddr = <API key>,
.sockaddr_len = sizeof(struct sockaddr_in),
#ifdef CONFIG_COMPAT
.compat_setsockopt = <API key>,
.compat_getsockopt = <API key>,
#endif
};
static int dccp_v4_init_sock(struct sock *sk)
{
static __u8 <API key>;
int err = dccp_init_sock(sk, <API key>);
if (err == 0) {
if (unlikely(!<API key>))
<API key> = 1;
inet_csk(sk)->icsk_af_ops = &dccp_ipv4_af_ops;
}
return err;
}
static struct timewait_sock_ops <API key> = {
.twsk_obj_size = sizeof(struct inet_timewait_sock),
};
static struct proto dccp_v4_prot = {
.name = "DCCP",
.owner = THIS_MODULE,
.close = dccp_close,
.connect = dccp_v4_connect,
.disconnect = dccp_disconnect,
.ioctl = dccp_ioctl,
.init = dccp_v4_init_sock,
.setsockopt = dccp_setsockopt,
.getsockopt = dccp_getsockopt,
.sendmsg = dccp_sendmsg,
.recvmsg = dccp_recvmsg,
.backlog_rcv = dccp_v4_do_rcv,
.hash = dccp_hash,
.unhash = dccp_unhash,
.accept = inet_csk_accept,
.get_port = dccp_v4_get_port,
.shutdown = dccp_shutdown,
.destroy = dccp_destroy_sock,
.orphan_count = &dccp_orphan_count,
.max_header = MAX_DCCP_HEADER,
.obj_size = sizeof(struct dccp_sock),
.rsk_prot = &<API key>,
.twsk_prot = &<API key>,
#ifdef CONFIG_COMPAT
.compat_setsockopt = <API key>,
.compat_getsockopt = <API key>,
#endif
};
static struct net_protocol dccp_v4_protocol = {
.handler = dccp_v4_rcv,
.err_handler = dccp_v4_err,
.no_policy = 1,
};
static const struct proto_ops inet_dccp_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release,
.bind = inet_bind,
.connect = inet_stream_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = inet_getname,
/* FIXME: work on tcp_poll to rename it to inet_csk_poll */
.poll = dccp_poll,
.ioctl = inet_ioctl,
/* FIXME: work on inet_listen to rename it to sock_common_listen */
.listen = inet_dccp_listen,
.shutdown = inet_shutdown,
.setsockopt = <API key>,
.getsockopt = <API key>,
.sendmsg = inet_sendmsg,
.recvmsg = sock_common_recvmsg,
.mmap = sock_no_mmap,
.sendpage = sock_no_sendpage,
#ifdef CONFIG_COMPAT
.compat_setsockopt = <API key>,
.compat_getsockopt = <API key>,
#endif
};
static struct inet_protosw dccp_v4_protosw = {
.type = SOCK_DCCP,
.protocol = IPPROTO_DCCP,
.prot = &dccp_v4_prot,
.ops = &inet_dccp_ops,
.capability = -1,
.no_check = 0,
.flags = INET_PROTOSW_ICSK,
};
static int __init dccp_v4_init(void)
{
int err = proto_register(&dccp_v4_prot, 1);
if (err != 0)
goto out;
err = inet_add_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
if (err != 0)
goto <API key>;
<API key>(&dccp_v4_protosw);
err = <API key>(&dccp_v4_ctl_socket, PF_INET,
SOCK_DCCP, IPPROTO_DCCP);
if (err)
goto <API key>;
out:
return err;
<API key>:
<API key>(&dccp_v4_protosw);
inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
<API key>:
proto_unregister(&dccp_v4_prot);
goto out;
}
static void __exit dccp_v4_exit(void)
{
<API key>(&dccp_v4_protosw);
inet_del_protocol(&dccp_v4_protocol, IPPROTO_DCCP);
proto_unregister(&dccp_v4_prot);
}
module_init(dccp_v4_init);
module_exit(dccp_v4_exit);
/*
* __stringify doesn't likes enums, so use SOCK_DCCP (6) and IPPROTO_DCCP (33)
* values directly, Also cover the case where the protocol is not specified,
* i.e. <API key>
*/
MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-33-type-6");
MODULE_ALIAS("net-pf-" __stringify(PF_INET) "-proto-0-type-6");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Arnaldo Carvalho de Melo <acme@mandriva.com>");
MODULE_DESCRIPTION("DCCP - Datagram Congestion Controlled Protocol");
|
#ifndef __TYPES_V7__
#define __TYPES_V7__
#if defined(_WIN32) && defined(_MSC_VER)
# define ALIGN_PREFIX(bytes) __declspec(align(bytes))
# define ALIGN_POSTFIX(bytes)
# define FUNC_DEF_INLINE __inline
# define <API key> extern __inline
#elif defined(__GNUC__)
# define ALIGN_PREFIX(bytes)
# define ALIGN_POSTFIX(bytes) __attribute__ ((aligned(bytes)))
# if defined (_DEBUG)
# define <API key> extern __inline
# define FUNC_DEF_INLINE static __inline
# else
# define <API key> extern __inline
# define FUNC_DEF_INLINE static __inline
# endif
#else
# define ALIGN_PREFIX(bytes)
# define ALIGN_POSTFIX(bytes)
# error UNKNOWN COMPILER AND OS
#endif
#define ALIGN16_PREFIX ALIGN_PREFIX(16)
#define ALIGN16_POSTFIX ALIGN_POSTFIX(16)
#define FUNC_CALL_TYPE __fastcall
#define FUNC_DEF_EXTERN extern
typedef signed long long int64;
typedef signed int int32;
typedef signed short int16;
typedef signed char int8;
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef unsigned short uint16;
typedef unsigned char uint8;
typedef float float4[4];
typedef int32 int32_4[4];
typedef float float44[4][4];
typedef float ALIGN16_PREFIX vec4[4] ALIGN16_POSTFIX;
typedef int32 ALIGN16_PREFIX ivec4[4] ALIGN16_POSTFIX;
typedef float ALIGN16_PREFIX mtx[4][4] ALIGN16_POSTFIX;
typedef float ALIGN16_PREFIX quat[4] ALIGN16_POSTFIX;
typedef union _intf {
float f;
int32 i;
} intf;
#endif//__TYPES__
|
package org.owasp.benchmark.testcode;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/BenchmarkTest01168")
public class BenchmarkTest01168 extends HttpServlet {
private static final long serialVersionUID = 1L;
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
String param = "";
boolean flag = true;
java.util.Enumeration<String> names = request.getHeaderNames();
while (names.hasMoreElements() && flag) {
String name = (String) names.nextElement();
java.util.Enumeration<String> values = request.getHeaders(name);
if (values != null) {
while (values.hasMoreElements() && flag) {
String value = (String) values.nextElement();
if (value.equals("vector")) {
param = name;
flag = false;
}
}
}
}
String bar = new Test().doSomething(param);
try {
java.util.Random numGen = java.security.SecureRandom.getInstance("SHA1PRNG");
double rand = getNextNumber(numGen);
String rememberMeKey = Double.toString(rand).substring(2); // Trim off the 0. at the front.
String user = "SafeDonatella";
String fullClassName = this.getClass().getName();
String testCaseNumber = fullClassName.substring(fullClassName.lastIndexOf('.')+1+"BenchmarkTest".length());
user+= testCaseNumber;
String cookieName = "rememberMe" + testCaseNumber;
boolean foundUser = false;
javax.servlet.http.Cookie[] cookies = request.getCookies();
for (int i = 0; cookies != null && ++i < cookies.length && !foundUser;) {
javax.servlet.http.Cookie cookie = cookies[i];
if (cookieName.equals(cookie.getName())) {
if (cookie.getValue().equals(request.getSession().getAttribute(cookieName))) {
foundUser = true;
}
}
}
if (foundUser) {
response.getWriter().println("Welcome back: " + user + "<br/>");
} else {
javax.servlet.http.Cookie rememberMe = new javax.servlet.http.Cookie(cookieName, rememberMeKey);
rememberMe.setSecure(true);
request.getSession().setAttribute(cookieName, rememberMeKey);
response.addCookie(rememberMe);
response.getWriter().println(user + " has been remembered with cookie: " + rememberMe.getName()
+ " whose value is: " + rememberMe.getValue() + "<br/>");
}
} catch (java.security.<API key> e) {
System.out.println("Problem executing SecureRandom.nextDouble() - TestCase");
throw new ServletException(e);
}
response.getWriter().println("Weak Randomness Test java.security.SecureRandom.nextDouble() executed");
}
double getNextNumber(java.util.Random generator) {
return generator.nextDouble();
} // end doPost
private class Test {
public String doSomething(String param) throws ServletException, IOException {
String bar;
// Simple if statement that assigns constant to bar on true condition
int num = 86;
if ( (7*42) - num > 200 )
bar = "<API key>";
else bar = param;
return bar;
}
} // end innerclass Test
} // end <API key>
|
#include "tst-interpose-aux.h"
#include <errno.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/uio.h>
#include <unistd.h>
#if INTERPOSE_THREADS
#include <pthread.h>
#endif
/* Print the error message and terminate the process with status 1. */
__attribute__ ((noreturn))
__attribute__ ((format (printf, 1, 2)))
static void *
fail (const char *format, ...)
{
/* This assumes that vsnprintf will not call malloc. It does not do
so for the format strings we use. */
char message[4096];
va_list ap;
va_start (ap, format);
vsnprintf (message, sizeof (message), format, ap);
va_end (ap);
enum { count = 3 };
struct iovec iov[count];
iov[0].iov_base = (char *) "error: ";
iov[1].iov_base = (char *) message;
iov[2].iov_base = (char *) "\n";
for (int i = 0; i < count; ++i)
iov[i].iov_len = strlen (iov[i].iov_base);
int unused __attribute__ ((unused));
unused = writev (STDOUT_FILENO, iov, count);
_exit (1);
}
#if INTERPOSE_THREADS
static pthread_mutex_t mutex = <API key>;
#endif
static void
lock (void)
{
#if INTERPOSE_THREADS
int ret = pthread_mutex_lock (&mutex);
if (ret != 0)
{
errno = ret;
fail ("pthread_mutex_lock: %m");
}
#endif
}
static void
unlock (void)
{
#if INTERPOSE_THREADS
int ret = <API key> (&mutex);
if (ret != 0)
{
errno = ret;
fail ("<API key>: %m");
}
#endif
}
struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header
{
size_t allocation_index;
size_t allocation_size;
};
/* Array of known allocations, to track invalid frees. */
enum { max_allocations = 65536 };
static struct allocation_header *allocations[max_allocations];
static size_t allocation_index;
static size_t deallocation_count;
/* Sanity check for successful malloc interposition. */
__attribute__ ((destructor))
static void
<API key> (void)
{
if (allocation_index == 0)
{
/* Make sure that malloc is called at least once from libc. */
void *volatile ptr = strdup ("ptr");
/* Compiler barrier. The strdup function calls malloc, which
updates allocation_index, but strdup is marked __THROW, so
the compiler could optimize away the reload. */
__asm__ volatile ("" ::: "memory");
free (ptr);
/* If the allocation count is still zero, it means we did not
interpose malloc successfully. */
if (allocation_index == 0)
fail ("malloc does not seem to have been interposed");
}
}
static struct allocation_header *get_header (const char *op, void *ptr)
{
struct allocation_header *header = ((struct allocation_header *) ptr) - 1;
if (header->allocation_index >= allocation_index)
fail ("%s: %p: invalid allocation index: %zu (not less than %zu)",
op, ptr, header->allocation_index, allocation_index);
if (allocations[header->allocation_index] != header)
fail ("%s: %p: allocation pointer does not point to header, but %p",
op, ptr, allocations[header->allocation_index]);
return header;
}
/* Internal helper functions. Those must be called while the lock is
acquired. */
static void *
malloc_internal (size_t size)
{
if (allocation_index == max_allocations)
{
errno = ENOMEM;
return NULL;
}
size_t allocation_size = size + sizeof (struct allocation_header);
if (allocation_size < size)
{
errno = ENOMEM;
return NULL;
}
size_t index = allocation_index++;
void *result = mmap (NULL, allocation_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (result == MAP_FAILED)
return NULL;
allocations[index] = result;
*allocations[index] = (struct allocation_header)
{
.allocation_index = index,
.allocation_size = allocation_size
};
return allocations[index] + 1;
}
static void
free_internal (const char *op, struct allocation_header *header)
{
size_t index = header->allocation_index;
int result = mprotect (header, header->allocation_size, PROT_NONE);
if (result != 0)
fail ("%s: mprotect (%p, %zu): %m", op, header, header->allocation_size);
/* Catch double-free issues. */
allocations[index] = NULL;
++deallocation_count;
}
static void *
realloc_internal (void *ptr, size_t new_size)
{
struct allocation_header *header = get_header ("realloc", ptr);
size_t old_size = header->allocation_size - sizeof (struct allocation_header);
if (old_size >= new_size)
return ptr;
void *newptr = malloc_internal (new_size);
if (newptr == NULL)
return NULL;
memcpy (newptr, ptr, old_size);
free_internal ("realloc", header);
return newptr;
}
/* Public interfaces. These functions must perform locking. */
size_t
<API key> (void)
{
lock ();
size_t count = allocation_index;
unlock ();
return count;
}
size_t
<API key> (void)
{
lock ();
size_t count = deallocation_count;
unlock ();
return count;
}
void *
malloc (size_t size)
{
lock ();
void *result = malloc_internal (size);
unlock ();
return result;
}
void
free (void *ptr)
{
if (ptr == NULL)
return;
lock ();
struct allocation_header *header = get_header ("free", ptr);
free_internal ("free", header);
unlock ();
}
void *
calloc (size_t a, size_t b)
{
if (b > 0 && a > SIZE_MAX / b)
{
errno = ENOMEM;
return NULL;
}
lock ();
/* malloc_internal uses mmap, so the memory is zeroed. */
void *result = malloc_internal (a * b);
unlock ();
return result;
}
void *
realloc (void *ptr, size_t n)
{
if (n ==0)
{
free (ptr);
return NULL;
}
else if (ptr == NULL)
return malloc (n);
else
{
lock ();
void *result = realloc_internal (ptr, n);
unlock ();
return result;
}
}
|
package com.bigdata.relation.accesspath;
import junit.framework.TestCase2;
import com.bigdata.striterator.IChunkedIterator;
/**
* @author <a href="mailto:thompsonbry@users.sourceforge.net">Bryan Thompson</a>
* @version $Id$
*/
public class <API key> extends TestCase2 {
public <API key>() {
}
/**
* @param arg0
*/
public <API key>(String arg0) {
super(arg0);
}
/**
* Test empty iterator.
*/
public void test_emptyIterator() {
final <API key><String> buffer = new <API key><String>(
3/* chunkCapacity */, String.class);
// the iterator is initially empty.
assertFalse(buffer.iterator().hasNext());
}
/**
* Verify that elements are flushed when an iterator is requested so
* that they will be visited by the iterator.
*/
public void <API key>() {
final <API key><String> buffer = new <API key><String>(
3/* chunkCapacity */, String.class);
buffer.add("a");
assertSameIterator(new String[] { "a" }, buffer.iterator());
}
/**
* Verify that the iterator has snapshot semantics.
*/
public void <API key>() {
final <API key><String> buffer = new <API key><String>(
3/* chunkCapacity */, String.class);
buffer.add("a");
buffer.add("b");
buffer.add("c");
// visit once.
assertSameIterator(new String[] { "a", "b", "c" }, buffer.iterator());
// will visit again.
assertSameIterator(new String[] { "a", "b", "c" }, buffer.iterator());
}
/**
* Verify iterator visits chunks as placed onto the queue.
*/
public void <API key>() {
final <API key><String> buffer = new <API key><String>(
3/* chunkCapacity */, String.class);
buffer.add("a");
buffer.flush();
buffer.add("b");
buffer.add("c");
// visit once.
<API key>(new String[][] { new String[] { "a" },
new String[] { "b", "c" } }, buffer.iterator());
}
// @SuppressWarnings("unchecked")
public void test_chunkClass() {
final <API key><String> buffer = new <API key><String>(
3/* chunkCapacity */, String.class);
buffer.add("a");
buffer.flush();
buffer.add("b");
buffer.add("c");
// visit once.
<API key>(new String[][] { new String[] { "a" },
new String[] { "b", "c" } }, buffer.iterator());
}
/**
* Verify that the iterator visits the expected chunks in the expected
* order.
*
* @param <E>
* @param chunks
* @param itr
*/
protected <E> void <API key>(final E[][] chunks,
final IChunkedIterator<E> itr) {
for(E[] chunk : chunks) {
assertTrue(itr.hasNext());
final E[] actual = itr.nextChunk();
assertSameArray(chunk, actual);
}
assertFalse(itr.hasNext());
}
}
|
package edu.cornell.cs.nlp.spf.parser.ccg.rules.coordination;
import edu.cornell.cs.nlp.spf.ccg.categories.Category;
import edu.cornell.cs.nlp.spf.ccg.categories.syntax.ComplexSyntax;
import edu.cornell.cs.nlp.spf.ccg.categories.syntax.Slash;
import edu.cornell.cs.nlp.spf.ccg.categories.syntax.Syntax;
import edu.cornell.cs.nlp.spf.parser.ccg.rules.IBinaryParseRule;
import edu.cornell.cs.nlp.spf.parser.ccg.rules.ParseRuleResult;
import edu.cornell.cs.nlp.spf.parser.ccg.rules.RuleName;
import edu.cornell.cs.nlp.spf.parser.ccg.rules.SentenceSpan;
import edu.cornell.cs.nlp.spf.parser.ccg.rules.RuleName.Direction;
class C2Rule<MR> implements IBinaryParseRule<MR> {
private static final RuleName RULE_NAME = RuleName
.create("c2",
Direction.FORWARD);
private static final long serialVersionUID = <API key>;
private final <API key><MR> services;
public C2Rule(<API key><MR> services) {
this.services = services;
}
@Override
public ParseRuleResult<MR> apply(Category<MR> left, Category<MR> right,
SentenceSpan span) {
if (left.getSyntax().equals(Syntax.C)
&& <API key>.<API key>(
right.getSyntax(), null)) {
final MR semantics = services.expandCoordination(right
.getSemantics());
if (semantics != null) {
return new ParseRuleResult<MR>(RULE_NAME,
Category.create(
new ComplexSyntax(right.getSyntax(),
<API key>
.getCoordinationType(right
.getSyntax()),
Slash.BACKWARD), semantics));
}
}
return null;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
@SuppressWarnings("rawtypes")
final C2Rule other = (C2Rule) obj;
if (services == null) {
if (other.services != null) {
return false;
}
} else if (!services.equals(other.services)) {
return false;
}
return true;
}
@Override
public RuleName getName() {
return RULE_NAME;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ (RULE_NAME == null ? 0 : RULE_NAME.hashCode());
result = prime * result + (services == null ? 0 : services.hashCode());
return result;
}
}
|
#include <linux/module.h>
#include <linux/string.h>
#include <linux/fs.h>
#include <linux/time.h>
#include <linux/vmalloc.h>
#include <linux/jbd2.h>
#include <linux/slab.h>
#include <linux/init.h>
#include <linux/blkdev.h>
#include <linux/parser.h>
#include <linux/buffer_head.h>
#include <linux/exportfs.h>
#include <linux/vfs.h>
#include <linux/random.h>
#include <linux/mount.h>
#include <linux/namei.h>
#include <linux/quotaops.h>
#include <linux/seq_file.h>
#include <linux/proc_fs.h>
#include <linux/ctype.h>
#include <linux/log2.h>
#include <linux/crc16.h>
#include <linux/cleancache.h>
#include <asm/uaccess.h>
#include <linux/kthread.h>
#include <linux/freezer.h>
#include "ext4.h"
#include "ext4_extents.h" /* Needed for trace points definition */
#include "ext4_jbd2.h"
#include "xattr.h"
#include "acl.h"
#include "mballoc.h"
#define CREATE_TRACE_POINTS
#include <trace/events/ext4.h>
static struct proc_dir_entry *ext4_proc_root;
static struct kset *ext4_kset;
static struct ext4_lazy_init *ext4_li_info;
static struct mutex ext4_li_mtx;
static struct ext4_features *ext4_feat;
static int ext4_load_journal(struct super_block *, struct ext4_super_block *,
unsigned long journal_devnum);
static int ext4_show_options(struct seq_file *seq, struct dentry *root);
static int ext4_commit_super(struct super_block *sb, int sync);
static void <API key>(struct super_block *sb,
struct ext4_super_block *es);
static void <API key>(struct super_block *sb,
struct ext4_super_block *es);
static int ext4_sync_fs(struct super_block *sb, int wait);
static int <API key>(struct super_block *sb, int wait);
static int ext4_remount(struct super_block *sb, int *flags, char *data);
static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf);
static int ext4_unfreeze(struct super_block *sb);
static int ext4_freeze(struct super_block *sb);
static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data);
static inline int ext2_feature_set_ok(struct super_block *sb);
static inline int ext3_feature_set_ok(struct super_block *sb);
static int ext4_feature_set_ok(struct super_block *sb, int readonly);
static void <API key>(void);
static void <API key>(struct super_block *sb);
static void <API key>(void);
static int <API key>(struct ext4_sb_info *, ext4_fsblk_t);
#if !defined(CONFIG_EXT2_FS) && !defined(<API key>) && defined(<API key>)
static struct file_system_type ext2_fs_type = {
.owner = THIS_MODULE,
.name = "ext2",
.mount = ext4_mount,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
MODULE_ALIAS_FS("ext2");
MODULE_ALIAS("ext2");
#define IS_EXT2_SB(sb) ((sb)->s_bdev->bd_holder == &ext2_fs_type)
#else
#define IS_EXT2_SB(sb) (0)
#endif
#if !defined(CONFIG_EXT3_FS) && !defined(<API key>) && defined(<API key>)
static struct file_system_type ext3_fs_type = {
.owner = THIS_MODULE,
.name = "ext3",
.mount = ext4_mount,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
MODULE_ALIAS_FS("ext3");
MODULE_ALIAS("ext3");
#define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type)
#else
#define IS_EXT3_SB(sb) (0)
#endif
static int <API key>(struct super_block *sb,
struct ext4_super_block *es)
{
if (!<API key>(sb,
<API key>))
return 1;
return es->s_checksum_type == EXT4_CRC32C_CHKSUM;
}
static __le32 <API key>(struct super_block *sb,
struct ext4_super_block *es)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
int offset = offsetof(struct ext4_super_block, s_checksum);
__u32 csum;
csum = ext4_chksum(sbi, ~0, (char *)es, offset);
return cpu_to_le32(csum);
}
int <API key>(struct super_block *sb,
struct ext4_super_block *es)
{
if (!<API key>(sb,
<API key>))
return 1;
return es->s_checksum == <API key>(sb, es);
}
void <API key>(struct super_block *sb)
{
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
if (!<API key>(sb,
<API key>))
return;
es->s_checksum = <API key>(sb, es);
}
void *ext4_kvmalloc(size_t size, gfp_t flags)
{
void *ret;
ret = kmalloc(size, flags);
if (!ret)
ret = __vmalloc(size, flags, PAGE_KERNEL);
return ret;
}
void *ext4_kvzalloc(size_t size, gfp_t flags)
{
void *ret;
ret = kzalloc(size, flags);
if (!ret)
ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL);
return ret;
}
void ext4_kvfree(void *ptr)
{
if (is_vmalloc_addr(ptr))
vfree(ptr);
else
kfree(ptr);
}
ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le32_to_cpu(bg->bg_block_bitmap_lo) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(ext4_fsblk_t)le32_to_cpu(bg->bg_block_bitmap_hi) << 32 : 0);
}
ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le32_to_cpu(bg->bg_inode_bitmap_lo) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(ext4_fsblk_t)le32_to_cpu(bg->bg_inode_bitmap_hi) << 32 : 0);
}
ext4_fsblk_t ext4_inode_table(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le32_to_cpu(bg->bg_inode_table_lo) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(ext4_fsblk_t)le32_to_cpu(bg->bg_inode_table_hi) << 32 : 0);
}
__u32 <API key>(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le16_to_cpu(bg-><API key>) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(__u32)le16_to_cpu(bg-><API key>) << 16 : 0);
}
__u32 <API key>(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le16_to_cpu(bg-><API key>) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(__u32)le16_to_cpu(bg-><API key>) << 16 : 0);
}
__u32 <API key>(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le16_to_cpu(bg-><API key>) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(__u32)le16_to_cpu(bg-><API key>) << 16 : 0);
}
__u32 <API key>(struct super_block *sb,
struct ext4_group_desc *bg)
{
return le16_to_cpu(bg->bg_itable_unused_lo) |
(EXT4_DESC_SIZE(sb) >= <API key> ?
(__u32)le16_to_cpu(bg->bg_itable_unused_hi) << 16 : 0);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk)
{
bg->bg_block_bitmap_lo = cpu_to_le32((u32)blk);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg->bg_block_bitmap_hi = cpu_to_le32(blk >> 32);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk)
{
bg->bg_inode_bitmap_lo = cpu_to_le32((u32)blk);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg->bg_inode_bitmap_hi = cpu_to_le32(blk >> 32);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, ext4_fsblk_t blk)
{
bg->bg_inode_table_lo = cpu_to_le32((u32)blk);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg->bg_inode_table_hi = cpu_to_le32(blk >> 32);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count)
{
bg-><API key> = cpu_to_le16((__u16)count);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg-><API key> = cpu_to_le16(count >> 16);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count)
{
bg-><API key> = cpu_to_le16((__u16)count);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg-><API key> = cpu_to_le16(count >> 16);
}
void ext4_used_dirs_set(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count)
{
bg-><API key> = cpu_to_le16((__u16)count);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg-><API key> = cpu_to_le16(count >> 16);
}
void <API key>(struct super_block *sb,
struct ext4_group_desc *bg, __u32 count)
{
bg->bg_itable_unused_lo = cpu_to_le16((__u16)count);
if (EXT4_DESC_SIZE(sb) >= <API key>)
bg->bg_itable_unused_hi = cpu_to_le16(count >> 16);
}
static void __save_error_info(struct super_block *sb, const char *func,
unsigned int line)
{
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
es->s_last_error_time = cpu_to_le32(get_seconds());
strncpy(es->s_last_error_func, func, sizeof(es->s_last_error_func));
es->s_last_error_line = cpu_to_le32(line);
if (!es->s_first_error_time) {
es->s_first_error_time = es->s_last_error_time;
strncpy(es->s_first_error_func, func,
sizeof(es->s_first_error_func));
es->s_first_error_line = cpu_to_le32(line);
es->s_first_error_ino = es->s_last_error_ino;
es->s_first_error_block = es->s_last_error_block;
}
/*
* Start the daily error reporting function if it hasn't been
* started already
*/
if (!es->s_error_count)
mod_timer(&EXT4_SB(sb)->s_err_report, jiffies + 24*60*60*HZ);
le32_add_cpu(&es->s_error_count, 1);
}
static void save_error_info(struct super_block *sb, const char *func,
unsigned int line)
{
__save_error_info(sb, func, line);
ext4_commit_super(sb, 1);
}
/*
* The del_gendisk() function uninitializes the disk-specific data
* structures, including the bdi structure, without telling anyone
* else. Once this happens, any attempt to call mark_buffer_dirty()
* (for example, by ext4_commit_super), will cause a kernel OOPS.
* This is a kludge to prevent these oops until we can put in a proper
* hook in del_gendisk() to inform the VFS and file system layers.
*/
static int <API key>(struct super_block *sb)
{
struct inode *bd_inode = sb->s_bdev->bd_inode;
struct backing_dev_info *bdi = bd_inode->i_mapping->backing_dev_info;
return bdi->dev == NULL;
}
static void <API key>(journal_t *journal, transaction_t *txn)
{
struct super_block *sb = journal->j_private;
struct ext4_sb_info *sbi = EXT4_SB(sb);
int error = is_journal_aborted(journal);
struct <API key> *jce;
BUG_ON(txn->t_state == T_FINISHED);
spin_lock(&sbi->s_md_lock);
while (!list_empty(&txn->t_private_list)) {
jce = list_entry(txn->t_private_list.next,
struct <API key>, jce_list);
list_del_init(&jce->jce_list);
spin_unlock(&sbi->s_md_lock);
jce->jce_func(sb, jce, error);
spin_lock(&sbi->s_md_lock);
}
spin_unlock(&sbi->s_md_lock);
}
/* Deal with the reporting of failure conditions on a filesystem such as
* inconsistencies detected or read IO failures.
*
* On ext2, we can store the error state of the filesystem in the
* superblock. That is not possible on ext4, because we may have other
* write ordering constraints on the superblock which prevent us from
* writing it out straight away; and given that the journal is about to
* be aborted, we can't rely on the current, or future, transactions to
* write out the superblock safely.
*
* We'll just use the jbd2_journal_abort() error code to record an error in
* the journal instead. On recovery, the journal will complain about
* that error until we've noted it down and cleared it.
*/
static void ext4_handle_error(struct super_block *sb)
{
if (sb->s_flags & MS_RDONLY)
return;
if (!test_opt(sb, ERRORS_CONT)) {
journal_t *journal = EXT4_SB(sb)->s_journal;
EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED;
if (journal)
jbd2_journal_abort(journal, -EIO);
}
if (test_opt(sb, ERRORS_RO)) {
ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
/*
* Make sure updated value of ->s_mount_flags will be visible
* before ->s_flags update
*/
smp_wmb();
sb->s_flags |= MS_RDONLY;
}
if (test_opt(sb, ERRORS_PANIC))
panic("EXT4-fs (device %s): panic forced after error\n",
sb->s_id);
}
void __ext4_error(struct super_block *sb, const char *function,
unsigned int line, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: comm %s: %pV\n",
sb->s_id, function, line, current->comm, &vaf);
va_end(args);
save_error_info(sb, function, line);
ext4_handle_error(sb);
}
void __ext4_error_inode(struct inode *inode, const char *function,
unsigned int line, ext4_fsblk_t block,
const char *fmt, ...)
{
va_list args;
struct va_format vaf;
struct ext4_super_block *es = EXT4_SB(inode->i_sb)->s_es;
es->s_last_error_ino = cpu_to_le32(inode->i_ino);
es->s_last_error_block = cpu_to_le64(block);
save_error_info(inode->i_sb, function, line);
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
if (block)
printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
"inode #%lu: block %llu: comm %s: %pV\n",
inode->i_sb->s_id, function, line, inode->i_ino,
block, current->comm, &vaf);
else
printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: "
"inode #%lu: comm %s: %pV\n",
inode->i_sb->s_id, function, line, inode->i_ino,
current->comm, &vaf);
va_end(args);
ext4_handle_error(inode->i_sb);
}
void __ext4_error_file(struct file *file, const char *function,
unsigned int line, ext4_fsblk_t block,
const char *fmt, ...)
{
va_list args;
struct va_format vaf;
struct ext4_super_block *es;
struct inode *inode = file_inode(file);
char pathname[80], *path;
es = EXT4_SB(inode->i_sb)->s_es;
es->s_last_error_ino = cpu_to_le32(inode->i_ino);
save_error_info(inode->i_sb, function, line);
path = d_path(&(file->f_path), pathname, sizeof(pathname));
if (IS_ERR(path))
path = "(unknown)";
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
if (block)
printk(KERN_CRIT
"EXT4-fs error (device %s): %s:%d: inode
"block %llu: comm %s: path %s: %pV\n",
inode->i_sb->s_id, function, line, inode->i_ino,
block, current->comm, path, &vaf);
else
printk(KERN_CRIT
"EXT4-fs error (device %s): %s:%d: inode
"comm %s: path %s: %pV\n",
inode->i_sb->s_id, function, line, inode->i_ino,
current->comm, path, &vaf);
va_end(args);
ext4_handle_error(inode->i_sb);
}
const char *ext4_decode_error(struct super_block *sb, int errno,
char nbuf[16])
{
char *errstr = NULL;
switch (errno) {
case -EIO:
errstr = "IO failure";
break;
case -ENOMEM:
errstr = "Out of memory";
break;
case -EROFS:
if (!sb || (EXT4_SB(sb)->s_journal &&
EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT))
errstr = "Journal has aborted";
else
errstr = "Readonly filesystem";
break;
default:
/* If the caller passed in an extra buffer for unknown
* errors, textualise them now. Else we just return
* NULL. */
if (nbuf) {
/* Check for truncated error codes... */
if (snprintf(nbuf, 16, "error %d", -errno) >= 0)
errstr = nbuf;
}
break;
}
return errstr;
}
/* __ext4_std_error decodes expected errors from journaling functions
* automatically and invokes the appropriate error response. */
void __ext4_std_error(struct super_block *sb, const char *function,
unsigned int line, int errno)
{
char nbuf[16];
const char *errstr;
/* Special case: if the error is EROFS, and we're not already
* inside a transaction, then there's really no point in logging
* an error. */
if (errno == -EROFS && <API key>() == NULL &&
(sb->s_flags & MS_RDONLY))
return;
errstr = ext4_decode_error(sb, errno, nbuf);
printk(KERN_CRIT "EXT4-fs error (device %s) in %s:%d: %s\n",
sb->s_id, function, line, errstr);
save_error_info(sb, function, line);
ext4_handle_error(sb);
}
/*
* ext4_abort is a much stronger failure handler than ext4_error. The
* abort function may be used to deal with unrecoverable failures such
* as journal IO errors or ENOMEM at a critical moment in log management.
*
* We unconditionally force the filesystem into an ABORT|READONLY state,
* unless the error response on the fs has been set to panic in which
* case we take the easy way out and panic immediately.
*/
void __ext4_abort(struct super_block *sb, const char *function,
unsigned int line, const char *fmt, ...)
{
va_list args;
save_error_info(sb, function, line);
va_start(args, fmt);
printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: ", sb->s_id,
function, line);
vprintk(fmt, args);
printk("\n");
va_end(args);
if ((sb->s_flags & MS_RDONLY) == 0) {
ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED;
/*
* Make sure updated value of ->s_mount_flags will be visible
* before ->s_flags update
*/
smp_wmb();
sb->s_flags |= MS_RDONLY;
if (EXT4_SB(sb)->s_journal)
jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
save_error_info(sb, function, line);
}
if (test_opt(sb, ERRORS_PANIC))
panic("EXT4-fs panic from previous error\n");
}
void __ext4_msg(struct super_block *sb,
const char *prefix, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
va_end(args);
}
void __ext4_warning(struct super_block *sb, const char *function,
unsigned int line, const char *fmt, ...)
{
struct va_format vaf;
va_list args;
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk(KERN_WARNING "EXT4-fs warning (device %s): %s:%d: %pV\n",
sb->s_id, function, line, &vaf);
va_end(args);
}
void <API key>(const char *function, unsigned int line,
struct super_block *sb, ext4_group_t grp,
unsigned long ino, ext4_fsblk_t block,
const char *fmt, ...)
__releases(bitlock)
__acquires(bitlock)
{
struct va_format vaf;
va_list args;
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
es->s_last_error_ino = cpu_to_le32(ino);
es->s_last_error_block = cpu_to_le64(block);
__save_error_info(sb, function, line);
va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
printk(KERN_CRIT "EXT4-fs error (device %s): %s:%d: group %u, ",
sb->s_id, function, line, grp);
if (ino)
printk(KERN_CONT "inode %lu: ", ino);
if (block)
printk(KERN_CONT "block %llu:", (unsigned long long) block);
printk(KERN_CONT "%pV\n", &vaf);
va_end(args);
if (test_opt(sb, ERRORS_CONT)) {
ext4_commit_super(sb, 0);
return;
}
ext4_unlock_group(sb, grp);
ext4_handle_error(sb);
/*
* We only get here in the ERRORS_RO case; relocking the group
* may be dangerous, but nothing bad will happen since the
* filesystem will have already been marked read/only and the
* journal has been aborted. We return 1 as a hint to callers
* who might what to use the return value from
* <API key>() to distinguish between the
* ERRORS_CONT and ERRORS_RO case, and perhaps return more
* aggressively from the ext4 function in question, with a
* more appropriate error code.
*/
ext4_lock_group(sb, grp);
return;
}
void <API key>(struct super_block *sb)
{
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV)
return;
ext4_warning(sb,
"updating to rev %d because of new feature flag, "
"running e2fsck is recommended",
EXT4_DYNAMIC_REV);
es->s_first_ino = cpu_to_le32(<API key>);
es->s_inode_size = cpu_to_le16(<API key>);
es->s_rev_level = cpu_to_le32(EXT4_DYNAMIC_REV);
/* leave es->s_feature_*compat flags alone */
/* es->s_uuid will be set by e2fsck if empty */
/*
* The rest of the superblock fields should be zero, and if not it
* means they are likely already in use, so leave them alone. We
* can leave it up to e2fsck to clean up any inconsistencies there.
*/
}
/*
* Open the external journal device
*/
static struct block_device *ext4_blkdev_get(dev_t dev, struct super_block *sb)
{
struct block_device *bdev;
char b[BDEVNAME_SIZE];
bdev = blkdev_get_by_dev(dev, FMODE_READ|FMODE_WRITE|FMODE_EXCL, sb);
if (IS_ERR(bdev))
goto fail;
return bdev;
fail:
ext4_msg(sb, KERN_ERR, "failed to open journal device %s: %ld",
__bdevname(dev, b), PTR_ERR(bdev));
return NULL;
}
/*
* Release the journal device
*/
static void ext4_blkdev_put(struct block_device *bdev)
{
blkdev_put(bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
}
static void ext4_blkdev_remove(struct ext4_sb_info *sbi)
{
struct block_device *bdev;
bdev = sbi->journal_bdev;
if (bdev) {
ext4_blkdev_put(bdev);
sbi->journal_bdev = NULL;
}
}
static inline struct inode *orphan_list_entry(struct list_head *l)
{
return &list_entry(l, struct ext4_inode_info, i_orphan)->vfs_inode;
}
static void dump_orphan_list(struct super_block *sb, struct ext4_sb_info *sbi)
{
struct list_head *l;
ext4_msg(sb, KERN_ERR, "sb orphan head is %d",
le32_to_cpu(sbi->s_es->s_last_orphan));
printk(KERN_ERR "sb_info orphan list:\n");
list_for_each(l, &sbi->s_orphan) {
struct inode *inode = orphan_list_entry(l);
printk(KERN_ERR " "
"inode %s:%lu at %p: mode %o, nlink %d, next %d\n",
inode->i_sb->s_id, inode->i_ino, inode,
inode->i_mode, inode->i_nlink,
NEXT_ORPHAN(inode));
}
}
static void ext4_put_super(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
int i, err;
<API key>(sb);
dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | <API key>);
flush_workqueue(sbi->unrsv_conversion_wq);
flush_workqueue(sbi->rsv_conversion_wq);
destroy_workqueue(sbi->unrsv_conversion_wq);
destroy_workqueue(sbi->rsv_conversion_wq);
if (sbi->s_journal) {
err = <API key>(sbi->s_journal);
sbi->s_journal = NULL;
if (err < 0)
ext4_abort(sb, "Couldn't clean up the journal");
}
<API key>(sbi);
del_timer(&sbi->s_err_report);
<API key>(sb);
ext4_mb_release(sb);
ext4_ext_release(sb);
<API key>(sb);
if (!(sb->s_flags & MS_RDONLY)) {
<API key>(sb, <API key>);
es->s_state = cpu_to_le16(sbi->s_mount_state);
}
if (!(sb->s_flags & MS_RDONLY))
ext4_commit_super(sb, 1);
if (sbi->s_proc) {
remove_proc_entry("options", sbi->s_proc);
remove_proc_entry(sb->s_id, ext4_proc_root);
}
kobject_del(&sbi->s_kobj);
for (i = 0; i < sbi->s_gdb_count; i++)
brelse(sbi->s_group_desc[i]);
ext4_kvfree(sbi->s_group_desc);
ext4_kvfree(sbi->s_flex_groups);
<API key>(&sbi-><API key>);
<API key>(&sbi-><API key>);
<API key>(&sbi->s_dirs_counter);
<API key>(&sbi-><API key>);
<API key>(&sbi->s_extent_cache_cnt);
brelse(sbi->s_sbh);
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]);
#endif
/* Debugging code just in case the in-memory inode orphan list
* isn't empty. The on-disk one can be non-empty if we've
* detected an error and taken the fs readonly, but the
* in-memory list had better be clean by this point. */
if (!list_empty(&sbi->s_orphan))
dump_orphan_list(sb, sbi);
J_ASSERT(list_empty(&sbi->s_orphan));
invalidate_bdev(sb->s_bdev);
if (sbi->journal_bdev && sbi->journal_bdev != sb->s_bdev) {
/*
* Invalidate the journal device's buffers. We don't want them
* floating about in memory - the physical journal device may
* hotswapped, and it breaks the `ro-after' testing code.
*/
sync_blockdev(sbi->journal_bdev);
invalidate_bdev(sbi->journal_bdev);
ext4_blkdev_remove(sbi);
}
if (sbi->s_mmp_tsk)
kthread_stop(sbi->s_mmp_tsk);
sb->s_fs_info = NULL;
/*
* Now that we are completely done shutting down the
* superblock, we need to actually destroy the kobject.
*/
kobject_put(&sbi->s_kobj);
wait_for_completion(&sbi->s_kobj_unregister);
if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver);
kfree(sbi->s_blockgroup_lock);
kfree(sbi);
}
static struct kmem_cache *ext4_inode_cachep;
/*
* Called inside transaction, so use GFP_NOFS
*/
static struct inode *ext4_alloc_inode(struct super_block *sb)
{
struct ext4_inode_info *ei;
ei = kmem_cache_alloc(ext4_inode_cachep, GFP_NOFS);
if (!ei)
return NULL;
ei->vfs_inode.i_version = 1;
INIT_LIST_HEAD(&ei->i_prealloc_list);
spin_lock_init(&ei->i_prealloc_lock);
ext4_es_init_tree(&ei->i_es_tree);
rwlock_init(&ei->i_es_lock);
INIT_LIST_HEAD(&ei->i_es_lru);
ei->i_es_lru_nr = 0;
ei->i_touch_when = 0;
ei-><API key> = 0;
ei-><API key> = 0;
ei-><API key> = 0;
ei-><API key> = 0;
ei-><API key> = 0;
spin_lock_init(&(ei-><API key>));
#ifdef CONFIG_QUOTA
ei->i_reserved_quota = 0;
#endif
ei->jinode = NULL;
INIT_LIST_HEAD(&ei-><API key>);
INIT_LIST_HEAD(&ei-><API key>);
spin_lock_init(&ei->i_completed_io_lock);
ei->i_sync_tid = 0;
ei->i_datasync_tid = 0;
atomic_set(&ei->i_ioend_count, 0);
atomic_set(&ei->i_unwritten, 0);
INIT_WORK(&ei-><API key>, <API key>);
INIT_WORK(&ei-><API key>, <API key>);
return &ei->vfs_inode;
}
static int ext4_drop_inode(struct inode *inode)
{
int drop = generic_drop_inode(inode);
<API key>(inode, drop);
return drop;
}
static void ext4_i_callback(struct rcu_head *head)
{
struct inode *inode = container_of(head, struct inode, i_rcu);
kmem_cache_free(ext4_inode_cachep, EXT4_I(inode));
}
static void ext4_destroy_inode(struct inode *inode)
{
if (!list_empty(&(EXT4_I(inode)->i_orphan))) {
ext4_msg(inode->i_sb, KERN_ERR,
"Inode %lu (%p): orphan list check failed!",
inode->i_ino, EXT4_I(inode));
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 16, 4,
EXT4_I(inode), sizeof(struct ext4_inode_info),
true);
dump_stack();
}
call_rcu(&inode->i_rcu, ext4_i_callback);
}
static void init_once(void *foo)
{
struct ext4_inode_info *ei = (struct ext4_inode_info *) foo;
INIT_LIST_HEAD(&ei->i_orphan);
init_rwsem(&ei->xattr_sem);
init_rwsem(&ei->i_data_sem);
inode_init_once(&ei->vfs_inode);
}
static int init_inodecache(void)
{
ext4_inode_cachep = kmem_cache_create("ext4_inode_cache",
sizeof(struct ext4_inode_info),
0, (<API key>|
SLAB_MEM_SPREAD),
init_once);
if (ext4_inode_cachep == NULL)
return -ENOMEM;
return 0;
}
static void destroy_inodecache(void)
{
/*
* Make sure all delayed rcu free inodes are flushed before we
* destroy cache.
*/
rcu_barrier();
kmem_cache_destroy(ext4_inode_cachep);
}
void ext4_clear_inode(struct inode *inode)
{
<API key>(inode);
clear_inode(inode);
dquot_drop(inode);
<API key>(inode);
<API key>(inode, 0, EXT_MAX_BLOCKS);
ext4_es_lru_del(inode);
if (EXT4_I(inode)->jinode) {
<API key>(EXT4_JOURNAL(inode),
EXT4_I(inode)->jinode);
jbd2_free_inode(EXT4_I(inode)->jinode);
EXT4_I(inode)->jinode = NULL;
}
}
static struct inode *ext4_nfs_get_inode(struct super_block *sb,
u64 ino, u32 generation)
{
struct inode *inode;
if (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)
return ERR_PTR(-ESTALE);
if (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))
return ERR_PTR(-ESTALE);
/* iget isn't really right if the inode is currently unallocated!!
*
* ext4_read_inode will return a bad_inode if the inode had been
* deleted, so we should be safe.
*
* Currently we don't know the generation for parent directory, so
* a generation of 0 means "accept any"
*/
inode = ext4_iget(sb, ino);
if (IS_ERR(inode))
return ERR_CAST(inode);
if (generation && inode->i_generation != generation) {
iput(inode);
return ERR_PTR(-ESTALE);
}
return inode;
}
static struct dentry *ext4_fh_to_dentry(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
return <API key>(sb, fid, fh_len, fh_type,
ext4_nfs_get_inode);
}
static struct dentry *ext4_fh_to_parent(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type)
{
return <API key>(sb, fid, fh_len, fh_type,
ext4_nfs_get_inode);
}
/*
* Try to release metadata pages (indirect blocks, directories) which are
* mapped via the block device. Since these pages could have journal heads
* which would prevent try_to_free_buffers() from freeing them, we must use
* jbd2 layer's try_to_free_buffers() function to release them.
*/
static int <API key>(struct super_block *sb, struct page *page,
gfp_t wait)
{
journal_t *journal = EXT4_SB(sb)->s_journal;
WARN_ON(PageChecked(page));
if (!page_has_buffers(page))
return 0;
if (journal)
return <API key>(journal, page,
wait & ~__GFP_WAIT);
return try_to_free_buffers(page);
}
#ifdef CONFIG_QUOTA
#define QTYPE2NAME(t) ((t) == USRQUOTA ? "user" : "group")
#define QTYPE2MOPT(on, t) ((t) == USRQUOTA?((on)##USRJQUOTA):((on)##GRPJQUOTA))
static int ext4_write_dquot(struct dquot *dquot);
static int ext4_acquire_dquot(struct dquot *dquot);
static int ext4_release_dquot(struct dquot *dquot);
static int <API key>(struct dquot *dquot);
static int ext4_write_info(struct super_block *sb, int type);
static int ext4_quota_on(struct super_block *sb, int type, int format_id,
struct path *path);
static int <API key>(struct super_block *sb, int type,
int format_id);
static int ext4_quota_off(struct super_block *sb, int type);
static int <API key>(struct super_block *sb, int type);
static int ext4_quota_on_mount(struct super_block *sb, int type);
static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
size_t len, loff_t off);
static ssize_t ext4_quota_write(struct super_block *sb, int type,
const char *data, size_t len, loff_t off);
static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
unsigned int flags);
static int ext4_enable_quotas(struct super_block *sb);
static const struct dquot_operations <API key> = {
.get_reserved_space = <API key>,
.write_dquot = ext4_write_dquot,
.acquire_dquot = ext4_acquire_dquot,
.release_dquot = ext4_release_dquot,
.mark_dirty = <API key>,
.write_info = ext4_write_info,
.alloc_dquot = dquot_alloc,
.destroy_dquot = dquot_destroy,
};
static const struct quotactl_ops <API key> = {
.quota_on = ext4_quota_on,
.quota_off = ext4_quota_off,
.quota_sync = dquot_quota_sync,
.get_info = dquot_get_dqinfo,
.set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk,
.set_dqblk = dquot_set_dqblk
};
static const struct quotactl_ops <API key> = {
.quota_on_meta = <API key>,
.quota_off = <API key>,
.quota_sync = dquot_quota_sync,
.get_info = dquot_get_dqinfo,
.set_info = dquot_set_dqinfo,
.get_dqblk = dquot_get_dqblk,
.set_dqblk = dquot_set_dqblk
};
#endif
static const struct super_operations ext4_sops = {
.alloc_inode = ext4_alloc_inode,
.destroy_inode = ext4_destroy_inode,
.write_inode = ext4_write_inode,
.dirty_inode = ext4_dirty_inode,
.drop_inode = ext4_drop_inode,
.evict_inode = ext4_evict_inode,
.put_super = ext4_put_super,
.sync_fs = ext4_sync_fs,
.freeze_fs = ext4_freeze,
.unfreeze_fs = ext4_unfreeze,
.statfs = ext4_statfs,
.remount_fs = ext4_remount,
.show_options = ext4_show_options,
#ifdef CONFIG_QUOTA
.quota_read = ext4_quota_read,
.quota_write = ext4_quota_write,
#endif
.<API key> = <API key>,
};
static const struct super_operations ext4_nojournal_sops = {
.alloc_inode = ext4_alloc_inode,
.destroy_inode = ext4_destroy_inode,
.write_inode = ext4_write_inode,
.dirty_inode = ext4_dirty_inode,
.drop_inode = ext4_drop_inode,
.evict_inode = ext4_evict_inode,
.sync_fs = <API key>,
.put_super = ext4_put_super,
.statfs = ext4_statfs,
.remount_fs = ext4_remount,
.show_options = ext4_show_options,
#ifdef CONFIG_QUOTA
.quota_read = ext4_quota_read,
.quota_write = ext4_quota_write,
#endif
.<API key> = <API key>,
};
static const struct export_operations ext4_export_ops = {
.fh_to_dentry = ext4_fh_to_dentry,
.fh_to_parent = ext4_fh_to_parent,
.get_parent = ext4_get_parent,
};
enum {
Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic, Opt_err_ro,
Opt_nouid32, Opt_debug, Opt_removed,
Opt_user_xattr, Opt_nouser_xattr, Opt_acl, Opt_noacl,
Opt_auto_da_alloc, Opt_noauto_da_alloc, Opt_noload,
Opt_commit, Opt_min_batch_time, Opt_max_batch_time,
Opt_journal_dev, <API key>, <API key>,
Opt_abort, Opt_data_journal, Opt_data_ordered, Opt_data_writeback,
Opt_data_err_abort, Opt_data_err_ignore,
Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
Opt_noquota, Opt_barrier, Opt_nobarrier, Opt_err,
Opt_usrquota, Opt_grpquota, Opt_i_version,
Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit,
<API key>, Opt_block_validity, <API key>,
<API key>, Opt_journal_ioprio,
Opt_dioread_nolock, Opt_dioread_lock,
Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
Opt_max_dir_size_kb,
};
static const match_table_t tokens = {
{Opt_bsd_df, "bsddf"},
{Opt_minix_df, "minixdf"},
{Opt_grpid, "grpid"},
{Opt_grpid, "bsdgroups"},
{Opt_nogrpid, "nogrpid"},
{Opt_nogrpid, "sysvgroups"},
{Opt_resgid, "resgid=%u"},
{Opt_resuid, "resuid=%u"},
{Opt_sb, "sb=%u"},
{Opt_err_cont, "errors=continue"},
{Opt_err_panic, "errors=panic"},
{Opt_err_ro, "errors=remount-ro"},
{Opt_nouid32, "nouid32"},
{Opt_debug, "debug"},
{Opt_removed, "oldalloc"},
{Opt_removed, "orlov"},
{Opt_user_xattr, "user_xattr"},
{Opt_nouser_xattr, "nouser_xattr"},
{Opt_acl, "acl"},
{Opt_noacl, "noacl"},
{Opt_noload, "norecovery"},
{Opt_noload, "noload"},
{Opt_removed, "nobh"},
{Opt_removed, "bh"},
{Opt_commit, "commit=%u"},
{Opt_min_batch_time, "min_batch_time=%u"},
{Opt_max_batch_time, "max_batch_time=%u"},
{Opt_journal_dev, "journal_dev=%u"},
{<API key>, "journal_checksum"},
{<API key>, "<API key>"},
{Opt_abort, "abort"},
{Opt_data_journal, "data=journal"},
{Opt_data_ordered, "data=ordered"},
{Opt_data_writeback, "data=writeback"},
{Opt_data_err_abort, "data_err=abort"},
{Opt_data_err_ignore, "data_err=ignore"},
{Opt_offusrjquota, "usrjquota="},
{Opt_usrjquota, "usrjquota=%s"},
{Opt_offgrpjquota, "grpjquota="},
{Opt_grpjquota, "grpjquota=%s"},
{Opt_jqfmt_vfsold, "jqfmt=vfsold"},
{Opt_jqfmt_vfsv0, "jqfmt=vfsv0"},
{Opt_jqfmt_vfsv1, "jqfmt=vfsv1"},
{Opt_grpquota, "grpquota"},
{Opt_noquota, "noquota"},
{Opt_quota, "quota"},
{Opt_usrquota, "usrquota"},
{Opt_barrier, "barrier=%u"},
{Opt_barrier, "barrier"},
{Opt_nobarrier, "nobarrier"},
{Opt_i_version, "i_version"},
{Opt_stripe, "stripe=%u"},
{Opt_delalloc, "delalloc"},
{Opt_nodelalloc, "nodelalloc"},
{Opt_removed, "mblk_io_submit"},
{Opt_removed, "nomblk_io_submit"},
{Opt_block_validity, "block_validity"},
{<API key>, "noblock_validity"},
{<API key>, "<API key>=%u"},
{Opt_journal_ioprio, "journal_ioprio=%u"},
{Opt_auto_da_alloc, "auto_da_alloc=%u"},
{Opt_auto_da_alloc, "auto_da_alloc"},
{Opt_noauto_da_alloc, "noauto_da_alloc"},
{Opt_dioread_nolock, "dioread_nolock"},
{Opt_dioread_lock, "dioread_lock"},
{Opt_discard, "discard"},
{Opt_nodiscard, "nodiscard"},
{Opt_init_itable, "init_itable=%u"},
{Opt_init_itable, "init_itable"},
{Opt_noinit_itable, "noinit_itable"},
{Opt_max_dir_size_kb, "max_dir_size_kb=%u"},
{Opt_removed, "check=none"}, /* mount option from ext2/3 */
{Opt_removed, "nocheck"}, /* mount option from ext2/3 */
{Opt_removed, "reservation"}, /* mount option from ext2/3 */
{Opt_removed, "noreservation"}, /* mount option from ext2/3 */
{Opt_removed, "journal=%u"}, /* mount option from ext2/3 */
{Opt_err, NULL},
};
static ext4_fsblk_t get_sb_block(void **data)
{
ext4_fsblk_t sb_block;
char *options = (char *) *data;
if (!options || strncmp(options, "sb=", 3) != 0)
return 1; /* Default location */
options += 3;
/* TODO: use simple_strtoll with >32bit ext4 */
sb_block = simple_strtoul(options, &options, 0);
if (*options && *options != ',') {
printk(KERN_ERR "EXT4-fs: Invalid sb specification: %s\n",
(char *) *data);
return 1;
}
if (*options == ',')
options++;
*data = (void *) options;
return sb_block;
}
#define <API key> (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
"Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
#ifdef CONFIG_QUOTA
static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
char *qname;
int ret = -1;
if (sb_any_quota_loaded(sb) &&
!sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR,
"Cannot change journaled "
"quota options when quota turned on");
return -1;
}
if (<API key>(sb, <API key>)) {
ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options "
"when QUOTA feature is enabled");
return -1;
}
qname = match_strdup(args);
if (!qname) {
ext4_msg(sb, KERN_ERR,
"Not enough memory for storing quotafile name");
return -1;
}
if (sbi->s_qf_names[qtype]) {
if (strcmp(sbi->s_qf_names[qtype], qname) == 0)
ret = 1;
else
ext4_msg(sb, KERN_ERR,
"%s quota file already specified",
QTYPE2NAME(qtype));
goto errout;
}
if (strchr(qname, '/')) {
ext4_msg(sb, KERN_ERR,
"quotafile must be on filesystem root");
goto errout;
}
sbi->s_qf_names[qtype] = qname;
set_opt(sb, QUOTA);
return 1;
errout:
kfree(qname);
return ret;
}
static int clear_qf_name(struct super_block *sb, int qtype)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
if (sb_any_quota_loaded(sb) &&
sbi->s_qf_names[qtype]) {
ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options"
" when quota turned on");
return -1;
}
kfree(sbi->s_qf_names[qtype]);
sbi->s_qf_names[qtype] = NULL;
return 1;
}
#endif
#define MOPT_SET 0x0001
#define MOPT_CLEAR 0x0002
#define MOPT_NOSUPPORT 0x0004
#define MOPT_EXPLICIT 0x0008
#define MOPT_CLEAR_ERR 0x0010
#define MOPT_GTE0 0x0020
#ifdef CONFIG_QUOTA
#define MOPT_Q 0
#define MOPT_QFMT 0x0040
#else
#define MOPT_Q MOPT_NOSUPPORT
#define MOPT_QFMT MOPT_NOSUPPORT
#endif
#define MOPT_DATAJ 0x0080
#define MOPT_NO_EXT2 0x0100
#define MOPT_NO_EXT3 0x0200
#define MOPT_EXT4_ONLY (MOPT_NO_EXT2 | MOPT_NO_EXT3)
static const struct mount_opts {
int token;
int mount_opt;
int flags;
} ext4_mount_opts[] = {
{Opt_minix_df, EXT4_MOUNT_MINIX_DF, MOPT_SET},
{Opt_bsd_df, EXT4_MOUNT_MINIX_DF, MOPT_CLEAR},
{Opt_grpid, EXT4_MOUNT_GRPID, MOPT_SET},
{Opt_nogrpid, EXT4_MOUNT_GRPID, MOPT_CLEAR},
{Opt_block_validity, <API key>, MOPT_SET},
{<API key>, <API key>, MOPT_CLEAR},
{Opt_dioread_nolock, <API key>,
MOPT_EXT4_ONLY | MOPT_SET},
{Opt_dioread_lock, <API key>,
MOPT_EXT4_ONLY | MOPT_CLEAR},
{Opt_discard, EXT4_MOUNT_DISCARD, MOPT_SET},
{Opt_nodiscard, EXT4_MOUNT_DISCARD, MOPT_CLEAR},
{Opt_delalloc, EXT4_MOUNT_DELALLOC,
MOPT_EXT4_ONLY | MOPT_SET | MOPT_EXPLICIT},
{Opt_nodelalloc, EXT4_MOUNT_DELALLOC,
MOPT_EXT4_ONLY | MOPT_CLEAR | MOPT_EXPLICIT},
{<API key>, <API key>,
MOPT_EXT4_ONLY | MOPT_SET},
{<API key>, (<API key> |
<API key>),
MOPT_EXT4_ONLY | MOPT_SET},
{Opt_noload, EXT4_MOUNT_NOLOAD, MOPT_NO_EXT2 | MOPT_SET},
{Opt_err_panic, <API key>, MOPT_SET | MOPT_CLEAR_ERR},
{Opt_err_ro, <API key>, MOPT_SET | MOPT_CLEAR_ERR},
{Opt_err_cont, <API key>, MOPT_SET | MOPT_CLEAR_ERR},
{Opt_data_err_abort, <API key>,
MOPT_NO_EXT2 | MOPT_SET},
{Opt_data_err_ignore, <API key>,
MOPT_NO_EXT2 | MOPT_CLEAR},
{Opt_barrier, EXT4_MOUNT_BARRIER, MOPT_SET},
{Opt_nobarrier, EXT4_MOUNT_BARRIER, MOPT_CLEAR},
{Opt_noauto_da_alloc, <API key>, MOPT_SET},
{Opt_auto_da_alloc, <API key>, MOPT_CLEAR},
{Opt_noinit_itable, <API key>, MOPT_CLEAR},
{Opt_commit, 0, MOPT_GTE0},
{Opt_max_batch_time, 0, MOPT_GTE0},
{Opt_min_batch_time, 0, MOPT_GTE0},
{<API key>, 0, MOPT_GTE0},
{Opt_init_itable, 0, MOPT_GTE0},
{Opt_stripe, 0, MOPT_GTE0},
{Opt_resuid, 0, MOPT_GTE0},
{Opt_resgid, 0, MOPT_GTE0},
{Opt_journal_dev, 0, MOPT_GTE0},
{Opt_journal_ioprio, 0, MOPT_GTE0},
{Opt_data_journal, <API key>, MOPT_NO_EXT2 | MOPT_DATAJ},
{Opt_data_ordered, <API key>, MOPT_NO_EXT2 | MOPT_DATAJ},
{Opt_data_writeback, <API key>,
MOPT_NO_EXT2 | MOPT_DATAJ},
{Opt_user_xattr, <API key>, MOPT_SET},
{Opt_nouser_xattr, <API key>, MOPT_CLEAR},
#ifdef <API key>
{Opt_acl, <API key>, MOPT_SET},
{Opt_noacl, <API key>, MOPT_CLEAR},
#else
{Opt_acl, 0, MOPT_NOSUPPORT},
{Opt_noacl, 0, MOPT_NOSUPPORT},
#endif
{Opt_nouid32, EXT4_MOUNT_NO_UID32, MOPT_SET},
{Opt_debug, EXT4_MOUNT_DEBUG, MOPT_SET},
{Opt_quota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA, MOPT_SET | MOPT_Q},
{Opt_usrquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA,
MOPT_SET | MOPT_Q},
{Opt_grpquota, EXT4_MOUNT_QUOTA | EXT4_MOUNT_GRPQUOTA,
MOPT_SET | MOPT_Q},
{Opt_noquota, (EXT4_MOUNT_QUOTA | EXT4_MOUNT_USRQUOTA |
EXT4_MOUNT_GRPQUOTA), MOPT_CLEAR | MOPT_Q},
{Opt_usrjquota, 0, MOPT_Q},
{Opt_grpjquota, 0, MOPT_Q},
{Opt_offusrjquota, 0, MOPT_Q},
{Opt_offgrpjquota, 0, MOPT_Q},
{Opt_jqfmt_vfsold, QFMT_VFS_OLD, MOPT_QFMT},
{Opt_jqfmt_vfsv0, QFMT_VFS_V0, MOPT_QFMT},
{Opt_jqfmt_vfsv1, QFMT_VFS_V1, MOPT_QFMT},
{Opt_max_dir_size_kb, 0, MOPT_GTE0},
{Opt_err, 0, 0}
};
static int handle_mount_opt(struct super_block *sb, char *opt, int token,
substring_t *args, unsigned long *journal_devnum,
unsigned int *journal_ioprio, int is_remount)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
const struct mount_opts *m;
kuid_t uid;
kgid_t gid;
int arg = 0;
#ifdef CONFIG_QUOTA
if (token == Opt_usrjquota)
return set_qf_name(sb, USRQUOTA, &args[0]);
else if (token == Opt_grpjquota)
return set_qf_name(sb, GRPQUOTA, &args[0]);
else if (<API key>)
return clear_qf_name(sb, USRQUOTA);
else if (<API key>)
return clear_qf_name(sb, GRPQUOTA);
#endif
switch (token) {
case Opt_noacl:
case Opt_nouser_xattr:
ext4_msg(sb, KERN_WARNING, deprecated_msg, opt, "3.5");
break;
case Opt_sb:
return 1; /* handled by get_sb_block() */
case Opt_removed:
ext4_msg(sb, KERN_WARNING, "Ignoring removed %s option", opt);
return 1;
case Opt_abort:
sbi->s_mount_flags |= EXT4_MF_FS_ABORTED;
return 1;
case Opt_i_version:
sb->s_flags |= MS_I_VERSION;
return 1;
}
for (m = ext4_mount_opts; m->token != Opt_err; m++)
if (token == m->token)
break;
if (m->token == Opt_err) {
ext4_msg(sb, KERN_ERR, "Unrecognized mount option \"%s\" "
"or missing value", opt);
return -1;
}
if ((m->flags & MOPT_NO_EXT2) && IS_EXT2_SB(sb)) {
ext4_msg(sb, KERN_ERR,
"Mount option \"%s\" incompatible with ext2", opt);
return -1;
}
if ((m->flags & MOPT_NO_EXT3) && IS_EXT3_SB(sb)) {
ext4_msg(sb, KERN_ERR,
"Mount option \"%s\" incompatible with ext3", opt);
return -1;
}
if (args->from && match_int(args, &arg))
return -1;
if (args->from && (m->flags & MOPT_GTE0) && (arg < 0))
return -1;
if (m->flags & MOPT_EXPLICIT)
set_opt2(sb, EXPLICIT_DELALLOC);
if (m->flags & MOPT_CLEAR_ERR)
clear_opt(sb, ERRORS_MASK);
if (token == Opt_noquota && sb_any_quota_loaded(sb)) {
ext4_msg(sb, KERN_ERR, "Cannot change quota "
"options when quota turned on");
return -1;
}
if (m->flags & MOPT_NOSUPPORT) {
ext4_msg(sb, KERN_ERR, "%s option not supported", opt);
} else if (token == Opt_commit) {
if (arg == 0)
arg = <API key>;
sbi->s_commit_interval = HZ * arg;
} else if (<API key>) {
if (arg == 0)
arg = <API key>;
sbi->s_max_batch_time = arg;
} else if (<API key>) {
sbi->s_min_batch_time = arg;
} else if (<API key>) {
if (arg && (arg > (1 << 30) || !is_power_of_2(arg))) {
ext4_msg(sb, KERN_ERR,
"EXT4-fs: <API key> must be "
"0 or a power of 2 smaller than 2^31");
return -1;
}
sbi-><API key> = arg;
} else if (token == Opt_init_itable) {
set_opt(sb, INIT_INODE_TABLE);
if (!args->from)
arg = <API key>;
sbi->s_li_wait_mult = arg;
} else if (<API key>) {
sbi->s_max_dir_size_kb = arg;
} else if (token == Opt_stripe) {
sbi->s_stripe = arg;
} else if (token == Opt_resuid) {
uid = make_kuid(current_user_ns(), arg);
if (!uid_valid(uid)) {
ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg);
return -1;
}
sbi->s_resuid = uid;
} else if (token == Opt_resgid) {
gid = make_kgid(current_user_ns(), arg);
if (!gid_valid(gid)) {
ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg);
return -1;
}
sbi->s_resgid = gid;
} else if (token == Opt_journal_dev) {
if (is_remount) {
ext4_msg(sb, KERN_ERR,
"Cannot specify journal on remount");
return -1;
}
*journal_devnum = arg;
} else if (<API key>) {
if (arg > 7) {
ext4_msg(sb, KERN_ERR, "Invalid journal IO priority"
" (must be 0-7)");
return -1;
}
*journal_ioprio =
IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, arg);
} else if (m->flags & MOPT_DATAJ) {
if (is_remount) {
if (!sbi->s_journal)
ext4_msg(sb, KERN_WARNING, "Remounting file system with no journal so ignoring journalled data option");
else if (test_opt(sb, DATA_FLAGS) != m->mount_opt) {
ext4_msg(sb, KERN_ERR,
"Cannot change data mode on remount");
return -1;
}
} else {
clear_opt(sb, DATA_FLAGS);
sbi->s_mount_opt |= m->mount_opt;
}
#ifdef CONFIG_QUOTA
} else if (m->flags & MOPT_QFMT) {
if (sb_any_quota_loaded(sb) &&
sbi->s_jquota_fmt != m->mount_opt) {
ext4_msg(sb, KERN_ERR, "Cannot change journaled "
"quota options when quota turned on");
return -1;
}
if (<API key>(sb,
<API key>)) {
ext4_msg(sb, KERN_ERR,
"Cannot set journaled quota options "
"when QUOTA feature is enabled");
return -1;
}
sbi->s_jquota_fmt = m->mount_opt;
#endif
} else {
if (!args->from)
arg = 1;
if (m->flags & MOPT_CLEAR)
arg = !arg;
else if (unlikely(!(m->flags & MOPT_SET))) {
ext4_msg(sb, KERN_WARNING,
"buggy handling of option %s", opt);
WARN_ON(1);
return -1;
}
if (arg != 0)
sbi->s_mount_opt |= m->mount_opt;
else
sbi->s_mount_opt &= ~m->mount_opt;
}
return 1;
}
static int parse_options(char *options, struct super_block *sb,
unsigned long *journal_devnum,
unsigned int *journal_ioprio,
int is_remount)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
char *p;
substring_t args[MAX_OPT_ARGS];
int token;
if (!options)
return 1;
while ((p = strsep(&options, ",")) != NULL) {
if (!*p)
continue;
/*
* Initialize args struct so we know whether arg was
* found; some options take optional arguments.
*/
args[0].to = args[0].from = NULL;
token = match_token(p, tokens, args);
if (handle_mount_opt(sb, p, token, args, journal_devnum,
journal_ioprio, is_remount) < 0)
return 0;
}
#ifdef CONFIG_QUOTA
if (<API key>(sb, <API key>) &&
(test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) {
ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA "
"feature is enabled");
return 0;
}
if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA])
clear_opt(sb, USRQUOTA);
if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA])
clear_opt(sb, GRPQUOTA);
if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) {
ext4_msg(sb, KERN_ERR, "old and new quota "
"format mixing");
return 0;
}
if (!sbi->s_jquota_fmt) {
ext4_msg(sb, KERN_ERR, "journaled quota format "
"not specified");
return 0;
}
} else {
if (sbi->s_jquota_fmt) {
ext4_msg(sb, KERN_ERR, "journaled quota format "
"specified with no journaling "
"enabled");
return 0;
}
}
#endif
if (test_opt(sb, DIOREAD_NOLOCK)) {
int blocksize =
BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
if (blocksize < PAGE_CACHE_SIZE) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"dioread_nolock if block size != PAGE_SIZE");
return 0;
}
}
return 1;
}
static inline void <API key>(struct seq_file *seq,
struct super_block *sb)
{
#if defined(CONFIG_QUOTA)
struct ext4_sb_info *sbi = EXT4_SB(sb);
if (sbi->s_jquota_fmt) {
char *fmtname = "";
switch (sbi->s_jquota_fmt) {
case QFMT_VFS_OLD:
fmtname = "vfsold";
break;
case QFMT_VFS_V0:
fmtname = "vfsv0";
break;
case QFMT_VFS_V1:
fmtname = "vfsv1";
break;
}
seq_printf(seq, ",jqfmt=%s", fmtname);
}
if (sbi->s_qf_names[USRQUOTA])
seq_printf(seq, ",usrjquota=%s", sbi->s_qf_names[USRQUOTA]);
if (sbi->s_qf_names[GRPQUOTA])
seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]);
#endif
}
static const char *token2str(int token)
{
const struct match_token *t;
for (t = tokens; t->token != Opt_err; t++)
if (t->token == token && !strchr(t->pattern, '='))
break;
return t->pattern;
}
/*
* Show an option if
* - it's set to a non-default value OR
* - if the per-sb default is different from the global default
*/
static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
int nodefs)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
int def_errors, def_mount_opt = nodefs ? 0 : sbi->s_def_mount_opt;
const struct mount_opts *m;
char sep = nodefs ? '\n' : ',';
#define SEQ_OPTS_PUTS(str) seq_printf(seq, "%c" str, sep)
#define SEQ_OPTS_PRINT(str, arg) seq_printf(seq, "%c" str, sep, arg)
if (sbi->s_sb_block != 1)
SEQ_OPTS_PRINT("sb=%llu", sbi->s_sb_block);
for (m = ext4_mount_opts; m->token != Opt_err; m++) {
int want_set = m->flags & MOPT_SET;
if (((m->flags & (MOPT_SET|MOPT_CLEAR)) == 0) ||
(m->flags & MOPT_CLEAR_ERR))
continue;
if (!(m->mount_opt & (sbi->s_mount_opt ^ def_mount_opt)))
continue; /* skip if same as the default */
if ((want_set &&
(sbi->s_mount_opt & m->mount_opt) != m->mount_opt) ||
(!want_set && (sbi->s_mount_opt & m->mount_opt)))
continue; /* select Opt_noFoo vs Opt_Foo */
SEQ_OPTS_PRINT("%s", token2str(m->token));
}
if (nodefs || !uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT4_DEF_RESUID)) ||
le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID)
SEQ_OPTS_PRINT("resuid=%u",
from_kuid_munged(&init_user_ns, sbi->s_resuid));
if (nodefs || !gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT4_DEF_RESGID)) ||
le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID)
SEQ_OPTS_PRINT("resgid=%u",
from_kgid_munged(&init_user_ns, sbi->s_resgid));
def_errors = nodefs ? -1 : le16_to_cpu(es->s_errors);
if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO)
SEQ_OPTS_PUTS("errors=remount-ro");
if (test_opt(sb, ERRORS_CONT) && def_errors != <API key>)
SEQ_OPTS_PUTS("errors=continue");
if (test_opt(sb, ERRORS_PANIC) && def_errors != EXT4_ERRORS_PANIC)
SEQ_OPTS_PUTS("errors=panic");
if (nodefs || sbi->s_commit_interval != <API key>*HZ)
SEQ_OPTS_PRINT("commit=%lu", sbi->s_commit_interval / HZ);
if (nodefs || sbi->s_min_batch_time != <API key>)
SEQ_OPTS_PRINT("min_batch_time=%u", sbi->s_min_batch_time);
if (nodefs || sbi->s_max_batch_time != <API key>)
SEQ_OPTS_PRINT("max_batch_time=%u", sbi->s_max_batch_time);
if (sb->s_flags & MS_I_VERSION)
SEQ_OPTS_PUTS("i_version");
if (nodefs || sbi->s_stripe)
SEQ_OPTS_PRINT("stripe=%lu", sbi->s_stripe);
if (<API key> & (sbi->s_mount_opt ^ def_mount_opt)) {
if (test_opt(sb, DATA_FLAGS) == <API key>)
SEQ_OPTS_PUTS("data=journal");
else if (test_opt(sb, DATA_FLAGS) == <API key>)
SEQ_OPTS_PUTS("data=ordered");
else if (test_opt(sb, DATA_FLAGS) == <API key>)
SEQ_OPTS_PUTS("data=writeback");
}
if (nodefs ||
sbi-><API key> != <API key>)
SEQ_OPTS_PRINT("<API key>=%u",
sbi-><API key>);
if (nodefs || (test_opt(sb, INIT_INODE_TABLE) &&
(sbi->s_li_wait_mult != <API key>)))
SEQ_OPTS_PRINT("init_itable=%u", sbi->s_li_wait_mult);
if (nodefs || sbi->s_max_dir_size_kb)
SEQ_OPTS_PRINT("max_dir_size_kb=%u", sbi->s_max_dir_size_kb);
<API key>(seq, sb);
return 0;
}
static int ext4_show_options(struct seq_file *seq, struct dentry *root)
{
return _ext4_show_options(seq, root->d_sb, 0);
}
static int options_seq_show(struct seq_file *seq, void *offset)
{
struct super_block *sb = seq->private;
int rc;
seq_puts(seq, (sb->s_flags & MS_RDONLY) ? "ro" : "rw");
rc = _ext4_show_options(seq, sb, 1);
seq_puts(seq, "\n");
return rc;
}
static int options_open_fs(struct inode *inode, struct file *file)
{
return single_open(file, options_seq_show, PDE_DATA(inode));
}
static const struct file_operations <API key> = {
.owner = THIS_MODULE,
.open = options_open_fs,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int ext4_setup_super(struct super_block *sb, struct ext4_super_block *es,
int read_only)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
int res = 0;
if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
ext4_msg(sb, KERN_ERR, "revision level too high, "
"forcing read-only mode");
res = MS_RDONLY;
}
if (read_only)
goto done;
if (!(sbi->s_mount_state & EXT4_VALID_FS))
ext4_msg(sb, KERN_WARNING, "warning: mounting unchecked fs, "
"running e2fsck is recommended");
else if ((sbi->s_mount_state & EXT4_ERROR_FS))
ext4_msg(sb, KERN_WARNING,
"warning: mounting fs with errors, "
"running e2fsck is recommended");
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) > 0 &&
le16_to_cpu(es->s_mnt_count) >=
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
ext4_msg(sb, KERN_WARNING,
"warning: maximal mount count reached, "
"running e2fsck is recommended");
else if (le32_to_cpu(es->s_checkinterval) &&
(le32_to_cpu(es->s_lastcheck) +
le32_to_cpu(es->s_checkinterval) <= get_seconds()))
ext4_msg(sb, KERN_WARNING,
"warning: checktime reached, "
"running e2fsck is recommended");
if (!sbi->s_journal)
es->s_state &= cpu_to_le16(~EXT4_VALID_FS);
if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = cpu_to_le16(<API key>);
le16_add_cpu(&es->s_mnt_count, 1);
es->s_mtime = cpu_to_le32(get_seconds());
<API key>(sb);
if (sbi->s_journal)
<API key>(sb, <API key>);
ext4_commit_super(sb, 1);
done:
if (test_opt(sb, DEBUG))
printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, "
"bpg=%lu, ipg=%lu, mo=%04x, mo2=%04x]\n",
sb->s_blocksize,
sbi->s_groups_count,
<API key>(sb),
<API key>(sb),
sbi->s_mount_opt, sbi->s_mount_opt2);
cleancache_init_fs(sb);
return res;
}
int <API key>(struct super_block *sb, ext4_group_t ngroup)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct flex_groups *new_groups;
int size;
if (!sbi-><API key>)
return 0;
size = ext4_flex_group(sbi, ngroup - 1) + 1;
if (size <= sbi-><API key>)
return 0;
size = roundup_pow_of_two(size * sizeof(struct flex_groups));
new_groups = ext4_kvzalloc(size, GFP_KERNEL);
if (!new_groups) {
ext4_msg(sb, KERN_ERR, "not enough memory for %d flex groups",
size / (int) sizeof(struct flex_groups));
return -ENOMEM;
}
if (sbi->s_flex_groups) {
memcpy(new_groups, sbi->s_flex_groups,
(sbi-><API key> *
sizeof(struct flex_groups)));
ext4_kvfree(sbi->s_flex_groups);
}
sbi->s_flex_groups = new_groups;
sbi-><API key> = size / sizeof(struct flex_groups);
return 0;
}
static int ext4_fill_flex_info(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_group_desc *gdp = NULL;
ext4_group_t flex_group;
int i, err;
sbi-><API key> = sbi->s_es-><API key>;
if (sbi-><API key> < 1 || sbi-><API key> > 31) {
sbi-><API key> = 0;
return 1;
}
err = <API key>(sb, sbi->s_groups_count);
if (err)
goto failed;
for (i = 0; i < sbi->s_groups_count; i++) {
gdp = ext4_get_group_desc(sb, i, NULL);
flex_group = ext4_flex_group(sbi, i);
atomic_add(<API key>(sb, gdp),
&sbi->s_flex_groups[flex_group].free_inodes);
atomic64_add(<API key>(sb, gdp),
&sbi->s_flex_groups[flex_group].free_clusters);
atomic_add(<API key>(sb, gdp),
&sbi->s_flex_groups[flex_group].used_dirs);
}
return 1;
failed:
return 0;
}
static __le16 <API key>(struct ext4_sb_info *sbi, __u32 block_group,
struct ext4_group_desc *gdp)
{
int offset;
__u16 crc = 0;
__le32 le_group = cpu_to_le32(block_group);
if ((sbi->s_es->s_feature_ro_compat &
cpu_to_le32(<API key>))) {
/* Use new metadata_csum algorithm */
__le16 save_csum;
__u32 csum32;
save_csum = gdp->bg_checksum;
gdp->bg_checksum = 0;
csum32 = ext4_chksum(sbi, sbi->s_csum_seed, (__u8 *)&le_group,
sizeof(le_group));
csum32 = ext4_chksum(sbi, csum32, (__u8 *)gdp,
sbi->s_desc_size);
gdp->bg_checksum = save_csum;
crc = csum32 & 0xFFFF;
goto out;
}
/* old crc16 code */
offset = offsetof(struct ext4_group_desc, bg_checksum);
crc = crc16(~0, sbi->s_es->s_uuid, sizeof(sbi->s_es->s_uuid));
crc = crc16(crc, (__u8 *)&le_group, sizeof(le_group));
crc = crc16(crc, (__u8 *)gdp, offset);
offset += sizeof(gdp->bg_checksum); /* skip checksum */
/* for checksum of struct ext4_group_desc do the rest...*/
if ((sbi->s_es->s_feature_incompat &
cpu_to_le32(<API key>)) &&
offset < le16_to_cpu(sbi->s_es->s_desc_size))
crc = crc16(crc, (__u8 *)gdp + offset,
le16_to_cpu(sbi->s_es->s_desc_size) -
offset);
out:
return cpu_to_le16(crc);
}
int <API key>(struct super_block *sb, __u32 block_group,
struct ext4_group_desc *gdp)
{
if (<API key>(sb) &&
(gdp->bg_checksum != <API key>(EXT4_SB(sb),
block_group, gdp)))
return 0;
return 1;
}
void <API key>(struct super_block *sb, __u32 block_group,
struct ext4_group_desc *gdp)
{
if (!<API key>(sb))
return;
gdp->bg_checksum = <API key>(EXT4_SB(sb), block_group, gdp);
}
/* Called at mount-time, super-block is locked */
static int <API key>(struct super_block *sb,
ext4_group_t *first_not_zeroed)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_fsblk_t first_block = le32_to_cpu(sbi->s_es->s_first_data_block);
ext4_fsblk_t last_block;
ext4_fsblk_t block_bitmap;
ext4_fsblk_t inode_bitmap;
ext4_fsblk_t inode_table;
int flexbg_flag = 0;
ext4_group_t i, grp = sbi->s_groups_count;
if (<API key>(sb, <API key>))
flexbg_flag = 1;
ext4_debug("Checking group descriptors");
for (i = 0; i < sbi->s_groups_count; i++) {
struct ext4_group_desc *gdp = ext4_get_group_desc(sb, i, NULL);
if (i == sbi->s_groups_count - 1 || flexbg_flag)
last_block = ext4_blocks_count(sbi->s_es) - 1;
else
last_block = first_block +
(<API key>(sb) - 1);
if ((grp == sbi->s_groups_count) &&
!(gdp->bg_flags & cpu_to_le16(<API key>)))
grp = i;
block_bitmap = ext4_block_bitmap(sb, gdp);
if (block_bitmap < first_block || block_bitmap > last_block) {
ext4_msg(sb, KERN_ERR, "<API key>: "
"Block bitmap for group %u not in group "
"(block %llu)!", i, block_bitmap);
return 0;
}
inode_bitmap = ext4_inode_bitmap(sb, gdp);
if (inode_bitmap < first_block || inode_bitmap > last_block) {
ext4_msg(sb, KERN_ERR, "<API key>: "
"Inode bitmap for group %u not in group "
"(block %llu)!", i, inode_bitmap);
return 0;
}
inode_table = ext4_inode_table(sb, gdp);
if (inode_table < first_block ||
inode_table + sbi->s_itb_per_group - 1 > last_block) {
ext4_msg(sb, KERN_ERR, "<API key>: "
"Inode table for group %u not in group "
"(block %llu)!", i, inode_table);
return 0;
}
ext4_lock_group(sb, i);
if (!<API key>(sb, i, gdp)) {
ext4_msg(sb, KERN_ERR, "<API key>: "
"Checksum for group %u failed (%u!=%u)",
i, le16_to_cpu(<API key>(sbi, i,
gdp)), le16_to_cpu(gdp->bg_checksum));
if (!(sb->s_flags & MS_RDONLY)) {
ext4_unlock_group(sb, i);
return 0;
}
}
ext4_unlock_group(sb, i);
if (!flexbg_flag)
first_block += <API key>(sb);
}
if (NULL != first_not_zeroed)
*first_not_zeroed = grp;
<API key>(sbi->s_es,
EXT4_C2B(sbi, <API key>(sb)));
sbi->s_es->s_free_inodes_count =cpu_to_le32(<API key>(sb));
return 1;
}
/* ext4_orphan_cleanup() walks a singly-linked list of inodes (starting at
* the superblock) which were deleted from all directories, but held open by
* a process at the time of a crash. We walk the list and try to delete these
* inodes at recovery time (only with a read-write filesystem).
*
* In order to keep the orphan inode chain consistent during traversal (in
* case of crash during recovery), we link each inode into the superblock
* orphan list_head and handle it the same way as an inode deletion during
* normal operation (which journals the operations for us).
*
* We only do an iget() and an iput() on each inode, which is very safe if we
* accidentally point at an in-use or already deleted inode. The worst that
* can happen in this case is that we get a "bit already cleared" message from
* ext4_free_inode(). The only reason we would point at a wrong inode is if
* e2fsck was run on this filesystem, and it must have already done the orphan
* inode cleanup for us, so we can safely abort without any further action.
*/
static void ext4_orphan_cleanup(struct super_block *sb,
struct ext4_super_block *es)
{
unsigned int s_flags = sb->s_flags;
int nr_orphans = 0, nr_truncates = 0;
#ifdef CONFIG_QUOTA
int i;
#endif
if (!es->s_last_orphan) {
jbd_debug(4, "no orphan inodes to clean up\n");
return;
}
if (bdev_read_only(sb->s_bdev)) {
ext4_msg(sb, KERN_ERR, "write access "
"unavailable, skipping orphan cleanup");
return;
}
/* Check if feature set would not allow a r/w mount */
if (!ext4_feature_set_ok(sb, 0)) {
ext4_msg(sb, KERN_INFO, "Skipping orphan cleanup due to "
"unknown ROCOMPAT features");
return;
}
if (EXT4_SB(sb)->s_mount_state & EXT4_ERROR_FS) {
/* don't clear list on RO mount w/ errors */
if (es->s_last_orphan && !(s_flags & MS_RDONLY)) {
jbd_debug(1, "Errors on filesystem, "
"clearing orphan list.\n");
es->s_last_orphan = 0;
}
jbd_debug(1, "Skipping orphan recovery on fs with errors.\n");
return;
}
if (s_flags & MS_RDONLY) {
ext4_msg(sb, KERN_INFO, "orphan cleanup on readonly fs");
sb->s_flags &= ~MS_RDONLY;
}
#ifdef CONFIG_QUOTA
/* Needed for iput() to work correctly and not trash data */
sb->s_flags |= MS_ACTIVE;
/* Turn on quotas so that they are updated correctly */
for (i = 0; i < MAXQUOTAS; i++) {
if (EXT4_SB(sb)->s_qf_names[i]) {
int ret = ext4_quota_on_mount(sb, i);
if (ret < 0)
ext4_msg(sb, KERN_ERR,
"Cannot turn on journaled "
"quota: error %d", ret);
}
}
#endif
while (es->s_last_orphan) {
struct inode *inode;
inode = ext4_orphan_get(sb, le32_to_cpu(es->s_last_orphan));
if (IS_ERR(inode)) {
es->s_last_orphan = 0;
break;
}
list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan);
dquot_initialize(inode);
if (inode->i_nlink) {
if (test_opt(sb, DEBUG))
ext4_msg(sb, KERN_DEBUG,
"%s: truncating inode %lu to %lld bytes",
__func__, inode->i_ino, inode->i_size);
jbd_debug(2, "truncating inode %lu to %lld bytes\n",
inode->i_ino, inode->i_size);
mutex_lock(&inode->i_mutex);
<API key>(inode->i_mapping, inode->i_size);
ext4_truncate(inode);
mutex_unlock(&inode->i_mutex);
nr_truncates++;
} else {
if (test_opt(sb, DEBUG))
ext4_msg(sb, KERN_DEBUG,
"%s: deleting unreferenced inode %lu",
__func__, inode->i_ino);
jbd_debug(2, "deleting unreferenced inode %lu\n",
inode->i_ino);
nr_orphans++;
}
iput(inode); /* The delete magic happens here! */
}
#define PLURAL(x) (x), ((x) == 1) ? "" : "s"
if (nr_orphans)
ext4_msg(sb, KERN_INFO, "%d orphan inode%s deleted",
PLURAL(nr_orphans));
if (nr_truncates)
ext4_msg(sb, KERN_INFO, "%d truncate%s cleaned up",
PLURAL(nr_truncates));
#ifdef CONFIG_QUOTA
/* Turn quotas off */
for (i = 0; i < MAXQUOTAS; i++) {
if (sb_dqopt(sb)->files[i])
dquot_quota_off(sb, i);
}
#endif
sb->s_flags = s_flags; /* Restore MS_RDONLY status */
}
/*
* Maximal extent format file size.
* Resulting logical blkno at s_maxbytes must fit in our on-disk
* extent format containers, within a sector_t, and within i_blocks
* in the vfs. ext4 inode has 48 bits of i_block in fsblock units,
* so that won't be a limiting factor.
*
* However there is other limiting factor. We do store extents in the form
* of starting block and length, hence the resulting length of the extent
* covering maximum file size must fit into on-disk format containers as
* well. Given that length is always by 1 unit bigger than max unit (because
* we count 0 as well) we have to lower the s_maxbytes by one fs block.
*
* Note, this does *not* consider any metadata overhead for vfs i_blocks.
*/
static loff_t ext4_max_size(int blkbits, int has_huge_files)
{
loff_t res;
loff_t upper_limit = MAX_LFS_FILESIZE;
/* small i_blocks in vfs inode? */
if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
/*
* CONFIG_LBDAF is not enabled implies the inode
* i_block represent total blocks in 512 bytes
* 32 == size of vfs inode i_blocks * 8
*/
upper_limit = (1LL << 32) - 1;
/* total blocks in file system block size */
upper_limit >>= (blkbits - 9);
upper_limit <<= blkbits;
}
/*
* 32-bit extent-start container, ee_block. We lower the maxbytes
* by one fs block, so ee_len can cover the extent of maximum file
* size
*/
res = (1LL << 32) - 1;
res <<= blkbits;
/* Sanity check against vm- & vfs- imposed limits */
if (res > upper_limit)
res = upper_limit;
return res;
}
/*
* Maximal bitmap file size. There is a direct, and {,double-,triple-}indirect
* block limit, and also a limit of (2^48 - 1) 512-byte sectors in i_blocks.
* We need to be 1 filesystem block less than the 2^48 sector limit.
*/
static loff_t <API key>(int bits, int has_huge_files)
{
loff_t res = EXT4_NDIR_BLOCKS;
int meta_blocks;
loff_t upper_limit;
/* This is calculated to be the largest file size for a dense, block
* mapped file such that the file's total number of 512-byte sectors,
* including data and all indirect blocks, does not exceed (2^48 - 1).
*
* __u32 i_blocks_lo and _u16 i_blocks_high represent the total
* number of 512-byte sectors of the file.
*/
if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) {
/*
* !has_huge_files or CONFIG_LBDAF not enabled implies that
* the inode i_block field represents total file blocks in
* 2^32 512-byte sectors == size of vfs inode i_blocks * 8
*/
upper_limit = (1LL << 32) - 1;
/* total blocks in file system block size */
upper_limit >>= (bits - 9);
} else {
/*
* We use 48 bit ext4_inode i_blocks
* With EXT4_HUGE_FILE_FL set the i_blocks
* represent total number of blocks in
* file system block size
*/
upper_limit = (1LL << 48) - 1;
}
/* indirect blocks */
meta_blocks = 1;
/* double indirect blocks */
meta_blocks += 1 + (1LL << (bits-2));
/* tripple indirect blocks */
meta_blocks += 1 + (1LL << (bits-2)) + (1LL << (2*(bits-2)));
upper_limit -= meta_blocks;
upper_limit <<= bits;
res += 1LL << (bits-2);
res += 1LL << (2*(bits-2));
res += 1LL << (3*(bits-2));
res <<= bits;
if (res > upper_limit)
res = upper_limit;
if (res > MAX_LFS_FILESIZE)
res = MAX_LFS_FILESIZE;
return res;
}
static ext4_fsblk_t descriptor_loc(struct super_block *sb,
ext4_fsblk_t logical_sb_block, int nr)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
ext4_group_t bg, first_meta_bg;
int has_super = 0;
first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
if (!<API key>(sb, <API key>) ||
nr < first_meta_bg)
return logical_sb_block + nr + 1;
bg = sbi->s_desc_per_block * nr;
if (ext4_bg_has_super(sb, bg))
has_super = 1;
return (has_super + <API key>(sb, bg));
}
/**
* <API key>: Get the stripe size.
* @sbi: In memory super block info
*
* If we have specified it via mount option, then
* use the mount option value. If the value specified at mount time is
* greater than the blocks per group use the super block value.
* If the super block value is greater than blocks per group return 0.
* Allocator needs it be less than blocks per group.
*
*/
static unsigned long <API key>(struct ext4_sb_info *sbi)
{
unsigned long stride = le16_to_cpu(sbi->s_es->s_raid_stride);
unsigned long stripe_width =
le32_to_cpu(sbi->s_es->s_raid_stripe_width);
int ret;
if (sbi->s_stripe && sbi->s_stripe <= sbi->s_blocks_per_group)
ret = sbi->s_stripe;
else if (stripe_width <= sbi->s_blocks_per_group)
ret = stripe_width;
else if (stride <= sbi->s_blocks_per_group)
ret = stride;
else
ret = 0;
/*
* If the stripe width is 1, this makes no sense and
* we set it to 0 to turn off stripe handling code.
*/
if (ret <= 1)
ret = 0;
return ret;
}
/* sysfs supprt */
struct ext4_attr {
struct attribute attr;
ssize_t (*show)(struct ext4_attr *, struct ext4_sb_info *, char *);
ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
const char *, size_t);
union {
int offset;
int deprecated_val;
} u;
};
static int parse_strtoull(const char *buf,
unsigned long long max, unsigned long long *value)
{
int ret;
ret = kstrtoull(skip_spaces(buf), 0, value);
if (!ret && *value > max)
ret = -EINVAL;
return ret;
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi,
char *buf)
{
return snprintf(buf, PAGE_SIZE, "%llu\n",
(s64) EXT4_C2B(sbi,
percpu_counter_sum(&sbi-><API key>)));
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
struct super_block *sb = sbi->s_buddy_cache->i_sb;
if (!sb->s_bdev->bd_part)
return snprintf(buf, PAGE_SIZE, "0\n");
return snprintf(buf, PAGE_SIZE, "%lu\n",
(part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
sbi-><API key>) >> 1);
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
struct super_block *sb = sbi->s_buddy_cache->i_sb;
if (!sb->s_bdev->bd_part)
return snprintf(buf, PAGE_SIZE, "0\n");
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long)(sbi->s_kbytes_written +
((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
EXT4_SB(sb)-><API key>) >> 1)));
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi,
const char *buf, size_t count)
{
unsigned long t;
int ret;
ret = kstrtoul(skip_spaces(buf), 0, &t);
if (ret)
return ret;
if (t && (!is_power_of_2(t) || t > 0x40000000))
return -EINVAL;
sbi-><API key> = t;
return count;
}
static ssize_t sbi_ui_show(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
unsigned int *ui = (unsigned int *) (((char *) sbi) + a->u.offset);
return snprintf(buf, PAGE_SIZE, "%u\n", *ui);
}
static ssize_t sbi_ui_store(struct ext4_attr *a,
struct ext4_sb_info *sbi,
const char *buf, size_t count)
{
unsigned int *ui = (unsigned int *) (((char *) sbi) + a->u.offset);
unsigned long t;
int ret;
ret = kstrtoul(skip_spaces(buf), 0, &t);
if (ret)
return ret;
*ui = t;
return count;
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%llu\n",
(unsigned long long) atomic64_read(&sbi->s_resv_clusters));
}
static ssize_t <API key>(struct ext4_attr *a,
struct ext4_sb_info *sbi,
const char *buf, size_t count)
{
unsigned long long val;
int ret;
if (parse_strtoull(buf, -1ULL, &val))
return -EINVAL;
ret = <API key>(sbi, val);
return ret ? ret : count;
}
static ssize_t trigger_test_error(struct ext4_attr *a,
struct ext4_sb_info *sbi,
const char *buf, size_t count)
{
int len = count;
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (len && buf[len-1] == '\n')
len
if (len)
ext4_error(sbi->s_sb, "%.*s", len, buf);
return count;
}
static ssize_t sbi_deprecated_show(struct ext4_attr *a,
struct ext4_sb_info *sbi, char *buf)
{
return snprintf(buf, PAGE_SIZE, "%d\n", a->u.deprecated_val);
}
#define EXT4_ATTR_OFFSET(_name,_mode,_show,_store,_elname) \
static struct ext4_attr ext4_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = _mode }, \
.show = _show, \
.store = _store, \
.u = { \
.offset = offsetof(struct ext4_sb_info, _elname),\
}, \
}
#define EXT4_ATTR(name, mode, show, store) \
static struct ext4_attr ext4_attr_##name = __ATTR(name, mode, show, store)
#define EXT4_INFO_ATTR(name) EXT4_ATTR(name, 0444, NULL, NULL)
#define EXT4_RO_ATTR(name) EXT4_ATTR(name, 0444, name##_show, NULL)
#define EXT4_RW_ATTR(name) EXT4_ATTR(name, 0644, name##_show, name##_store)
#define EXT4_RW_ATTR_SBI_UI(name, elname) \
EXT4_ATTR_OFFSET(name, 0644, sbi_ui_show, sbi_ui_store, elname)
#define ATTR_LIST(name) &ext4_attr_##name.attr
#define <API key>(_name, _val) \
static struct ext4_attr ext4_attr_##_name = { \
.attr = {.name = __stringify(_name), .mode = 0444 }, \
.show = sbi_deprecated_show, \
.u = { \
.deprecated_val = _val, \
}, \
}
EXT4_RO_ATTR(<API key>);
EXT4_RO_ATTR(<API key>);
EXT4_RO_ATTR(<API key>);
EXT4_RW_ATTR(reserved_clusters);
EXT4_ATTR_OFFSET(<API key>, 0644, sbi_ui_show,
<API key>, <API key>);
EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats);
EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan);
EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan);
EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs);
EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request);
EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc);
<API key>(<API key>, 128);
EXT4_RW_ATTR_SBI_UI(<API key>, <API key>);
EXT4_ATTR(trigger_fs_error, 0200, NULL, trigger_test_error);
static struct attribute *ext4_attrs[] = {
ATTR_LIST(<API key>),
ATTR_LIST(<API key>),
ATTR_LIST(<API key>),
ATTR_LIST(reserved_clusters),
ATTR_LIST(<API key>),
ATTR_LIST(inode_goal),
ATTR_LIST(mb_stats),
ATTR_LIST(mb_max_to_scan),
ATTR_LIST(mb_min_to_scan),
ATTR_LIST(mb_order2_req),
ATTR_LIST(mb_stream_req),
ATTR_LIST(mb_group_prealloc),
ATTR_LIST(<API key>),
ATTR_LIST(<API key>),
ATTR_LIST(trigger_fs_error),
NULL,
};
/* Features this copy of ext4 supports */
EXT4_INFO_ATTR(lazy_itable_init);
EXT4_INFO_ATTR(batched_discard);
EXT4_INFO_ATTR(meta_bg_resize);
static struct attribute *ext4_feat_attrs[] = {
ATTR_LIST(lazy_itable_init),
ATTR_LIST(batched_discard),
ATTR_LIST(meta_bg_resize),
NULL,
};
static ssize_t ext4_attr_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
s_kobj);
struct ext4_attr *a = container_of(attr, struct ext4_attr, attr);
return a->show ? a->show(a, sbi, buf) : 0;
}
static ssize_t ext4_attr_store(struct kobject *kobj,
struct attribute *attr,
const char *buf, size_t len)
{
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
s_kobj);
struct ext4_attr *a = container_of(attr, struct ext4_attr, attr);
return a->store ? a->store(a, sbi, buf, len) : 0;
}
static void ext4_sb_release(struct kobject *kobj)
{
struct ext4_sb_info *sbi = container_of(kobj, struct ext4_sb_info,
s_kobj);
complete(&sbi->s_kobj_unregister);
}
static const struct sysfs_ops ext4_attr_ops = {
.show = ext4_attr_show,
.store = ext4_attr_store,
};
static struct kobj_type ext4_ktype = {
.default_attrs = ext4_attrs,
.sysfs_ops = &ext4_attr_ops,
.release = ext4_sb_release,
};
static void ext4_feat_release(struct kobject *kobj)
{
complete(&ext4_feat->f_kobj_unregister);
}
static struct kobj_type ext4_feat_ktype = {
.default_attrs = ext4_feat_attrs,
.sysfs_ops = &ext4_attr_ops,
.release = ext4_feat_release,
};
/*
* Check whether this filesystem can be mounted based on
* the features present and the RDONLY/RDWR mount requested.
* Returns 1 if this filesystem can be mounted as requested,
* 0 if it cannot be.
*/
static int ext4_feature_set_ok(struct super_block *sb, int readonly)
{
if (<API key>(sb, ~<API key>)) {
ext4_msg(sb, KERN_ERR,
"Couldn't mount because of "
"unsupported optional features (%x)",
(le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_incompat) &
~<API key>));
return 0;
}
if (readonly)
return 1;
/* Check that feature set is OK for a read-write mount */
if (<API key>(sb, ~<API key>)) {
ext4_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
"unsupported optional features (%x)",
(le32_to_cpu(EXT4_SB(sb)->s_es->s_feature_ro_compat) &
~<API key>));
return 0;
}
/*
* Large file size enabled file system can only be mounted
* read-write on 32-bit systems if kernel is built with CONFIG_LBDAF
*/
if (<API key>(sb, <API key>)) {
if (sizeof(blkcnt_t) < sizeof(u64)) {
ext4_msg(sb, KERN_ERR, "Filesystem with huge files "
"cannot be mounted RDWR without "
"CONFIG_LBDAF");
return 0;
}
}
if (<API key>(sb, <API key>) &&
!<API key>(sb, <API key>)) {
ext4_msg(sb, KERN_ERR,
"Can't support bigalloc feature without "
"extents feature\n");
return 0;
}
#ifndef CONFIG_QUOTA
if (<API key>(sb, <API key>) &&
!readonly) {
ext4_msg(sb, KERN_ERR,
"Filesystem with quota feature cannot be mounted RDWR "
"without CONFIG_QUOTA");
return 0;
}
#endif /* CONFIG_QUOTA */
return 1;
}
/*
* This function is called once a day if we have errors logged
* on the file system
*/
static void <API key>(unsigned long arg)
{
struct super_block *sb = (struct super_block *) arg;
struct ext4_sb_info *sbi;
struct ext4_super_block *es;
sbi = EXT4_SB(sb);
es = sbi->s_es;
if (es->s_error_count)
ext4_msg(sb, KERN_NOTICE, "error count: %u",
le32_to_cpu(es->s_error_count));
if (es->s_first_error_time) {
printk(KERN_NOTICE "EXT4-fs (%s): initial error at %u: %.*s:%d",
sb->s_id, le32_to_cpu(es->s_first_error_time),
(int) sizeof(es->s_first_error_func),
es->s_first_error_func,
le32_to_cpu(es->s_first_error_line));
if (es->s_first_error_ino)
printk(": inode %u",
le32_to_cpu(es->s_first_error_ino));
if (es->s_first_error_block)
printk(": block %llu", (unsigned long long)
le64_to_cpu(es->s_first_error_block));
printk("\n");
}
if (es->s_last_error_time) {
printk(KERN_NOTICE "EXT4-fs (%s): last error at %u: %.*s:%d",
sb->s_id, le32_to_cpu(es->s_last_error_time),
(int) sizeof(es->s_last_error_func),
es->s_last_error_func,
le32_to_cpu(es->s_last_error_line));
if (es->s_last_error_ino)
printk(": inode %u",
le32_to_cpu(es->s_last_error_ino));
if (es->s_last_error_block)
printk(": block %llu", (unsigned long long)
le64_to_cpu(es->s_last_error_block));
printk("\n");
}
mod_timer(&sbi->s_err_report, jiffies + 24*60*60*HZ); /* Once a day */
}
/* Find next suitable group and run <API key> */
static int ext4_run_li_request(struct ext4_li_request *elr)
{
struct ext4_group_desc *gdp = NULL;
ext4_group_t group, ngroups;
struct super_block *sb;
unsigned long timeout = 0;
int ret = 0;
sb = elr->lr_super;
ngroups = EXT4_SB(sb)->s_groups_count;
sb_start_write(sb);
for (group = elr->lr_next_group; group < ngroups; group++) {
gdp = ext4_get_group_desc(sb, group, NULL);
if (!gdp) {
ret = 1;
break;
}
if (!(gdp->bg_flags & cpu_to_le16(<API key>)))
break;
}
if (group >= ngroups)
ret = 1;
if (!ret) {
timeout = jiffies;
ret = <API key>(sb, group,
elr->lr_timeout ? 0 : 1);
if (elr->lr_timeout == 0) {
timeout = (jiffies - timeout) *
elr->lr_sbi->s_li_wait_mult;
elr->lr_timeout = timeout;
}
elr->lr_next_sched = jiffies + elr->lr_timeout;
elr->lr_next_group = group + 1;
}
sb_end_write(sb);
return ret;
}
/*
* Remove lr_request from the list_request and free the
* request structure. Should be called with li_list_mtx held
*/
static void <API key>(struct ext4_li_request *elr)
{
struct ext4_sb_info *sbi;
if (!elr)
return;
sbi = elr->lr_sbi;
list_del(&elr->lr_request);
sbi->s_li_request = NULL;
kfree(elr);
}
static void <API key>(struct super_block *sb)
{
mutex_lock(&ext4_li_mtx);
if (!ext4_li_info) {
mutex_unlock(&ext4_li_mtx);
return;
}
mutex_lock(&ext4_li_info->li_list_mtx);
<API key>(EXT4_SB(sb)->s_li_request);
mutex_unlock(&ext4_li_info->li_list_mtx);
mutex_unlock(&ext4_li_mtx);
}
static struct task_struct *ext4_lazyinit_task;
/*
* This is the function where ext4lazyinit thread lives. It walks
* through the request list searching for next scheduled filesystem.
* When such a fs is found, run the lazy initialization request
* (ext4_rn_li_request) and keep track of the time spend in this
* function. Based on that time we compute next schedule time of
* the request. When walking through the list is complete, compute
* next waking time and put itself into sleep.
*/
static int <API key>(void *arg)
{
struct ext4_lazy_init *eli = (struct ext4_lazy_init *)arg;
struct list_head *pos, *n;
struct ext4_li_request *elr;
unsigned long next_wakeup, cur;
BUG_ON(NULL == eli);
cont_thread:
while (true) {
next_wakeup = MAX_JIFFY_OFFSET;
mutex_lock(&eli->li_list_mtx);
if (list_empty(&eli->li_request_list)) {
mutex_unlock(&eli->li_list_mtx);
goto exit_thread;
}
list_for_each_safe(pos, n, &eli->li_request_list) {
elr = list_entry(pos, struct ext4_li_request,
lr_request);
if (time_after_eq(jiffies, elr->lr_next_sched)) {
if (ext4_run_li_request(elr) != 0) {
/* error, remove the lazy_init job */
<API key>(elr);
continue;
}
}
if (time_before(elr->lr_next_sched, next_wakeup))
next_wakeup = elr->lr_next_sched;
}
mutex_unlock(&eli->li_list_mtx);
try_to_freeze();
cur = jiffies;
if ((time_after_eq(cur, next_wakeup)) ||
(MAX_JIFFY_OFFSET == next_wakeup)) {
cond_resched();
continue;
}
<API key>(next_wakeup - cur);
if (kthread_should_stop()) {
<API key>();
goto exit_thread;
}
}
exit_thread:
/*
* It looks like the request list is empty, but we need
* to check it under the li_list_mtx lock, to prevent any
* additions into it, and of course we should lock ext4_li_mtx
* to atomically free the list and ext4_li_info, because at
* this point another ext4 filesystem could be registering
* new one.
*/
mutex_lock(&ext4_li_mtx);
mutex_lock(&eli->li_list_mtx);
if (!list_empty(&eli->li_request_list)) {
mutex_unlock(&eli->li_list_mtx);
mutex_unlock(&ext4_li_mtx);
goto cont_thread;
}
mutex_unlock(&eli->li_list_mtx);
kfree(ext4_li_info);
ext4_li_info = NULL;
mutex_unlock(&ext4_li_mtx);
return 0;
}
static void <API key>(void)
{
struct list_head *pos, *n;
struct ext4_li_request *elr;
mutex_lock(&ext4_li_info->li_list_mtx);
list_for_each_safe(pos, n, &ext4_li_info->li_request_list) {
elr = list_entry(pos, struct ext4_li_request,
lr_request);
<API key>(elr);
}
mutex_unlock(&ext4_li_info->li_list_mtx);
}
static int <API key>(void)
{
ext4_lazyinit_task = kthread_run(<API key>,
ext4_li_info, "ext4lazyinit");
if (IS_ERR(ext4_lazyinit_task)) {
int err = PTR_ERR(ext4_lazyinit_task);
<API key>();
kfree(ext4_li_info);
ext4_li_info = NULL;
printk(KERN_CRIT "EXT4-fs: error %d creating inode table "
"initialization thread\n",
err);
return err;
}
ext4_li_info->li_state |= <API key>;
return 0;
}
/*
* Check whether it make sense to run itable init. thread or not.
* If there is at least one uninitialized inode table, return
* corresponding group number, else the loop goes through all
* groups and return total number of groups.
*/
static ext4_group_t <API key>(struct super_block *sb)
{
ext4_group_t group, ngroups = EXT4_SB(sb)->s_groups_count;
struct ext4_group_desc *gdp = NULL;
for (group = 0; group < ngroups; group++) {
gdp = ext4_get_group_desc(sb, group, NULL);
if (!gdp)
continue;
if (!(gdp->bg_flags & cpu_to_le16(<API key>)))
break;
}
return group;
}
static int ext4_li_info_new(void)
{
struct ext4_lazy_init *eli = NULL;
eli = kzalloc(sizeof(*eli), GFP_KERNEL);
if (!eli)
return -ENOMEM;
INIT_LIST_HEAD(&eli->li_request_list);
mutex_init(&eli->li_list_mtx);
eli->li_state |= EXT4_LAZYINIT_QUIT;
ext4_li_info = eli;
return 0;
}
static struct ext4_li_request *ext4_li_request_new(struct super_block *sb,
ext4_group_t start)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_li_request *elr;
unsigned long rnd;
elr = kzalloc(sizeof(*elr), GFP_KERNEL);
if (!elr)
return NULL;
elr->lr_super = sb;
elr->lr_sbi = sbi;
elr->lr_next_group = start;
/*
* Randomize first schedule time of the request to
* spread the inode table initialization requests
* better.
*/
get_random_bytes(&rnd, sizeof(rnd));
elr->lr_next_sched = jiffies + (unsigned long)rnd %
(<API key> * HZ);
return elr;
}
int <API key>(struct super_block *sb,
ext4_group_t first_not_zeroed)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_li_request *elr = NULL;
ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
int ret = 0;
mutex_lock(&ext4_li_mtx);
if (sbi->s_li_request != NULL) {
/*
* Reset timeout so it can be computed again, because
* s_li_wait_mult might have changed.
*/
sbi->s_li_request->lr_timeout = 0;
goto out;
}
if (first_not_zeroed == ngroups ||
(sb->s_flags & MS_RDONLY) ||
!test_opt(sb, INIT_INODE_TABLE))
goto out;
elr = ext4_li_request_new(sb, first_not_zeroed);
if (!elr) {
ret = -ENOMEM;
goto out;
}
if (NULL == ext4_li_info) {
ret = ext4_li_info_new();
if (ret)
goto out;
}
mutex_lock(&ext4_li_info->li_list_mtx);
list_add(&elr->lr_request, &ext4_li_info->li_request_list);
mutex_unlock(&ext4_li_info->li_list_mtx);
sbi->s_li_request = elr;
/*
* set elr to NULL here since it has been inserted to
* the request_list and the removal and free of it is
* handled by <API key> from now on.
*/
elr = NULL;
if (!(ext4_li_info->li_state & <API key>)) {
ret = <API key>();
if (ret)
goto out;
}
out:
mutex_unlock(&ext4_li_mtx);
if (ret)
kfree(elr);
return ret;
}
/*
* We do not need to lock anything since this is called on
* module unload.
*/
static void <API key>(void)
{
/*
* If thread exited earlier
* there's nothing to be done.
*/
if (!ext4_li_info || !ext4_lazyinit_task)
return;
kthread_stop(ext4_lazyinit_task);
}
static int <API key>(struct super_block *sb)
{
int ret = 1;
int compat, incompat;
struct ext4_sb_info *sbi = EXT4_SB(sb);
if (<API key>(sb,
<API key>)) {
/* journal checksum v2 */
compat = 0;
incompat = <API key>;
} else {
/* journal checksum v1 */
compat = <API key>;
incompat = 0;
}
if (test_opt(sb, <API key>)) {
ret = <API key>(sbi->s_journal,
compat, 0,
<API key> |
incompat);
} else if (test_opt(sb, JOURNAL_CHECKSUM)) {
ret = <API key>(sbi->s_journal,
compat, 0,
incompat);
<API key>(sbi->s_journal, 0, 0,
<API key>);
} else {
<API key>(sbi->s_journal,
<API key>, 0,
<API key> |
<API key>);
}
return ret;
}
static int count_overhead(struct super_block *sb, ext4_group_t grp,
char *buf)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_group_desc *gdp;
ext4_fsblk_t first_block, last_block, b;
ext4_group_t i, ngroups = <API key>(sb);
int s, j, count = 0;
if (!<API key>(sb, <API key>))
return (ext4_bg_has_super(sb, grp) + ext4_bg_num_gdb(sb, grp) +
sbi->s_itb_per_group + 2);
first_block = le32_to_cpu(sbi->s_es->s_first_data_block) +
(grp * <API key>(sb));
last_block = first_block + <API key>(sb) - 1;
for (i = 0; i < ngroups; i++) {
gdp = ext4_get_group_desc(sb, i, NULL);
b = ext4_block_bitmap(sb, gdp);
if (b >= first_block && b <= last_block) {
ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
count++;
}
b = ext4_inode_bitmap(sb, gdp);
if (b >= first_block && b <= last_block) {
ext4_set_bit(EXT4_B2C(sbi, b - first_block), buf);
count++;
}
b = ext4_inode_table(sb, gdp);
if (b >= first_block && b + sbi->s_itb_per_group <= last_block)
for (j = 0; j < sbi->s_itb_per_group; j++, b++) {
int c = EXT4_B2C(sbi, b - first_block);
ext4_set_bit(c, buf);
count++;
}
if (i != grp)
continue;
s = 0;
if (ext4_bg_has_super(sb, grp)) {
ext4_set_bit(s++, buf);
count++;
}
for (j = ext4_bg_num_gdb(sb, grp); j > 0; j
ext4_set_bit(EXT4_B2C(sbi, s++), buf);
count++;
}
}
if (!count)
return 0;
return <API key>(sb) -
ext4_count_free(buf, <API key>(sb) / 8);
}
/*
* Compute the overhead and stash it in sbi->s_overhead
*/
int <API key>(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
ext4_group_t i, ngroups = <API key>(sb);
ext4_fsblk_t overhead = 0;
char *buf = (char *) get_zeroed_page(GFP_KERNEL);
if (!buf)
return -ENOMEM;
/*
* Compute the overhead (FS structures). This is constant
* for a given filesystem unless the number of block groups
* changes so we cache the previous value until it does.
*/
/*
* All of the blocks before first_data_block are overhead
*/
overhead = EXT4_B2C(sbi, le32_to_cpu(es->s_first_data_block));
/*
* Add the overhead found in each block group
*/
for (i = 0; i < ngroups; i++) {
int blks;
blks = count_overhead(sb, i, buf);
overhead += blks;
if (blks)
memset(buf, 0, PAGE_SIZE);
cond_resched();
}
/* Add the journal blocks as well */
if (sbi->s_journal)
overhead += EXT4_NUM_B2C(sbi, sbi->s_journal->j_maxlen);
sbi->s_overhead = overhead;
smp_wmb();
free_page((unsigned long) buf);
return 0;
}
static ext4_fsblk_t <API key>(struct ext4_sb_info *sbi)
{
ext4_fsblk_t resv_clusters;
/*
* By default we reserve 2% or 4096 clusters, whichever is smaller.
* This should cover the situations where we can not afford to run
* out of space like for example punch hole, or converting
* uninitialized extents in delalloc path. In most cases such
* allocation would require 1, or 2 blocks, higher numbers are
* very rare.
*/
resv_clusters = ext4_blocks_count(sbi->s_es) >> sbi->s_cluster_bits;
do_div(resv_clusters, 50);
resv_clusters = min_t(ext4_fsblk_t, resv_clusters, 4096);
return resv_clusters;
}
static int <API key>(struct ext4_sb_info *sbi, ext4_fsblk_t count)
{
ext4_fsblk_t clusters = ext4_blocks_count(sbi->s_es) >>
sbi->s_cluster_bits;
if (count >= clusters)
return -EINVAL;
atomic64_set(&sbi->s_resv_clusters, count);
return 0;
}
static int ext4_fill_super(struct super_block *sb, void *data, int silent)
{
char *orig_data = kstrdup(data, GFP_KERNEL);
struct buffer_head *bh;
struct ext4_super_block *es = NULL;
struct ext4_sb_info *sbi;
ext4_fsblk_t block;
ext4_fsblk_t sb_block = get_sb_block(&data);
ext4_fsblk_t logical_sb_block;
unsigned long offset = 0;
unsigned long journal_devnum = 0;
unsigned long def_mount_opts;
struct inode *root;
char *cp;
const char *descr;
int ret = -ENOMEM;
int blocksize, clustersize;
unsigned int db_count;
unsigned int i;
int needs_recovery, has_huge_files, has_bigalloc;
__u64 blocks_count;
int err = 0;
unsigned int journal_ioprio = <API key>;
ext4_group_t first_not_zeroed;
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi)
goto out_free_orig;
sbi->s_blockgroup_lock =
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
if (!sbi->s_blockgroup_lock) {
kfree(sbi);
goto out_free_orig;
}
sb->s_fs_info = sbi;
sbi->s_sb = sb;
sbi-><API key> = <API key>;
sbi->s_sb_block = sb_block;
if (sb->s_bdev->bd_part)
sbi-><API key> =
part_stat_read(sb->s_bdev->bd_part, sectors[1]);
/* Cleanup superblock name */
for (cp = sb->s_id; (cp = strchr(cp, '/'));)
*cp = '!';
/* -EINVAL is default */
ret = -EINVAL;
blocksize = sb_min_blocksize(sb, EXT4_MIN_BLOCK_SIZE);
if (!blocksize) {
ext4_msg(sb, KERN_ERR, "unable to set blocksize");
goto out_fail;
}
/*
* The ext4 superblock will not be buffer aligned for other than 1kB
* block sizes. We need to calculate the offset from buffer start.
*/
if (blocksize != EXT4_MIN_BLOCK_SIZE) {
logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
offset = do_div(logical_sb_block, blocksize);
} else {
logical_sb_block = sb_block;
}
if (!(bh = sb_bread(sb, logical_sb_block))) {
ext4_msg(sb, KERN_ERR, "unable to read superblock");
goto out_fail;
}
/*
* Note: s_es must be initialized as soon as possible because
* some ext4 macro-instructions depend on its value
*/
es = (struct ext4_super_block *) (bh->b_data + offset);
sbi->s_es = es;
sb->s_magic = le16_to_cpu(es->s_magic);
if (sb->s_magic != EXT4_SUPER_MAGIC)
goto cantfind_ext4;
sbi->s_kbytes_written = le64_to_cpu(es->s_kbytes_written);
/* Warn if metadata_csum and gdt_csum are both set. */
if (<API key>(sb,
<API key>) &&
<API key>(sb, <API key>))
ext4_warning(sb, KERN_INFO "metadata_csum and uninit_bg are "
"redundant flags; please run fsck.");
/* Check for a known checksum algorithm */
if (!<API key>(sb, es)) {
ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with "
"unknown checksum algorithm.");
silent = 1;
goto cantfind_ext4;
}
/* Load the checksum driver */
if (<API key>(sb,
<API key>)) {
sbi->s_chksum_driver = crypto_alloc_shash("crc32c", 0, 0);
if (IS_ERR(sbi->s_chksum_driver)) {
ext4_msg(sb, KERN_ERR, "Cannot load crc32c driver.");
ret = PTR_ERR(sbi->s_chksum_driver);
sbi->s_chksum_driver = NULL;
goto failed_mount;
}
}
/* Check superblock checksum */
if (!<API key>(sb, es)) {
ext4_msg(sb, KERN_ERR, "VFS: Found ext4 filesystem with "
"invalid superblock checksum. Run e2fsck?");
silent = 1;
goto cantfind_ext4;
}
/* Precompute checksum seed for all metadata */
if (<API key>(sb,
<API key>))
sbi->s_csum_seed = ext4_chksum(sbi, ~0, es->s_uuid,
sizeof(es->s_uuid));
/* Set defaults before we parse the mount options */
def_mount_opts = le32_to_cpu(es-><API key>);
set_opt(sb, INIT_INODE_TABLE);
if (def_mount_opts & EXT4_DEFM_DEBUG)
set_opt(sb, DEBUG);
if (def_mount_opts & EXT4_DEFM_BSDGROUPS)
set_opt(sb, GRPID);
if (def_mount_opts & EXT4_DEFM_UID16)
set_opt(sb, NO_UID32);
/* xattr user namespace & acls are now defaulted on */
set_opt(sb, XATTR_USER);
#ifdef <API key>
set_opt(sb, POSIX_ACL);
#endif
if ((def_mount_opts & EXT4_DEFM_JMODE) == <API key>)
set_opt(sb, JOURNAL_DATA);
else if ((def_mount_opts & EXT4_DEFM_JMODE) == <API key>)
set_opt(sb, ORDERED_DATA);
else if ((def_mount_opts & EXT4_DEFM_JMODE) == <API key>)
set_opt(sb, WRITEBACK_DATA);
if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC)
set_opt(sb, ERRORS_PANIC);
else if (le16_to_cpu(sbi->s_es->s_errors) == <API key>)
set_opt(sb, ERRORS_CONT);
else
set_opt(sb, ERRORS_RO);
if (def_mount_opts & <API key>)
set_opt(sb, BLOCK_VALIDITY);
if (def_mount_opts & EXT4_DEFM_DISCARD)
set_opt(sb, DISCARD);
sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
sbi->s_commit_interval = <API key> * HZ;
sbi->s_min_batch_time = <API key>;
sbi->s_max_batch_time = <API key>;
if ((def_mount_opts & EXT4_DEFM_NOBARRIER) == 0)
set_opt(sb, BARRIER);
/*
* enable delayed allocation by default
* Use -o nodelalloc to turn it off
*/
if (!IS_EXT3_SB(sb) && !IS_EXT2_SB(sb) &&
((def_mount_opts & <API key>) == 0))
set_opt(sb, DELALLOC);
/*
* set default s_li_wait_mult for lazyinit, for the case there is
* no mount option specified.
*/
sbi->s_li_wait_mult = <API key>;
if (!parse_options((char *) sbi->s_es->s_mount_opts, sb,
&journal_devnum, &journal_ioprio, 0)) {
ext4_msg(sb, KERN_WARNING,
"failed to parse options in superblock: %s",
sbi->s_es->s_mount_opts);
}
sbi->s_def_mount_opt = sbi->s_mount_opt;
if (!parse_options((char *) data, sb, &journal_devnum,
&journal_ioprio, 0))
goto failed_mount;
if (test_opt(sb, DATA_FLAGS) == <API key>) {
printk_once(KERN_WARNING "EXT4-fs: Warning: mounting "
"with data=journal disables delayed "
"allocation and O_DIRECT support!\n");
if (test_opt2(sb, EXPLICIT_DELALLOC)) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"both data=journal and delalloc");
goto failed_mount;
}
if (test_opt(sb, DIOREAD_NOLOCK)) {
ext4_msg(sb, KERN_ERR, "can't mount with "
"both data=journal and delalloc");
goto failed_mount;
}
if (test_opt(sb, DELALLOC))
clear_opt(sb, DELALLOC);
}
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
(test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
(<API key>(sb, ~0U) ||
<API key>(sb, ~0U) ||
<API key>(sb, ~0U)))
ext4_msg(sb, KERN_WARNING,
"feature flags set on rev 0 fs, "
"running e2fsck is recommended");
if (IS_EXT2_SB(sb)) {
if (ext2_feature_set_ok(sb))
ext4_msg(sb, KERN_INFO, "mounting ext2 file system "
"using the ext4 subsystem");
else {
ext4_msg(sb, KERN_ERR, "couldn't mount as ext2 due "
"to feature incompatibilities");
goto failed_mount;
}
}
if (IS_EXT3_SB(sb)) {
if (ext3_feature_set_ok(sb))
ext4_msg(sb, KERN_INFO, "mounting ext3 file system "
"using the ext4 subsystem");
else {
ext4_msg(sb, KERN_ERR, "couldn't mount as ext3 due "
"to feature incompatibilities");
goto failed_mount;
}
}
/*
* Check feature flags regardless of the revision level, since we
* previously didn't change the revision level when setting the flags,
* so there is a chance incompat flags are set on a rev 0 filesystem.
*/
if (!ext4_feature_set_ok(sb, (sb->s_flags & MS_RDONLY)))
goto failed_mount;
blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
if (blocksize < EXT4_MIN_BLOCK_SIZE ||
blocksize > EXT4_MAX_BLOCK_SIZE) {
ext4_msg(sb, KERN_ERR,
"Unsupported filesystem blocksize %d", blocksize);
goto failed_mount;
}
if (sb->s_blocksize != blocksize) {
/* Validate the filesystem blocksize */
if (!sb_set_blocksize(sb, blocksize)) {
ext4_msg(sb, KERN_ERR, "bad block size %d",
blocksize);
goto failed_mount;
}
brelse(bh);
logical_sb_block = sb_block * EXT4_MIN_BLOCK_SIZE;
offset = do_div(logical_sb_block, blocksize);
bh = sb_bread(sb, logical_sb_block);
if (!bh) {
ext4_msg(sb, KERN_ERR,
"Can't read superblock on 2nd try");
goto failed_mount;
}
es = (struct ext4_super_block *)(bh->b_data + offset);
sbi->s_es = es;
if (es->s_magic != cpu_to_le16(EXT4_SUPER_MAGIC)) {
ext4_msg(sb, KERN_ERR,
"Magic mismatch, very weird!");
goto failed_mount;
}
}
has_huge_files = <API key>(sb,
<API key>);
sbi->s_bitmap_maxbytes = <API key>(sb->s_blocksize_bits,
has_huge_files);
sb->s_maxbytes = ext4_max_size(sb->s_blocksize_bits, has_huge_files);
if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV) {
sbi->s_inode_size = <API key>;
sbi->s_first_ino = <API key>;
} else {
sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
if ((sbi->s_inode_size < <API key>) ||
(!is_power_of_2(sbi->s_inode_size)) ||
(sbi->s_inode_size > blocksize)) {
ext4_msg(sb, KERN_ERR,
"unsupported inode size: %d",
sbi->s_inode_size);
goto failed_mount;
}
if (sbi->s_inode_size > <API key>)
sb->s_time_gran = 1 << (EXT4_EPOCH_BITS - 2);
}
sbi->s_desc_size = le16_to_cpu(es->s_desc_size);
if (<API key>(sb, <API key>)) {
if (sbi->s_desc_size < <API key> ||
sbi->s_desc_size > EXT4_MAX_DESC_SIZE ||
!is_power_of_2(sbi->s_desc_size)) {
ext4_msg(sb, KERN_ERR,
"unsupported descriptor size %lu",
sbi->s_desc_size);
goto failed_mount;
}
} else
sbi->s_desc_size = EXT4_MIN_DESC_SIZE;
sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
if (EXT4_INODE_SIZE(sb) == 0 || <API key>(sb) == 0)
goto cantfind_ext4;
sbi->s_inodes_per_block = blocksize / EXT4_INODE_SIZE(sb);
if (sbi->s_inodes_per_block == 0)
goto cantfind_ext4;
sbi->s_itb_per_group = sbi->s_inodes_per_group /
sbi->s_inodes_per_block;
sbi->s_desc_per_block = blocksize / EXT4_DESC_SIZE(sb);
sbi->s_sbh = bh;
sbi->s_mount_state = le16_to_cpu(es->s_state);
sbi-><API key> = ilog2(EXT4_ADDR_PER_BLOCK(sb));
sbi-><API key> = ilog2(EXT4_DESC_PER_BLOCK(sb));
for (i = 0; i < 4; i++)
sbi->s_hash_seed[i] = le32_to_cpu(es->s_hash_seed[i]);
sbi->s_def_hash_version = es->s_def_hash_version;
i = le32_to_cpu(es->s_flags);
if (i & <API key>)
sbi->s_hash_unsigned = 3;
else if ((i & <API key>) == 0) {
#ifdef __CHAR_UNSIGNED__
es->s_flags |= cpu_to_le32(<API key>);
sbi->s_hash_unsigned = 3;
#else
es->s_flags |= cpu_to_le32(<API key>);
#endif
}
/* Handle clustersize */
clustersize = BLOCK_SIZE << le32_to_cpu(es->s_log_cluster_size);
has_bigalloc = <API key>(sb,
<API key>);
if (has_bigalloc) {
if (clustersize < blocksize) {
ext4_msg(sb, KERN_ERR,
"cluster size (%d) smaller than "
"block size (%d)", clustersize, blocksize);
goto failed_mount;
}
sbi->s_cluster_bits = le32_to_cpu(es->s_log_cluster_size) -
le32_to_cpu(es->s_log_block_size);
sbi-><API key> =
le32_to_cpu(es-><API key>);
if (sbi-><API key> > blocksize * 8) {
ext4_msg(sb, KERN_ERR,
"#clusters per group too big: %lu",
sbi-><API key>);
goto failed_mount;
}
if (sbi->s_blocks_per_group !=
(sbi-><API key> * (clustersize / blocksize))) {
ext4_msg(sb, KERN_ERR, "blocks per group (%lu) and "
"clusters per group (%lu) inconsistent",
sbi->s_blocks_per_group,
sbi-><API key>);
goto failed_mount;
}
} else {
if (clustersize != blocksize) {
ext4_warning(sb, "fragment/cluster size (%d) != "
"block size (%d)", clustersize,
blocksize);
clustersize = blocksize;
}
if (sbi->s_blocks_per_group > blocksize * 8) {
ext4_msg(sb, KERN_ERR,
"#blocks per group too big: %lu",
sbi->s_blocks_per_group);
goto failed_mount;
}
sbi-><API key> = sbi->s_blocks_per_group;
sbi->s_cluster_bits = 0;
}
sbi->s_cluster_ratio = clustersize / blocksize;
if (sbi->s_inodes_per_group > blocksize * 8) {
ext4_msg(sb, KERN_ERR,
"#inodes per group too big: %lu",
sbi->s_inodes_per_group);
goto failed_mount;
}
/* Do we have standard group size of clustersize * 8 blocks ? */
if (sbi->s_blocks_per_group == clustersize << 3)
set_opt2(sb, STD_GROUP_SIZE);
/*
* Test whether we have more sectors than will fit in sector_t,
* and whether the max offset is addressable by the page cache.
*/
err = <API key>(sb->s_blocksize_bits,
ext4_blocks_count(es));
if (err) {
ext4_msg(sb, KERN_ERR, "filesystem"
" too large to mount safely on this system");
if (sizeof(sector_t) < 8)
ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled");
goto failed_mount;
}
if (<API key>(sb) == 0)
goto cantfind_ext4;
/* check blocks count against device size */
blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits;
if (blocks_count && ext4_blocks_count(es) > blocks_count) {
ext4_msg(sb, KERN_WARNING, "bad geometry: block count %llu "
"exceeds size of device (%llu blocks)",
ext4_blocks_count(es), blocks_count);
goto failed_mount;
}
/*
* It makes no sense for the first data block to be beyond the end
* of the filesystem.
*/
if (le32_to_cpu(es->s_first_data_block) >= ext4_blocks_count(es)) {
ext4_msg(sb, KERN_WARNING, "bad geometry: first data "
"block %u is beyond end of filesystem (%llu)",
le32_to_cpu(es->s_first_data_block),
ext4_blocks_count(es));
goto failed_mount;
}
blocks_count = (ext4_blocks_count(es) -
le32_to_cpu(es->s_first_data_block) +
<API key>(sb) - 1);
do_div(blocks_count, <API key>(sb));
if (blocks_count > ((uint64_t)1<<32) - EXT4_DESC_PER_BLOCK(sb)) {
ext4_msg(sb, KERN_WARNING, "groups count too large: %u "
"(block count %llu, first data block %u, "
"blocks per group %lu)", sbi->s_groups_count,
ext4_blocks_count(es),
le32_to_cpu(es->s_first_data_block),
<API key>(sb));
goto failed_mount;
}
sbi->s_groups_count = blocks_count;
sbi->s_blockfile_groups = min_t(ext4_group_t, sbi->s_groups_count,
(<API key> / <API key>(sb)));
db_count = (sbi->s_groups_count + EXT4_DESC_PER_BLOCK(sb) - 1) /
EXT4_DESC_PER_BLOCK(sb);
sbi->s_group_desc = ext4_kvmalloc(db_count *
sizeof(struct buffer_head *),
GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
ext4_msg(sb, KERN_ERR, "not enough memory");
ret = -ENOMEM;
goto failed_mount;
}
if (ext4_proc_root)
sbi->s_proc = proc_mkdir(sb->s_id, ext4_proc_root);
if (sbi->s_proc)
proc_create_data("options", S_IRUGO, sbi->s_proc,
&<API key>, sb);
bgl_lock_init(sbi->s_blockgroup_lock);
for (i = 0; i < db_count; i++) {
block = descriptor_loc(sb, logical_sb_block, i);
sbi->s_group_desc[i] = sb_bread(sb, block);
if (!sbi->s_group_desc[i]) {
ext4_msg(sb, KERN_ERR,
"can't read group descriptor %d", i);
db_count = i;
goto failed_mount2;
}
}
if (!<API key>(sb, &first_not_zeroed)) {
ext4_msg(sb, KERN_ERR, "group descriptors corrupted!");
goto failed_mount2;
}
if (<API key>(sb, <API key>))
if (!ext4_fill_flex_info(sb)) {
ext4_msg(sb, KERN_ERR,
"unable to initialize "
"flex_bg meta info!");
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
get_random_bytes(&sbi->s_next_generation, sizeof(u32));
spin_lock_init(&sbi->s_next_gen_lock);
init_timer(&sbi->s_err_report);
sbi->s_err_report.function = <API key>;
sbi->s_err_report.data = (unsigned long) sb;
/* Register extent status tree shrinker */
<API key>(sbi);
err = percpu_counter_init(&sbi-><API key>,
<API key>(sb));
if (!err) {
err = percpu_counter_init(&sbi-><API key>,
<API key>(sb));
}
if (!err) {
err = percpu_counter_init(&sbi->s_dirs_counter,
ext4_count_dirs(sb));
}
if (!err) {
err = percpu_counter_init(&sbi-><API key>, 0);
}
if (!err) {
err = percpu_counter_init(&sbi->s_extent_cache_cnt, 0);
}
if (err) {
ext4_msg(sb, KERN_ERR, "insufficient memory");
goto failed_mount3;
}
sbi->s_stripe = <API key>(sbi);
sbi-><API key> = 32;
/*
* set up enough so that it can read an inode
*/
if (!test_opt(sb, NOLOAD) &&
<API key>(sb, <API key>))
sb->s_op = &ext4_sops;
else
sb->s_op = &ext4_nojournal_sops;
sb->s_export_op = &ext4_export_ops;
sb->s_xattr = ext4_xattr_handlers;
#ifdef CONFIG_QUOTA
sb->dq_op = &<API key>;
if (<API key>(sb, <API key>))
sb->s_qcop = &<API key>;
else
sb->s_qcop = &<API key>;
#endif
memcpy(sb->s_uuid, es->s_uuid, sizeof(es->s_uuid));
INIT_LIST_HEAD(&sbi->s_orphan); /* unlinked but open files */
mutex_init(&sbi->s_orphan_lock);
sb->s_root = NULL;
needs_recovery = (es->s_last_orphan != 0 ||
<API key>(sb,
<API key>));
if (<API key>(sb, <API key>) &&
!(sb->s_flags & MS_RDONLY))
if (<API key>(sb, le64_to_cpu(es->s_mmp_block)))
goto failed_mount3;
/*
* The first inode we look at is the journal inode. Don't try
* root first: it may be modified in the journal!
*/
if (!test_opt(sb, NOLOAD) &&
<API key>(sb, <API key>)) {
if (ext4_load_journal(sb, es, journal_devnum))
goto failed_mount3;
} else if (test_opt(sb, NOLOAD) && !(sb->s_flags & MS_RDONLY) &&
<API key>(sb, <API key>)) {
ext4_msg(sb, KERN_ERR, "required journal recovery "
"suppressed and not mounted read-only");
goto failed_mount_wq;
} else {
clear_opt(sb, DATA_FLAGS);
sbi->s_journal = NULL;
needs_recovery = 0;
goto no_journal;
}
if (<API key>(sb, <API key>) &&
!<API key>(EXT4_SB(sb)->s_journal, 0, 0,
<API key>)) {
ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature");
goto failed_mount_wq;
}
if (!<API key>(sb)) {
ext4_msg(sb, KERN_ERR, "Failed to set journal checksum "
"feature set");
goto failed_mount_wq;
}
/* We have now updated the journal if required, so we can
* validate the data journaling mode. */
switch (test_opt(sb, DATA_FLAGS)) {
case 0:
/* No mode set, assume a default based on the journal
* capabilities: ORDERED_DATA if the journal can
* cope, else JOURNAL_DATA
*/
if (<API key>
(sbi->s_journal, 0, 0, <API key>))
set_opt(sb, ORDERED_DATA);
else
set_opt(sb, JOURNAL_DATA);
break;
case <API key>:
case <API key>:
if (!<API key>
(sbi->s_journal, 0, 0, <API key>)) {
ext4_msg(sb, KERN_ERR, "Journal does not support "
"requested data journaling mode");
goto failed_mount_wq;
}
default:
break;
}
set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
sbi->s_journal->j_commit_callback = <API key>;
/*
* The journal may have updated the bg summary counts, so we
* need to update the global counters.
*/
percpu_counter_set(&sbi-><API key>,
<API key>(sb));
percpu_counter_set(&sbi-><API key>,
<API key>(sb));
percpu_counter_set(&sbi->s_dirs_counter,
ext4_count_dirs(sb));
percpu_counter_set(&sbi-><API key>, 0);
no_journal:
/*
* Get the # of file system overhead blocks from the
* superblock if present.
*/
if (es->s_overhead_clusters)
sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
else {
err = <API key>(sb);
if (err)
goto failed_mount_wq;
}
/*
* The maximum number of concurrent works can be high and
* concurrency isn't really necessary. Limit it to 1.
*/
EXT4_SB(sb)->rsv_conversion_wq =
alloc_workqueue("ext4-rsv-conversion", WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
if (!EXT4_SB(sb)->rsv_conversion_wq) {
printk(KERN_ERR "EXT4-fs: failed to create workqueue\n");
ret = -ENOMEM;
goto failed_mount4;
}
EXT4_SB(sb)->unrsv_conversion_wq =
alloc_workqueue("<API key>", WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
if (!EXT4_SB(sb)->unrsv_conversion_wq) {
printk(KERN_ERR "EXT4-fs: failed to create workqueue\n");
ret = -ENOMEM;
goto failed_mount4;
}
/*
* The jbd2_journal_load will have done any necessary log recovery,
* so we can safely mount the rest of the filesystem now.
*/
root = ext4_iget(sb, EXT4_ROOT_INO);
if (IS_ERR(root)) {
ext4_msg(sb, KERN_ERR, "get root inode failed");
ret = PTR_ERR(root);
root = NULL;
goto failed_mount4;
}
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
ext4_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck");
iput(root);
goto failed_mount4;
}
sb->s_root = d_make_root(root);
if (!sb->s_root) {
ext4_msg(sb, KERN_ERR, "get root dentry failed");
ret = -ENOMEM;
goto failed_mount4;
}
if (ext4_setup_super(sb, es, sb->s_flags & MS_RDONLY))
sb->s_flags |= MS_RDONLY;
/* determine the minimum size of new large inodes, if present */
if (sbi->s_inode_size > <API key>) {
sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
<API key>;
if (<API key>(sb,
<API key>)) {
if (sbi->s_want_extra_isize <
le16_to_cpu(es->s_want_extra_isize))
sbi->s_want_extra_isize =
le16_to_cpu(es->s_want_extra_isize);
if (sbi->s_want_extra_isize <
le16_to_cpu(es->s_min_extra_isize))
sbi->s_want_extra_isize =
le16_to_cpu(es->s_min_extra_isize);
}
}
/* Check if enough inode space is available */
if (<API key> + sbi->s_want_extra_isize >
sbi->s_inode_size) {
sbi->s_want_extra_isize = sizeof(struct ext4_inode) -
<API key>;
ext4_msg(sb, KERN_INFO, "required extra inode space not"
"available");
}
err = <API key>(sbi, <API key>(sbi));
if (err) {
ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for "
"reserved pool", <API key>(sbi));
goto failed_mount4a;
}
err = <API key>(sb);
if (err) {
ext4_msg(sb, KERN_ERR, "failed to initialize system "
"zone (%d)", err);
goto failed_mount4a;
}
ext4_ext_init(sb);
err = ext4_mb_init(sb);
if (err) {
ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)",
err);
goto failed_mount5;
}
err = <API key>(sb, first_not_zeroed);
if (err)
goto failed_mount6;
sbi->s_kobj.kset = ext4_kset;
init_completion(&sbi->s_kobj_unregister);
err = <API key>(&sbi->s_kobj, &ext4_ktype, NULL,
"%s", sb->s_id);
if (err)
goto failed_mount7;
#ifdef CONFIG_QUOTA
/* Enable quota usage during mount. */
if (<API key>(sb, <API key>) &&
!(sb->s_flags & MS_RDONLY)) {
err = ext4_enable_quotas(sb);
if (err)
goto failed_mount8;
}
#endif /* CONFIG_QUOTA */
EXT4_SB(sb)->s_mount_state |= EXT4_ORPHAN_FS;
ext4_orphan_cleanup(sb, es);
EXT4_SB(sb)->s_mount_state &= ~EXT4_ORPHAN_FS;
if (needs_recovery) {
ext4_msg(sb, KERN_INFO, "recovery complete");
<API key>(sb, es);
}
if (EXT4_SB(sb)->s_journal) {
if (test_opt(sb, DATA_FLAGS) == <API key>)
descr = " journalled data mode";
else if (test_opt(sb, DATA_FLAGS) == <API key>)
descr = " ordered data mode";
else
descr = " writeback data mode";
} else
descr = "out journal";
if (test_opt(sb, DISCARD)) {
struct request_queue *q = bdev_get_queue(sb->s_bdev);
if (!blk_queue_discard(q))
ext4_msg(sb, KERN_WARNING,
"mounting with \"discard\" option, but "
"the device does not support discard");
}
ext4_msg(sb, KERN_INFO, "mounted filesystem with%s. "
"Opts: %s%s%s", descr, sbi->s_es->s_mount_opts,
*sbi->s_es->s_mount_opts ? "; " : "", orig_data);
if (es->s_error_count)
mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */
kfree(orig_data);
return 0;
cantfind_ext4:
if (!silent)
ext4_msg(sb, KERN_ERR, "VFS: Can't find ext4 filesystem");
goto failed_mount;
#ifdef CONFIG_QUOTA
failed_mount8:
kobject_del(&sbi->s_kobj);
#endif
failed_mount7:
<API key>(sb);
failed_mount6:
ext4_mb_release(sb);
failed_mount5:
ext4_ext_release(sb);
<API key>(sb);
failed_mount4a:
dput(sb->s_root);
sb->s_root = NULL;
failed_mount4:
ext4_msg(sb, KERN_ERR, "mount failed");
if (EXT4_SB(sb)->rsv_conversion_wq)
destroy_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
if (EXT4_SB(sb)->unrsv_conversion_wq)
destroy_workqueue(EXT4_SB(sb)->unrsv_conversion_wq);
failed_mount_wq:
if (sbi->s_journal) {
<API key>(sbi->s_journal);
sbi->s_journal = NULL;
}
failed_mount3:
<API key>(sbi);
del_timer(&sbi->s_err_report);
if (sbi->s_flex_groups)
ext4_kvfree(sbi->s_flex_groups);
<API key>(&sbi-><API key>);
<API key>(&sbi-><API key>);
<API key>(&sbi->s_dirs_counter);
<API key>(&sbi-><API key>);
<API key>(&sbi->s_extent_cache_cnt);
if (sbi->s_mmp_tsk)
kthread_stop(sbi->s_mmp_tsk);
failed_mount2:
for (i = 0; i < db_count; i++)
brelse(sbi->s_group_desc[i]);
ext4_kvfree(sbi->s_group_desc);
failed_mount:
if (sbi->s_chksum_driver)
crypto_free_shash(sbi->s_chksum_driver);
if (sbi->s_proc) {
remove_proc_entry("options", sbi->s_proc);
remove_proc_entry(sb->s_id, ext4_proc_root);
}
#ifdef CONFIG_QUOTA
for (i = 0; i < MAXQUOTAS; i++)
kfree(sbi->s_qf_names[i]);
#endif
ext4_blkdev_remove(sbi);
brelse(bh);
out_fail:
sb->s_fs_info = NULL;
kfree(sbi->s_blockgroup_lock);
kfree(sbi);
out_free_orig:
kfree(orig_data);
return err ? err : ret;
}
/*
* Setup any per-fs journal parameters now. We'll do this both on
* initial mount, once the journal has been initialised but before we've
* done any recovery; and again on any subsequent remount.
*/
static void <API key>(struct super_block *sb, journal_t *journal)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
journal->j_commit_interval = sbi->s_commit_interval;
journal->j_min_batch_time = sbi->s_min_batch_time;
journal->j_max_batch_time = sbi->s_max_batch_time;
write_lock(&journal->j_state_lock);
if (test_opt(sb, BARRIER))
journal->j_flags |= JBD2_BARRIER;
else
journal->j_flags &= ~JBD2_BARRIER;
if (test_opt(sb, DATA_ERR_ABORT))
journal->j_flags |= <API key>;
else
journal->j_flags &= ~<API key>;
write_unlock(&journal->j_state_lock);
}
static journal_t *ext4_get_journal(struct super_block *sb,
unsigned int journal_inum)
{
struct inode *journal_inode;
journal_t *journal;
BUG_ON(!<API key>(sb, <API key>));
/* First, test for the existence of a valid inode on disk. Bad
* things happen if we iget() an unused inode, as the subsequent
* iput() will try to delete it. */
journal_inode = ext4_iget(sb, journal_inum);
if (IS_ERR(journal_inode)) {
ext4_msg(sb, KERN_ERR, "no journal found");
return NULL;
}
if (!journal_inode->i_nlink) {
make_bad_inode(journal_inode);
iput(journal_inode);
ext4_msg(sb, KERN_ERR, "journal inode is deleted");
return NULL;
}
jbd_debug(2, "Journal inode found at %p: %lld bytes\n",
journal_inode, journal_inode->i_size);
if (!S_ISREG(journal_inode->i_mode)) {
ext4_msg(sb, KERN_ERR, "invalid journal inode");
iput(journal_inode);
return NULL;
}
journal = <API key>(journal_inode);
if (!journal) {
ext4_msg(sb, KERN_ERR, "Could not load journal inode");
iput(journal_inode);
return NULL;
}
journal->j_private = sb;
<API key>(sb, journal);
return journal;
}
static journal_t *<API key>(struct super_block *sb,
dev_t j_dev)
{
struct buffer_head *bh;
journal_t *journal;
ext4_fsblk_t start;
ext4_fsblk_t len;
int hblock, blocksize;
ext4_fsblk_t sb_block;
unsigned long offset;
struct ext4_super_block *es;
struct block_device *bdev;
BUG_ON(!<API key>(sb, <API key>));
bdev = ext4_blkdev_get(j_dev, sb);
if (bdev == NULL)
return NULL;
blocksize = sb->s_blocksize;
hblock = <API key>(bdev);
if (blocksize < hblock) {
ext4_msg(sb, KERN_ERR,
"blocksize too small for journal device");
goto out_bdev;
}
sb_block = EXT4_MIN_BLOCK_SIZE / blocksize;
offset = EXT4_MIN_BLOCK_SIZE % blocksize;
set_blocksize(bdev, blocksize);
if (!(bh = __bread(bdev, sb_block, blocksize))) {
ext4_msg(sb, KERN_ERR, "couldn't read superblock of "
"external journal");
goto out_bdev;
}
es = (struct ext4_super_block *) (bh->b_data + offset);
if ((le16_to_cpu(es->s_magic) != EXT4_SUPER_MAGIC) ||
!(le32_to_cpu(es->s_feature_incompat) &
<API key>)) {
ext4_msg(sb, KERN_ERR, "external journal has "
"bad superblock");
brelse(bh);
goto out_bdev;
}
if (memcmp(EXT4_SB(sb)->s_es->s_journal_uuid, es->s_uuid, 16)) {
ext4_msg(sb, KERN_ERR, "journal UUID does not match");
brelse(bh);
goto out_bdev;
}
len = ext4_blocks_count(es);
start = sb_block + 1;
brelse(bh); /* we're done with the superblock */
journal = <API key>(bdev, sb->s_bdev,
start, len, blocksize);
if (!journal) {
ext4_msg(sb, KERN_ERR, "failed to create device journal");
goto out_bdev;
}
journal->j_private = sb;
ll_rw_block(READ | REQ_META | REQ_PRIO, 1, &journal->j_sb_buffer);
wait_on_buffer(journal->j_sb_buffer);
if (!buffer_uptodate(journal->j_sb_buffer)) {
ext4_msg(sb, KERN_ERR, "I/O error on journal device");
goto out_journal;
}
if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
ext4_msg(sb, KERN_ERR, "External journal has more than one "
"user (unsupported) - %d",
be32_to_cpu(journal->j_superblock->s_nr_users));
goto out_journal;
}
EXT4_SB(sb)->journal_bdev = bdev;
<API key>(sb, journal);
return journal;
out_journal:
<API key>(journal);
out_bdev:
ext4_blkdev_put(bdev);
return NULL;
}
static int ext4_load_journal(struct super_block *sb,
struct ext4_super_block *es,
unsigned long journal_devnum)
{
journal_t *journal;
unsigned int journal_inum = le32_to_cpu(es->s_journal_inum);
dev_t journal_dev;
int err = 0;
int really_read_only;
BUG_ON(!<API key>(sb, <API key>));
if (journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
ext4_msg(sb, KERN_INFO, "external journal device major/minor "
"numbers have changed");
journal_dev = new_decode_dev(journal_devnum);
} else
journal_dev = new_decode_dev(le32_to_cpu(es->s_journal_dev));
really_read_only = bdev_read_only(sb->s_bdev);
/*
* Are we loading a blank journal or performing recovery after a
* crash? For recovery, we need to check in advance whether we
* can get read-write access to the device.
*/
if (<API key>(sb, <API key>)) {
if (sb->s_flags & MS_RDONLY) {
ext4_msg(sb, KERN_INFO, "INFO: recovery "
"required on readonly filesystem");
if (really_read_only) {
ext4_msg(sb, KERN_ERR, "write access "
"unavailable, cannot proceed");
return -EROFS;
}
ext4_msg(sb, KERN_INFO, "write access will "
"be enabled during recovery");
}
}
if (journal_inum && journal_dev) {
ext4_msg(sb, KERN_ERR, "filesystem has both journal "
"and inode journals!");
return -EINVAL;
}
if (journal_inum) {
if (!(journal = ext4_get_journal(sb, journal_inum)))
return -EINVAL;
} else {
if (!(journal = <API key>(sb, journal_dev)))
return -EINVAL;
}
if (!(journal->j_flags & JBD2_BARRIER))
ext4_msg(sb, KERN_INFO, "barriers disabled");
if (!<API key>(sb, <API key>))
err = jbd2_journal_wipe(journal, !really_read_only);
if (!err) {
char *save = kmalloc(EXT4_S_ERR_LEN, GFP_KERNEL);
if (save)
memcpy(save, ((char *) es) +
EXT4_S_ERR_START, EXT4_S_ERR_LEN);
err = jbd2_journal_load(journal);
if (save)
memcpy(((char *) es) + EXT4_S_ERR_START,
save, EXT4_S_ERR_LEN);
kfree(save);
}
if (err) {
ext4_msg(sb, KERN_ERR, "error loading journal");
<API key>(journal);
return err;
}
EXT4_SB(sb)->s_journal = journal;
<API key>(sb, es);
if (!really_read_only && journal_devnum &&
journal_devnum != le32_to_cpu(es->s_journal_dev)) {
es->s_journal_dev = cpu_to_le32(journal_devnum);
/* Make sure we flush the recovery flag to disk. */
ext4_commit_super(sb, 1);
}
return 0;
}
static int ext4_commit_super(struct super_block *sb, int sync)
{
struct ext4_super_block *es = EXT4_SB(sb)->s_es;
struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
int error = 0;
if (!sbh || <API key>(sb))
return error;
if (<API key>(sbh)) {
/*
* Oh, dear. A previous attempt to write the
* superblock failed. This could happen because the
* USB device was yanked out. Or it could happen to
* be a transient write error and maybe the block will
* be remapped. Nothing we can do but to retry the
* write and hope for the best.
*/
ext4_msg(sb, KERN_ERR, "previous I/O error to "
"superblock detected");
<API key>(sbh);
set_buffer_uptodate(sbh);
}
/*
* If the file system is mounted read-only, don't update the
* superblock write time. This avoids updating the superblock
* write time when we are mounting the root file system
* read/only but we need to replay the journal; at that point,
* for people who are east of GMT and who make their clock
* tick in localtime for Windows bug-for-bug compatibility,
* the clock is set in the future, and this will cause e2fsck
* to complain and force a full file system check.
*/
if (!(sb->s_flags & MS_RDONLY))
es->s_wtime = cpu_to_le32(get_seconds());
if (sb->s_bdev->bd_part)
es->s_kbytes_written =
cpu_to_le64(EXT4_SB(sb)->s_kbytes_written +
((part_stat_read(sb->s_bdev->bd_part, sectors[1]) -
EXT4_SB(sb)-><API key>) >> 1));
else
es->s_kbytes_written =
cpu_to_le64(EXT4_SB(sb)->s_kbytes_written);
<API key>(es,
EXT4_C2B(EXT4_SB(sb), <API key>(
&EXT4_SB(sb)-><API key>)));
es->s_free_inodes_count =
cpu_to_le32(<API key>(
&EXT4_SB(sb)-><API key>));
BUFFER_TRACE(sbh, "marking dirty");
<API key>(sb);
mark_buffer_dirty(sbh);
if (sync) {
error = sync_dirty_buffer(sbh);
if (error)
return error;
error = <API key>(sbh);
if (error) {
ext4_msg(sb, KERN_ERR, "I/O error while writing "
"superblock");
<API key>(sbh);
set_buffer_uptodate(sbh);
}
}
return error;
}
/*
* Have we just finished recovery? If so, and if we are mounting (or
* remounting) the filesystem readonly, then we will end up with a
* consistent fs on disk. Record that fact.
*/
static void <API key>(struct super_block *sb,
struct ext4_super_block *es)
{
journal_t *journal = EXT4_SB(sb)->s_journal;
if (!<API key>(sb, <API key>)) {
BUG_ON(journal != NULL);
return;
}
<API key>(journal);
if (jbd2_journal_flush(journal) < 0)
goto out;
if (<API key>(sb, <API key>) &&
sb->s_flags & MS_RDONLY) {
<API key>(sb, <API key>);
ext4_commit_super(sb, 1);
}
out:
<API key>(journal);
}
/*
* If we are mounting (or read-write remounting) a filesystem whose journal
* has recorded an error from a previous lifetime, move that error to the
* main filesystem now.
*/
static void <API key>(struct super_block *sb,
struct ext4_super_block *es)
{
journal_t *journal;
int j_errno;
const char *errstr;
BUG_ON(!<API key>(sb, <API key>));
journal = EXT4_SB(sb)->s_journal;
/*
* Now check for any error status which may have been recorded in the
* journal by a prior ext4_error() or ext4_abort()
*/
j_errno = jbd2_journal_errno(journal);
if (j_errno) {
char nbuf[16];
errstr = ext4_decode_error(sb, j_errno, nbuf);
ext4_warning(sb, "Filesystem error recorded "
"from previous mount: %s", errstr);
ext4_warning(sb, "Marking fs in need of filesystem check.");
EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
ext4_commit_super(sb, 1);
<API key>(journal);
<API key>(journal);
}
}
/*
* Force the running and committing transactions to commit,
* and wait on the commit.
*/
int ext4_force_commit(struct super_block *sb)
{
journal_t *journal;
if (sb->s_flags & MS_RDONLY)
return 0;
journal = EXT4_SB(sb)->s_journal;
return <API key>(journal);
}
static int ext4_sync_fs(struct super_block *sb, int wait)
{
int ret = 0;
tid_t target;
bool needs_barrier = false;
struct ext4_sb_info *sbi = EXT4_SB(sb);
trace_ext4_sync_fs(sb, wait);
flush_workqueue(sbi->rsv_conversion_wq);
flush_workqueue(sbi->unrsv_conversion_wq);
/*
* Writeback quota in non-journalled quota case - journalled quota has
* no dirty dquots
*/
<API key>(sb, -1);
/*
* Data writeback is possible w/o journal transaction, so barrier must
* being sent at the end of the function. But we can skip it if
* transaction_commit will do it for us.
*/
target = <API key>(sbi->s_journal);
if (wait && sbi->s_journal->j_flags & JBD2_BARRIER &&
!<API key>(sbi->s_journal, target))
needs_barrier = true;
if (<API key>(sbi->s_journal, &target)) {
if (wait)
ret = <API key>(sbi->s_journal, target);
}
if (needs_barrier) {
int err;
err = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
if (!ret)
ret = err;
}
return ret;
}
static int <API key>(struct super_block *sb, int wait)
{
int ret = 0;
trace_ext4_sync_fs(sb, wait);
flush_workqueue(EXT4_SB(sb)->rsv_conversion_wq);
flush_workqueue(EXT4_SB(sb)->unrsv_conversion_wq);
<API key>(sb, -1);
if (wait && test_opt(sb, BARRIER))
ret = blkdev_issue_flush(sb->s_bdev, GFP_KERNEL, NULL);
return ret;
}
/*
* LVM calls this function before a (read-only) snapshot is created. This
* gives us a chance to flush the journal completely and mark the fs clean.
*
* Note that only this function cannot bring a filesystem to be in a clean
* state independently. It relies on upper layer to stop all data & metadata
* modifications.
*/
static int ext4_freeze(struct super_block *sb)
{
int error = 0;
journal_t *journal;
if (sb->s_flags & MS_RDONLY)
return 0;
journal = EXT4_SB(sb)->s_journal;
/* Now we set up the journal barrier. */
<API key>(journal);
/*
* Don't clear the needs_recovery flag if we failed to flush
* the journal.
*/
error = jbd2_journal_flush(journal);
if (error < 0)
goto out;
/* Journal blocked and flushed, clear needs_recovery flag. */
<API key>(sb, <API key>);
error = ext4_commit_super(sb, 1);
out:
/* we rely on upper layer to stop further updates */
<API key>(EXT4_SB(sb)->s_journal);
return error;
}
/*
* Called by LVM after the snapshot is done. We need to reset the RECOVER
* flag here, even though the filesystem is not technically dirty yet.
*/
static int ext4_unfreeze(struct super_block *sb)
{
if (sb->s_flags & MS_RDONLY)
return 0;
/* Reset the needs_recovery flag before the fs is unlocked. */
<API key>(sb, <API key>);
ext4_commit_super(sb, 1);
return 0;
}
/*
* Structure to save mount options for ext4_remount's benefit
*/
struct ext4_mount_options {
unsigned long s_mount_opt;
unsigned long s_mount_opt2;
kuid_t s_resuid;
kgid_t s_resgid;
unsigned long s_commit_interval;
u32 s_min_batch_time, s_max_batch_time;
#ifdef CONFIG_QUOTA
int s_jquota_fmt;
char *s_qf_names[MAXQUOTAS];
#endif
};
static int ext4_remount(struct super_block *sb, int *flags, char *data)
{
struct ext4_super_block *es;
struct ext4_sb_info *sbi = EXT4_SB(sb);
unsigned long old_sb_flags;
struct ext4_mount_options old_opts;
int enable_quota = 0;
ext4_group_t g;
unsigned int journal_ioprio = <API key>;
int err = 0;
#ifdef CONFIG_QUOTA
int i, j;
#endif
char *orig_data = kstrdup(data, GFP_KERNEL);
/* Store the original options */
old_sb_flags = sb->s_flags;
old_opts.s_mount_opt = sbi->s_mount_opt;
old_opts.s_mount_opt2 = sbi->s_mount_opt2;
old_opts.s_resuid = sbi->s_resuid;
old_opts.s_resgid = sbi->s_resgid;
old_opts.s_commit_interval = sbi->s_commit_interval;
old_opts.s_min_batch_time = sbi->s_min_batch_time;
old_opts.s_max_batch_time = sbi->s_max_batch_time;
#ifdef CONFIG_QUOTA
old_opts.s_jquota_fmt = sbi->s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++)
if (sbi->s_qf_names[i]) {
old_opts.s_qf_names[i] = kstrdup(sbi->s_qf_names[i],
GFP_KERNEL);
if (!old_opts.s_qf_names[i]) {
for (j = 0; j < i; j++)
kfree(old_opts.s_qf_names[j]);
kfree(orig_data);
return -ENOMEM;
}
} else
old_opts.s_qf_names[i] = NULL;
#endif
if (sbi->s_journal && sbi->s_journal->j_task->io_context)
journal_ioprio = sbi->s_journal->j_task->io_context->ioprio;
/*
* Allow the "check" option to be passed as a remount option.
*/
if (!parse_options(data, sb, NULL, &journal_ioprio, 1)) {
err = -EINVAL;
goto restore_opts;
}
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
ext4_abort(sb, "Abort forced by user");
sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
(test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
es = sbi->s_es;
if (sbi->s_journal) {
<API key>(sb, sbi->s_journal);
set_task_ioprio(sbi->s_journal->j_task, journal_ioprio);
}
if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY)) {
if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) {
err = -EROFS;
goto restore_opts;
}
if (*flags & MS_RDONLY) {
err = dquot_suspend(sb, -1);
if (err < 0)
goto restore_opts;
/*
* First of all, the unconditional stuff we have to do
* to disable replay of the journal when we next remount
*/
sb->s_flags |= MS_RDONLY;
/*
* OK, test if we are remounting a valid rw partition
* readonly, and if so set the rdonly flag and then
* mark the partition as valid again.
*/
if (!(es->s_state & cpu_to_le16(EXT4_VALID_FS)) &&
(sbi->s_mount_state & EXT4_VALID_FS))
es->s_state = cpu_to_le16(sbi->s_mount_state);
if (sbi->s_journal)
<API key>(sb, es);
} else {
/* Make sure we can mount this feature set readwrite */
if (!ext4_feature_set_ok(sb, 0)) {
err = -EROFS;
goto restore_opts;
}
/*
* Make sure the group descriptor checksums
* are sane. If they aren't, refuse to remount r/w.
*/
for (g = 0; g < sbi->s_groups_count; g++) {
struct ext4_group_desc *gdp =
ext4_get_group_desc(sb, g, NULL);
if (!<API key>(sb, g, gdp)) {
ext4_msg(sb, KERN_ERR,
"ext4_remount: Checksum for group %u failed (%u!=%u)",
g, le16_to_cpu(<API key>(sbi, g, gdp)),
le16_to_cpu(gdp->bg_checksum));
err = -EINVAL;
goto restore_opts;
}
}
/*
* If we have an unprocessed orphan list hanging
* around from a previously readonly bdev mount,
* require a full umount/remount for now.
*/
if (es->s_last_orphan) {
ext4_msg(sb, KERN_WARNING, "Couldn't "
"remount RDWR because of unprocessed "
"orphan inode list. Please "
"umount/remount instead");
err = -EINVAL;
goto restore_opts;
}
/*
* Mounting a RDONLY partition read-write, so reread
* and store the current valid flag. (It may have
* been changed by e2fsck since we originally mounted
* the partition.)
*/
if (sbi->s_journal)
<API key>(sb, es);
sbi->s_mount_state = le16_to_cpu(es->s_state);
if (!ext4_setup_super(sb, es, 0))
sb->s_flags &= ~MS_RDONLY;
if (<API key>(sb,
<API key>))
if (<API key>(sb,
le64_to_cpu(es->s_mmp_block))) {
err = -EROFS;
goto restore_opts;
}
enable_quota = 1;
}
}
/*
* Reinitialize lazy itable initialization thread based on
* current settings
*/
if ((sb->s_flags & MS_RDONLY) || !test_opt(sb, INIT_INODE_TABLE))
<API key>(sb);
else {
ext4_group_t first_not_zeroed;
first_not_zeroed = <API key>(sb);
<API key>(sb, first_not_zeroed);
}
<API key>(sb);
if (sbi->s_journal == NULL && !(old_sb_flags & MS_RDONLY))
ext4_commit_super(sb, 1);
#ifdef CONFIG_QUOTA
/* Release old quota file names */
for (i = 0; i < MAXQUOTAS; i++)
kfree(old_opts.s_qf_names[i]);
if (enable_quota) {
if (<API key>(sb))
dquot_resume(sb, -1);
else if (<API key>(sb,
<API key>)) {
err = ext4_enable_quotas(sb);
if (err)
goto restore_opts;
}
}
#endif
ext4_msg(sb, KERN_INFO, "re-mounted. Opts: %s", orig_data);
kfree(orig_data);
return 0;
restore_opts:
sb->s_flags = old_sb_flags;
sbi->s_mount_opt = old_opts.s_mount_opt;
sbi->s_mount_opt2 = old_opts.s_mount_opt2;
sbi->s_resuid = old_opts.s_resuid;
sbi->s_resgid = old_opts.s_resgid;
sbi->s_commit_interval = old_opts.s_commit_interval;
sbi->s_min_batch_time = old_opts.s_min_batch_time;
sbi->s_max_batch_time = old_opts.s_max_batch_time;
#ifdef CONFIG_QUOTA
sbi->s_jquota_fmt = old_opts.s_jquota_fmt;
for (i = 0; i < MAXQUOTAS; i++) {
kfree(sbi->s_qf_names[i]);
sbi->s_qf_names[i] = old_opts.s_qf_names[i];
}
#endif
kfree(orig_data);
return err;
}
static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf)
{
struct super_block *sb = dentry->d_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb);
struct ext4_super_block *es = sbi->s_es;
ext4_fsblk_t overhead = 0, resv_blocks;
u64 fsid;
s64 bfree;
resv_blocks = EXT4_C2B(sbi, atomic64_read(&sbi->s_resv_clusters));
if (!test_opt(sb, MINIX_DF))
overhead = sbi->s_overhead;
buf->f_type = EXT4_SUPER_MAGIC;
buf->f_bsize = sb->s_blocksize;
buf->f_blocks = ext4_blocks_count(es) - EXT4_C2B(sbi, overhead);
bfree = <API key>(&sbi-><API key>) -
<API key>(&sbi-><API key>);
/* prevent underflow in case that few free space is available */
buf->f_bfree = EXT4_C2B(sbi, max_t(s64, bfree, 0));
buf->f_bavail = buf->f_bfree -
(ext4_r_blocks_count(es) + resv_blocks);
if (buf->f_bfree < (ext4_r_blocks_count(es) + resv_blocks))
buf->f_bavail = 0;
buf->f_files = le32_to_cpu(es->s_inodes_count);
buf->f_ffree = <API key>(&sbi-><API key>);
buf->f_namelen = EXT4_NAME_LEN;
fsid = le64_to_cpup((void *)es->s_uuid) ^
le64_to_cpup((void *)es->s_uuid + sizeof(u64));
buf->f_fsid.val[0] = fsid & 0xFFFFFFFFUL;
buf->f_fsid.val[1] = (fsid >> 32) & 0xFFFFFFFFUL;
return 0;
}
/* Helper function for writing quotas on sync - we need to start transaction
* before quota file is locked for write. Otherwise the are possible deadlocks:
* Process 1 Process 2
* ext4_create() quota_sync()
* jbd2_journal_start() write_dquot()
* dquot_initialize() down(dqio_mutex)
* down(dqio_mutex) jbd2_journal_start()
*
*/
#ifdef CONFIG_QUOTA
static inline struct inode *dquot_to_inode(struct dquot *dquot)
{
return sb_dqopt(dquot->dq_sb)->files[dquot->dq_id.type];
}
static int ext4_write_dquot(struct dquot *dquot)
{
int ret, err;
handle_t *handle;
struct inode *inode;
inode = dquot_to_inode(dquot);
handle = ext4_journal_start(inode, EXT4_HT_QUOTA,
<API key>(dquot->dq_sb));
if (IS_ERR(handle))
return PTR_ERR(handle);
ret = dquot_commit(dquot);
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
return ret;
}
static int ext4_acquire_dquot(struct dquot *dquot)
{
int ret, err;
handle_t *handle;
handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
<API key>(dquot->dq_sb));
if (IS_ERR(handle))
return PTR_ERR(handle);
ret = dquot_acquire(dquot);
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
return ret;
}
static int ext4_release_dquot(struct dquot *dquot)
{
int ret, err;
handle_t *handle;
handle = ext4_journal_start(dquot_to_inode(dquot), EXT4_HT_QUOTA,
<API key>(dquot->dq_sb));
if (IS_ERR(handle)) {
/* Release dquot anyway to avoid endless cycle in dqput() */
dquot_release(dquot);
return PTR_ERR(handle);
}
ret = dquot_release(dquot);
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
return ret;
}
static int <API key>(struct dquot *dquot)
{
struct super_block *sb = dquot->dq_sb;
struct ext4_sb_info *sbi = EXT4_SB(sb);
/* Are we journaling quotas? */
if (<API key>(sb, <API key>) ||
sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) {
<API key>(dquot);
return ext4_write_dquot(dquot);
} else {
return <API key>(dquot);
}
}
static int ext4_write_info(struct super_block *sb, int type)
{
int ret, err;
handle_t *handle;
/* Data block + inode block */
handle = ext4_journal_start(sb->s_root->d_inode, EXT4_HT_QUOTA, 2);
if (IS_ERR(handle))
return PTR_ERR(handle);
ret = dquot_commit_info(sb, type);
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
return ret;
}
/*
* Turn on quotas during mount time - we need to find
* the quota file and such...
*/
static int ext4_quota_on_mount(struct super_block *sb, int type)
{
return <API key>(sb, EXT4_SB(sb)->s_qf_names[type],
EXT4_SB(sb)->s_jquota_fmt, type);
}
/*
* Standard function to be called on quota_on
*/
static int ext4_quota_on(struct super_block *sb, int type, int format_id,
struct path *path)
{
int err;
if (!test_opt(sb, QUOTA))
return -EINVAL;
/* Quotafile not on the same filesystem? */
if (path->dentry->d_sb != sb)
return -EXDEV;
/* Journaling quota? */
if (EXT4_SB(sb)->s_qf_names[type]) {
/* Quotafile not in fs root? */
if (path->dentry->d_parent != sb->s_root)
ext4_msg(sb, KERN_WARNING,
"Quota file not on filesystem root. "
"Journaled quota will not work");
}
/*
* When we journal data on quota file, we have to flush journal to see
* all updates to the file when we bypass pagecache...
*/
if (EXT4_SB(sb)->s_journal &&
<API key>(path->dentry->d_inode)) {
/*
* We don't need to lock updates but journal_flush() could
* otherwise be livelocked...
*/
<API key>(EXT4_SB(sb)->s_journal);
err = jbd2_journal_flush(EXT4_SB(sb)->s_journal);
<API key>(EXT4_SB(sb)->s_journal);
if (err)
return err;
}
return dquot_quota_on(sb, type, format_id, path);
}
static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
unsigned int flags)
{
int err;
struct inode *qf_inode;
unsigned long qf_inums[MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
};
BUG_ON(!<API key>(sb, <API key>));
if (!qf_inums[type])
return -EPERM;
qf_inode = ext4_iget(sb, qf_inums[type]);
if (IS_ERR(qf_inode)) {
ext4_error(sb, "Bad quota inode # %lu", qf_inums[type]);
return PTR_ERR(qf_inode);
}
/* Don't account quota for quota files to avoid recursion */
qf_inode->i_flags |= S_NOQUOTA;
err = dquot_enable(qf_inode, type, format_id, flags);
iput(qf_inode);
return err;
}
/* Enable usage tracking for all quota types. */
static int ext4_enable_quotas(struct super_block *sb)
{
int type, err = 0;
unsigned long qf_inums[MAXQUOTAS] = {
le32_to_cpu(EXT4_SB(sb)->s_es->s_usr_quota_inum),
le32_to_cpu(EXT4_SB(sb)->s_es->s_grp_quota_inum)
};
sb_dqopt(sb)->flags |= <API key>;
for (type = 0; type < MAXQUOTAS; type++) {
if (qf_inums[type]) {
err = ext4_quota_enable(sb, type, QFMT_VFS_V1,
DQUOT_USAGE_ENABLED);
if (err) {
ext4_warning(sb,
"Failed to enable quota tracking "
"(type=%d, err=%d). Please run "
"e2fsck to fix.", type, err);
return err;
}
}
}
return 0;
}
/*
* quota_on function that is used when QUOTA feature is set.
*/
static int <API key>(struct super_block *sb, int type,
int format_id)
{
if (!<API key>(sb, <API key>))
return -EINVAL;
/*
* USAGE was enabled at mount time. Only need to enable LIMITS now.
*/
return ext4_quota_enable(sb, type, format_id, <API key>);
}
static int ext4_quota_off(struct super_block *sb, int type)
{
struct inode *inode = sb_dqopt(sb)->files[type];
handle_t *handle;
/* Force all delayed allocation blocks to be allocated.
* Caller already holds s_umount sem */
if (test_opt(sb, DELALLOC))
sync_filesystem(sb);
if (!inode)
goto out;
/* Update modification times of quota files when userspace can
* start looking at them */
handle = ext4_journal_start(inode, EXT4_HT_QUOTA, 1);
if (IS_ERR(handle))
goto out;
inode->i_mtime = inode->i_ctime = CURRENT_TIME;
<API key>(handle, inode);
ext4_journal_stop(handle);
out:
return dquot_quota_off(sb, type);
}
/*
* quota_off function that is used when QUOTA feature is set.
*/
static int <API key>(struct super_block *sb, int type)
{
if (!<API key>(sb, <API key>))
return -EINVAL;
/* Disable only the limits. */
return dquot_disable(sb, type, <API key>);
}
/* Read data from quotafile - avoid pagecache and such because we cannot afford
* acquiring the locks... As quota files are never truncated and quota code
* itself serializes the operations (and no one else should touch the files)
* we don't have to be afraid of races */
static ssize_t ext4_quota_read(struct super_block *sb, int type, char *data,
size_t len, loff_t off)
{
struct inode *inode = sb_dqopt(sb)->files[type];
ext4_lblk_t blk = off >> <API key>(sb);
int err = 0;
int offset = off & (sb->s_blocksize - 1);
int tocopy;
size_t toread;
struct buffer_head *bh;
loff_t i_size = i_size_read(inode);
if (off > i_size)
return 0;
if (off+len > i_size)
len = i_size-off;
toread = len;
while (toread > 0) {
tocopy = sb->s_blocksize - offset < toread ?
sb->s_blocksize - offset : toread;
bh = ext4_bread(NULL, inode, blk, 0, &err);
if (err)
return err;
if (!bh) /* A hole? */
memset(data, 0, tocopy);
else
memcpy(data, bh->b_data+offset, tocopy);
brelse(bh);
offset = 0;
toread -= tocopy;
data += tocopy;
blk++;
}
return len;
}
/* Write to quotafile (we know the transaction is already started and has
* enough credits) */
static ssize_t ext4_quota_write(struct super_block *sb, int type,
const char *data, size_t len, loff_t off)
{
struct inode *inode = sb_dqopt(sb)->files[type];
ext4_lblk_t blk = off >> <API key>(sb);
int err = 0;
int offset = off & (sb->s_blocksize - 1);
struct buffer_head *bh;
handle_t *handle = <API key>();
if (EXT4_SB(sb)->s_journal && !handle) {
ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)"
" cancelled because transaction is not started",
(unsigned long long)off, (unsigned long long)len);
return -EIO;
}
/*
* Since we account only one data block in transaction credits,
* then it is impossible to cross a block boundary.
*/
if (sb->s_blocksize - offset < len) {
ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)"
" cancelled because not block aligned",
(unsigned long long)off, (unsigned long long)len);
return -EIO;
}
bh = ext4_bread(handle, inode, blk, 1, &err);
if (!bh)
goto out;
err = <API key>(handle, bh);
if (err) {
brelse(bh);
goto out;
}
lock_buffer(bh);
memcpy(bh->b_data+offset, data, len);
flush_dcache_page(bh->b_page);
unlock_buffer(bh);
err = <API key>(handle, NULL, bh);
brelse(bh);
out:
if (err)
return err;
if (inode->i_size < off + len) {
i_size_write(inode, off + len);
EXT4_I(inode)->i_disksize = inode->i_size;
<API key>(handle, inode);
}
return len;
}
#endif
static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data)
{
return mount_bdev(fs_type, flags, dev_name, data, ext4_fill_super);
}
#if !defined(CONFIG_EXT2_FS) && !defined(<API key>) && defined(<API key>)
static inline void register_as_ext2(void)
{
int err = register_filesystem(&ext2_fs_type);
if (err)
printk(KERN_WARNING
"EXT4-fs: Unable to register as ext2 (%d)\n", err);
}
static inline void unregister_as_ext2(void)
{
<API key>(&ext2_fs_type);
}
static inline int ext2_feature_set_ok(struct super_block *sb)
{
if (<API key>(sb, ~<API key>))
return 0;
if (sb->s_flags & MS_RDONLY)
return 1;
if (<API key>(sb, ~<API key>))
return 0;
return 1;
}
#else
static inline void register_as_ext2(void) { }
static inline void unregister_as_ext2(void) { }
static inline int ext2_feature_set_ok(struct super_block *sb) { return 0; }
#endif
#if !defined(CONFIG_EXT3_FS) && !defined(<API key>) && defined(<API key>)
static inline void register_as_ext3(void)
{
int err = register_filesystem(&ext3_fs_type);
if (err)
printk(KERN_WARNING
"EXT4-fs: Unable to register as ext3 (%d)\n", err);
}
static inline void unregister_as_ext3(void)
{
<API key>(&ext3_fs_type);
}
static inline int ext3_feature_set_ok(struct super_block *sb)
{
if (<API key>(sb, ~<API key>))
return 0;
if (!<API key>(sb, <API key>))
return 0;
if (sb->s_flags & MS_RDONLY)
return 1;
if (<API key>(sb, ~<API key>))
return 0;
return 1;
}
#else
static inline void register_as_ext3(void) { }
static inline void unregister_as_ext3(void) { }
static inline int ext3_feature_set_ok(struct super_block *sb) { return 0; }
#endif
static struct file_system_type ext4_fs_type = {
.owner = THIS_MODULE,
.name = "ext4",
.mount = ext4_mount,
.kill_sb = kill_block_super,
.fs_flags = FS_REQUIRES_DEV,
};
MODULE_ALIAS_FS("ext4");
static int __init <API key>(void)
{
struct ext4_features *ef;
int ret = -ENOMEM;
ef = kzalloc(sizeof(struct ext4_features), GFP_KERNEL);
if (!ef)
goto out;
ef->f_kobj.kset = ext4_kset;
init_completion(&ef->f_kobj_unregister);
ret = <API key>(&ef->f_kobj, &ext4_feat_ktype, NULL,
"features");
if (ret) {
kfree(ef);
goto out;
}
ext4_feat = ef;
ret = 0;
out:
return ret;
}
static void <API key>(void)
{
kobject_put(&ext4_feat->f_kobj);
wait_for_completion(&ext4_feat->f_kobj_unregister);
kfree(ext4_feat);
}
/* Shared across all ext4 file systems */
wait_queue_head_t ext4__ioend_wq[EXT4_WQ_HASH_SZ];
struct mutex ext4__aio_mutex[EXT4_WQ_HASH_SZ];
static int __init ext4_init_fs(void)
{
int i, err;
ext4_li_info = NULL;
mutex_init(&ext4_li_mtx);
/* Build-time check for flags consistency */
<API key>();
for (i = 0; i < EXT4_WQ_HASH_SZ; i++) {
mutex_init(&ext4__aio_mutex[i]);
init_waitqueue_head(&ext4__ioend_wq[i]);
}
err = ext4_init_es();
if (err)
return err;
err = ext4_init_pageio();
if (err)
goto out7;
err = <API key>();
if (err)
goto out6;
ext4_kset = kset_create_and_add("ext4", NULL, fs_kobj);
if (!ext4_kset) {
err = -ENOMEM;
goto out5;
}
ext4_proc_root = proc_mkdir("fs/ext4", NULL);
err = <API key>();
if (err)
goto out4;
err = ext4_init_mballoc();
if (err)
goto out3;
err = ext4_init_xattr();
if (err)
goto out2;
err = init_inodecache();
if (err)
goto out1;
register_as_ext3();
register_as_ext2();
err = register_filesystem(&ext4_fs_type);
if (err)
goto out;
return 0;
out:
unregister_as_ext2();
unregister_as_ext3();
destroy_inodecache();
out1:
ext4_exit_xattr();
out2:
ext4_exit_mballoc();
out3:
<API key>();
out4:
if (ext4_proc_root)
remove_proc_entry("fs/ext4", NULL);
kset_unregister(ext4_kset);
out5:
<API key>();
out6:
ext4_exit_pageio();
out7:
ext4_exit_es();
return err;
}
static void __exit ext4_exit_fs(void)
{
<API key>();
unregister_as_ext2();
unregister_as_ext3();
<API key>(&ext4_fs_type);
destroy_inodecache();
ext4_exit_xattr();
ext4_exit_mballoc();
<API key>();
remove_proc_entry("fs/ext4", NULL);
kset_unregister(ext4_kset);
<API key>();
ext4_exit_pageio();
ext4_exit_es();
}
MODULE_AUTHOR("Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others");
MODULE_DESCRIPTION("Fourth Extended Filesystem");
MODULE_LICENSE("GPL");
module_init(ext4_init_fs)
module_exit(ext4_exit_fs)
|
#include "sysdep.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
#include "elf-bfd.h"
#include "elf/score.h"
#include "elf/common.h"
#include "elf/internal.h"
#include "hashtab.h"
#include "elf32-score.h"
int score3 = 0;
int score7 = 1;
/* The SCORE ELF linker needs additional information for each symbol in
the global hash table. */
struct <API key>
{
struct elf_link_hash_entry root;
/* Number of R_SCORE_ABS32, R_SCORE_REL32 relocs against this symbol. */
unsigned int <API key>;
/* If the R_SCORE_ABS32, R_SCORE_REL32 reloc is against a readonly section. */
bfd_boolean readonly_reloc;
/* We must not create a stub for a symbol that has relocations related to
taking the function's address, i.e. any but R_SCORE_CALL15 ones. */
bfd_boolean no_fn_stub;
/* Are we forced local? This will only be set if we have converted
the initial global GOT entry to a local GOT entry. */
bfd_boolean forced_local;
};
/* Traverse a score ELF linker hash table. */
#define <API key>(table, func, info) \
(<API key> \
((table), \
(bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
(info)))
/* This structure is used to hold .got entries while estimating got sizes. */
struct score_got_entry
{
/* The input bfd in which the symbol is defined. */
bfd *abfd;
/* The index of the symbol, as stored in the relocation r_info, if
we have a local symbol; -1 otherwise. */
long symndx;
union
{
/* If abfd == NULL, an address that must be stored in the got. */
bfd_vma address;
/* If abfd != NULL && symndx != -1, the addend of the relocation
that should be added to the symbol value. */
bfd_vma addend;
/* If abfd != NULL && symndx == -1, the hash table entry
corresponding to a global symbol in the got (or, local, if
h->forced_local). */
struct <API key> *h;
} d;
/* The offset from the beginning of the .got section to the entry
corresponding to this symbol+addend. If it's a global symbol
whose offset is yet to be decided, it's going to be -1. */
long gotidx;
};
/* This structure is passed to <API key> when sorting
the dynamic symbols. */
struct <API key>
{
/* The symbol in the global GOT with the lowest dynamic symbol table index. */
struct elf_link_hash_entry *low;
/* The least dynamic symbol table index corresponding to a symbol with a GOT entry. */
long min_got_dynindx;
/* The greatest dynamic symbol table index corresponding to a symbol
with a GOT entry that is not referenced (e.g., a dynamic symbol
with dynamic relocations pointing to it from non-primary GOTs). */
long <API key>;
/* The greatest dynamic symbol table index not corresponding to a
symbol without a GOT entry. */
long max_non_got_dynindx;
};
struct score_got_info
{
/* The global symbol in the GOT with the lowest index in the dynamic
symbol table. */
struct elf_link_hash_entry *global_gotsym;
/* The number of global .got entries. */
unsigned int global_gotno;
/* The number of local .got entries. */
unsigned int local_gotno;
/* The number of local .got entries we have used. */
unsigned int assigned_gotno;
/* A hash table holding members of the got. */
struct htab *got_entries;
/* In multi-got links, a pointer to the next got (err, rather, most
of the time, it points to the previous got). */
struct score_got_info *next;
};
/* A structure used to count GOT entries, for GOT entry or ELF symbol table traversal. */
struct <API key>
{
struct <API key> elf;
union
{
struct score_got_info *got_info;
bfd_byte *tdata;
}
u;
};
#define <API key>(sec) \
((struct <API key> *) elf_section_data (sec))
/* The size of a symbol-table entry. */
#define SCORE_ELF_SYM_SIZE(abfd) \
(<API key> (abfd)->s->sizeof_sym)
/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
from smaller values. Start with zero, widen, *then* decrement. */
#define MINUS_ONE (((bfd_vma)0) - 1)
#define MINUS_TWO (((bfd_vma)0) - 2)
#define PDR_SIZE 32
/* The number of local .got entries we reserve. */
#define <API key> (2)
#define <API key> "/usr/lib/ld.so.1"
/* The offset of $gp from the beginning of the .got section. */
#define ELF_SCORE_GP_OFFSET(abfd) (0x3ff0)
/* The maximum size of the GOT for it to be addressable using 15-bit offsets from $gp. */
#define <API key>(abfd) (ELF_SCORE_GP_OFFSET(abfd) + 0x3fff)
#define <API key> (".SCORE.stub")
#define <API key> (16)
#define STUB_LW 0xc3bcc010 /* lw r29, [r28, -0x3ff0] */
#define STUB_MOVE 0x8363bc56 /* mv r27, r3 */
#define STUB_LI16 0x87548000 /* ori r26, .dynsym_index */
#define STUB_BRL 0x801dbc09 /* brl r29 */
#define SCORE_ELF_GOT_SIZE(abfd) \
(<API key> (abfd)->s->arch_size / 8)
#define <API key>(info, tag, val) \
(<API key> (info, (bfd_vma) tag, (bfd_vma) val))
/* The size of an external dynamic table entry. */
#define SCORE_ELF_DYN_SIZE(abfd) \
(<API key> (abfd)->s->sizeof_dyn)
/* The size of an external REL relocation. */
#define SCORE_ELF_REL_SIZE(abfd) \
(<API key> (abfd)->s->sizeof_rel)
/* The default alignment for sections, as a power of two. */
#define <API key>(abfd)\
(<API key> (abfd)->s->log_file_align)
static bfd_byte *hi16_rel_addr;
/* This will be used when we sort the dynamic relocation records. */
static bfd *reldyn_sorting_bfd;
/* SCORE ELF uses two common sections. One is the usual one, and the
other is for small objects. All the small objects are kept
together, and then referenced via the gp pointer, which yields
faster assembler code. This is what we use for the small common
section. This approach is copied from ecoff.c. */
static asection <API key>;
static asymbol <API key>;
static asymbol *<API key>;
static bfd_vma
score_bfd_get_16 (bfd *abfd, const void *data)
{
return bfd_get_16 (abfd, data);
}
static bfd_vma
score3_bfd_getl32 (const void *p)
{
const bfd_byte *addr = p;
unsigned long v;
v = (unsigned long) addr[2];
v |= (unsigned long) addr[3] << 8;
v |= (unsigned long) addr[0] << 16;
v |= (unsigned long) addr[1] << 24;
return v;
}
static bfd_vma
score3_bfd_getl48 (const void *p)
{
const bfd_byte *addr = p;
unsigned long long v;
v = (unsigned long long) addr[4];
v |= (unsigned long long) addr[5] << 8;
v |= (unsigned long long) addr[2] << 16;
v |= (unsigned long long) addr[3] << 24;
v |= (unsigned long long) addr[0] << 32;
v |= (unsigned long long) addr[1] << 40;
return v;
}
static bfd_vma
score_bfd_get_32 (bfd *abfd, const void *data)
{
if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
return score3_bfd_getl32 (data);
else
return bfd_get_32 (abfd, data);
}
static bfd_vma
score_bfd_get_48 (bfd *abfd, const void *p)
{
if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
return score3_bfd_getl48 (p);
else
return bfd_get_bits (p, 48, 1);
}
static void
score_bfd_put_16 (bfd *abfd, bfd_vma addr, void *data)
{
return bfd_put_16 (abfd, addr, data);
}
static void
score3_bfd_putl32 (bfd_vma data, void *p)
{
bfd_byte *addr = p;
addr[0] = (data >> 16) & 0xff;
addr[1] = (data >> 24) & 0xff;
addr[2] = data & 0xff;
addr[3] = (data >> 8) & 0xff;
}
static void
score3_bfd_putl48 (bfd_vma data, void *p)
{
bfd_byte *addr = p;
addr[0] = (data >> 32) & 0xff;
addr[1] = (data >> 40) & 0xff;
addr[2] = (data >> 16) & 0xff;
addr[3] = (data >> 24) & 0xff;
addr[4] = data & 0xff;
addr[5] = (data >> 8) & 0xff;
}
static void
score_bfd_put_32 (bfd *abfd, bfd_vma addr, void *data)
{
if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
return score3_bfd_putl32 (addr, data);
else
return bfd_put_32 (abfd, addr, data);
}
static void
score_bfd_put_48 (bfd *abfd, bfd_vma val, void *p)
{
if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
return score3_bfd_putl48 (val, p);
else
return bfd_put_bits (val, p, 48, 1);
}
static <API key>
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * data,
asection *input_section ATTRIBUTE_UNUSED,
bfd *output_bfd ATTRIBUTE_UNUSED,
char **error_message ATTRIBUTE_UNUSED)
{
hi16_rel_addr = (bfd_byte *) data + reloc_entry->address;
return bfd_reloc_ok;
}
static <API key>
<API key> (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * data,
asection *input_section,
bfd *output_bfd ATTRIBUTE_UNUSED,
char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma addend = 0, offset = 0;
unsigned long val;
unsigned long hi16_offset, hi16_value, uvalue;
hi16_value = score_bfd_get_32 (abfd, hi16_rel_addr);
hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
addend = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
val = reloc_entry->addend;
if (reloc_entry->address > input_section->size)
return <API key>;
uvalue = ((hi16_offset << 16) | (offset & 0xffff)) + val;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
score_bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
offset = (uvalue & 0xffff) << 1;
addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
score_bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
return bfd_reloc_ok;
}
/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
dangerous relocation. */
static bfd_boolean
score_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
{
unsigned int count;
asymbol **sym;
unsigned int i;
/* If we've already figured out what GP will be, just return it. */
*pgp = _bfd_get_gp_value (output_bfd);
if (*pgp)
return TRUE;
count = bfd_get_symcount (output_bfd);
sym = bfd_get_outsymbols (output_bfd);
/* The linker script will have created a symbol named `_gp' with the
appropriate value. */
if (sym == NULL)
i = count;
else
{
for (i = 0; i < count; i++, sym++)
{
const char *name;
name = bfd_asymbol_name (*sym);
if (*name == '_' && strcmp (name, "_gp") == 0)
{
*pgp = bfd_asymbol_value (*sym);
_bfd_set_gp_value (output_bfd, *pgp);
break;
}
}
}
if (i >= count)
{
/* Only get the error once. */
*pgp = 4;
_bfd_set_gp_value (output_bfd, *pgp);
return FALSE;
}
return TRUE;
}
/* We have to figure out the gp value, so that we can adjust the
symbol value correctly. We look up the symbol _gp in the output
BFD. If we can't find it, we're stuck. We cache it in the ELF
target data. We don't need to adjust the symbol value for an
external symbol if we are producing relocatable output. */
static <API key>
score_elf_final_gp (bfd *output_bfd,
asymbol *symbol,
bfd_boolean relocatable,
char **error_message,
bfd_vma *pgp)
{
if (bfd_is_und_section (symbol->section)
&& ! relocatable)
{
*pgp = 0;
return bfd_reloc_undefined;
}
*pgp = _bfd_get_gp_value (output_bfd);
if (*pgp == 0
&& (! relocatable
|| (symbol->flags & BSF_SECTION_SYM) != 0))
{
if (relocatable)
{
/* Make up a value. */
*pgp = symbol->section->output_section->vma + 0x4000;
_bfd_set_gp_value (output_bfd, *pgp);
}
else if (!score_elf_assign_gp (output_bfd, pgp))
{
*error_message =
(char *) _("GP relative relocation when _gp not defined");
return bfd_reloc_dangerous;
}
}
return bfd_reloc_ok;
}
static <API key>
<API key> (bfd *abfd,
asymbol *symbol,
arelent *reloc_entry,
asection *input_section,
bfd_boolean relocateable,
void * data,
bfd_vma gp ATTRIBUTE_UNUSED)
{
bfd_vma relocation;
unsigned long insn;
if (bfd_is_com_section (symbol->section))
relocation = 0;
else
relocation = symbol->value;
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
if (reloc_entry->address > input_section->size)
return <API key>;
insn = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
if (((reloc_entry->addend & 0xffffc000) != 0)
&& ((reloc_entry->addend & 0xffffc000) != 0xffffc000))
return bfd_reloc_overflow;
insn = (insn & ~0x7fff) | (reloc_entry->addend & 0x7fff);
score_bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
if (relocateable)
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
static <API key>
gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
asection *input_section, bfd_boolean relocatable,
void *data, bfd_vma gp)
{
bfd_vma relocation;
bfd_vma val;
if (bfd_is_com_section (symbol->section))
relocation = 0;
else
relocation = symbol->value;
relocation += symbol->section->output_section->vma;
relocation += symbol->section->output_offset;
if (reloc_entry->address > <API key> (abfd, input_section))
return <API key>;
/* Set val to the offset into the section or symbol. */
val = reloc_entry->addend;
if (reloc_entry->howto->partial_inplace)
val += score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
/* Adjust val for the final section location and GP value. If we
are producing relocatable output, we don't want to do this for
an external symbol. */
if (! relocatable
|| (symbol->flags & BSF_SECTION_SYM) != 0)
val += relocation - gp;
if (reloc_entry->howto->partial_inplace)
score_bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
else
reloc_entry->addend = val;
if (relocatable)
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
static <API key>
<API key> (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol,
void * data,
asection *input_section,
bfd *output_bfd,
char **error_message)
{
bfd_boolean relocateable;
<API key> ret;
bfd_vma gp;
if (output_bfd != NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0 && reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
if (output_bfd != NULL)
relocateable = TRUE;
else
{
relocateable = FALSE;
output_bfd = symbol->section->output_section->owner;
}
ret = score_elf_final_gp (output_bfd, symbol, relocateable, error_message, &gp);
if (ret != bfd_reloc_ok)
return ret;
return <API key> (abfd, symbol, reloc_entry,
input_section, relocateable, data, gp);
}
/* Do a R_SCORE_GPREL32 relocation. This is a 32 bit value which must
become the offset from the gp register. */
static <API key>
<API key> (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
void *data, asection *input_section, bfd *output_bfd,
char **error_message)
{
bfd_boolean relocatable;
<API key> ret;
bfd_vma gp;
/* R_SCORE_GPREL32 relocations are defined for local symbols only. */
if (output_bfd != NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0
&& (symbol->flags & BSF_LOCAL) != 0)
{
*error_message = (char *)
_("32bits gp relative relocation occurs for an external symbol");
return <API key>;
}
if (output_bfd != NULL)
relocatable = TRUE;
else
{
relocatable = FALSE;
output_bfd = symbol->section->output_section->owner;
}
ret = score_elf_final_gp (output_bfd, symbol, relocatable, error_message, &gp);
if (ret != bfd_reloc_ok)
return ret;
gp = 0;
return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
relocatable, data, gp);
}
/* A howto special_function for R_SCORE_GOT15 relocations. This is just
like any other 16-bit relocation when applied to global symbols, but is
treated in the same as R_SCORE_HI16 when applied to local symbols. */
static <API key>
<API key> (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
void *data, asection *input_section,
bfd *output_bfd, char **error_message)
{
if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
|| bfd_is_und_section (bfd_get_section (symbol))
|| bfd_is_com_section (bfd_get_section (symbol)))
/* The relocation is against a global symbol. */
return <API key> (abfd, reloc_entry, symbol, data,
input_section, output_bfd,
error_message);
return <API key> (abfd, reloc_entry, symbol, data,
input_section, output_bfd, error_message);
}
static <API key>
<API key> (bfd *abfd,
arelent *reloc_entry,
asymbol *symbol ATTRIBUTE_UNUSED,
void * data,
asection *input_section,
bfd *output_bfd ATTRIBUTE_UNUSED,
char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma addend = 0, offset = 0;
signed long val;
signed long hi16_offset, hi16_value, uvalue;
hi16_value = score_bfd_get_32 (abfd, hi16_rel_addr);
hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
addend = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
val = reloc_entry->addend;
if (reloc_entry->address > input_section->size)
return <API key>;
uvalue = ((hi16_offset << 16) | (offset & 0xffff)) + val;
if ((uvalue > -0x8000) && (uvalue < 0x7fff))
hi16_offset = 0;
else
hi16_offset = (uvalue >> 16) & 0x7fff;
hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
score_bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
offset = (uvalue & 0xffff) << 1;
addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
score_bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
return bfd_reloc_ok;
}
static reloc_howto_type <API key>[] =
{
/* No relocation. */
HOWTO (R_SCORE_NONE, /* type */
0, /* rightshift */
3, /* size (0 = byte, 1 = short, 2 = long) */
0, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_NONE", /* name */
FALSE, /* partial_inplace */
0, /* src_mask */
0, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_HI16 */
HOWTO (R_SCORE_HI16, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_HI16", /* name */
TRUE, /* partial_inplace */
0x37fff, /* src_mask */
0x37fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_LO16 */
HOWTO (R_SCORE_LO16, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_LO16", /* name */
TRUE, /* partial_inplace */
0x37fff, /* src_mask */
0x37fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_BCMP */
HOWTO (R_SCORE_BCMP, /* type */
1, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
TRUE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_BCMP", /* name */
FALSE, /* partial_inplace */
0x03e00381, /* src_mask */
0x03e00381, /* dst_mask */
FALSE), /* pcrel_offset */
/*R_SCORE_24 */
HOWTO (R_SCORE_24, /* type */
1, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
24, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_24", /* name */
FALSE, /* partial_inplace */
0x3ff7fff, /* src_mask */
0x3ff7fff, /* dst_mask */
FALSE), /* pcrel_offset */
/*R_SCORE_PC19 */
HOWTO (R_SCORE_PC19, /* type */
1, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
19, /* bitsize */
TRUE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_PC19", /* name */
FALSE, /* partial_inplace */
0x3ff03fe, /* src_mask */
0x3ff03fe, /* dst_mask */
FALSE), /* pcrel_offset */
/*R_SCORE16_11 */
HOWTO (R_SCORE16_11, /* type */
1, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
11, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE16_11", /* name */
FALSE, /* partial_inplace */
0x000000ffe, /* src_mask */
0x000000ffe, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE16_PC8 */
HOWTO (R_SCORE16_PC8, /* type */
1, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
9, /* bitsize */
TRUE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE16_PC8", /* name */
FALSE, /* partial_inplace */
0x000001ff, /* src_mask */
0x000001ff, /* dst_mask */
FALSE), /* pcrel_offset */
/* 32 bit absolute */
HOWTO (R_SCORE_ABS32, /* type 8 */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>, /* <API key> */
<API key>, /* special_function */
"R_SCORE_ABS32", /* name */
FALSE, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
FALSE), /* pcrel_offset */
/* 16 bit absolute */
HOWTO (R_SCORE_ABS16, /* type 11 */
0, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>, /* <API key> */
<API key>, /* special_function */
"R_SCORE_ABS16", /* name */
FALSE, /* partial_inplace */
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_DUMMY2 */
HOWTO (R_SCORE_DUMMY2, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_DUMMY2", /* name */
TRUE, /* partial_inplace */
0x00007fff, /* src_mask */
0x00007fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_GP15 */
HOWTO (R_SCORE_GP15, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>,/* special_function */
"R_SCORE_GP15", /* name */
TRUE, /* partial_inplace */
0x00007fff, /* src_mask */
0x00007fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* GNU extension to record C++ vtable hierarchy. */
HOWTO (<API key>, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
0, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
NULL, /* special_function */
"<API key>", /* name */
FALSE, /* partial_inplace */
0, /* src_mask */
0, /* dst_mask */
FALSE), /* pcrel_offset */
/* GNU extension to record C++ vtable member usage */
HOWTO (R_SCORE_GNU_VTENTRY, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
0, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_GNU_VTENTRY", /* name */
FALSE, /* partial_inplace */
0, /* src_mask */
0, /* dst_mask */
FALSE), /* pcrel_offset */
/* Reference to global offset table. */
HOWTO (R_SCORE_GOT15, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>, /* <API key> */
<API key>, /* special_function */
"R_SCORE_GOT15", /* name */
TRUE, /* partial_inplace */
0x00007fff, /* src_mask */
0x00007fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* Low 16 bits of displacement in global offset table. */
HOWTO (R_SCORE_GOT_LO16, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_GOT_LO16", /* name */
TRUE, /* partial_inplace */
0x37ffe, /* src_mask */
0x37ffe, /* dst_mask */
FALSE), /* pcrel_offset */
/* 15 bit call through global offset table. */
HOWTO (R_SCORE_CALL15, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>, /* <API key> */
<API key>, /* special_function */
"R_SCORE_CALL15", /* name */
TRUE, /* partial_inplace */
0x0000ffff, /* src_mask */
0x0000ffff, /* dst_mask */
FALSE), /* pcrel_offset */
/* 32 bit GP relative reference. */
HOWTO (R_SCORE_GPREL32, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_GPREL32", /* name */
TRUE, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
FALSE), /* pcrel_offset */
/* 32 bit symbol relative relocation. */
HOWTO (R_SCORE_REL32, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
FALSE, /* pc_relative */
0, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_REL32", /* name */
TRUE, /* partial_inplace */
0xffffffff, /* src_mask */
0xffffffff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_DUMMY_HI16 */
HOWTO (R_SCORE_DUMMY_HI16, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
FALSE, /* pc_relative */
1, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_DUMMY_HI16", /* name */
TRUE, /* partial_inplace */
0x37fff, /* src_mask */
0x37fff, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_IMM30 */
HOWTO (R_SCORE_IMM30, /* type */
2, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
30, /* bitsize */
FALSE, /* pc_relative */
7, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_IMM30", /* name */
FALSE, /* partial_inplace */
0x7f7fff7f80LL, /* src_mask */
0x7f7fff7f80LL, /* dst_mask */
FALSE), /* pcrel_offset */
/* R_SCORE_IMM32 */
HOWTO (R_SCORE_IMM32, /* type */
0, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
32, /* bitsize */
FALSE, /* pc_relative */
5, /* bitpos */
<API key>,/* <API key> */
<API key>, /* special_function */
"R_SCORE_IMM32", /* name */
FALSE, /* partial_inplace */
0x7f7fff7fe0LL, /* src_mask */
0x7f7fff7fe0LL, /* dst_mask */
FALSE), /* pcrel_offset */
};
struct score_reloc_map
{
<API key> bfd_reloc_val;
unsigned char elf_reloc_val;
};
static const struct score_reloc_map <API key>[] =
{
{BFD_RELOC_NONE, R_SCORE_NONE},
{BFD_RELOC_HI16_S, R_SCORE_HI16},
{BFD_RELOC_LO16, R_SCORE_LO16},
{<API key>, R_SCORE_BCMP},
{BFD_RELOC_SCORE_JMP, R_SCORE_24},
{<API key>, R_SCORE_PC19},
{<API key>, R_SCORE16_11},
{<API key>, R_SCORE16_PC8},
{BFD_RELOC_32, R_SCORE_ABS32},
{BFD_RELOC_16, R_SCORE_ABS16},
{<API key>, R_SCORE_DUMMY2},
{<API key>, R_SCORE_GP15},
{<API key>, <API key>},
{<API key>, R_SCORE_GNU_VTENTRY},
{<API key>, R_SCORE_GOT15},
{<API key>, R_SCORE_GOT_LO16},
{<API key>, R_SCORE_CALL15},
{BFD_RELOC_GPREL32, R_SCORE_GPREL32},
{BFD_RELOC_32_PCREL, R_SCORE_REL32},
{<API key>, R_SCORE_DUMMY_HI16},
{<API key>, R_SCORE_IMM30},
{<API key>, R_SCORE_IMM32},
};
/* got_entries only match if they're identical, except for gotidx, so
use all fields to compute the hash, and compare the appropriate
union members. */
static hashval_t
<API key> (const void *entry_)
{
const struct score_got_entry *entry = (struct score_got_entry *)entry_;
return entry->symndx
+ (!entry->abfd ? entry->d.address : entry->abfd->id);
}
static int
<API key> (const void *entry1, const void *entry2)
{
const struct score_got_entry *e1 = (struct score_got_entry *)entry1;
const struct score_got_entry *e2 = (struct score_got_entry *)entry2;
return e1->abfd == e2->abfd && e1->symndx == e2->symndx
&& (! e1->abfd ? e1->d.address == e2->d.address
: e1->symndx >= 0 ? e1->d.addend == e2->d.addend
: e1->d.h == e2->d.h);
}
/* If H needs a GOT entry, assign it the highest available dynamic
index. Otherwise, assign it the lowest available dynamic
index. */
static bfd_boolean
<API key> (struct <API key> *h, void *data)
{
struct <API key> *hsd = data;
/* Symbols without dynamic symbol table entries aren't interesting at all. */
if (h->root.dynindx == -1)
return TRUE;
/* Global symbols that need GOT entries that are not explicitly
referenced are marked with got offset 2. Those that are
referenced get a 1, and those that don't need GOT entries get
-1. */
if (h->root.got.offset == 2)
{
if (hsd-><API key> == hsd->min_got_dynindx)
hsd->low = (struct elf_link_hash_entry *) h;
h->root.dynindx = hsd-><API key>++;
}
else if (h->root.got.offset != 1)
h->root.dynindx = hsd->max_non_got_dynindx++;
else
{
h->root.dynindx = --hsd->min_got_dynindx;
hsd->low = (struct elf_link_hash_entry *) h;
}
return TRUE;
}
static asection *
<API key> (bfd *abfd, bfd_boolean maybe_excluded)
{
asection *sgot = <API key> (abfd, ".got");
if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0))
return NULL;
return sgot;
}
/* Returns the GOT information associated with the link indicated by
INFO. If SGOTP is non-NULL, it is filled in with the GOT section. */
static struct score_got_info *
score_elf_got_info (bfd *abfd, asection **sgotp)
{
asection *sgot;
struct score_got_info *g;
sgot = <API key> (abfd, TRUE);
BFD_ASSERT (sgot != NULL);
BFD_ASSERT (elf_section_data (sgot) != NULL);
g = <API key> (sgot)->u.got_info;
BFD_ASSERT (g != NULL);
if (sgotp)
*sgotp = sgot;
return g;
}
/* Sort the dynamic symbol table so that symbols that need GOT entries
appear towards the end. This reduces the amount of GOT space
required. MAX_LOCAL is used to set the number of local symbols
known to be in the dynamic symbol table. During
<API key>, this value is 1. Afterward, the
section symbols are added and the count is higher. */
static bfd_boolean
<API key> (struct bfd_link_info *info,
unsigned long max_local)
{
struct <API key> hsd;
struct score_got_info *g;
bfd *dynobj;
dynobj = elf_hash_table (info)->dynobj;
g = score_elf_got_info (dynobj, NULL);
hsd.low = NULL;
hsd.<API key> =
hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount
/* In the multi-got case, assigned_gotno of the master got_info
indicate the number of entries that aren't referenced in the
primary GOT, but that must have entries because there are
dynamic relocations that reference it. Since they aren't
referenced, we move them to the end of the GOT, so that they
don't prevent other entries that are referenced from getting
too large offsets. */
- (g->next ? g->assigned_gotno : 0);
hsd.max_non_got_dynindx = max_local;
<API key> (elf_hash_table (info),
<API key>,
&hsd);
/* There should have been enough room in the symbol table to
accommodate both the GOT and non-GOT symbols. */
BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
BFD_ASSERT ((unsigned long)hsd.<API key>
<= elf_hash_table (info)->dynsymcount);
/* Now we know which dynamic symbol has the lowest dynamic symbol
table index in the GOT. */
g->global_gotsym = hsd.low;
return TRUE;
}
/* Create an entry in an score ELF linker hash table. */
static struct bfd_hash_entry *
<API key> (struct bfd_hash_entry *entry,
struct bfd_hash_table *table,
const char *string)
{
struct <API key> *ret = (struct <API key> *) entry;
/* Allocate the structure if it has not already been allocated by a subclass. */
if (ret == NULL)
ret = bfd_hash_allocate (table, sizeof (struct <API key>));
if (ret == NULL)
return (struct bfd_hash_entry *) ret;
/* Call the allocation method of the superclass. */
ret = ((struct <API key> *)
<API key> ((struct bfd_hash_entry *) ret, table, string));
if (ret != NULL)
{
ret-><API key> = 0;
ret->readonly_reloc = FALSE;
ret->no_fn_stub = FALSE;
ret->forced_local = FALSE;
}
return (struct bfd_hash_entry *) ret;
}
/* Returns the first relocation of type r_type found, beginning with
RELOCATION. RELEND is one-past-the-end of the relocation table. */
static const Elf_Internal_Rela *
<API key> (bfd *abfd ATTRIBUTE_UNUSED, unsigned int r_type,
const Elf_Internal_Rela *relocation,
const Elf_Internal_Rela *relend)
{
while (relocation < relend)
{
if (ELF32_R_TYPE (relocation->r_info) == r_type)
return relocation;
++relocation;
}
/* We didn't find it. */
bfd_set_error (bfd_error_bad_value);
return NULL;
}
/* This function is called via qsort() to sort the dynamic relocation
entries by increasing r_symndx value. */
static int
<API key> (const void *arg1, const void *arg2)
{
Elf_Internal_Rela int_reloc1;
Elf_Internal_Rela int_reloc2;
<API key> (reldyn_sorting_bfd, arg1, &int_reloc1);
<API key> (reldyn_sorting_bfd, arg2, &int_reloc2);
return (ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info));
}
/* Return whether a relocation is against a local symbol. */
static bfd_boolean
<API key> (bfd *input_bfd,
const Elf_Internal_Rela *relocation,
asection **local_sections,
bfd_boolean check_forced)
{
unsigned long r_symndx;
Elf_Internal_Shdr *symtab_hdr;
struct <API key> *h;
size_t extsymoff;
r_symndx = ELF32_R_SYM (relocation->r_info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
if (r_symndx < extsymoff)
return TRUE;
if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
return TRUE;
if (check_forced)
{
/* Look up the hash table to check whether the symbol was forced local. */
h = (struct <API key> *)
elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
/* Find the real hash-table entry for this symbol. */
while (h->root.root.type == <API key>
|| h->root.root.type == <API key>)
h = (struct <API key> *) h->root.root.u.i.link;
if (h->root.forced_local)
return TRUE;
}
return FALSE;
}
/* Returns the dynamic relocation section for DYNOBJ. */
static asection *
<API key> (bfd *dynobj, bfd_boolean create_p)
{
static const char dname[] = ".rel.dyn";
asection *sreloc;
sreloc = <API key> (dynobj, dname);
if (sreloc == NULL && create_p)
{
sreloc = <API key> (dynobj, dname,
(SEC_ALLOC
| SEC_LOAD
| SEC_HAS_CONTENTS
| SEC_IN_MEMORY
| SEC_LINKER_CREATED
| SEC_READONLY));
if (sreloc == NULL
|| ! <API key> (dynobj, sreloc,
<API key> (dynobj)))
return NULL;
}
return sreloc;
}
static void
<API key> (bfd *abfd, unsigned int n)
{
asection *s;
s = <API key> (abfd, FALSE);
BFD_ASSERT (s != NULL);
if (s->size == 0)
{
/* Make room for a null element. */
s->size += SCORE_ELF_REL_SIZE (abfd);
++s->reloc_count;
}
s->size += n * SCORE_ELF_REL_SIZE (abfd);
}
/* Create a rel.dyn relocation for the dynamic linker to resolve. REL
is the original relocation, which is now being transformed into a
dynamic relocation. The ADDENDP is adjusted if necessary; the
caller should store the result in place of the original addend. */
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info,
const Elf_Internal_Rela *rel,
struct <API key> *h,
bfd_vma symbol,
bfd_vma *addendp, asection *input_section)
{
Elf_Internal_Rela outrel[3];
asection *sreloc;
bfd *dynobj;
int r_type;
long indx;
bfd_boolean defined_p;
r_type = ELF32_R_TYPE (rel->r_info);
dynobj = elf_hash_table (info)->dynobj;
sreloc = <API key> (dynobj, FALSE);
BFD_ASSERT (sreloc != NULL);
BFD_ASSERT (sreloc->contents != NULL);
BFD_ASSERT (sreloc->reloc_count * SCORE_ELF_REL_SIZE (output_bfd) < sreloc->size);
outrel[0].r_offset =
<API key> (output_bfd, info, input_section, rel[0].r_offset);
outrel[1].r_offset =
<API key> (output_bfd, info, input_section, rel[1].r_offset);
outrel[2].r_offset =
<API key> (output_bfd, info, input_section, rel[2].r_offset);
if (outrel[0].r_offset == MINUS_ONE)
/* The relocation field has been deleted. */
return TRUE;
if (outrel[0].r_offset == MINUS_TWO)
{
/* The relocation field has been converted into a relative value of
some sort. Functions like <API key> expect
the field to be fully relocated, so add in the symbol's value. */
*addendp += symbol;
return TRUE;
}
/* We must now calculate the dynamic symbol table index to use
in the relocation. */
if (h != NULL
&& (! info->symbolic || !h->root.def_regular)
/* h->root.dynindx may be -1 if this symbol was marked to
become local. */
&& h->root.dynindx != -1)
{
indx = h->root.dynindx;
/* ??? glibc's ld.so just adds the final GOT entry to the
relocation field. It therefore treats relocs against
defined symbols in the same way as relocs against
undefined symbols. */
defined_p = FALSE;
}
else
{
indx = 0;
defined_p = TRUE;
}
/* If the relocation was previously an absolute relocation and
this symbol will not be referred to by the relocation, we must
adjust it by the value we give it in the dynamic symbol table.
Otherwise leave the job up to the dynamic linker. */
if (defined_p && r_type != R_SCORE_REL32)
*addendp += symbol;
/* The relocation is always an REL32 relocation because we don't
know where the shared library will wind up at load-time. */
outrel[0].r_info = ELF32_R_INFO ((unsigned long) indx, R_SCORE_REL32);
/* For strict adherence to the ABI specification, we should
generate a R_SCORE_64 relocation record by itself before the
_REL32/_64 record as well, such that the addend is read in as
a 64-bit value (REL32 is a 32-bit relocation, after all).
However, since none of the existing ELF64 SCORE dynamic
loaders seems to care, we don't waste space with these
artificial relocations. If this turns out to not be true,
<API key>() should be tweaked so
as to make room for a pair of dynamic relocations per
invocation if ABI_64_P, and here we should generate an
additional relocation record with R_SCORE_64 by itself for a
NULL symbol before this relocation record. */
outrel[1].r_info = ELF32_R_INFO (0, R_SCORE_NONE);
outrel[2].r_info = ELF32_R_INFO (0, R_SCORE_NONE);
/* Adjust the output offset of the relocation to reference the
correct location in the output file. */
outrel[0].r_offset += (input_section->output_section->vma
+ input_section->output_offset);
outrel[1].r_offset += (input_section->output_section->vma
+ input_section->output_offset);
outrel[2].r_offset += (input_section->output_section->vma
+ input_section->output_offset);
/* Put the relocation back out. We have to use the special
relocation outputter in the 64-bit case since the 64-bit
relocation format is non-standard. */
<API key>
(output_bfd, &outrel[0],
(sreloc->contents + sreloc->reloc_count * sizeof (Elf32_External_Rel)));
/* We've now added another relocation. */
++sreloc->reloc_count;
/* Make sure the output section is writable. The dynamic linker
will be writing to it. */
elf_section_data (input_section->output_section)->this_hdr.sh_flags |= SHF_WRITE;
return TRUE;
}
static bfd_boolean
<API key> (bfd *abfd,
struct bfd_link_info *info,
bfd_boolean maybe_exclude)
{
flagword flags;
asection *s;
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
struct score_got_info *g;
bfd_size_type amt;
/* This function may be called more than once. */
s = <API key> (abfd, TRUE);
if (s)
{
if (! maybe_exclude)
s->flags &= ~SEC_EXCLUDE;
return TRUE;
}
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
if (maybe_exclude)
flags |= SEC_EXCLUDE;
/* We have to use an alignment of 2**4 here because this is hardcoded
in the function stub generation and in the linker script. */
s = <API key> (abfd, ".got", flags);
elf_hash_table (info)->sgot = s;
if (s == NULL
|| ! <API key> (abfd, s, 4))
return FALSE;
/* Define the symbol <API key>. We don't do this in the
linker script because we don't want to define the symbol if we
are not creating a global offset table. */
bh = NULL;
if (! (<API key>
(info, abfd, "<API key>", BSF_GLOBAL, s,
0, NULL, FALSE, <API key> (abfd)->collect, &bh)))
return FALSE;
h = (struct elf_link_hash_entry *) bh;
h->non_elf = 0;
h->def_regular = 1;
h->type = STT_OBJECT;
elf_hash_table (info)->hgot = h;
if (bfd_link_pic (info) && ! <API key> (info, h))
return FALSE;
amt = sizeof (struct score_got_info);
g = bfd_alloc (abfd, amt);
if (g == NULL)
return FALSE;
g->global_gotsym = NULL;
g->global_gotno = 0;
g->local_gotno = <API key>;
g->assigned_gotno = <API key>;
g->next = NULL;
g->got_entries = htab_try_create (1, <API key>,
<API key>, NULL);
if (g->got_entries == NULL)
return FALSE;
<API key> (s)->u.got_info = g;
<API key> (s)->elf.this_hdr.sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
return TRUE;
}
/* Calculate the %high function. */
static bfd_vma
score_elf_high (bfd_vma value)
{
return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff;
}
/* Create a local GOT entry for VALUE. Return the index of the entry,
or -1 if it could not be created. */
static struct score_got_entry *
<API key> (bfd *abfd,
bfd *ibfd ATTRIBUTE_UNUSED,
struct score_got_info *gg,
asection *sgot, bfd_vma value,
unsigned long r_symndx ATTRIBUTE_UNUSED,
struct <API key> *h ATTRIBUTE_UNUSED,
int r_type ATTRIBUTE_UNUSED)
{
struct score_got_entry entry, **loc;
struct score_got_info *g;
entry.abfd = NULL;
entry.symndx = -1;
entry.d.address = value;
g = gg;
loc = (struct score_got_entry **) htab_find_slot (g->got_entries, &entry, INSERT);
if (*loc)
return *loc;
entry.gotidx = SCORE_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
*loc = bfd_alloc (abfd, sizeof entry);
if (! *loc)
return NULL;
memcpy (*loc, &entry, sizeof entry);
if (g->assigned_gotno >= g->local_gotno)
{
(*loc)->gotidx = -1;
/* We didn't allocate enough space in the GOT. */
_bfd_error_handler
(_("not enough GOT space for local GOT entries"));
bfd_set_error (bfd_error_bad_value);
return NULL;
}
score_bfd_put_32 (abfd, value, (sgot->contents + entry.gotidx));
return *loc;
}
/* Find a GOT entry whose higher-order 16 bits are the same as those
for value. Return the index into the GOT for this entry. */
static bfd_vma
<API key> (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
bfd_vma value, bfd_boolean external)
{
asection *sgot;
struct score_got_info *g;
struct score_got_entry *entry;
if (!external)
{
/* Although the ABI says that it is "the high-order 16 bits" that we
want, it is really the %high value. The complete value is
calculated with a `addiu' of a LO16 relocation, just as with a
HI16/LO16 pair. */
value = score_elf_high (value) << 16;
}
g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
entry = <API key> (abfd, ibfd, g, sgot, value, 0, NULL,
R_SCORE_GOT15);
if (entry)
return entry->gotidx;
else
return MINUS_ONE;
}
static void
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *entry,
bfd_boolean force_local)
{
bfd *dynobj;
asection *got;
struct score_got_info *g;
struct <API key> *h;
h = (struct <API key> *) entry;
if (h->forced_local)
return;
h->forced_local = TRUE;
dynobj = elf_hash_table (info)->dynobj;
if (dynobj != NULL && force_local)
{
got = <API key> (dynobj, FALSE);
if (got == NULL)
return;
g = <API key> (got)->u.got_info;
if (g->next)
{
struct score_got_entry e;
struct score_got_info *gg = g;
/* Since we're turning what used to be a global symbol into a
local one, bump up the number of local entries of each GOT
that had an entry for it. This will automatically decrease
the number of global entries, since global_gotno is actually
the upper limit of global entries. */
e.abfd = dynobj;
e.symndx = -1;
e.d.h = h;
for (g = g->next; g != gg; g = g->next)
if (htab_find (g->got_entries, &e))
{
BFD_ASSERT (g->global_gotno > 0);
g->local_gotno++;
g->global_gotno
}
/* If this was a global symbol forced into the primary GOT, we
no longer need an entry for it. We can't release the entry
at this point, but we must at least stop counting it as one
of the symbols that required a forced got entry. */
if (h->root.got.offset == 2)
{
BFD_ASSERT (gg->assigned_gotno > 0);
gg->assigned_gotno
}
}
else if (g->global_gotno == 0 && g->global_gotsym == NULL)
/* If we haven't got through GOT allocation yet, just bump up the
number of local entries, as this symbol won't be counted as
global. */
g->local_gotno++;
else if (h->root.got.offset == 1)
{
/* If we're past non-multi-GOT allocation and this symbol had
been marked for a global got entry, give it a local entry
instead. */
BFD_ASSERT (g->global_gotno > 0);
g->local_gotno++;
g->global_gotno
}
}
<API key> (info, &h->root, force_local);
}
/* If H is a symbol that needs a global GOT entry, but has a dynamic
symbol table index lower than any we've seen to date, record it for
posterity. */
static bfd_boolean
<API key> (struct elf_link_hash_entry *h,
bfd *abfd,
struct bfd_link_info *info,
struct score_got_info *g)
{
struct score_got_entry entry, **loc;
/* A global symbol in the GOT must also be in the dynamic symbol table. */
if (h->dynindx == -1)
{
switch (ELF_ST_VISIBILITY (h->other))
{
case STV_INTERNAL:
case STV_HIDDEN:
<API key> (info, h, TRUE);
break;
}
if (!<API key> (info, h))
return FALSE;
}
entry.abfd = abfd;
entry.symndx = -1;
entry.d.h = (struct <API key> *)h;
loc = (struct score_got_entry **)htab_find_slot (g->got_entries, &entry, INSERT);
/* If we've already marked this entry as needing GOT space, we don't
need to do it again. */
if (*loc)
return TRUE;
*loc = bfd_alloc (abfd, sizeof entry);
if (! *loc)
return FALSE;
entry.gotidx = -1;
memcpy (*loc, &entry, sizeof (entry));
if (h->got.offset != MINUS_ONE)
return TRUE;
/* By setting this to a value other than -1, we are indicating that
there needs to be a GOT entry for H. Avoid using zero, as the
generic ELF <API key> tests for <= 0. */
h->got.offset = 1;
return TRUE;
}
/* Reserve space in G for a GOT entry containing the value of symbol
SYMNDX in input bfd ABDF, plus ADDEND. */
static bfd_boolean
<API key> (bfd *abfd,
long symndx,
bfd_vma addend,
struct score_got_info *g)
{
struct score_got_entry entry, **loc;
entry.abfd = abfd;
entry.symndx = symndx;
entry.d.addend = addend;
loc = (struct score_got_entry **)htab_find_slot (g->got_entries, &entry, INSERT);
if (*loc)
return TRUE;
entry.gotidx = g->local_gotno++;
*loc = bfd_alloc (abfd, sizeof(entry));
if (! *loc)
return FALSE;
memcpy (*loc, &entry, sizeof (entry));
return TRUE;
}
/* Returns the GOT offset at which the indicated address can be found.
If there is not yet a GOT entry for this value, create one.
Returns -1 if no satisfactory GOT offset can be found. */
static bfd_vma
<API key> (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
bfd_vma value, unsigned long r_symndx,
struct <API key> *h, int r_type)
{
asection *sgot;
struct score_got_info *g;
struct score_got_entry *entry;
g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
entry = <API key> (abfd, ibfd, g, sgot, value,
r_symndx, h, r_type);
if (!entry)
return MINUS_ONE;
else
return entry->gotidx;
}
/* Returns the GOT index for the global symbol indicated by H. */
static bfd_vma
<API key> (bfd *abfd, struct elf_link_hash_entry *h)
{
bfd_vma got_index;
asection *sgot;
struct score_got_info *g;
long global_got_dynindx = 0;
g = score_elf_got_info (abfd, &sgot);
if (g->global_gotsym != NULL)
global_got_dynindx = g->global_gotsym->dynindx;
/* Once we determine the global GOT entry with the lowest dynamic
symbol table index, we must put all dynamic symbols with greater
indices into the GOT. That makes it easy to calculate the GOT
offset. */
BFD_ASSERT (h->dynindx >= global_got_dynindx);
got_index = ((h->dynindx - global_got_dynindx + g->local_gotno) * SCORE_ELF_GOT_SIZE (abfd));
BFD_ASSERT (got_index < sgot->size);
return got_index;
}
/* Returns the offset for the entry at the INDEXth position in the GOT. */
static bfd_vma
<API key> (bfd *dynobj,
bfd *output_bfd,
bfd *input_bfd ATTRIBUTE_UNUSED,
bfd_vma got_index)
{
asection *sgot;
bfd_vma gp;
score_elf_got_info (dynobj, &sgot);
gp = _bfd_get_gp_value (output_bfd);
return sgot->output_section->vma + sgot->output_offset + got_index - gp;
}
/* Follow indirect and warning hash entries so that each got entry
points to the final symbol definition. P must point to a pointer
to the hash table we're traversing. Since this traversal may
modify the hash table, we set this pointer to NULL to indicate
we've made a <API key> change to the hash table, so
the traversal must be restarted. */
static int
<API key> (void **entryp, void *p)
{
struct score_got_entry *entry = (struct score_got_entry *)*entryp;
htab_t got_entries = *(htab_t *)p;
if (entry->abfd != NULL && entry->symndx == -1)
{
struct <API key> *h = entry->d.h;
while (h->root.root.type == <API key>
|| h->root.root.type == <API key>)
h = (struct <API key> *) h->root.root.u.i.link;
if (entry->d.h == h)
return 1;
entry->d.h = h;
/* If we can't find this entry with the new bfd hash, re-insert
it, and get the traversal restarted. */
if (! htab_find (got_entries, entry))
{
htab_clear_slot (got_entries, entryp);
entryp = htab_find_slot (got_entries, entry, INSERT);
if (! *entryp)
*entryp = entry;
/* Abort the traversal, since the whole table may have
moved, and leave it up to the parent to restart the
process. */
*(htab_t *)p = NULL;
return 0;
}
/* We might want to decrement the global_gotno count, but it's
either too early or too late for that at this point. */
}
return 1;
}
/* Turn indirect got entries in a got_entries table into their final locations. */
static void
<API key> (struct score_got_info *g)
{
htab_t got_entries;
do
{
got_entries = g->got_entries;
htab_traverse (got_entries,
<API key>,
&got_entries);
}
while (got_entries == NULL);
}
/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. for -r */
static void
<API key> (bfd *abfd,
bfd_byte *address,
reloc_howto_type *howto,
bfd_signed_vma increment)
{
bfd_signed_vma addend;
bfd_vma contents;
unsigned long offset;
unsigned long r_type = howto->type;
unsigned long hi16_addend, hi16_offset, hi16_value, uvalue;
contents = score_bfd_get_32 (abfd, address);
/* Get the (signed) value from the instruction. */
addend = contents & howto->src_mask;
if (addend & ((howto->src_mask + 1) >> 1))
{
bfd_signed_vma mask;
mask = -1;
mask &= ~howto->src_mask;
addend |= mask;
}
/* Add in the increment, (which is a byte value). */
switch (r_type)
{
case R_SCORE_PC19:
offset =
(((contents & howto->src_mask) & 0x3ff0000) >> 6) | ((contents & howto->src_mask) & 0x3ff);
offset += increment;
contents =
(contents & ~howto->
src_mask) | (((offset << 6) & howto->src_mask) & 0x3ff0000) | (offset & 0x3ff);
score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE_HI16:
break;
case R_SCORE_LO16:
hi16_addend = score_bfd_get_32 (abfd, address - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
offset = ((((contents >> 16) & 0x3) << 15) | (contents & 0x7fff)) >> 1;
offset = (hi16_offset << 16) | (offset & 0xffff);
uvalue = increment + offset;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
score_bfd_put_32 (abfd, hi16_value, address - 4);
offset = (uvalue & 0xffff) << 1;
contents = (contents & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE_24:
offset =
(((contents & howto->src_mask) >> 1) & 0x1ff8000) | ((contents & howto->src_mask) & 0x7fff);
offset += increment;
contents =
(contents & ~howto->
src_mask) | (((offset << 1) & howto->src_mask) & 0x3ff0000) | (offset & 0x7fff);
score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE16_11:
contents = score_bfd_get_16 (abfd, address);
offset = contents & howto->src_mask;
offset += increment;
contents = (contents & ~howto->src_mask) | (offset & howto->src_mask);
score_bfd_put_16 (abfd, contents, address);
break;
case R_SCORE16_PC8:
contents = score_bfd_get_16 (abfd, address);
offset = (contents & howto->src_mask) + ((increment >> 1) & 0x1ff);
contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
score_bfd_put_16 (abfd, contents, address);
break;
case R_SCORE_BCMP:
contents = score_bfd_get_32 (abfd, address);
offset = (contents & howto->src_mask);
offset <<= howto->rightshift;
offset += increment;
offset >>= howto->rightshift;
contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE_IMM30:
contents = score_bfd_get_48 (abfd, address);
offset = (contents & howto->src_mask);
offset <<= howto->rightshift;
offset += increment;
offset >>= howto->rightshift;
contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
score_bfd_put_48 (abfd, contents, address);
break;
case R_SCORE_IMM32:
contents = score_bfd_get_48 (abfd, address);
offset = (contents & howto->src_mask);
offset += increment;
contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
score_bfd_put_48 (abfd, contents, address);
break;
default:
addend += increment;
contents = (contents & ~howto->dst_mask) | (addend & howto->dst_mask);
score_bfd_put_32 (abfd, contents, address);
break;
}
}
/* Perform a relocation as part of a final link. */
static <API key>
<API key> (reloc_howto_type *howto,
bfd *input_bfd,
bfd *output_bfd,
asection *input_section,
bfd_byte *contents,
Elf_Internal_Rela *rel,
Elf_Internal_Rela *relocs,
bfd_vma symbol,
struct bfd_link_info *info,
const char *sym_name ATTRIBUTE_UNUSED,
int sym_flags ATTRIBUTE_UNUSED,
struct <API key> *h,
asection **local_sections,
bfd_boolean gp_disp_p)
{
unsigned long r_type;
unsigned long r_symndx;
bfd_byte *hit_data = contents + rel->r_offset;
bfd_vma addend;
/* The final GP value to be used for the relocatable, executable, or
shared object file being produced. */
bfd_vma gp = MINUS_ONE;
/* The place (section offset or address) of the storage unit being relocated. */
bfd_vma rel_addr;
/* The offset into the global offset table at which the address of the relocation entry
symbol, adjusted by the addend, resides during execution. */
bfd_vma g = MINUS_ONE;
/* TRUE if the symbol referred to by this relocation is a local symbol. */
bfd_boolean local_p;
/* The eventual value we will relocate. */
bfd_vma value = symbol;
unsigned long hi16_addend, hi16_offset, hi16_value, uvalue, offset, abs_value = 0;
if (elf_gp (output_bfd) == 0)
{
struct bfd_link_hash_entry *bh;
asection *o;
bh = <API key> (info->hash, "_gp", 0, 0, 1);
if (bh != NULL && bh->type == <API key>)
elf_gp (output_bfd) = (bh->u.def.value
+ bh->u.def.section->output_section->vma
+ bh->u.def.section->output_offset);
else if (<API key> (info))
{
bfd_vma lo = -1;
/* Find the GP-relative section with the lowest offset. */
for (o = output_bfd->sections; o != NULL; o = o->next)
if (o->vma < lo)
lo = o->vma;
/* And calculate GP relative to that. */
elf_gp (output_bfd) = lo + ELF_SCORE_GP_OFFSET (input_bfd);
}
else
{
/* If the relocate_section function needs to do a reloc
involving the GP value, it should make a reloc_dangerous
callback to warn that GP is not defined. */
}
}
/* Parse the relocation. */
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
rel_addr = (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
local_p = <API key> (input_bfd, rel, local_sections, TRUE);
if (r_type == R_SCORE_GOT15)
{
const Elf_Internal_Rela *relend;
const Elf_Internal_Rela *lo16_rel;
const struct elf_backend_data *bed;
bfd_vma lo_value = 0;
bed = <API key> (output_bfd);
relend = relocs + input_section->reloc_count * bed->s-><API key>;
lo16_rel = <API key> (input_bfd, R_SCORE_GOT_LO16, rel, relend);
if ((local_p) && (lo16_rel != NULL))
{
bfd_vma tmp = 0;
tmp = score_bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
lo_value = (((tmp >> 16) & 0x3) << 14) | ((tmp & 0x7fff) >> 1);
}
addend = lo_value;
}
/* For score3 R_SCORE_ABS32. */
else if (r_type == R_SCORE_ABS32 || r_type == R_SCORE_REL32)
{
addend = (bfd_get_32 (input_bfd, hit_data) >> howto->bitpos) & howto->src_mask;
}
else
{
addend = (score_bfd_get_32 (input_bfd, hit_data) >> howto->bitpos) & howto->src_mask;
}
/* If we haven't already determined the GOT offset, or the GP value,
and we're going to need it, get it now. */
switch (r_type)
{
case R_SCORE_CALL15:
case R_SCORE_GOT15:
if (!local_p)
{
g = <API key> (elf_hash_table (info)->dynobj,
(struct elf_link_hash_entry *) h);
if ((! elf_hash_table (info)-><API key>
|| (bfd_link_pic (info)
&& (info->symbolic || h->root.dynindx == -1)
&& h->root.def_regular)))
{
/* This is a static link or a -Bsymbolic link. The
symbol is defined locally, or was forced to be local.
We must initialize this entry in the GOT. */
bfd *tmpbfd = elf_hash_table (info)->dynobj;
asection *sgot = <API key> (tmpbfd, FALSE);
score_bfd_put_32 (tmpbfd, value, sgot->contents + g);
}
}
else if (r_type == R_SCORE_GOT15 || r_type == R_SCORE_CALL15)
{
/* There's no need to create a local GOT entry here; the
calculation for a local GOT15 entry does not involve G. */
;
}
else
{
g = <API key> (output_bfd, input_bfd, info,
symbol + addend, r_symndx, h, r_type);
if (g == MINUS_ONE)
return <API key>;
}
/* Convert GOT indices to actual offsets. */
g = <API key> (elf_hash_table (info)->dynobj,
output_bfd, input_bfd, g);
break;
case R_SCORE_HI16:
case R_SCORE_LO16:
case R_SCORE_GPREL32:
gp = _bfd_get_gp_value (output_bfd);
break;
case R_SCORE_GP15:
gp = _bfd_get_gp_value (output_bfd);
default:
break;
}
switch (r_type)
{
case R_SCORE_NONE:
return bfd_reloc_ok;
case R_SCORE_ABS32:
case R_SCORE_REL32:
if ((bfd_link_pic (info)
|| (elf_hash_table (info)-><API key>
&& h != NULL
&& h->root.def_dynamic
&& !h->root.def_regular))
&& r_symndx != STN_UNDEF
&& (input_section->flags & SEC_ALLOC) != 0)
{
/* If we're creating a shared library, or this relocation is against a symbol
in a shared library, then we can't know where the symbol will end up.
So, we create a relocation record in the output, and leave the job up
to the dynamic linker. */
value = addend;
if (!<API key> (output_bfd, info, rel, h,
symbol, &value,
input_section))
return bfd_reloc_undefined;
}
else if (r_symndx == STN_UNDEF)
/* r_symndx will be STN_UNDEF (zero) only for relocs against symbols
from removed linkonce sections, or sections discarded by
a linker script. */
value = 0;
else
{
if (r_type != R_SCORE_REL32)
value = symbol + addend;
else
value = addend;
}
value &= howto->dst_mask;
bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_ABS16:
value += addend;
if ((long)value > 0x7fff || (long)value < -0x8000)
return bfd_reloc_overflow;
score_bfd_put_16 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_24:
addend = score_bfd_get_32 (input_bfd, hit_data);
offset = (((addend & howto->src_mask) >> 1) & 0x1ff8000) | ((addend & howto->src_mask) & 0x7fff);
if ((offset & 0x1000000) != 0)
offset |= 0xfe000000;
value += offset;
abs_value = value - rel_addr;
if ((abs_value & 0xfe000000) != 0)
return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask)
| (((value << 1) & howto->src_mask) & 0x3ff0000) | (value & 0x7fff);
score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
/* signed imm32. */
case R_SCORE_IMM30:
{
int not_word_align_p = 0;
bfd_vma imm_offset = 0;
addend = score_bfd_get_48 (input_bfd, hit_data);
imm_offset = ((addend >> 7) & 0xff)
| (((addend >> 16) & 0x7fff) << 8)
| (((addend >> 32) & 0x7f) << 23);
imm_offset <<= howto->rightshift;
value += imm_offset;
value &= 0xffffffff;
/* Check lw48/sw48 rd, value/label word align. */
if ((value & 0x3) != 0)
not_word_align_p = 1;
value >>= howto->rightshift;
addend = (addend & ~howto->src_mask)
| (((value & 0xff) >> 0) << 7)
| (((value & 0x7fff00) >> 8) << 16)
| (((value & 0x3f800000) >> 23) << 32);
score_bfd_put_48 (input_bfd, addend, hit_data);
if (not_word_align_p)
return bfd_reloc_other;
else
return bfd_reloc_ok;
}
case R_SCORE_IMM32:
{
bfd_vma imm_offset = 0;
addend = score_bfd_get_48 (input_bfd, hit_data);
imm_offset = ((addend >> 5) & 0x3ff)
| (((addend >> 16) & 0x7fff) << 10)
| (((addend >> 32) & 0x7f) << 25);
value += imm_offset;
value &= 0xffffffff;
addend = (addend & ~howto->src_mask)
| ((value & 0x3ff) << 5)
| (((value >> 10) & 0x7fff) << 16)
| (((value >> 25) & 0x7f) << 32);
score_bfd_put_48 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
}
case R_SCORE_PC19:
addend = score_bfd_get_32 (input_bfd, hit_data);
offset = (((addend & howto->src_mask) & 0x3ff0000) >> 6) | ((addend & howto->src_mask) & 0x3ff);
if ((offset & 0x80000) != 0)
offset |= 0xfff00000;
abs_value = value = value - rel_addr + offset;
/* exceed 20 bit : overflow. */
if ((abs_value & 0x80000000) == 0x80000000)
abs_value = 0xffffffff - value + 1;
if ((abs_value & 0xfff80000) != 0)
return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask)
| (((value << 6) & howto->src_mask) & 0x3ff0000) | (value & 0x3ff);
score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE16_11:
addend = score_bfd_get_16 (input_bfd, hit_data);
offset = addend & howto->src_mask;
if ((offset & 0x800) != 0) /* Offset is negative. */
offset |= 0xfffff000;
value += offset;
abs_value = value - rel_addr;
if ((abs_value & 0xfffff000) != 0)
return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
score_bfd_put_16 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE16_PC8:
addend = score_bfd_get_16 (input_bfd, hit_data);
offset = (addend & howto->src_mask) << 1;
if ((offset & 0x200) != 0) /* Offset is negative. */
offset |= 0xfffffe00;
abs_value = value = value - rel_addr + offset;
/* Sign bit + exceed 9 bit. */
if (((value & 0xfffffe00) != 0) && ((value & 0xfffffe00) != 0xfffffe00))
return bfd_reloc_overflow;
value >>= 1;
addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
score_bfd_put_16 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE_BCMP:
addend = score_bfd_get_32 (input_bfd, hit_data);
offset = (addend & howto->src_mask) << howto->rightshift;
if ((offset & 0x200) != 0) /* Offset is negative. */
offset |= 0xfffffe00;
value = value - rel_addr + offset;
/* Sign bit + exceed 9 bit. */
if (((value & 0xfffffe00) != 0) && ((value & 0xfffffe00) != 0xfffffe00))
return bfd_reloc_overflow;
value >>= howto->rightshift;
addend = (addend & ~howto->src_mask)
| (value & 0x1)
| (((value >> 1) & 0x7) << 7)
| (((value >> 4) & 0x1f) << 21);
score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE_HI16:
return bfd_reloc_ok;
case R_SCORE_LO16:
hi16_addend = score_bfd_get_32 (input_bfd, hit_data - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
addend = score_bfd_get_32 (input_bfd, hit_data);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
offset = (hi16_offset << 16) | (offset & 0xffff);
if (!gp_disp_p)
uvalue = value + offset;
else
uvalue = offset + gp - rel_addr + 4;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
score_bfd_put_32 (input_bfd, hi16_value, hit_data - 4);
offset = (uvalue & 0xffff) << 1;
value = (addend & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GP15:
addend = score_bfd_get_32 (input_bfd, hit_data);
offset = addend & 0x7fff;
if ((offset & 0x4000) == 0x4000)
offset |= 0xffffc000;
value = value + offset - gp;
if (((value & 0xffffc000) != 0) && ((value & 0xffffc000) != 0xffffc000))
return bfd_reloc_overflow;
value = (addend & ~howto->src_mask) | (value & howto->src_mask);
score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GOT15:
case R_SCORE_CALL15:
if (local_p)
{
bfd_boolean forced;
/* The special case is when the symbol is forced to be local. We need the
full address in the GOT since no R_SCORE_GOT_LO16 relocation follows. */
forced = ! <API key> (input_bfd, rel,
local_sections, FALSE);
value = <API key> (output_bfd, input_bfd, info,
symbol + addend, forced);
if (value == MINUS_ONE)
return <API key>;
value = <API key> (elf_hash_table (info)->dynobj,
output_bfd, input_bfd, value);
}
else
{
value = g;
}
if ((long) value > 0x3fff || (long) value < -0x4000)
return bfd_reloc_overflow;
addend = score_bfd_get_32 (input_bfd, hit_data);
value = (addend & ~howto->dst_mask) | (value & howto->dst_mask);
score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GPREL32:
value = (addend + symbol - gp);
value &= howto->dst_mask;
score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GOT_LO16:
addend = score_bfd_get_32 (input_bfd, hit_data);
value = (((addend >> 16) & 0x3) << 14) | ((addend & 0x7fff) >> 1);
value += symbol;
value = (addend & (~(howto->dst_mask))) | ((value & 0x3fff) << 1)
| (((value >> 14) & 0x3) << 16);
score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_DUMMY_HI16:
return bfd_reloc_ok;
case <API key>:
case R_SCORE_GNU_VTENTRY:
/* We don't do anything with these at present. */
return bfd_reloc_continue;
default:
return <API key>;
}
}
/* Score backend functions. */
static void
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc)
{
unsigned int r_type;
r_type = ELF32_R_TYPE (elf_reloc->r_info);
if (r_type >= ARRAY_SIZE (<API key>))
bfd_reloc->howto = NULL;
else
bfd_reloc->howto = &<API key>[r_type];
}
/* Relocate an score ELF section. */
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info,
bfd *input_bfd,
asection *input_section,
bfd_byte *contents,
Elf_Internal_Rela *relocs,
Elf_Internal_Sym *local_syms,
asection **local_sections)
{
Elf_Internal_Shdr *symtab_hdr;
Elf_Internal_Rela *rel;
Elf_Internal_Rela *relend;
const char *name;
unsigned long offset;
unsigned long hi16_addend, hi16_offset, hi16_value, uvalue;
size_t extsymoff;
bfd_boolean gp_disp_p = FALSE;
/* Sort dynsym. */
if (elf_hash_table (info)-><API key>)
{
bfd_size_type dynsecsymcount = 0;
if (bfd_link_pic (info))
{
asection * p;
const struct elf_backend_data *bed = <API key> (output_bfd);
for (p = output_bfd->sections; p ; p = p->next)
if ((p->flags & SEC_EXCLUDE) == 0
&& (p->flags & SEC_ALLOC) != 0
&& !(*bed-><API key>) (output_bfd, info, p))
++ dynsecsymcount;
}
if (!<API key> (info, dynsecsymcount + 1))
return FALSE;
}
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
rel = relocs;
relend = relocs + input_section->reloc_count;
for (; rel < relend; rel++)
{
int r_type;
reloc_howto_type *howto;
unsigned long r_symndx;
Elf_Internal_Sym *sym;
asection *sec;
struct <API key> *h;
bfd_vma relocation = 0;
<API key> r;
arelent bfd_reloc;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
<API key> (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
howto = bfd_reloc.howto;
h = NULL;
sym = NULL;
sec = NULL;
if (r_symndx < extsymoff)
{
sym = local_syms + r_symndx;
sec = local_sections[r_symndx];
relocation = (sec->output_section->vma
+ sec->output_offset
+ sym->st_value);
name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec);
if (!<API key> (info)
&& (sec->flags & SEC_MERGE)
&& ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
asection *msec;
bfd_vma addend, value;
switch (r_type)
{
case R_SCORE_HI16:
break;
case R_SCORE_LO16:
hi16_addend = score_bfd_get_32 (input_bfd, contents + rel->r_offset - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
offset = ((((value >> 16) & 0x3) << 15) | (value & 0x7fff)) >> 1;
addend = (hi16_offset << 16) | (offset & 0xffff);
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend);
addend -= relocation;
addend += msec->output_section->vma + msec->output_offset;
uvalue = addend;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
score_bfd_put_32 (input_bfd, hi16_value, contents + rel->r_offset - 4);
offset = (uvalue & 0xffff) << 1;
value = (value & (~(howto->dst_mask)))
| (offset & 0x7fff) | ((offset << 1) & 0x30000);
score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
case R_SCORE_IMM32:
{
value = score_bfd_get_48 (input_bfd, contents + rel->r_offset);
addend = ((value >> 5) & 0x3ff)
| (((value >> 16) & 0x7fff) << 10)
| (((value >> 32) & 0x7f) << 25);
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend);
addend -= relocation;
addend += msec->output_section->vma + msec->output_offset;
addend &= 0xffffffff;
value = (value & ~howto->src_mask)
| ((addend & 0x3ff) << 5)
| (((addend >> 10) & 0x7fff) << 16)
| (((addend >> 25) & 0x7f) << 32);
score_bfd_put_48 (input_bfd, value, contents + rel->r_offset);
break;
}
case R_SCORE_IMM30:
{
int not_word_align_p = 0;
value = score_bfd_get_48 (input_bfd, contents + rel->r_offset);
addend = ((value >> 7) & 0xff)
| (((value >> 16) & 0x7fff) << 8)
| (((value >> 32) & 0x7f) << 23);
addend <<= howto->rightshift;
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend);
addend -= relocation;
addend += msec->output_section->vma + msec->output_offset;
addend &= 0xffffffff;
/* Check lw48/sw48 rd, value/label word align. */
if ((addend & 0x3) != 0)
not_word_align_p = 1;
addend >>= howto->rightshift;
value = (value & ~howto->src_mask)
| (((addend & 0xff) >> 0) << 7)
| (((addend & 0x7fff00) >> 8) << 16)
| (((addend & 0x3f800000) >> 23) << 32);
score_bfd_put_48 (input_bfd, value, contents + rel->r_offset);
if (not_word_align_p)
return bfd_reloc_other;
else
break;
}
case R_SCORE_GOT_LO16:
value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
addend = (((value >> 16) & 0x3) << 14) | ((value & 0x7fff) >> 1);
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend) - relocation;
addend += msec->output_section->vma + msec->output_offset;
value = (value & (~(howto->dst_mask))) | ((addend & 0x3fff) << 1)
| (((addend >> 14) & 0x3) << 16);
score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
case R_SCORE_ABS32:
case R_SCORE_REL32:
value = bfd_get_32 (input_bfd, contents + rel->r_offset);
/* Get the (signed) value from the instruction. */
addend = value & howto->src_mask;
if (addend & ((howto->src_mask + 1) >> 1))
{
bfd_signed_vma mask;
mask = -1;
mask &= ~howto->src_mask;
addend |= mask;
}
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend) - relocation;
addend += msec->output_section->vma + msec->output_offset;
value = (value & ~howto->dst_mask) | (addend & howto->dst_mask);
bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
default:
value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
/* Get the (signed) value from the instruction. */
addend = value & howto->src_mask;
if (addend & ((howto->src_mask + 1) >> 1))
{
bfd_signed_vma mask;
mask = -1;
mask &= ~howto->src_mask;
addend |= mask;
}
msec = sec;
addend = <API key> (output_bfd, sym, &msec, addend) - relocation;
addend += msec->output_section->vma + msec->output_offset;
value = (value & ~howto->dst_mask) | (addend & howto->dst_mask);
score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
}
}
}
else
{
/* For global symbols we look up the symbol in the hash-table. */
h = ((struct <API key> *)
elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
if (info->wrap_hash != NULL
&& (input_section->flags & SEC_DEBUGGING) != 0)
h = ((struct <API key> *)
unwrap_hash_lookup (info, input_bfd, &h->root.root));
/* Find the real hash-table entry for this symbol. */
while (h->root.root.type == <API key>
|| h->root.root.type == <API key>)
h = (struct <API key> *) h->root.root.u.i.link;
/* Record the name of this symbol, for our caller. */
name = h->root.root.root.string;
/* See if this is the special GP_DISP_LABEL symbol. Note that such a
symbol must always be a global symbol. */
if (strcmp (name, GP_DISP_LABEL) == 0)
{
/* Relocations against GP_DISP_LABEL are permitted only with
R_SCORE_HI16 and R_SCORE_LO16 relocations. */
if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
return <API key>;
gp_disp_p = TRUE;
}
/* If this symbol is defined, calculate its address. Note that
GP_DISP_LABEL is a magic symbol, always implicitly defined by the
linker, so it's inappropriate to check to see whether or not
its defined. */
else if ((h->root.root.type == <API key>
|| h->root.root.type == <API key>)
&& h->root.root.u.def.section)
{
sec = h->root.root.u.def.section;
if (sec->output_section)
relocation = (h->root.root.u.def.value
+ sec->output_section->vma
+ sec->output_offset);
else
{
relocation = h->root.root.u.def.value;
}
}
else if (h->root.root.type == <API key>)
/* We allow relocations against undefined weak symbols, giving
it the value zero, so that you can undefined weak functions
and check to see if they exist by looking at their addresses. */
relocation = 0;
else if (info-><API key> == RM_IGNORE
&& ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
relocation = 0;
else if (strcmp (name, "_DYNAMIC_LINK") == 0)
{
/* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
in <API key>. Otherwise, we should define
the symbol with a value of 0. */
BFD_ASSERT (! bfd_link_pic (info));
BFD_ASSERT (<API key> (output_bfd, ".dynamic") == NULL);
relocation = 0;
}
else if (!<API key> (info))
{
(*info->callbacks->undefined_symbol)
(info, h->root.root.root.string, input_bfd,
input_section, rel->r_offset,
(info-><API key> == RM_GENERATE_ERROR)
|| ELF_ST_VISIBILITY (h->root.other));
relocation = 0;
}
}
if (sec != NULL && discarded_section (sec))
<API key> (info, input_bfd, input_section,
rel, 1, relend, howto, 0, contents);
if (<API key> (info))
{
/* This is a relocatable link. We don't have to change
anything, unless the reloc is against a section symbol,
in which case we have to adjust according to where the
section symbol winds up in the output section. */
if (r_symndx < symtab_hdr->sh_info)
{
sym = local_syms + r_symndx;
if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
sec = local_sections[r_symndx];
<API key> (input_bfd, contents + rel->r_offset,
howto, (bfd_signed_vma) (sec->output_offset + sym->st_value));
}
}
continue;
}
/* This is a final link. */
r = <API key> (howto, input_bfd, output_bfd,
input_section, contents, rel, relocs,
relocation, info, name,
(h ? ELF_ST_TYPE ((unsigned int)h->root.root.type) :
ELF_ST_TYPE ((unsigned int)sym->st_info)), h, local_sections,
gp_disp_p);
if (r != bfd_reloc_ok)
{
const char *msg = (const char *)0;
switch (r)
{
case bfd_reloc_overflow:
/* If the overflowing reloc was to an undefined symbol,
we have already printed one error message and there
is no point complaining again. */
if (!h || h->root.root.type != <API key>)
(*info->callbacks->reloc_overflow)
(info, NULL, name, howto->name, (bfd_vma) 0,
input_bfd, input_section, rel->r_offset);
break;
case bfd_reloc_undefined:
(*info->callbacks->undefined_symbol)
(info, name, input_bfd, input_section, rel->r_offset, TRUE);
break;
case <API key>:
msg = _("internal error: out of range error");
goto common_error;
case <API key>:
msg = _("internal error: unsupported relocation error");
goto common_error;
case bfd_reloc_dangerous:
msg = _("internal error: dangerous error");
goto common_error;
/* Use bfd_reloc_other to check lw48, sw48 word align. */
case bfd_reloc_other:
msg = _("address not word align");
goto common_error;
default:
msg = _("internal error: unknown error");
/* Fall through. */
common_error:
(*info->callbacks->warning) (info, msg, name, input_bfd,
input_section, rel->r_offset);
break;
}
}
}
return TRUE;
}
/* Look through the relocs for a section during the first phase, and
allocate space in the global offset table. */
static bfd_boolean
<API key> (bfd *abfd,
struct bfd_link_info *info,
asection *sec,
const Elf_Internal_Rela *relocs)
{
bfd *dynobj;
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
struct score_got_info *g;
size_t extsymoff;
const Elf_Internal_Rela *rel;
const Elf_Internal_Rela *rel_end;
asection *sgot;
asection *sreloc;
const struct elf_backend_data *bed;
if (<API key> (info))
return TRUE;
dynobj = elf_hash_table (info)->dynobj;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
if (dynobj == NULL)
{
sgot = NULL;
g = NULL;
}
else
{
sgot = <API key> (dynobj, FALSE);
if (sgot == NULL)
g = NULL;
else
{
BFD_ASSERT (<API key> (sgot) != NULL);
g = <API key> (sgot)->u.got_info;
BFD_ASSERT (g != NULL);
}
}
sreloc = NULL;
bed = <API key> (abfd);
rel_end = relocs + sec->reloc_count * bed->s-><API key>;
for (rel = relocs; rel < rel_end; ++rel)
{
unsigned long r_symndx;
unsigned int r_type;
struct elf_link_hash_entry *h;
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
if (r_symndx < extsymoff)
{
h = NULL;
}
else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
{
_bfd_error_handler
/* xgettext:c-format */
(_("%B: Malformed reloc detected for section %A"), abfd, sec);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
else
{
h = sym_hashes[r_symndx - extsymoff];
/* This may be an indirect symbol created because of a version. */
if (h != NULL)
{
while (h->root.type == <API key>)
h = (struct elf_link_hash_entry *)h->root.u.i.link;
/* PR15323, ref flags aren't set for references in the
same object. */
h->root.non_ir_ref = 1;
}
}
/* Some relocs require a global offset table. */
if (dynobj == NULL || sgot == NULL)
{
switch (r_type)
{
case R_SCORE_GOT15:
case R_SCORE_CALL15:
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
if (!<API key> (dynobj, info, FALSE))
return FALSE;
g = score_elf_got_info (dynobj, &sgot);
break;
case R_SCORE_ABS32:
case R_SCORE_REL32:
if (dynobj == NULL
&& (bfd_link_pic (info) || h != NULL)
&& (sec->flags & SEC_ALLOC) != 0)
elf_hash_table (info)->dynobj = dynobj = abfd;
break;
default:
break;
}
}
if (!h && (r_type == R_SCORE_GOT_LO16))
{
if (! <API key> (abfd, r_symndx, rel->r_addend, g))
return FALSE;
}
switch (r_type)
{
case R_SCORE_CALL15:
if (h == NULL)
{
_bfd_error_handler
/* xgettext:c-format */
(_("%B: CALL15 reloc at 0x%lx not against global symbol"),
abfd, (unsigned long) rel->r_offset);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
else
{
/* This symbol requires a global offset table entry. */
if (! <API key> (h, abfd, info, g))
return FALSE;
/* We need a stub, not a plt entry for the undefined function. But we record
it as if it needs plt. See <API key>. */
h->needs_plt = 1;
h->type = STT_FUNC;
}
break;
case R_SCORE_GOT15:
if (h && ! <API key> (h, abfd, info, g))
return FALSE;
break;
case R_SCORE_ABS32:
case R_SCORE_REL32:
if ((bfd_link_pic (info) || h != NULL)
&& (sec->flags & SEC_ALLOC) != 0)
{
if (sreloc == NULL)
{
sreloc = <API key> (dynobj, TRUE);
if (sreloc == NULL)
return FALSE;
}
#define <API key> (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
if (bfd_link_pic (info))
{
/* When creating a shared object, we must copy these reloc types into
the output file as R_SCORE_REL32 relocs. We make room for this reloc
in the .rel.dyn reloc section. */
<API key> (dynobj, 1);
if ((sec->flags & <API key>)
== <API key>)
/* We tell the dynamic linker that there are
relocations against the text segment. */
info->flags |= DF_TEXTREL;
}
else
{
struct <API key> *hscore;
/* We only need to copy this reloc if the symbol is
defined in a dynamic object. */
hscore = (struct <API key> *)h;
++hscore-><API key>;
if ((sec->flags & <API key>)
== <API key>)
/* We need it to tell the dynamic linker if there
are relocations against the text segment. */
hscore->readonly_reloc = TRUE;
}
/* Even though we don't directly need a GOT entry for this symbol,
a symbol must have a dynamic symbol table index greater that
DT_SCORE_GOTSYM if there are dynamic relocations against it. */
if (h != NULL)
{
if (dynobj == NULL)
elf_hash_table (info)->dynobj = dynobj = abfd;
if (! <API key> (dynobj, info, TRUE))
return FALSE;
g = score_elf_got_info (dynobj, &sgot);
if (! <API key> (h, abfd, info, g))
return FALSE;
}
}
break;
/* This relocation describes the C++ object vtable hierarchy.
Reconstruct it for later use during GC. */
case <API key>:
if (!<API key> (abfd, sec, h, rel->r_offset))
return FALSE;
break;
/* This relocation describes which C++ vtable entries are actually
used. Record for later use during GC. */
case R_SCORE_GNU_VTENTRY:
if (!<API key> (abfd, sec, h, rel->r_offset))
return FALSE;
break;
default:
break;
}
/* We must not create a stub for a symbol that has relocations
related to taking the function's address. */
switch (r_type)
{
default:
if (h != NULL)
{
struct <API key> *sh;
sh = (struct <API key> *) h;
sh->no_fn_stub = TRUE;
}
break;
case R_SCORE_CALL15:
break;
}
}
return TRUE;
}
static bfd_boolean
<API key> (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
const char **namep ATTRIBUTE_UNUSED,
flagword *flagsp ATTRIBUTE_UNUSED,
asection **secp,
bfd_vma *valp)
{
switch (sym->st_shndx)
{
case SHN_COMMON:
if (sym->st_size > elf_gp_size (abfd))
break;
/* Fall through. */
case SHN_SCORE_SCOMMON:
*secp = <API key> (abfd, ".scommon");
(*secp)->flags |= SEC_IS_COMMON;
*valp = sym->st_size;
break;
}
return TRUE;
}
static void
<API key> (bfd *abfd, asymbol *asym)
{
elf_symbol_type *elfsym;
elfsym = (elf_symbol_type *) asym;
switch (elfsym->internal_elf_sym.st_shndx)
{
case SHN_COMMON:
if (asym->value > elf_gp_size (abfd))
break;
/* Fall through. */
case SHN_SCORE_SCOMMON:
if (<API key>.name == NULL)
{
/* Initialize the small common section. */
<API key>.name = ".scommon";
<API key>.flags = SEC_IS_COMMON;
<API key>.output_section = &<API key>;
<API key>.symbol = &<API key>;
<API key>.symbol_ptr_ptr = &<API key>;
<API key>.name = ".scommon";
<API key>.flags = BSF_SECTION_SYM;
<API key>.section = &<API key>;
<API key> = &<API key>;
}
asym->section = &<API key>;
asym->value = elfsym->internal_elf_sym.st_size;
break;
}
}
static int
<API key> (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
asection *input_sec,
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
{
/* If we see a common symbol, which implies a relocatable link, then
if a symbol was small common in an input file, mark it as small
common in the output file. */
if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
sym->st_shndx = SHN_SCORE_SCOMMON;
return 1;
}
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
int *retval)
{
if (strcmp (<API key> (abfd, sec), ".scommon") == 0)
{
*retval = SHN_SCORE_SCOMMON;
return TRUE;
}
return FALSE;
}
/* Adjust a symbol defined by a dynamic object and referenced by a
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
change the definition to something the rest of the link can understand. */
static bfd_boolean
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
bfd *dynobj;
struct <API key> *hscore;
asection *s;
dynobj = elf_hash_table (info)->dynobj;
/* Make sure we know what is going on here. */
BFD_ASSERT (dynobj != NULL
&& (h->needs_plt
|| h->u.weakdef != NULL
|| (h->def_dynamic && h->ref_regular && !h->def_regular)));
/* If this symbol is defined in a dynamic object, we need to copy
any R_SCORE_ABS32 or R_SCORE_REL32 relocs against it into the output
file. */
hscore = (struct <API key> *)h;
if (!<API key> (info)
&& hscore-><API key> != 0
&& (h->root.type == <API key> || !h->def_regular))
{
<API key> (dynobj, hscore-><API key>);
if (hscore->readonly_reloc)
/* We tell the dynamic linker that there are relocations
against the text segment. */
info->flags |= DF_TEXTREL;
}
/* For a function, create a stub, if allowed. */
if (!hscore->no_fn_stub && h->needs_plt)
{
if (!elf_hash_table (info)-><API key>)
return TRUE;
/* If this symbol is not defined in a regular file, then set
the symbol to the stub location. This is required to make
function pointers compare as equal between the normal
executable and the shared library. */
if (!h->def_regular)
{
/* We need .stub section. */
s = <API key> (dynobj, <API key>);
BFD_ASSERT (s != NULL);
h->root.u.def.section = s;
h->root.u.def.value = s->size;
/* XXX Write this stub address somewhere. */
h->plt.offset = s->size;
/* Make room for this stub code. */
s->size += <API key>;
/* The last half word of the stub will be filled with the index
of this symbol in .dynsym section. */
return TRUE;
}
}
else if ((h->type == STT_FUNC) && !h->needs_plt)
{
/* This will set the entry for this symbol in the GOT to 0, and
the dynamic linker will take care of this. */
h->root.u.def.value = 0;
return TRUE;
}
/* If this is a weak symbol, and there is a real definition, the
processor independent code will have arranged for us to see the
real definition first, and we can just use the same value. */
if (h->u.weakdef != NULL)
{
BFD_ASSERT (h->u.weakdef->root.type == <API key>
|| h->u.weakdef->root.type == <API key>);
h->root.u.def.section = h->u.weakdef->root.u.def.section;
h->root.u.def.value = h->u.weakdef->root.u.def.value;
return TRUE;
}
/* This is a reference to a symbol defined by a dynamic object which
is not a function. */
return TRUE;
}
/* This function is called after all the input files have been read,
and the input sections have been assigned to output sections. */
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info)
{
bfd *dynobj;
asection *s;
struct score_got_info *g;
int i;
bfd_size_type loadable_size = 0;
bfd_size_type local_gotno;
bfd *sub;
dynobj = elf_hash_table (info)->dynobj;
if (dynobj == NULL)
/* Relocatable links don't have it. */
return TRUE;
g = score_elf_got_info (dynobj, &s);
if (s == NULL)
return TRUE;
/* Calculate the total loadable size of the output. That will give us the
maximum number of GOT_PAGE entries required. */
for (sub = info->input_bfds; sub; sub = sub->link.next)
{
asection *subsection;
for (subsection = sub->sections;
subsection;
subsection = subsection->next)
{
if ((subsection->flags & SEC_ALLOC) == 0)
continue;
loadable_size += ((subsection->size + 0xf)
&~ (bfd_size_type) 0xf);
}
}
/* There has to be a global GOT entry for every symbol with
a dynamic symbol table index of DT_SCORE_GOTSYM or
higher. Therefore, it make sense to put those symbols
that need GOT entries at the end of the symbol table. We
do that here. */
if (! <API key> (info, 1))
return FALSE;
if (g->global_gotsym != NULL)
i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
else
/* If there are no global symbols, or none requiring
relocations, then GLOBAL_GOTSYM will be NULL. */
i = 0;
/* In the worst case, we'll get one stub per dynamic symbol. */
loadable_size += <API key> * i;
/* Assume there are two loadable segments consisting of
contiguous sections. Is 5 enough? */
local_gotno = (loadable_size >> 16) + 5;
g->local_gotno += local_gotno;
s->size += g->local_gotno * SCORE_ELF_GOT_SIZE (output_bfd);
g->global_gotno = i;
s->size += i * SCORE_ELF_GOT_SIZE (output_bfd);
<API key> (g);
if (s->size > <API key> (output_bfd))
{
/* Fixme. Error message or Warning message should be issued here. */
}
return TRUE;
}
/* Set the sizes of the dynamic sections. */
static bfd_boolean
<API key> (bfd *output_bfd, struct bfd_link_info *info)
{
bfd *dynobj;
asection *s;
bfd_boolean reltext;
dynobj = elf_hash_table (info)->dynobj;
BFD_ASSERT (dynobj != NULL);
if (elf_hash_table (info)-><API key>)
{
/* Set the contents of the .interp section to the interpreter. */
if (!bfd_link_pic (info) && !info->nointerp)
{
s = <API key> (dynobj, ".interp");
BFD_ASSERT (s != NULL);
s->size = strlen (<API key>) + 1;
s->contents = (bfd_byte *) <API key>;
}
}
/* The check_relocs and <API key> entry points have
determined the sizes of the various dynamic sections. Allocate
memory for them. */
reltext = FALSE;
for (s = dynobj->sections; s != NULL; s = s->next)
{
const char *name;
if ((s->flags & SEC_LINKER_CREATED) == 0)
continue;
/* It's OK to base decisions on the section name, because none
of the dynobj section names depend upon the input files. */
name = <API key> (dynobj, s);
if (CONST_STRNEQ (name, ".rel"))
{
if (s->size == 0)
{
/* We only strip the section if the output section name
has the same name. Otherwise, there might be several
input sections for this output section. FIXME: This
code is probably not needed these days anyhow, since
the linker now does not create empty output sections. */
if (s->output_section != NULL
&& strcmp (name,
<API key> (s->output_section->owner,
s->output_section)) == 0)
s->flags |= SEC_EXCLUDE;
}
else
{
const char *outname;
asection *target;
/* If this relocation section applies to a read only
section, then we probably need a DT_TEXTREL entry.
If the relocation section is .rel.dyn, we always
assert a DT_TEXTREL entry rather than testing whether
there exists a relocation to a read only section or
not. */
outname = <API key> (output_bfd, s->output_section);
target = <API key> (output_bfd, outname + 4);
if ((target != NULL
&& (target->flags & SEC_READONLY) != 0
&& (target->flags & SEC_ALLOC) != 0) || strcmp (outname, ".rel.dyn") == 0)
reltext = TRUE;
/* We use the reloc_count field as a counter if we need
to copy relocs into the output file. */
if (strcmp (name, ".rel.dyn") != 0)
s->reloc_count = 0;
}
}
else if (CONST_STRNEQ (name, ".got"))
{
/* <API key>() has already done
most of the work, but some symbols may have been mapped
to versions that we must now resolve in the got_entries
hash tables. */
}
else if (strcmp (name, <API key>) == 0)
{
/* IRIX rld assumes that the function stub isn't at the end
of .text section. So put a dummy. XXX */
s->size += <API key>;
}
else if (! CONST_STRNEQ (name, ".init"))
{
/* It's not one of our sections, so don't allocate space. */
continue;
}
/* Allocate memory for the section contents. */
s->contents = bfd_zalloc (dynobj, s->size);
if (s->contents == NULL && s->size != 0)
{
bfd_set_error (bfd_error_no_memory);
return FALSE;
}
}
if (elf_hash_table (info)-><API key>)
{
/* Add some entries to the .dynamic section. We fill in the
values later, in <API key>, but we
must add the entries now so that we get the correct size for
the .dynamic section. The DT_DEBUG entry is filled in by the
dynamic linker and used by the debugger. */
if (!<API key> (info, DT_DEBUG, 0))
return FALSE;
if (reltext)
info->flags |= DF_TEXTREL;
if ((info->flags & DF_TEXTREL) != 0)
{
if (!<API key> (info, DT_TEXTREL, 0))
return FALSE;
}
if (! <API key> (info, DT_PLTGOT, 0))
return FALSE;
if (<API key> (dynobj, FALSE))
{
if (!<API key> (info, DT_REL, 0))
return FALSE;
if (!<API key> (info, DT_RELSZ, 0))
return FALSE;
if (!<API key> (info, DT_RELENT, 0))
return FALSE;
}
if (!<API key> (info, <API key>, 0))
return FALSE;
if (!<API key> (info, <API key>, 0))
return FALSE;
if (!<API key> (info, DT_SCORE_SYMTABNO, 0))
return FALSE;
if (!<API key> (info, DT_SCORE_UNREFEXTNO, 0))
return FALSE;
if (!<API key> (info, DT_SCORE_GOTSYM, 0))
return FALSE;
if (!<API key> (info, DT_SCORE_HIPAGENO, 0))
return FALSE;
}
return TRUE;
}
static bfd_boolean
<API key> (bfd *abfd, struct bfd_link_info *info)
{
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
flagword flags;
asection *s;
flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
| SEC_LINKER_CREATED | SEC_READONLY);
/* ABI requests the .dynamic section to be read only. */
s = <API key> (abfd, ".dynamic");
if (s != NULL)
{
if (!<API key> (abfd, s, flags))
return FALSE;
}
/* We need to create .got section. */
if (!<API key> (abfd, info, FALSE))
return FALSE;
if (!<API key> (elf_hash_table (info)->dynobj, TRUE))
return FALSE;
/* Create .stub section. */
if (<API key> (abfd, <API key>) == NULL)
{
s = <API key> (abfd, <API key>,
flags | SEC_CODE);
if (s == NULL
|| !<API key> (abfd, s, 2))
return FALSE;
}
if (!bfd_link_pic (info))
{
const char *name;
name = "_DYNAMIC_LINK";
bh = NULL;
if (!(<API key>
(info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr,
(bfd_vma) 0, NULL, FALSE, <API key> (abfd)->collect, &bh)))
return FALSE;
h = (struct elf_link_hash_entry *)bh;
h->non_elf = 0;
h->def_regular = 1;
h->type = STT_SECTION;
if (!<API key> (info, h))
return FALSE;
}
return TRUE;
}
/* Finish up dynamic symbol handling. We set the contents of various
dynamic sections here. */
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
bfd *dynobj;
asection *sgot;
struct score_got_info *g;
const char *name;
dynobj = elf_hash_table (info)->dynobj;
if (h->plt.offset != MINUS_ONE)
{
asection *s;
bfd_byte stub[<API key>];
/* This symbol has a stub. Set it up. */
BFD_ASSERT (h->dynindx != -1);
s = <API key> (dynobj, <API key>);
BFD_ASSERT (s != NULL);
/* FIXME: Can h->dynindex be more than 64K? */
if (h->dynindx & 0xffff0000)
return FALSE;
/* Fill the stub. */
score_bfd_put_32 (output_bfd, STUB_LW, stub);
score_bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
score_bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8);
score_bfd_put_32 (output_bfd, STUB_BRL, stub + 12);
BFD_ASSERT (h->plt.offset <= s->size);
memcpy (s->contents + h->plt.offset, stub, <API key>);
/* Mark the symbol as undefined. plt.offset != -1 occurs
only for the referenced symbol. */
sym->st_shndx = SHN_UNDEF;
/* The run-time linker uses the st_value field of the symbol
to reset the global offset table entry for this external
to its stub address when unlinking a shared object. */
sym->st_value = (s->output_section->vma + s->output_offset + h->plt.offset);
}
BFD_ASSERT (h->dynindx != -1 || h->forced_local);
sgot = <API key> (dynobj, FALSE);
BFD_ASSERT (sgot != NULL);
BFD_ASSERT (<API key> (sgot) != NULL);
g = <API key> (sgot)->u.got_info;
BFD_ASSERT (g != NULL);
/* Run through the global symbol table, creating GOT entries for all
the symbols that need them. */
if (g->global_gotsym != NULL && h->dynindx >= g->global_gotsym->dynindx)
{
bfd_vma offset;
bfd_vma value;
value = sym->st_value;
offset = <API key> (dynobj, h);
score_bfd_put_32 (output_bfd, value, sgot->contents + offset);
}
/* Mark _DYNAMIC and <API key> as absolute. */
name = h->root.root.string;
if (h == elf_hash_table (info)->hdynamic
|| h == elf_hash_table (info)->hgot)
sym->st_shndx = SHN_ABS;
else if (strcmp (name, "_DYNAMIC_LINK") == 0)
{
sym->st_shndx = SHN_ABS;
sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
sym->st_value = 1;
}
else if (strcmp (name, GP_DISP_LABEL) == 0)
{
sym->st_shndx = SHN_ABS;
sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
sym->st_value = elf_gp (output_bfd);
}
return TRUE;
}
/* Finish up the dynamic sections. */
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info)
{
bfd *dynobj;
asection *sdyn;
asection *sgot;
asection *s;
struct score_got_info *g;
dynobj = elf_hash_table (info)->dynobj;
sdyn = <API key> (dynobj, ".dynamic");
sgot = <API key> (dynobj, FALSE);
if (sgot == NULL)
g = NULL;
else
{
BFD_ASSERT (<API key> (sgot) != NULL);
g = <API key> (sgot)->u.got_info;
BFD_ASSERT (g != NULL);
}
if (elf_hash_table (info)-><API key>)
{
bfd_byte *b;
BFD_ASSERT (sdyn != NULL);
BFD_ASSERT (g != NULL);
for (b = sdyn->contents;
b < sdyn->contents + sdyn->size;
b += SCORE_ELF_DYN_SIZE (dynobj))
{
Elf_Internal_Dyn dyn;
const char *name;
size_t elemsize;
bfd_boolean swap_out_p;
/* Read in the current dynamic entry. */
(*<API key> (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
/* Assume that we're going to modify it and write it out. */
swap_out_p = TRUE;
switch (dyn.d_tag)
{
case DT_RELENT:
dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
break;
case DT_STRSZ:
/* Rewrite DT_STRSZ. */
dyn.d_un.d_val
= <API key> (elf_hash_table (info)->dynstr);
break;
case DT_PLTGOT:
s = elf_hash_table (info)->sgot;
dyn.d_un.d_ptr = s->output_section->vma + s->output_offset;
break;
case <API key>:
s = output_bfd->sections;
BFD_ASSERT (s != NULL);
dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
break;
case <API key>:
dyn.d_un.d_val = g->local_gotno;
break;
case DT_SCORE_UNREFEXTNO:
/* The index into the dynamic symbol table which is the
entry of the first external symbol that is not
referenced within the same object. */
dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
break;
case DT_SCORE_GOTSYM:
if (g->global_gotsym)
{
dyn.d_un.d_val = g->global_gotsym->dynindx;
break;
}
/* In case if we don't have global got symbols we default
to setting DT_SCORE_GOTSYM to the same value as
DT_SCORE_SYMTABNO. */
/* Fall through. */
case DT_SCORE_SYMTABNO:
name = ".dynsym";
elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
s = <API key> (dynobj, name);
dyn.d_un.d_val = s->size / elemsize;
break;
case DT_SCORE_HIPAGENO:
dyn.d_un.d_val = g->local_gotno - <API key>;
break;
default:
swap_out_p = FALSE;
break;
}
if (swap_out_p)
(*<API key> (dynobj)->s->swap_dyn_out) (dynobj, &dyn, b);
}
}
/* The first entry of the global offset table will be filled at
runtime. The second entry will be used by some runtime loaders.
This isn't the case of IRIX rld. */
if (sgot != NULL && sgot->size > 0)
{
score_bfd_put_32 (output_bfd, 0, sgot->contents);
score_bfd_put_32 (output_bfd, 0x80000000, sgot->contents + SCORE_ELF_GOT_SIZE (output_bfd));
}
if (sgot != NULL)
elf_section_data (sgot->output_section)->this_hdr.sh_entsize
= SCORE_ELF_GOT_SIZE (output_bfd);
/* We need to sort the entries of the dynamic relocation section. */
s = <API key> (dynobj, FALSE);
if (s != NULL && s->size > (bfd_vma)2 * SCORE_ELF_REL_SIZE (output_bfd))
{
reldyn_sorting_bfd = output_bfd;
qsort ((Elf32_External_Rel *) s->contents + 1, s->reloc_count - 1,
sizeof (Elf32_External_Rel), <API key>);
}
return TRUE;
}
/* This function set up the ELF section header for a BFD section in preparation for writing
it out. This is where the flags and type fields are set for unusual sections. */
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
Elf_Internal_Shdr *hdr,
asection *sec)
{
const char *name;
name = <API key> (abfd, sec);
if (strcmp (name, ".got") == 0
|| strcmp (name, ".srdata") == 0
|| strcmp (name, ".sdata") == 0
|| strcmp (name, ".sbss") == 0)
hdr->sh_flags |= SHF_SCORE_GPREL;
return TRUE;
}
/* This function do additional processing on the ELF section header before writing
it out. This is used to set the flags and type fields for some sections. */
/* <API key>() check section flag and if it is allocatable,
warning message will be issued. <API key> is called before
<API key>(); <API key> after it. so, we
modify section flag there, but not <API key>. */
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
{
if (hdr->bfd_section != NULL)
{
const char *name = <API key> (abfd, hdr->bfd_section);
if (strcmp (name, ".sdata") == 0)
{
hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
hdr->sh_type = SHT_PROGBITS;
}
else if (strcmp (name, ".sbss") == 0)
{
hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
hdr->sh_type = SHT_NOBITS;
}
else if (strcmp (name, ".srdata") == 0)
{
hdr->sh_flags |= SHF_ALLOC | SHF_SCORE_GPREL;
hdr->sh_type = SHT_PROGBITS;
}
}
return TRUE;
}
static bfd_boolean
<API key> (bfd *output_bfd, asection *sec, bfd_byte *contents)
{
bfd_byte *to, *from, *end;
int i;
if (strcmp (sec->name, ".pdr") != 0)
return FALSE;
if (<API key> (sec)->u.tdata == NULL)
return FALSE;
to = contents;
end = contents + sec->size;
for (from = contents, i = 0; from < end; from += PDR_SIZE, i++)
{
if ((<API key> (sec)->u.tdata)[i] == 1)
continue;
if (to != from)
memcpy (to, from, PDR_SIZE);
to += PDR_SIZE;
}
<API key> (output_bfd, sec->output_section, contents,
(file_ptr) sec->output_offset, sec->size);
return TRUE;
}
/* Copy data from a SCORE ELF indirect symbol to its direct symbol, hiding the old
indirect symbol. Process additional relocation information. */
static void
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *dir,
struct elf_link_hash_entry *ind)
{
struct <API key> *dirscore, *indscore;
<API key> (info, dir, ind);
if (ind->root.type != <API key>)
return;
dirscore = (struct <API key> *) dir;
indscore = (struct <API key> *) ind;
dirscore-><API key> += indscore-><API key>;
if (indscore->readonly_reloc)
dirscore->readonly_reloc = TRUE;
if (indscore->no_fn_stub)
dirscore->no_fn_stub = TRUE;
}
/* Remove information about discarded functions from other sections which mention them. */
static bfd_boolean
<API key> (bfd *abfd, struct elf_reloc_cookie *cookie,
struct bfd_link_info *info)
{
asection *o;
bfd_boolean ret = FALSE;
unsigned char *tdata;
size_t i, skip;
o = <API key> (abfd, ".pdr");
if ((!o) || (o->size == 0) || (o->size % PDR_SIZE != 0)
|| (o->output_section != NULL && bfd_is_abs_section (o->output_section)))
return FALSE;
tdata = bfd_zmalloc (o->size / PDR_SIZE);
if (!tdata)
return FALSE;
cookie->rels = <API key> (abfd, o, NULL, NULL, info->keep_memory);
if (!cookie->rels)
{
free (tdata);
return FALSE;
}
cookie->rel = cookie->rels;
cookie->relend = cookie->rels + o->reloc_count;
for (i = 0, skip = 0; i < o->size; i++)
{
if (<API key> (i * PDR_SIZE, cookie))
{
tdata[i] = 1;
skip++;
}
}
if (skip != 0)
{
<API key> (o)->u.tdata = tdata;
o->size -= skip * PDR_SIZE;
ret = TRUE;
}
else
free (tdata);
if (!info->keep_memory)
free (cookie->rels);
return ret;
}
/* Signal that discard_info() has removed the discarded relocations for this section. */
static bfd_boolean
<API key> (asection *sec)
{
if (strcmp (sec->name, ".pdr") == 0)
return TRUE;
return FALSE;
}
/* Return the section that should be marked against GC for a given
relocation. */
static asection *
<API key> (asection *sec,
struct bfd_link_info *info,
Elf_Internal_Rela *rel,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
if (h != NULL)
switch (ELF32_R_TYPE (rel->r_info))
{
case <API key>:
case R_SCORE_GNU_VTENTRY:
return NULL;
}
return <API key> (sec, info, rel, h, sym);
}
/* Support for core dump NOTE sections. */
static bfd_boolean
<API key> (bfd *abfd, Elf_Internal_Note *note)
{
int offset;
unsigned int raw_size;
switch (note->descsz)
{
default:
return FALSE;
case 148: /* Linux/Score 32-bit. */
/* pr_cursig */
elf_tdata (abfd)->core->signal
= score_bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
elf_tdata (abfd)->core->lwpid
= score_bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
raw_size = 72;
break;
}
/* Make a ".reg/999" section. */
return <API key> (abfd, ".reg", raw_size,
note->descpos + offset);
}
static bfd_boolean
<API key> (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->descsz)
{
default:
return FALSE;
case 124: /* Linux/Score elf_prpsinfo. */
elf_tdata (abfd)->core->program
= <API key> (abfd, note->descdata + 28, 16);
elf_tdata (abfd)->core->command
= <API key> (abfd, note->descdata + 44, 80);
}
/* Note that for some reason, a spurious space is tacked
onto the end of the args in some (at least one anyway)
implementations, so strip it off if it exists. */
{
char *command = elf_tdata (abfd)->core->command;
int n = strlen (command);
if (0 < n && command[n - 1] == ' ')
command[n - 1] = '\0';
}
return TRUE;
}
/* Score BFD functions. */
static reloc_howto_type *
<API key> (bfd *abfd ATTRIBUTE_UNUSED, <API key> code)
{
unsigned int i;
for (i = 0; i < ARRAY_SIZE (<API key>); i++)
if (<API key>[i].bfd_reloc_val == code)
return &<API key>[<API key>[i].elf_reloc_val];
return NULL;
}
static reloc_howto_type *
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
const char *r_name)
{
unsigned int i;
for (i = 0;
i < (sizeof (<API key>)
/ sizeof (<API key>[0]));
i++)
if (<API key>[i].name != NULL
&& strcasecmp (<API key>[i].name, r_name) == 0)
return &<API key>[i];
return NULL;
}
static bfd_boolean
<API key> (bfd *abfd, void * ptr)
{
FILE *file = (FILE *) ptr;
BFD_ASSERT (abfd != NULL && ptr != NULL);
/* Print normal ELF private data. */
<API key> (abfd, ptr);
/* xgettext:c-format */
fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
if (elf_elfheader (abfd)->e_flags & EF_SCORE_PIC)
{
fprintf (file, _(" [pic]"));
}
if (elf_elfheader (abfd)->e_flags & EF_SCORE_FIXDEP)
{
fprintf (file, _(" [fix dep]"));
}
fputc ('\n', file);
return TRUE;
}
static bfd_boolean
<API key> (bfd *ibfd, struct bfd_link_info *info)
{
bfd *obfd = info->output_bfd;
flagword in_flags;
flagword out_flags;
if (!<API key> (ibfd, info))
return FALSE;
in_flags = elf_elfheader (ibfd)->e_flags;
out_flags = elf_elfheader (obfd)->e_flags;
if (bfd_get_flavour (ibfd) != <API key>
|| bfd_get_flavour (obfd) != <API key>)
return TRUE;
in_flags = elf_elfheader (ibfd)->e_flags;
out_flags = elf_elfheader (obfd)->e_flags;
if (! elf_flags_init (obfd))
{
elf_flags_init (obfd) = TRUE;
elf_elfheader (obfd)->e_flags = in_flags;
if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
&& bfd_get_arch_info (obfd)->the_default)
{
return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
}
return TRUE;
}
if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0))
_bfd_error_handler
(_("%B: warning: linking PIC files with non-PIC files"), ibfd);
/* FIXME: Maybe dependency fix compatibility should be checked here. */
return TRUE;
}
static bfd_boolean
<API key> (bfd *abfd, asection *sec)
{
struct <API key> *sdata;
bfd_size_type amt = sizeof (*sdata);
sdata = bfd_zalloc (abfd, amt);
if (sdata == NULL)
return FALSE;
sec->used_by_bfd = sdata;
return <API key> (abfd, sec);
}
/* s3_s7: backend hooks. */
static void
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
arelent *bfd_reloc,
Elf_Internal_Rela *elf_reloc)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, bfd_reloc, elf_reloc);
else
return <API key> (abfd, bfd_reloc, elf_reloc);
}
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info,
bfd *input_bfd,
asection *input_section,
bfd_byte *contents,
Elf_Internal_Rela *relocs,
Elf_Internal_Sym *local_syms,
asection **local_sections)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd,
info, input_bfd, input_section, contents, relocs,
local_syms, local_sections);
else
return <API key> (output_bfd,
info, input_bfd, input_section, contents, relocs,
local_syms, local_sections);
}
static bfd_boolean
<API key> (bfd *abfd,
struct bfd_link_info *info,
asection *sec,
const Elf_Internal_Rela *relocs)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, info, sec, relocs);
else
return <API key> (abfd, info, sec, relocs);
}
static bfd_boolean
<API key> (bfd *abfd,
struct bfd_link_info *info ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
const char **namep ATTRIBUTE_UNUSED,
flagword *flagsp ATTRIBUTE_UNUSED,
asection **secp,
bfd_vma *valp)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, info, sym, namep, flagsp,
secp, valp);
else
return <API key> (abfd, info, sym, namep, flagsp,
secp, valp);
}
static void
<API key> (bfd *abfd, asymbol *asym)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, asym);
else
return <API key> (abfd, asym);
}
static int
<API key> (struct bfd_link_info *info ATTRIBUTE_UNUSED,
const char *name ATTRIBUTE_UNUSED,
Elf_Internal_Sym *sym,
asection *input_sec,
struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
{
/* If link a empty .o, then this filed is NULL. */
if (info->input_bfds == NULL)
{
/* If we see a common symbol, which implies a relocatable link, then
if a symbol was small common in an input file, mark it as small
common in the output file. */
if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
sym->st_shndx = SHN_SCORE_SCOMMON;
return 1;
}
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
return <API key> (info, name, sym, input_sec, h);
else
return <API key> (info, name, sym, input_sec, h);
}
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
asection *sec,
int *retval)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, sec, retval);
else
return <API key> (abfd, sec, retval);
}
static bfd_boolean
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *h)
{
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
return <API key> (info, h);
else
return <API key> (info, h);
}
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd, info);
else
return <API key> (output_bfd, info);
}
static bfd_boolean
<API key> (bfd *output_bfd, struct bfd_link_info *info)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd, info);
else
return <API key> (output_bfd, info);
}
static bfd_boolean
<API key> (bfd *abfd, struct bfd_link_info *info)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, info);
else
return <API key> (abfd, info);
}
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd, info, h, sym);
else
return <API key> (output_bfd, info, h, sym);
}
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *info)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd, info);
else
return <API key> (output_bfd, info);
}
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED,
Elf_Internal_Shdr *hdr,
asection *sec)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, hdr, sec);
else
return <API key> (abfd, hdr, sec);
}
static bfd_boolean
<API key> (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, hdr);
else
return <API key> (abfd, hdr);
}
static bfd_boolean
<API key> (bfd *output_bfd,
struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
asection *sec, bfd_byte *contents)
{
if (bfd_get_mach (output_bfd) == bfd_mach_score3)
return <API key> (output_bfd, sec, contents);
else
return <API key> (output_bfd, sec, contents);
}
static void
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *dir,
struct elf_link_hash_entry *ind)
{
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
return <API key> (info, dir, ind);
else
return <API key> (info, dir, ind);
}
static void
<API key> (struct bfd_link_info *info,
struct elf_link_hash_entry *entry,
bfd_boolean force_local)
{
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
return <API key> (info, entry, force_local);
else
return <API key> (info, entry, force_local);
}
static bfd_boolean
<API key> (bfd *abfd, struct elf_reloc_cookie *cookie,
struct bfd_link_info *info)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, cookie, info);
else
return <API key> (abfd, cookie, info);
}
static bfd_boolean
<API key> (asection *sec)
{
if (bfd_get_mach (sec->owner) == bfd_mach_score3)
return <API key> (sec);
else
return <API key> (sec);
}
static asection *
<API key> (asection *sec,
struct bfd_link_info *info,
Elf_Internal_Rela *rel,
struct elf_link_hash_entry *h,
Elf_Internal_Sym *sym)
{
if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
return <API key> (sec, info, rel, h, sym);
else
return <API key> (sec, info, rel, h, sym);
}
static bfd_boolean
<API key> (bfd *abfd, Elf_Internal_Note *note)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, note);
else
return <API key> (abfd, note);
}
static bfd_boolean
<API key> (bfd *abfd, Elf_Internal_Note *note)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, note);
else
return <API key> (abfd, note);
}
static reloc_howto_type *
<API key> (bfd *abfd ATTRIBUTE_UNUSED, <API key> code)
{
/* s3: NOTE!!!
gas will call <API key>, and don't write elf file.
So just using score3, but we don't know ld will call this or not.
If so, this way can't work. */
if (score3)
return <API key> (abfd, code);
else
return <API key> (abfd, code);
}
/* Create a score elf linker hash table.
This is a copy of <API key>() except with a
different hash table entry creation function. */
static struct bfd_link_hash_table *
<API key> (bfd *abfd)
{
struct elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct elf_link_hash_table);
ret = (struct elf_link_hash_table *) bfd_zmalloc (amt);
if (ret == NULL)
return NULL;
if (!<API key> (ret, abfd, <API key>,
sizeof (struct <API key>),
GENERIC_ELF_DATA))
{
free (ret);
return NULL;
}
return &ret->root;
}
static bfd_boolean
<API key> (bfd *abfd, void * ptr)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, ptr);
else
return <API key> (abfd, ptr);
}
static bfd_boolean
<API key> (bfd *ibfd, struct bfd_link_info *info)
{
if (bfd_get_mach (info->output_bfd) == bfd_mach_score3)
return <API key> (ibfd, info);
else
return <API key> (ibfd, info);
}
static bfd_boolean
<API key> (bfd *abfd, asection *sec)
{
if (bfd_get_mach (abfd) == bfd_mach_score3)
return <API key> (abfd, sec);
else
return <API key> (abfd, sec);
}
/* s3_s7: don't need to split. */
/* Set the right machine number. */
static bfd_boolean
<API key> (bfd * abfd)
{
int e_set = bfd_mach_score7;
if (elf_elfheader (abfd)->e_machine == EM_SCORE)
{
int e_mach = elf_elfheader (abfd)->e_flags & EF_SCORE_MACH & EF_OMIT_PIC_FIXDD;
switch (e_mach)
{
/* Set default target is score7. */
default:
case E_SCORE_MACH_SCORE7:
e_set = bfd_mach_score7;
break;
case E_SCORE_MACH_SCORE3:
e_set = bfd_mach_score3;
break;
}
}
return <API key> (abfd, bfd_arch_score, e_set);
}
bfd_boolean
<API key> (Elf_Internal_Sym *sym)
{
return (sym->st_shndx == SHN_COMMON || sym->st_shndx == SHN_SCORE_SCOMMON);
}
#define USE_REL 1
#define TARGET_LITTLE_SYM score_elf32_le_vec
#define TARGET_LITTLE_NAME "elf32-littlescore"
#define TARGET_BIG_SYM score_elf32_be_vec
#define TARGET_BIG_NAME "elf32-bigscore"
#define ELF_ARCH bfd_arch_score
#define ELF_MACHINE_CODE EM_SCORE
#define ELF_MACHINE_ALT1 EM_SCORE_OLD
#define ELF_MAXPAGESIZE 0x8000
#define elf_info_to_howto 0
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> \
((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> \
<API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> \
<API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> 1
#define <API key> 0
#define <API key> (4 * <API key>)
#define <API key> 0
#define elf_backend_collect TRUE
#define <API key> TRUE
#define <API key> <API key>
#define <API key> <API key>
#define <API key> \
<API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#define <API key> <API key>
#include "elf32-target.h"
|
html .mceContentBody {
max-width:640px;
background:#fff;
color:#333;
font:100% Arial,sans-serif;
line-height:1.5em;
}
* {
font-family: Arial,sans-serif;
color: #333;
line-height: 1.5em;
}
a, a:visited {
text-decoration:none;
color:#999;
}
a:hover, a:active {
color:#333;
}
h1,h2,h3,h4,h5,h6 {
color:#111;
font-weight:bold;
font-family:Arial,sans-serif;
line-height:2em;
}
h1 { font-size:2em; }
h2 { font-size:1.8em; }
h3 { font-size:1.4em; }
h4 { font-size:1.2em; }
h5 { font-size:1em; }
h6 { font-size:.8em; }
hr {
margin:1.4em auto;
display:block;
clear:both;
border-collapse:collapse;
border:0;
border-bottom:1px solid #aaa;
}
p { margin-bottom:18px; }
blockquote { font-style:italic; }
cite { border:0; }
sup, sub { font-size:.6em; }
pre {
background:#f9f9f9;
padding:1em;
border:1px solid #dadada;
}
del {
color:inherit;
}
ins {
background:#ff8;
color:inherit;
text-decoration:none;
border:0;
padding:0 4px;
}
.wp-caption {
background:#f0f0f0;
color:#555;
padding:10px;
border:1px solid #ddd;
}
.wp-caption img { margin:0; padding:0; }
strong { color:#111; }
table {
border:1px solid #ddd;
width:100%;
}
table th {
padding:5px 20px;
text-align:left;
font-weight:bold;
color:#111;
}
table td {
border-top:1px solid #ddd;
padding:5px 20px;
}
.al, .alignleft, .left {
position:relative;
float:left!important;
margin-right:10px;
}
.ar, .alignright, .right {
position:relative;
float:right!important;
margin-left:10px;
}
.ma {margin:auto;}
.cb {clear:both;}
img, p img {
float:none;
margin:auto;
border:0;
}
.more-link {
display:block;
position:relative;
float:left;
clear:both;
}
.submit-button {
background:#333;
color:#fff;
border:0;
width:auto;
font-weight:bold;
text-transform:uppercase;
}
.submit-button:hover {
background:#555;
}
.hideme {
display:none;
}
dl,
ul,
ol {
margin:1em 2em;
}
dl dl,
ul ul,
ol ol {
margin:0em 2em;
}
ul {
list-style:disc;
}
ol {
list-style-type:lower-roman;
}
|
#pragma once
#if !defined(<API key>)
#define <API key>
#include "../rx-includes.hpp"
namespace rxcpp {
namespace operators {
namespace detail {
template<class T, class Observable, class OtherObservable, class BinaryPredicate, class Coordination>
struct sequence_equal : public operator_base<bool>
{
typedef rxu::decay_t<Observable> source_type;
typedef rxu::decay_t<T> source_value_type;
typedef rxu::decay_t<OtherObservable> other_source_type;
typedef typename other_source_type::value_type <API key>;
typedef rxu::decay_t<BinaryPredicate> predicate_type;
typedef rxu::decay_t<Coordination> coordination_type;
typedef typename coordination_type::coordinator_type coordinator_type;
struct values {
values(source_type s, other_source_type t, predicate_type pred, coordination_type sf)
: source(std::move(s))
, other(std::move(t))
, pred(std::move(pred))
, coordination(std::move(sf))
{
}
source_type source;
other_source_type other;
predicate_type pred;
coordination_type coordination;
};
values initial;
sequence_equal(source_type s, other_source_type t, predicate_type pred, coordination_type sf)
: initial(std::move(s), std::move(t), std::move(pred), std::move(sf))
{
}
template<class Subscriber>
void on_subscribe(Subscriber s) const {
typedef Subscriber output_type;
struct state_type
: public std::<API key><state_type>
, public values
{
state_type(const values& vals, coordinator_type coor, const output_type& o)
: values(vals)
, coordinator(std::move(coor))
, out(o)
, source_completed(false)
, other_completed(false)
{
out.add(other_lifetime);
out.add(source_lifetime);
}
<API key> other_lifetime;
<API key> source_lifetime;
coordinator_type coordinator;
output_type out;
mutable std::list<source_value_type> source_values;
mutable std::list<<API key>> other_values;
mutable bool source_completed;
mutable bool other_completed;
};
auto coordinator = initial.coordination.create_coordinator();
auto state = std::make_shared<state_type>(initial, std::move(coordinator), std::move(s));
auto other = on_exception(
[&](){ return state->coordinator.in(state->other); },
state->out);
if (other.empty()) {
return;
}
auto source = on_exception(
[&](){ return state->coordinator.in(state->source); },
state->out);
if (source.empty()) {
return;
}
auto check_equal = [state]() {
if(!state->source_values.empty() && !state->other_values.empty()) {
auto x = std::move(state->source_values.front());
state->source_values.pop_front();
auto y = std::move(state->other_values.front());
state->other_values.pop_front();
if (!state->pred(x, y)) {
state->out.on_next(false);
state->out.on_completed();
}
} else {
if((!state->source_values.empty() && state->other_completed) ||
(!state->other_values.empty() && state->source_completed)) {
state->out.on_next(false);
state->out.on_completed();
}
}
};
auto check_complete = [state]() {
if(state->source_completed && state->other_completed) {
state->out.on_next(state->source_values.empty() && state->other_values.empty());
state->out.on_completed();
}
};
auto sinkOther = make_subscriber<<API key>>(
state->out,
state->other_lifetime,
// on_next
[state, check_equal](<API key> t) {
auto& values = state->other_values;
values.push_back(t);
check_equal();
},
// on_error
[state](std::exception_ptr e) {
state->out.on_error(e);
},
// on_completed
[state, check_complete]() {
auto& completed = state->other_completed;
completed = true;
check_complete();
}
);
auto selectedSinkOther = on_exception(
[&](){ return state->coordinator.out(sinkOther); },
state->out);
if (selectedSinkOther.empty()) {
return;
}
other->subscribe(std::move(selectedSinkOther.get()));
source.get().subscribe(
state->source_lifetime,
// on_next
[state, check_equal](source_value_type t) {
auto& values = state->source_values;
values.push_back(t);
check_equal();
},
// on_error
[state](std::exception_ptr e) {
state->out.on_error(e);
},
// on_completed
[state, check_complete]() {
auto& completed = state->source_completed;
completed = true;
check_complete();
}
);
}
};
template<class OtherObservable, class BinaryPredicate, class Coordination>
class <API key>
{
typedef rxu::decay_t<OtherObservable> other_source_type;
typedef rxu::decay_t<Coordination> coordination_type;
typedef rxu::decay_t<BinaryPredicate> predicate_type;
other_source_type other_source;
coordination_type coordination;
predicate_type pred;
public:
<API key>(other_source_type t, predicate_type p, coordination_type sf)
: other_source(std::move(t))
, coordination(std::move(sf))
, pred(std::move(p))
{
}
template<class Observable>
auto operator()(Observable&& source)
-> observable<bool, sequence_equal<rxu::value_type_t<rxu::decay_t<Observable>>, Observable, other_source_type, BinaryPredicate, Coordination>> {
return observable<bool, sequence_equal<rxu::value_type_t<rxu::decay_t<Observable>>, Observable, other_source_type, BinaryPredicate, Coordination>>(
sequence_equal<rxu::value_type_t<rxu::decay_t<Observable>>, Observable, other_source_type, BinaryPredicate, Coordination>(std::forward<Observable>(source), other_source, pred, coordination));
}
};
}
template<class OtherObservable>
inline auto sequence_equal(OtherObservable&& t)
-> detail::<API key><OtherObservable, rxu::equal_to<>, identity_one_worker> {
return detail::<API key><OtherObservable, rxu::equal_to<>, identity_one_worker>(std::forward<OtherObservable>(t), rxu::equal_to<>(), <API key>());
}
template<class OtherObservable, class BinaryPredicate, class Check = typename std::enable_if<!is_coordination<BinaryPredicate>::value>::type>
inline auto sequence_equal(OtherObservable&& t, BinaryPredicate&& pred)
-> detail::<API key><OtherObservable, BinaryPredicate, identity_one_worker> {
return detail::<API key><OtherObservable, BinaryPredicate, identity_one_worker>(std::forward<OtherObservable>(t), std::forward<BinaryPredicate>(pred), <API key>());
}
template<class OtherObservable, class Coordination, class Check = typename std::enable_if<is_coordination<Coordination>::value>::type>
inline auto sequence_equal(OtherObservable&& t, Coordination&& cn)
-> detail::<API key><OtherObservable, rxu::equal_to<>, Coordination> {
return detail::<API key><OtherObservable, rxu::equal_to<>, Coordination>(std::forward<OtherObservable>(t), rxu::equal_to<>(), std::forward<Coordination>(cn));
}
template<class OtherObservable, class BinaryPredicate, class Coordination>
inline auto sequence_equal(OtherObservable&& t, BinaryPredicate&& pred, Coordination&& cn)
-> detail::<API key><OtherObservable, BinaryPredicate, Coordination> {
return detail::<API key><OtherObservable, BinaryPredicate, Coordination>(std::forward<OtherObservable>(t), std::forward<BinaryPredicate>(pred), std::forward<Coordination>(cn));
}
}
}
#endif
|
var varienTabs = new Class.create();
varienTabs.prototype = {
initialize : function(containerId, destElementId, activeTabId, shadowTabs){
this.containerId = containerId;
this.destElementId = destElementId;
this.activeTab = null;
this.tabOnClick = this.tabMouseClick.bindAsEventListener(this);
this.tabs = $$('#'+this.containerId+' li a.tab-item-link');
this.hideAllTabsContent();
for (var tab=0; tab<this.tabs.length; tab++) {
Event.observe(this.tabs[tab],'click',this.tabOnClick);
// move tab contents to destination element
if($(this.destElementId)){
var tabContentElement = $(this.<API key>(this.tabs[tab]));
if(tabContentElement && tabContentElement.parentNode.id != this.destElementId){
$(this.destElementId).appendChild(tabContentElement);
tabContentElement.container = this;
tabContentElement.statusBar = this.tabs[tab];
tabContentElement.tabObject = this.tabs[tab];
this.tabs[tab].contentMoved = true;
this.tabs[tab].container = this;
this.tabs[tab].show = function(){
this.container.showTabContent(this);
}
if(varienGlobalEvents){
varienGlobalEvents.fireEvent('moveTab', {tab:this.tabs[tab]});
}
}
}
/*
// this code is pretty slow in IE, so lets do it in tabs*.phtml
// mark ajax tabs as not loaded
if (Element.hasClassName($(this.tabs[tab].id), 'ajax')) {
Element.addClassName($(this.tabs[tab].id), 'notloaded');
}
*/
// bind shadow tabs
if (this.tabs[tab].id && shadowTabs && shadowTabs[this.tabs[tab].id]) {
this.tabs[tab].shadowTabs = shadowTabs[this.tabs[tab].id];
}
}
this.displayFirst = activeTabId;
Event.observe(window,'load',this.<API key>.bind(this));
},
<API key> : function(){
this.displayFirst = null;
},
<API key> : function(){
for(var tab=0; tab<this.tabs.length; tab++){
if($(this.destElementId) && !this.tabs[tab].contentMoved){
var tabContentElement = $(this.<API key>(this.tabs[tab]));
if(tabContentElement && tabContentElement.parentNode.id != this.destElementId){
$(this.destElementId).appendChild(tabContentElement);
tabContentElement.container = this;
tabContentElement.statusBar = this.tabs[tab];
tabContentElement.tabObject = this.tabs[tab];
this.tabs[tab].container = this;
this.tabs[tab].show = function(){
this.container.showTabContent(this);
}
if(varienGlobalEvents){
varienGlobalEvents.fireEvent('moveTab', {tab:this.tabs[tab]});
}
}
}
}
if (this.displayFirst) {
this.showTabContent($(this.displayFirst));
this.displayFirst = null;
}
},
<API key> : function(tab){
if(tab){
return tab.id+'_content';
}
return false;
},
tabMouseClick : function(event) {
var tab = Event.findElement(event, 'a');
// go directly to specified url or switch tab
if ((tab.href.indexOf('#') != tab.href.length-1)
&& !(Element.hasClassName(tab, 'ajax'))
) {
location.href = tab.href;
}
else {
this.showTabContent(tab);
}
Event.stop(event);
},
hideAllTabsContent : function(){
for(var tab in this.tabs){
this.hideTabContent(this.tabs[tab]);
}
},
// show tab, ready or not
<API key> : function(tab) {
this.hideAllTabsContent();
var tabContentElement = $(this.<API key>(tab));
if (tabContentElement) {
Element.show(tabContentElement);
Element.addClassName(tab, 'active');
// load shadow tabs, if any
if (tab.shadowTabs && tab.shadowTabs.length) {
for (var k in tab.shadowTabs) {
this.loadShadowTab($(tab.shadowTabs[k]));
}
}
if (!Element.hasClassName(tab, 'ajax only')) {
Element.removeClassName(tab, 'notloaded');
}
this.activeTab = tab;
}
if (varienGlobalEvents) {
varienGlobalEvents.fireEvent('showTab', {tab:tab});
}
},
// the lazy show tab method
showTabContent : function(tab) {
var tabContentElement = $(this.<API key>(tab));
if (tabContentElement) {
if (this.activeTab != tab) {
if (varienGlobalEvents) {
if (varienGlobalEvents.fireEvent('tabChangeBefore', $(this.<API key>(this.activeTab))).indexOf('cannotchange') != -1) {
return;
};
}
}
// wait for ajax request, if defined
var isAjax = Element.hasClassName(tab, 'ajax');
var isEmpty = tabContentElement.innerHTML=='' && tab.href.indexOf('#')!=tab.href.length-1;
var isNotLoaded = Element.hasClassName(tab, 'notloaded');
if ( isAjax && (isEmpty || isNotLoaded) )
{
new Ajax.Request(tab.href, {
parameters: {form_key: FORM_KEY},
evalScripts: true,
onSuccess: function(transport) {
try {
if (transport.responseText.isJSON()) {
var response = transport.responseText.evalJSON()
if (response.error) {
alert(response.message);
}
if(response.ajaxExpired && response.ajaxRedirect) {
setLocation(response.ajaxRedirect);
}
} else {
$(tabContentElement.id).update(transport.responseText);
this.<API key>(tab)
}
}
catch (e) {
$(tabContentElement.id).update(transport.responseText);
this.<API key>(tab)
}
}.bind(this)
});
}
else {
this.<API key>(tab);
}
}
},
loadShadowTab : function(tab) {
var tabContentElement = $(this.<API key>(tab));
if (tabContentElement && Element.hasClassName(tab, 'ajax') && Element.hasClassName(tab, 'notloaded')) {
new Ajax.Request(tab.href, {
parameters: {form_key: FORM_KEY},
evalScripts: true,
onSuccess: function(transport) {
try {
if (transport.responseText.isJSON()) {
var response = transport.responseText.evalJSON()
if (response.error) {
alert(response.message);
}
if(response.ajaxExpired && response.ajaxRedirect) {
setLocation(response.ajaxRedirect);
}
} else {
$(tabContentElement.id).update(transport.responseText);
if (!Element.hasClassName(tab, 'ajax only')) {
Element.removeClassName(tab, 'notloaded');
}
}
}
catch (e) {
$(tabContentElement.id).update(transport.responseText);
if (!Element.hasClassName(tab, 'ajax only')) {
Element.removeClassName(tab, 'notloaded');
}
}
}.bind(this)
});
}
},
hideTabContent : function(tab){
var tabContentElement = $(this.<API key>(tab));
if($(this.destElementId) && tabContentElement){
Element.hide(tabContentElement);
Element.removeClassName(tab, 'active');
}
if(varienGlobalEvents){
varienGlobalEvents.fireEvent('hideTab', {tab:tab});
}
}
}
|
#include "DatabaseEnv.h"
#include "Log.h"
ResultSet::ResultSet(MYSQL_RES *result, MYSQL_FIELD *fields, uint64 rowCount, uint32 fieldCount) :
_rowCount(rowCount),
_fieldCount(fieldCount),
_result(result),
_fields(fields)
{
_currentRow = new Field[_fieldCount];
ASSERT(_currentRow);
}
PreparedResultSet::PreparedResultSet(MYSQL_STMT* stmt, MYSQL_RES *result, uint64 rowCount, uint32 fieldCount) :
m_rowCount(rowCount),
m_rowPosition(0),
m_fieldCount(fieldCount),
m_rBind(NULL),
m_stmt(stmt),
m_res(result),
m_isNull(NULL),
m_length(NULL)
{
if (!m_res)
return;
if (m_stmt->bind_result_done)
{
delete[] m_stmt->bind->length;
delete[] m_stmt->bind->is_null;
}
m_rBind = new MYSQL_BIND[m_fieldCount];
m_isNull = new my_bool[m_fieldCount];
m_length = new unsigned long[m_fieldCount];
memset(m_isNull, 0, sizeof(my_bool) * m_fieldCount);
memset(m_rBind, 0, sizeof(MYSQL_BIND) * m_fieldCount);
memset(m_length, 0, sizeof(unsigned long) * m_fieldCount);
//- This is where we store the (entire) resultset
if (<API key>(m_stmt))
{
TC_LOG_WARN("sql.sql", "%s:<API key>, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
delete[] m_rBind;
delete[] m_isNull;
delete[] m_length;
return;
}
//- This is where we prepare the buffer based on metadata
uint32 i = 0;
MYSQL_FIELD* field = mysql_fetch_field(m_res);
while (field)
{
size_t size = Field::SizeForType(field);
m_rBind[i].buffer_type = field->type;
m_rBind[i].buffer = malloc(size);
memset(m_rBind[i].buffer, 0, size);
m_rBind[i].buffer_length = size;
m_rBind[i].length = &m_length[i];
m_rBind[i].is_null = &m_isNull[i];
m_rBind[i].error = NULL;
m_rBind[i].is_unsigned = field->flags & UNSIGNED_FLAG;
++i;
field = mysql_fetch_field(m_res);
}
//- This is where we bind the bind the buffer to the statement
if (<API key>(m_stmt, m_rBind))
{
TC_LOG_WARN("sql.sql", "%s:<API key>, cannot bind result from MySQL server. Error: %s", __FUNCTION__, mysql_stmt_error(m_stmt));
delete[] m_rBind;
delete[] m_isNull;
delete[] m_length;
return;
}
m_rowCount = mysql_stmt_num_rows(m_stmt);
m_rows.resize(uint32(m_rowCount));
while (_NextRow())
{
m_rows[uint32(m_rowPosition)] = new Field[m_fieldCount];
for (uint64 fIndex = 0; fIndex < m_fieldCount; ++fIndex)
{
if (!*m_rBind[fIndex].is_null)
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue( m_rBind[fIndex].buffer,
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length );
else
switch (m_rBind[fIndex].buffer_type)
{
case <API key>:
case <API key>:
case <API key>:
case MYSQL_TYPE_BLOB:
case MYSQL_TYPE_STRING:
case <API key>:
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue( "",
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length );
break;
default:
m_rows[uint32(m_rowPosition)][fIndex].SetByteValue( 0,
m_rBind[fIndex].buffer_length,
m_rBind[fIndex].buffer_type,
*m_rBind[fIndex].length );
}
}
m_rowPosition++;
}
m_rowPosition = 0;
All data is buffered, let go of mysql c api structures
CleanUp();
}
ResultSet::~ResultSet()
{
CleanUp();
}
PreparedResultSet::~PreparedResultSet()
{
for (uint32 i = 0; i < uint32(m_rowCount); ++i)
delete[] m_rows[i];
}
bool ResultSet::NextRow()
{
MYSQL_ROW row;
if (!_result)
return false;
row = mysql_fetch_row(_result);
if (!row)
{
CleanUp();
return false;
}
for (uint32 i = 0; i < _fieldCount; i++)
_currentRow[i].SetStructuredValue(row[i], _fields[i].type);
return true;
}
bool PreparedResultSet::NextRow()
{
Only updates the m_rowPosition so upper level code knows in which element
of the rows vector to look
if (++m_rowPosition >= m_rowCount)
return false;
return true;
}
bool PreparedResultSet::_NextRow()
{
Only called in low-level code, namely the constructor
Will iterate over every row of data and buffer it
if (m_rowPosition >= m_rowCount)
return false;
int retval = mysql_stmt_fetch( m_stmt );
if (!retval || retval == <API key>)
retval = true;
if (retval == MYSQL_NO_DATA)
retval = false;
return retval;
}
void ResultSet::CleanUp()
{
if (_currentRow)
{
delete [] _currentRow;
_currentRow = NULL;
}
if (_result)
{
mysql_free_result(_result);
_result = NULL;
}
}
void PreparedResultSet::CleanUp()
{
More of the in our code allocated sources are deallocated by the poorly documented mysql c api
if (m_res)
mysql_free_result(m_res);
FreeBindBuffer();
<API key>(m_stmt);
delete[] m_rBind;
}
void PreparedResultSet::FreeBindBuffer()
{
for (uint32 i = 0; i < m_fieldCount; ++i)
free (m_rBind[i].buffer);
}
|
#include "config.h"
#include <gtk/gtk.h>
#include <wiretap/wtap.h>
#include <epan/epan.h>
#include <epan/packet.h>
#include <epan/packet_info.h>
#include <epan/value_string.h>
#include <epan/tap.h>
#include <epan/asn1.h>
#include <epan/dissectors/packet-gsm_map.h>
#include "../stat_menu.h"
#include "../globals.h"
#include "../file.h"
#include "../summary.h"
#include "ui/gtk/gui_stat_menu.h"
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/gui_utils.h"
#include "ui/gtk/gsm_map_stat.h"
#define SUM_STR_MAX 1024
static void
add_string_to_box(gchar *str, GtkWidget *box)
{
GtkWidget *lb;
lb = gtk_label_new(str);
<API key>(GTK_MISC(lb), 0.0f, 0.5f);
gtk_box_pack_start(GTK_BOX(box), lb,FALSE,FALSE, 0);
gtk_widget_show(lb);
}
void <API key>(GtkAction *action _U_, gpointer user_data _U_)
{
summary_tally summary;
GtkWidget *sum_open_w,
*main_vb, *file_fr, *data_fr, *file_box,
*data_box, *bbox, *close_bt,
*invoke_fr, *invoke_box,
*rr_fr, *rr_box,
*tot_fr, *tot_box;
gchar string_buff[SUM_STR_MAX];
double seconds;
int i;
int tot_invokes, tot_rr;
double tot_invokes_size, tot_rr_size;
/* initialize the tally */
summary_fill_in(&cfile, &summary);
/* initial computations */
seconds = summary.stop_time - summary.start_time;
sum_open_w = dlg_window_new("GSM MAP Statistics: Summary"); /* transient_for top_level */
<API key> (GTK_WINDOW(sum_open_w), TRUE);
/* Container for each row of widgets */
main_vb = ws_gtk_box_new(<API key>, 3, FALSE);
<API key>(GTK_CONTAINER(main_vb), 5);
gtk_container_add(GTK_CONTAINER(sum_open_w), main_vb);
gtk_widget_show(main_vb);
/* File frame */
file_fr = gtk_frame_new("File");
gtk_box_pack_start(GTK_BOX (main_vb), file_fr, TRUE, TRUE, 0);
gtk_widget_show(file_fr);
file_box = ws_gtk_box_new(<API key>, 3, FALSE);
gtk_container_add(GTK_CONTAINER(file_fr), file_box);
gtk_widget_show(file_box);
/* filename */
g_snprintf(string_buff, SUM_STR_MAX, "Name: %s", ((summary.filename) ? summary.filename : "None"));
add_string_to_box(string_buff, file_box);
/* length */
g_snprintf(string_buff, SUM_STR_MAX, "Length: %" G_GINT64_MODIFIER "d", summary.file_length);
add_string_to_box(string_buff, file_box);
/* format */
g_snprintf(string_buff, SUM_STR_MAX, "Format: %s", <API key>(summary.file_type));
add_string_to_box(string_buff, file_box);
if (summary.has_snap) {
/* snapshot length */
g_snprintf(string_buff, SUM_STR_MAX, "Snapshot length: %u", summary.snap);
add_string_to_box(string_buff, file_box);
}
/* Data frame */
data_fr = gtk_frame_new("Data");
gtk_box_pack_start(GTK_BOX (main_vb), data_fr, TRUE, TRUE, 0);
gtk_widget_show(data_fr);
data_box = ws_gtk_box_new(<API key>, 3, FALSE);
gtk_container_add(GTK_CONTAINER(data_fr), data_box);
gtk_widget_show(data_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* seconds */
g_snprintf(string_buff, SUM_STR_MAX, "Elapsed time: %.3f seconds", summary.elapsed_time);
add_string_to_box(string_buff, data_box);
g_snprintf(string_buff, SUM_STR_MAX, "Between first and last packet: %.3f seconds", seconds);
add_string_to_box(string_buff, data_box);
}
/* Packet count */
g_snprintf(string_buff, SUM_STR_MAX, "Packet count: %i", summary.packet_count);
add_string_to_box(string_buff, data_box);
tot_invokes = 0;
tot_invokes_size = 0;
for (i=0; i < <API key>; i++)
{
tot_invokes += gsm_map_stat.opr_code[i];
tot_invokes_size += gsm_map_stat.size[i];
}
tot_rr = 0;
tot_rr_size = 0;
for (i=0; i < <API key>; i++)
{
tot_rr += gsm_map_stat.opr_code_rr[i];
tot_rr_size += gsm_map_stat.size_rr[i];
}
/* Invoke frame */
invoke_fr = gtk_frame_new("Invokes");
gtk_box_pack_start(GTK_BOX (main_vb), invoke_fr, TRUE, TRUE, 0);
gtk_widget_show(invoke_fr);
invoke_box = ws_gtk_box_new(<API key>, 3, FALSE);
gtk_container_add(GTK_CONTAINER(invoke_fr), invoke_box);
gtk_widget_show(invoke_box);
/* Total number of invokes */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes: %u", tot_invokes);
add_string_to_box(string_buff, invoke_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Total number of invokes per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: %.2f", tot_invokes/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Invokes per second: N/A");
add_string_to_box(string_buff, invoke_box);
}
/* Total size of invokes */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Invokes: %.0f", tot_invokes_size);
add_string_to_box(string_buff, invoke_box);
/* Average size of invokes */
if (tot_invokes)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: %.2f", tot_invokes_size/tot_invokes);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Invoke: N/A");
add_string_to_box(string_buff, invoke_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Average size of invokes per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_invokes_size/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
add_string_to_box(string_buff, invoke_box);
}
/* Return Results frame */
rr_fr = gtk_frame_new("Return Results");
gtk_box_pack_start(GTK_BOX (main_vb), rr_fr, TRUE, TRUE, 0);
gtk_widget_show(rr_fr);
rr_box = ws_gtk_box_new(<API key>, 3, FALSE);
gtk_container_add(GTK_CONTAINER(rr_fr), rr_box);
gtk_widget_show(rr_box);
/* Total number of return results */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results: %u", tot_rr);
add_string_to_box(string_buff, rr_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Total number of return results per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: %.2f", tot_rr/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of Return Results per second: N/A");
add_string_to_box(string_buff, rr_box);
}
/* Total size of return results */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for Return Results: %.0f", tot_rr_size);
add_string_to_box(string_buff, rr_box);
/* Average size of return results */
if (tot_rr)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: %.2f", tot_rr_size/tot_rr);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per Return Result: N/A");
add_string_to_box(string_buff, rr_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
/* Average size of return results per second */
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: %.2f", tot_rr_size/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per second: N/A");
add_string_to_box(string_buff, rr_box);
}
/* Totals frame */
tot_fr = gtk_frame_new("Totals");
gtk_box_pack_start(GTK_BOX (main_vb), tot_fr, TRUE, TRUE, 0);
gtk_widget_show(tot_fr);
tot_box = ws_gtk_box_new(<API key>, 3, FALSE);
gtk_container_add(GTK_CONTAINER(tot_fr), tot_box);
gtk_widget_show(tot_box);
/* Total number of return results */
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages: %u", tot_invokes + tot_rr);
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: %.2f",
(tot_invokes + tot_rr)/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Total number of GSM MAP messages per second: N/A");
add_string_to_box(string_buff, tot_box);
}
g_snprintf(string_buff, SUM_STR_MAX, "Total number of bytes for GSM MAP messages: %.0f", tot_invokes_size + tot_rr_size);
add_string_to_box(string_buff, tot_box);
if (tot_invokes + tot_rr)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: %.2f",
(tot_invokes_size + tot_rr_size)/(tot_invokes + tot_rr));
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes per GSM MAP messages: N/A");
add_string_to_box(string_buff, tot_box);
/*
* We must have no un-time-stamped packets (i.e., the number of
* time-stamped packets must be the same as the number of packets),
* and at least two time-stamped packets, in order for the elapsed
* time to be valid.
*/
if (summary.packet_count_ts == summary.packet_count &&
summary.packet_count_ts >= 2) {
if (seconds)
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: %.2f",
(tot_invokes_size + tot_rr_size)/seconds);
else
g_snprintf(string_buff, SUM_STR_MAX, "Average number of bytes second: N/A");
add_string_to_box(string_buff, tot_box);
}
/* Button row. */
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
gtk_box_pack_start(GTK_BOX(main_vb), bbox, TRUE, TRUE, 0);
gtk_widget_show(bbox);
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
<API key>(sum_open_w, close_bt, <API key>);
g_signal_connect(sum_open_w, "delete_event", G_CALLBACK(<API key>), NULL);
gtk_widget_show(sum_open_w);
window_present(sum_open_w);
}
void
<API key>(void)
{
}
|
#include <linux/types.h>
#include <linux/proc_fs.h>
#include <asm/setup.h>
#include <linux/pagemap.h>
struct st_read_proc {
char *name;
int (*read_proc)(char *, char **, off_t, int, int *, void *);
};
extern unsigned int get_pd_charge_flag(void);
extern unsigned int <API key>(void);
extern unsigned int resetmode_is_normal(void);
extern unsigned int <API key>(void);
/* same as in proc_misc.c */
static int proc_calc_metrics(char *page, char **start, off_t off,
int count, int *eof, int len)
{
if (len <= off + count)
*eof = 1;
*start = page + off;
len -= off;
if (len > count)
len = count;
if (len < 0)
len = 0;
return len;
}
static int app_tag_read_proc(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
int len = 0;
u32 charge_flag = 0;
u32 recovery_flag = 0;
u32 reset_normal_flag = 0;
recovery_flag = <API key>();
charge_flag = get_pd_charge_flag();
reset_normal_flag = resetmode_is_normal();
len = snprintf(page, PAGE_SIZE,
"recovery_flag:\n%d\n"
"charge_flag:\n%d\n"
"reset_normal_flag:\n%d\n",
recovery_flag,
charge_flag,
reset_normal_flag);
return proc_calc_metrics(page, start, off, count, eof, len);
}
static struct st_read_proc simple_ones[] = {
{"app_info", app_tag_read_proc},
{NULL,}
};
void __init proc_app_info_init(void)
{
struct st_read_proc *p;
for (p = simple_ones; p->name; p++)
<API key>(p->name, 0, NULL, p->read_proc, NULL);
}
|
Template.reassign_modal.helpers({
fields: function() {
var userOptions = null;
var showOrg = true;
var instance = WorkflowManager.getInstance();
var space = db.spaces.findOne(instance.space);
var flow = db.flows.findOne({
'_id': instance.flow
});
var curSpaceUser = db.space_users.findOne({
space: instance.space,
'user': Meteor.userId()
});
var organizations = db.organizations.find({
_id: {
$in: curSpaceUser.organizations
}
}).fetch();
if (space.admins.contains(Meteor.userId())) {
} else if (WorkflowManager.canAdmin(flow, curSpaceUser, organizations)) {
var currentStep = InstanceManager.getCurrentStep()
userOptions = ApproveManager.getNextStepUsers(instance, currentStep._id).getProperty("id").join(",")
showOrg = Session.get("<API key>")
} else {
userOptions = "0"
showOrg = false
}
var multi = false;
var c = InstanceManager.getCurrentStep();
if (c && c.step_type == "counterSign") {
multi = true;
}
return new SimpleSchema({
reassign_users: {
autoform: {
type: "selectuser",
userOptions: userOptions,
showOrg: showOrg,
multiple: multi
},
optional: true,
type: String,
label: TAPi18n.__("<API key>")
}
});
},
values: function() {
return {};
},
current_step_name: function() {
var s = InstanceManager.getCurrentStep();
var name;
if (s) {
name = s.name;
}
return name || '';
}
})
Template.reassign_modal.events({
'show.bs.modal #reassign_modal': function(event) {
var reassign_users = $("input[name='reassign_users']")[0];
reassign_users.value = "";
reassign_users.dataset.values = '';
$(reassign_users).change();
},
'click #reassign_help': function(event, template) {
Steedos.openWindow(t("reassign_help"));
},
'click #reassign_modal_ok': function(event, template) {
var val = AutoForm.getFieldValue("reassign_users", "reassign");
if (!val) {
toastr.error(TAPi18n.__("<API key>"));
return;
}
var reason = $("#reassign_modal_text").val();
var user_ids = val.split(",");
InstanceManager.reassignIns(user_ids, reason);
Modal.hide(template);
},
})
|
<html lang="en">
<head>
<title>Meta Options - Using as</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Using as">
<meta name="generator" content="makeinfo 4.8">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Meta_002dDependent.html#Meta_002dDependent" title="Meta-Dependent">
<link rel="next" href="Meta-Syntax.html#Meta-Syntax" title="Meta Syntax">
<link href="http:
<!
This file documents the GNU Assembler "as".
Copyright (C) 1991-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 no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the
section entitled ``GNU Free Documentation License''.
<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">
<p>
<a name="Meta-Options"></a>
Next: <a rel="next" accesskey="n" href="Meta-Syntax.html#Meta-Syntax">Meta Syntax</a>,
Up: <a rel="up" accesskey="u" href="Meta_002dDependent.html#Meta_002dDependent">Meta-Dependent</a>
<hr>
</div>
<h4 class="subsection">9.25.1 Options</h4>
<p><a name="<API key>"></a><a name="<API key>"></a><a name="<API key>"></a><a name="<API key>"></a>
The Imagination Technologies Meta architecture is implemented in a
number of versions, with each new version adding new features such as
instructions and registers. For precise details of what instructions
each core supports, please see the chip's technical reference manual.
<p>The following table lists all available Meta options.
<!-- man begin OPTIONS -->
<dl>
<dt><code>-mcpu=metac11</code><dd>Generate code for Meta 1.1.
<br><dt><code>-mcpu=metac12</code><dd>Generate code for Meta 1.2.
<br><dt><code>-mcpu=metac21</code><dd>Generate code for Meta 2.1.
<br><dt><code>-mfpu=metac21</code><dd>Allow code to use FPU hardware of Meta 2.1.
</dl>
<!-- man end -->
</body></html>
|
#ifndef _PLOT_H_
#define _PLOT_H_ 1
#include <qwt_plot.h>
class RectItem;
class QwtInterval;
class Plot: public QwtPlot
{
Q_OBJECT
public:
Plot( QWidget *parent, const QwtInterval & );
virtual void updateLayout();
void setRectOfInterest( const QRectF & );
Q_SIGNALS:
void resized( double xRatio, double yRatio );
private:
RectItem *d_rectOfInterest;
};
#endif
|
#pragma checksum "C:\Users\INDIA\Desktop\SpeechKit-WP7-1.4.0\SampleVoiceApp\hotel.xaml" "{<API key>}" "<API key>"
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
using Microsoft.Phone.Controls;
using System;
using System.Windows;
using System.Windows.Automation;
using System.Windows.Automation.Peers;
using System.Windows.Automation.Provider;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
using System.Windows.Resources;
using System.Windows.Shapes;
using System.Windows.Threading;
namespace SampleVoiceApp {
public partial class hotel : Microsoft.Phone.Controls.<API key> {
internal System.Windows.Controls.Grid LayoutRoot;
internal System.Windows.Controls.TextBlock textBlock1;
internal System.Windows.Controls.TextBlock textBlock2;
internal System.Windows.Controls.TextBlock textBlock3;
internal System.Windows.Controls.TextBlock textBlock4;
internal System.Windows.Controls.TextBlock textBlock5;
internal System.Windows.Controls.TextBlock textBlock6;
internal System.Windows.Controls.TextBlock textBlock7;
internal System.Windows.Controls.TextBlock textBlock8;
internal System.Windows.Controls.TextBlock textBlock9;
internal System.Windows.Controls.TextBlock textBlock11;
internal System.Windows.Controls.TextBlock textBlock12;
internal System.Windows.Controls.TextBlock textBlock13;
internal System.Windows.Controls.TextBlock textBlock14;
internal System.Windows.Controls.TextBlock textBlock15;
internal System.Windows.Controls.TextBlock textBlock16;
internal System.Windows.Controls.TextBlock textBlock17;
internal System.Windows.Controls.TextBlock textBlock18;
internal System.Windows.Controls.TextBlock textBlock19;
private bool _contentLoaded;
<summary>
InitializeComponent
</summary>
[System.Diagnostics.<API key>()]
public void InitializeComponent() {
if (_contentLoaded) {
return;
}
_contentLoaded = true;
System.Windows.Application.LoadComponent(this, new System.Uri("/SampleVoiceApp;component/hotel.xaml", System.UriKind.Relative));
this.LayoutRoot = ((System.Windows.Controls.Grid)(this.FindName("LayoutRoot")));
this.textBlock1 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock1")));
this.textBlock2 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock2")));
this.textBlock3 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock3")));
this.textBlock4 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock4")));
this.textBlock5 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock5")));
this.textBlock6 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock6")));
this.textBlock7 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock7")));
this.textBlock8 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock8")));
this.textBlock9 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock9")));
this.textBlock11 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock11")));
this.textBlock12 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock12")));
this.textBlock13 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock13")));
this.textBlock14 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock14")));
this.textBlock15 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock15")));
this.textBlock16 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock16")));
this.textBlock17 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock17")));
this.textBlock18 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock18")));
this.textBlock19 = ((System.Windows.Controls.TextBlock)(this.FindName("textBlock19")));
}
}
}
|
<?php
namespace Kbize\Sdk\Response;
class ProjectAndBoards
{
/**
*
* {
* "projects":[
* {"name":"Project","id":"1","boards":[
* {"name":"Service\/Merchant Integrations","id":"4"},
* {"name":"Tech Operations","id":"3"},
* {"name":"Main development","id":"2"}
* ]}
* ]
* }
*/
public static function fromArrayResponse(array $response)
{
return new self($response['projects']);
}
private function __construct(array $data)
{
$this->data = $data;
}
public function projects()
{
$projects = [];
foreach($this->data as $project) {
$projects[] = [
'name' => $project['name'],
'id' => $project['id'],
];
}
return $projects;
}
public function boards($projectId)
{
$projects = [];
foreach($this->data as $project) {
if ($project['id'] == $projectId) {
return $project['boards'];
}
}
throw new \Exception("Project: `$projectId` does not exists"); //TODO:! custom exception
}
}
|
#!/usr/bin/env python
# This program is free software; you can redistribute it and/or modify it
# query.py: Perform a few varieties of queries
from __future__ import print_function
import time
import bugzilla
# public test instance of bugzilla.redhat.com. It's okay to make changes
URL = "partner-bugzilla.redhat.com"
bzapi = bugzilla.Bugzilla(URL)
# build_query is a helper function that handles some bugzilla version
# incompatibility issues. All it does is return a properly formatted
# dict(), and provide friendly parameter names. The param names map
# to those accepted by XMLRPC Bug.search:
query = bzapi.build_query(
product="Fedora",
component="python-bugzilla")
# Since 'query' is just a dict, you could set your own parameters too, like
# if your bugzilla had a custom field. This will set 'status' for example,
# but for common opts it's better to use build_query
query["status"] = "CLOSED"
# query() is what actually performs the query. it's a wrapper around Bug.search
t1 = time.time()
bugs = bzapi.query(query)
t2 = time.time()
print("Found %d bugs with our query" % len(bugs))
print("Query processing time: %s" % (t2 - t1))
# Depending on the size of your query, you can massively speed things up
# by telling bugzilla to only return the fields you care about, since a
# large chunk of the return time is transmitting the extra bug data. You
# tweak this with include_fields:
# Bugzilla will only return those fields listed in include_fields.
query = bzapi.build_query(
product="Fedora",
component="python-bugzilla",
include_fields=["id", "summary"])
t1 = time.time()
bugs = bzapi.query(query)
t2 = time.time()
print("Quicker query processing time: %s" % (t2 - t1))
# bugzilla.redhat.com, and bugzilla >= 5.0 support queries using the same
# format as is used for 'advanced' search URLs via the Web UI. For example,
# I go to partner-bugzilla.redhat.com -> Search -> Advanced Search, select
# Classification=Fedora
# Product=Fedora
# Component=python-bugzilla
# Unselect all bug statuses (so, all status values)
# Under Custom Search
# Creation date -- is less than or equal to -- 2010-01-01
# Run that, copy the URL and bring it here, pass it to url_to_query to
# convert it to a dict(), and query as usual
query = bzapi.url_to_query("https://partner-bugzilla.redhat.com/"
"buglist.cgi?classification=Fedora&component=python-bugzilla&"
"f1=creation_ts&o1=lessthaneq&order=Importance&product=Fedora&"
"query_format=advanced&v1=2010-01-01")
query["include_fields"] = ["id", "summary"]
bugs = bzapi.query(query)
print("The URL query returned 22 bugs... "
"I know that without even checking because it shouldn't change!... "
"(count is %d)" % len(bugs))
# One note about querying... you can get subtley different results if
# you are not logged in. Depending on your bugzilla setup it may not matter,
# but if you are dealing with private bugs, check bzapi.logged_in setting
# to ensure your cached credentials are up to date. See update.py for
# an example usage
|
/* Initialize
*/
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function() {
return navigator.userAgent.match(/BlackBerry/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function() {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function() {
return navigator.userAgent.match(/IEMobile/i);
},
any: function() {
return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
}
};
jQuery(document).ready(function ($) {
// Bootstrap Init
$("[rel=tooltip]").tooltip();
$('[data-toggle=tooltip]').tooltip();
$("[rel=popover]").popover();
$('#authorTab a').click(function (e) {e.preventDefault(); $(this).tab('show'); });
$('.sc_tabs a').click(function (e) {e.preventDefault(); $(this).tab('show'); });
$(".videofit").fitVids();
$(".embed-youtube").fitVids();
$('.kad-select').customSelect();
$('.<API key> select').customSelect();
$('.collapse-next').click(function (e) {
//e.preventDefault();
var $target = $(this).siblings('.sf-dropdown-menu');
if($target.hasClass('in') ) {
$target.collapse('toggle');
$(this).removeClass('toggle-active');
} else {
$target.collapse('toggle');
$(this).addClass('toggle-active');
}
});
// Lightbox
function kt_check_images( index, element ) {
return /(png|jpg|jpeg|gif|tiff|bmp)$/.test(
$( element ).attr( 'href' ).toLowerCase().split( '?' )[0].split( '
);
}
function kt_find_images() {
$( 'a[href]' ).filter( kt_check_images ).attr( 'data-rel', 'lightbox' );
}
kt_find_images();
$.extend(true, $.magnificPopup.defaults, {
tClose: '',
tLoading: light_load, // Text that is displayed during loading. Can contain %curr% and %total% keys
gallery: {
tPrev: '', // Alt text on left arrow
tNext: '', // Alt text on right arrow
tCounter: light_of // Markup for "1 of 7" counter
},
image: {
tError: light_error, // Error message when image could not be loaded
titleSrc: function(item) {
return item.el.find('img').attr('alt');
}
}
});
$("a[rel^='lightbox']").magnificPopup({type:'image'});
$("a[data-rel^='lightbox']").magnificPopup({type:'image'});
$('.kad-light-gallery').each(function(){
$(this).find('a[rel^="lightbox"]').magnificPopup({
type: 'image',
gallery: {
enabled:true
},
image: {
titleSrc: 'title'
}
});
});
$('.kad-light-gallery').each(function(){
$(this).find("a[data-rel^='lightbox']").magnificPopup({
type: 'image',
gallery: {
enabled:true
},
image: {
titleSrc: 'title'
}
});
});
$('.<API key>').each(function(){
$(this).find('a[rel^="lightbox"]').magnificPopup({
type: 'image',
gallery: {
enabled:true
},
image: {
titleSrc: function(item) {
return item.el.find('img').attr('alt');
}
}
});
});
$('.<API key>').each(function(){
$(this).find("a[data-rel^='lightbox']").magnificPopup({
type: 'image',
gallery: {
enabled:true
},
image: {
titleSrc: function(item) {
return item.el.find('img').attr('alt');
}
}
});
});
//Superfish Menu
$('ul.sf-menu').superfish({
delay: 200, // one second delay on mouseout
animation: {opacity:'show',height:'show'}, // fade-in and slide-down animation
speed: 'fast' // faster animation speed
});
function kad_fullwidth_panel() {
var margins = $(window).width() - $('#content').width();
$('.<API key>').each(function(){
$(this).css({'padding-left': margins/2 + 'px'});
$(this).css({'padding-right': margins/2 + 'px'});
$(this).css({'margin-left': '-' + margins/2 + 'px'});
$(this).css({'margin-right': '-' + margins/2 + 'px'});
$(this).css({'visibility': 'visible'});
});
}
kad_fullwidth_panel();
$(window).on("debouncedresize", function( event ) {kad_fullwidth_panel();});
//init Flexslider
$('.kt-flexslider').each(function(){
var flex_speed = $(this).data('flex-speed'),
flex_animation = $(this).data('flex-animation'),
<API key> = $(this).data('flex-anim-speed'),
flex_auto = $(this).data('flex-auto');
$(this).flexslider({
animation:flex_animation,
animationSpeed: <API key>,
slideshow: flex_auto,
slideshowSpeed: flex_speed,
start: function ( slider ) {
slider.removeClass( 'loading' );
}
});
});
//init masonry
$('.init-masonry').each(function(){
var masonrycontainer = $(this),
masonry_selector = $(this).data('masonry-selector');
masonrycontainer.imagesLoadedn( function(){
masonrycontainer.masonry({itemSelector: masonry_selector});
});
});
//init carousel
jQuery('.initcaroufedsel').each(function(){
var container = jQuery(this);
var wcontainerclass = container.data('carousel-container'),
cspeed = container.data('carousel-speed'),
ctransition = container.data('carousel-transition'),
cauto = container.data('carousel-auto'),
carouselid = container.data('carousel-id'),
ss = container.data('carousel-ss'),
xs = container.data('carousel-xs'),
sm = container.data('carousel-sm'),
md = container.data('carousel-md');
var wcontainer = jQuery(wcontainerclass);
function getUnitWidth() {var width;
if(jQuery(window).width() <= 540) {
width = wcontainer.width() / ss;
} else if(jQuery(window).width() <= 768) {
width = wcontainer.width() / xs;
} else if(jQuery(window).width() <= 990) {
width = wcontainer.width() / sm;
} else {
width = wcontainer.width() / md;
}
return width;
}
function setWidths() {
var unitWidth = getUnitWidth() -1;
container.children().css({ width: unitWidth });
}
setWidths();
function initCarousel() {
container.carouFredSel({
scroll: {items:1, easing: "swing", duration: ctransition, pauseOnHover : true},
auto: {play: cauto, timeoutDuration: cspeed},
prev: '#prevport-'+carouselid, next: '#nextport-'+carouselid, pagination: false, swipe: true, items: {visible: null}
});
}
container.imagesLoadedn( function(){
initCarousel();
});
wcontainer.animate({'opacity' : 1});
jQuery(window).on("debouncedresize", function( event ) {
container.trigger("destroy");
setWidths();
initCarousel();
});
});
//init carouselslider
jQuery('.initcarouselslider').each(function(){
var container = jQuery(this);
var wcontainerclass = container.data('carousel-container'),
cspeed = container.data('carousel-speed'),
ctransition = container.data('carousel-transition'),
cauto = container.data('carousel-auto'),
carouselid = container.data('carousel-id'),
carheight = container.data('carousel-height'),
align = 'center';
var wcontainer = jQuery(wcontainerclass);
function setWidths() {
var unitWidth = container.width();
container.children().css({ width: unitWidth });
if(jQuery(window).width() <= 768) {
carheight = null;
container.children().css({ height: 'auto' });
}
}
setWidths();
function initCarouselslider() {
container.carouFredSel({
width: '100%',
height: carheight,
align: align,
auto: {play: cauto, timeoutDuration: cspeed},
scroll: {items : 1,easing: 'quadratic'},
items: {visible: 1,width: 'variable'},
prev: '#prevport-'+carouselid,
next: '#nextport-'+carouselid,
swipe: {onMouse: false,onTouch: true},
});
}
container.imagesLoadedn( function(){
initCarouselslider();
wcontainer.animate({'opacity' : 1});
wcontainer.css({ height: 'auto' });
wcontainer.parent().removeClass('loading');
});
jQuery(window).on("debouncedresize", function( event ) {
container.trigger("destroy");
setWidths();
initCarouselslider();
});
});
});
if( isMobile.any() ) {
jQuery(document).ready(function ($) {
$('.caroufedselclass').tswipe({
excludedElements:"button, input, select, textarea, .noSwipe",
tswipeLeft: function() {
$('.caroufedselclass').trigger('next', 1);
},
tswipeRight: function() {
$('.caroufedselclass').trigger('prev', 1);
},
tap: function(event, target) {
window.open(jQuery(target).closest('.grid_item').find('a').attr('href'), '_self');
}
});
});
}
|
<?php
// Security check to ensure this file is being included by a parent file.
if (!defined('_JEXEC')) die('Direct Access to this location is not allowed.');
$title = JText::_('<API key>') . '::' . JText::_('<API key>');
?>
<div class="hasAnalyticsTip width-100" title="<?php echo $title; ?>">
<fieldset class="adminform">
<legend>
<?php echo JText::_('<API key>') . JText::_( '<API key>') . <API key>::getDataTypeTitle(); ?>
</legend>
<ul class="adminformlist">
<li>
<div class="<API key>"><img src="<?php echo $this->analytics->analyticsData->images['sources']; ?>" /></div>
</li>
</ul>
</fieldset>
</div>
|
using System.IO;
using Nequeo.Cryptography.Key.Utilities.IO;
namespace Nequeo.Cryptography.Key.Asn1
{
public class BerGenerator
: Asn1Generator
{
private bool _tagged = false;
private bool _isExplicit;
private int _tagNo;
protected BerGenerator(
Stream outStream)
: base(outStream)
{
}
public BerGenerator(
Stream outStream,
int tagNo,
bool isExplicit)
: base(outStream)
{
_tagged = true;
_isExplicit = isExplicit;
_tagNo = tagNo;
}
public override void AddObject(
Asn1Encodable obj)
{
new BerOutputStream(Out).WriteObject(obj);
}
public override Stream GetRawOutputStream()
{
return Out;
}
public override void Close()
{
WriteBerEnd();
}
private void WriteHdr(
int tag)
{
Out.WriteByte((byte) tag);
Out.WriteByte(0x80);
}
protected void WriteBerHeader(
int tag)
{
if (_tagged)
{
int tagNum = _tagNo | Asn1Tags.Tagged;
if (_isExplicit)
{
WriteHdr(tagNum | Asn1Tags.Constructed);
WriteHdr(tag);
}
else
{
if ((tag & Asn1Tags.Constructed) != 0)
{
WriteHdr(tagNum | Asn1Tags.Constructed);
}
else
{
WriteHdr(tagNum);
}
}
}
else
{
WriteHdr(tag);
}
}
protected void WriteBerBody(
Stream contentStream)
{
Streams.PipeAll(contentStream, Out);
}
protected void WriteBerEnd()
{
Out.WriteByte(0x00);
Out.WriteByte(0x00);
if (_tagged && _isExplicit) // write extra end for tag header
{
Out.WriteByte(0x00);
Out.WriteByte(0x00);
}
}
}
}
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst-i18n-plugin.h>
#include "gstvideomeasure.h"
#include "<API key>.h"
#include "<API key>.h"
GstEvent *
<API key> (guint64 framenumber, GstClockTime timestamp,
const gchar * metric, const GValue * mean, const GValue * lowest,
const GValue * highest)
{
GstStructure *str = gst_structure_new (<API key>,
"event", G_TYPE_STRING, "frame-measured",
"offset", G_TYPE_UINT64, framenumber,
"timestamp", GST_TYPE_CLOCK_TIME, timestamp,
"metric", G_TYPE_STRING, metric,
NULL);
<API key> (str, "mean", mean);
<API key> (str, "lowest", lowest);
<API key> (str, "highest", highest);
return <API key> (<API key>, str);
}
static gboolean
plugin_init (GstPlugin * plugin)
{
gboolean res;
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
<API key> (GETTEXT_PACKAGE, "UTF-8");
#endif
res = <API key> (plugin, "ssim", GST_RANK_NONE, GST_TYPE_SSIM);
res &= <API key> (plugin, "measurecollector", GST_RANK_NONE,
<API key>);
return res;
}
GST_PLUGIN_DEFINE2 (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
videomeasure,
"Various video measurers",
plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|
<div class="wrap shopp">
<div class="icon32"></div>
<?php
<API key>();
do_action('shopp_admin_notices');
?>
<?php if (count(shopp_setting('target_markets')) == 0) echo '<div class="error"><p>'.__('No target markets have been selected in your store setup.','Shopp').'</p></div>'; ?>
<?php $this->taxes_menu(); ?>
<form action="<?php echo esc_url($this->url); ?>" id="taxrates" method="post" enctype="multipart/form-data" accept="text/plain,text/xml">
<div>
<?php wp_nonce_field('<API key>'); ?>
</div>
<div class="tablenav">
<div class="actions">
<button type="submit" name="addrate" id="addrate" class="button-secondary" tabindex="9999" <?php if (empty($countries)) echo 'disabled="disabled"'; ?>><?php _e('Add Tax Rate','Shopp'); ?></button>
</div>
</div>
<script id="property-menu" type="text/x-jquery-tmpl"><?php
$propertymenu = array(
'product-name' => __('Product name is','Shopp'),
'product-tags' => __('Product is tagged','Shopp'),
'product-category' => __('Product in category','Shopp'),
'customer-type' => __('Customer type is','Shopp')
);
echo Shopp::menuoptions($propertymenu,false,true);
?></script>
<script id="countries-menu" type="text/x-jquery-tmpl"><?php
echo Shopp::menuoptions($countries,false,true);
?></script>
<script id="conditional" type="text/x-jquery-tmpl">
<?php ob_start(); ?>
<li>
<?php echo ShoppUI::button('delete','deleterule'); ?>
<select name="settings[taxrates][${id}][rules][${ruleid}][p]" class="property">${property_menu}</select> <input type="text" name="settings[taxrates][${id}][rules][${ruleid}][v]" size="25" class="value" value="${rulevalue}" />
<?php echo ShoppUI::button('add','addrule'); ?></li>
<?php $conditional = ob_get_contents(); ob_end_clean(); echo str_replace(array("\n","\t"),'',$conditional); ?>
</script>
<script id="localrate" type="text/x-jquery-tmpl">
<?php ob_start(); ?>
<li><label title="${localename}"><input type="text" name="settings[taxrates][${id}][locals][${localename}]" size="6" value="${localerate}" /> ${localename}</label></li>
<?php $localrateui = ob_get_contents(); ob_end_clean(); echo $localrateui; ?>
</script>
<script id="editor" type="text/x-jquery-tmpl">
<?php ob_start(); ?>
<tr class="inline-edit-row ${classnames}" id="${id}">
<td colspan="5"><input type="hidden" name="id" value="${id}" /><input type="hidden" name="editing" value="true" />
<table id="taxrate-editor">
<tr>
<td scope="row" valign="top" class="rate"><input type="text" name="settings[taxrates][${id}][rate]" id="tax-rate" value="${rate}" size="7" class="selectall" tabindex="1" /><br /><label for="tax-rate"><?php _e('Tax Rate','Shopp'); ?></label><br />
<input type="hidden" name="settings[taxrates][${id}][compound]" value="off" /><label><input type="checkbox" id="tax-compound" name="settings[taxrates][${id}][compound]" value="on" ${compounded} tabindex="4" /> <?php Shopp::_e('Compound'); ?></label></td>
<td scope="row" class="conditions">
<select name="settings[taxrates][${id}][country]" class="country" tabindex="2">${countries}</select><select name="settings[taxrates][${id}][zone]" class="zone no-zones" tabindex="3">${zones}</select>
<?php echo ShoppUI::button('add','addrule'); ?>
<?php
$options = array('any' => Shopp::__('any'), 'all' => strtolower(Shopp::__('All')));
$menu = '<select name="settings[taxrates][${id}][logic]" class="logic">'.menuoptions($options,false,true).'</select>';
?>
<div class="conditionals no-conditions">
<p><label><?php printf(__('Apply tax rate when %s of the following conditions match','Shopp'),$menu); ?>:</label></p>
<ul>
${conditions}
</ul>
</div>
</td>
<td>
<div class="local-rates panel subpanel no-local-rates">
<div class="label"><label><?php _e('Local Rates','Shopp'); echo ShoppAdmin()->boxhelp('<API key>'); ?> <span class="counter"></span><input type="hidden" name="settings[taxrates][${id}][haslocals]" value="${haslocals}" class="has-locals" /></label></div>
<div class="ui">
<p class="instructions"><?php Shopp::_e('No local regions have been setup for this location. Local regions can be specified by uploading a formatted local rates file.'); ?></p>
${errors}
<ul>${localrates}</ul>
<div class="upload">
<h3><?php Shopp::_e('Upload Local Tax Rates'); ?></h3>
<input type="hidden" name="MAX_FILE_SIZE" value="1048576" />
<input type="file" name="ratefile" class="hide-if-js" />
<button type="submit" name="upload" class="button-secondary upload"><?php Shopp::_e('Upload'); ?></button>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td colspan="3">
<p class="textright">
<a href="<?php echo $this->url; ?>" class="button-secondary cancel alignleft"><?php Shopp::_e('Cancel'); ?></a>
<button type="submit" name="add-locals" class="button-secondary locals-toggle add-locals has-local-rates"><?php Shopp::_e('Add Local Rates'); ?></button>
<button type="submit" name="remove-locals" class="button-secondary locals-toggle rm-locals no-local-rates"><?php Shopp::_e('Remove Local Rates'); ?></button>
<input type="submit" class="button-primary" name="submit" value="<?php Shopp::_e('Save Changes'); ?>" />
</p>
</td>
</tr>
</table>
</td>
</tr>
<?php $editor = ob_get_contents(); ob_end_clean(); echo str_replace(array("\n","\t"),'',$editor); ?>
</script>
<table class="widefat" cellspacing="0">
<thead>
<tr><?php <API key>('<API key>'); ?></tr>
</thead>
<tfoot>
<tr><?php <API key>('<API key>',false); ?></tr>
</tfoot>
<tbody id="taxrates-table" class="list">
<?php
if ($edit !== false && !isset($rates[$edit])) {
$defaults = array(
'rate' => 0,
'country' => false,
'zone' => false,
'rules' => array(),
'locals' => array(),
'haslocals' => false,
'compound' => false
);
extract($defaults);
echo ShoppUI::template($editor,array(
'${id}' => $edit,
'${rate}' => percentage($rate,array('precision'=>4)),
'${countries}' => menuoptions($countries,$country,true),
'${zones}' => !empty($zones[$country])?menuoptions($zones[$country],$zone,true):'',
'${conditions}' => join('',$conditions),
'${haslocals}' => $haslocals,
'${localrates}' => join('',$localrates),
'${instructions}' => $localerror ? '<p class="error">'.$localerror.'</p>' : $instructions,
'${compounded}' => Shopp::str_true($compound) ? 'checked="checked"' : ''
));
}
if (count($rates) == 0 && $edit === false): ?>
<tr id="no-taxrates"><td colspan="5"><?php _e('No tax rates, yet.','Shopp'); ?></td></tr>
<?php
endif;
$hidden = get_hidden_columns('<API key>');
$even = false;
foreach ($rates as $index => $taxrate):
$defaults = array(
'rate' => 0,
'country' => false,
'zone' => false,
'rules' => array(),
'locals' => array(),
'haslocals' => false
);
$taxrate = array_merge($defaults,$taxrate);
extract($taxrate);
$rate = Shopp::percentage(Shopp::floatval($rate), array('precision'=>4));
$location = $countries[ $country ];
if (isset($zone) && !empty($zone))
$location = $zones[$country][$zone].", $location";
$editurl = wp_nonce_url(add_query_arg(array('id'=>$index),$this->url));
$deleteurl = wp_nonce_url(add_query_arg(array('delete'=>$index),$this->url),'<API key>');
$classes = array();
if (!$even) $classes[] = 'alternate'; $even = !$even;
if ($edit !== false && $edit === $index) {
$conditions = array();
foreach ($rules as $ruleid => $rule) {
$<API key> = array(
'${id}' => $edit,
'${ruleid}' => $ruleid,
'${property_menu}' => menuoptions($propertymenu,$rule['p'],true),
'${rulevalue}' => esc_attr($rule['v'])
);
$conditions[] = str_replace(array_keys($<API key>),$<API key>,$conditional);
}
$localrates = array();
foreach ($locals as $localename => $localerate) {
$localrateui_data = array(
'${id}' => $edit,
'${localename}' => $localename,
'${localerate}' => (float)$localerate,
);
$localrates[] = str_replace(array_keys($localrateui_data),$localrateui_data,$localrateui);
}
$data = array(
'${id}' => $edit,
'${rate}' => $rate,
'${countries}' => menuoptions($countries,$country,true),
'${zones}' => !empty($zones[$country])?menuoptions(array_merge(array(''=>''),$zones[$country]),$zone,true):'',
'${conditions}' => join('',$conditions),
'${haslocals}' => $haslocals,
'${localrates}' => join('',$localrates),
'${errors}' => $localerror ? '<p class="error">'.$localerror.'</p>' : '',
'${compounded}' => Shopp::str_true($compound) ? 'checked="checked"' : '',
'${cancel_href}' => $this->url
);
if ($conditions) $data['no-conditions'] = '';
if (!empty($zones[$country])) $data['no-zones'] = '';
if ($haslocals) $data['no-local-rates'] = '';
else $data['has-local-rates'] = '';
if (count($locals) > 0) $data['instructions'] = 'hidden';
echo ShoppUI::template($editor,$data);
if ($edit === $index) continue;
}
$label = "$rate — $location";
?>
<tr class="<?php echo join(' ',$classes); ?>" id="taxrates-<?php echo $index; ?>">
<td class="name column-name"><a href="<?php echo esc_url($editurl); ?>" title="<?php _e('Edit','Shopp'); ?> "<?php echo esc_attr($rate); ?>"" class="edit row-title"><?php echo esc_html($label); ?></a>
<div class="row-actions">
<span class='edit'><a href="<?php echo esc_url($editurl); ?>" title="<?php _e('Edit','Shopp'); ?> "<?php echo esc_attr($label); ?>"" class="edit"><?php _e('Edit','Shopp'); ?></a> | </span><span class='delete'><a href="<?php echo esc_url($deleteurl); ?>" title="<?php _e('Delete','Shopp'); ?> "<?php echo esc_attr($label); ?>"" class="delete"><?php _e('Delete','Shopp'); ?></a></span>
</div>
</td>
<td class="local column-local">
<div class="checkbox <?php if ( $haslocals ) echo 'checked'; ?>"> </div>
</td>
<td class="conditional column-conditional">
<div class="checkbox <?php if ( count($rules) > 0 ) echo 'checked'; ?>"> </div>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</form>
</div>
<script type="text/javascript">
/* <![CDATA[ */
var suggurl = '<?php echo wp_nonce_url(admin_url('admin-ajax.php'),'<API key>'); ?>',
rates = <?php echo json_encode($rates); ?>,
base = <?php echo json_encode($base); ?>,
zones = <?php echo json_encode($zones); ?>,
localities = <?php echo json_encode(Lookup::localities()); ?>,
taxrates = [];
</script>
|
/* Mednafen Fast SNES Emulation Module */
#include "snes.h"
#include "input.h"
namespace MDFN_IEN_SNES_FAUST
{
class InputDevice
{
public:
InputDevice() MDFN_COLD;
virtual ~InputDevice() MDFN_COLD;
virtual void Power(void) MDFN_COLD;
virtual void MDFN_FASTCALL UpdatePhysicalState(const uint8* data);
virtual uint8 MDFN_FASTCALL Read(bool IOB) MDFN_HOT;
virtual void MDFN_FASTCALL SetLatch(bool state) MDFN_HOT;
virtual void StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix);
};
InputDevice::InputDevice()
{
}
InputDevice::~InputDevice()
{
}
void InputDevice::Power(void)
{
}
void InputDevice::UpdatePhysicalState(const uint8* data)
{
}
uint8 InputDevice::Read(bool IOB)
{
return 0;
}
void InputDevice::SetLatch(bool state)
{
}
void InputDevice::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix)
{
}
class InputDevice_MTap final : public InputDevice
{
public:
InputDevice_MTap() MDFN_COLD;
virtual ~InputDevice_MTap() override MDFN_COLD;
virtual void Power(void) override MDFN_COLD;
virtual uint8 MDFN_FASTCALL Read(bool IOB) override MDFN_HOT;
virtual void MDFN_FASTCALL SetLatch(bool state) override MDFN_HOT;
virtual void StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix) override;
void SetSubDevice(const unsigned mport, InputDevice* device);
private:
InputDevice* MPorts[4];
bool pls;
};
void InputDevice_MTap::Power(void)
{
for(unsigned mport = 0; mport < 4; mport++)
MPorts[mport]->Power();
}
void InputDevice_MTap::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix)
{
SFORMAT StateRegs[] =
{
SFVAR(pls),
SFEND
};
char sname[64] = "MT_";
strncpy(sname + 3, sname_prefix, sizeof(sname) - 3);
sname[sizeof(sname) - 1] = 0;
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, sname, true) && load)
Power();
else
{
for(unsigned mport = 0; mport < 4; mport++)
{
sname[2] = '0' + mport;
MPorts[mport]->StateAction(sm, load, data_only, sname);
}
if(load)
{
}
}
}
InputDevice_MTap::InputDevice_MTap()
{
for(unsigned mport = 0; mport < 4; mport++)
MPorts[mport] = nullptr;
pls = false;
}
InputDevice_MTap::~InputDevice_MTap()
{
}
uint8 InputDevice_MTap::Read(bool IOB)
{
uint8 ret;
ret = ((MPorts[(!IOB << 1) + 0]->Read(false) & 0x1) << 0) | ((MPorts[(!IOB << 1) + 1]->Read(false) & 0x1) << 1);
if(pls)
ret = 0x2;
return ret;
}
void InputDevice_MTap::SetLatch(bool state)
{
for(unsigned mport = 0; mport < 4; mport++)
MPorts[mport]->SetLatch(state);
pls = state;
}
void InputDevice_MTap::SetSubDevice(const unsigned mport, InputDevice* device)
{
MPorts[mport] = device;
}
class InputDevice_Gamepad final : public InputDevice
{
public:
InputDevice_Gamepad() MDFN_COLD;
virtual ~InputDevice_Gamepad() override MDFN_COLD;
virtual void Power(void) override MDFN_COLD;
virtual void MDFN_FASTCALL UpdatePhysicalState(const uint8* data) override;
virtual uint8 MDFN_FASTCALL Read(bool IOB) override MDFN_HOT;
virtual void MDFN_FASTCALL SetLatch(bool state) override MDFN_HOT;
virtual void StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix) override;
private:
uint16 buttons;
uint32 latched;
bool pls;
};
InputDevice_Gamepad::InputDevice_Gamepad()
{
pls = false;
buttons = 0;
}
InputDevice_Gamepad::~InputDevice_Gamepad()
{
}
void InputDevice_Gamepad::StateAction(StateMem* sm, const unsigned load, const bool data_only, const char* sname_prefix)
{
SFORMAT StateRegs[] =
{
SFVAR(buttons),
SFVAR(latched),
SFVAR(pls),
SFEND
};
char sname[64] = "GP_";
strncpy(sname + 3, sname_prefix, sizeof(sname) - 3);
sname[sizeof(sname) - 1] = 0;
//printf("%s\n", sname);
if(!MDFNSS_StateAction(sm, load, data_only, StateRegs, sname, true) && load)
Power();
else if(load)
{
}
}
void InputDevice_Gamepad::Power(void)
{
latched = ~0U;
}
void InputDevice_Gamepad::UpdatePhysicalState(const uint8* data)
{
buttons = MDFN_de16lsb(data);
if(pls)
latched = buttons | 0xFFFF0000;
}
uint8 InputDevice_Gamepad::Read(bool IOB)
{
uint8 ret = latched & 1;
if(!pls)
latched = (int32)latched >> 1;
return ret;
}
void InputDevice_Gamepad::SetLatch(bool state)
{
if(pls && !state)
latched = buttons | 0xFFFF0000;
pls = state;
}
static struct
{
InputDevice_Gamepad gamepad;
} PossibleDevices[8];
static InputDevice NoneDevice;
static InputDevice_MTap PossibleMTaps[2];
static bool MTapEnabled[2];
// Mednafen virtual
static InputDevice* Devices[8];
static uint8* DeviceData[8];
// SNES physical
static InputDevice* Ports[2];
static uint8 WRIO;
static bool JoyLS;
static uint8 JoyARData[8];
static DEFREAD(Read_JoyARData)
{
if(MDFN_UNLIKELY(DBG_InHLRead))
{
return JoyARData[A & 0x7];
}
CPUM.timestamp += MEMCYC_FAST;
//printf("Read: %08x\n", A);
return JoyARData[A & 0x7];
}
static DEFREAD(Read_4016)
{
if(MDFN_UNLIKELY(DBG_InHLRead))
{
return CPUM.mdr & 0xFC; // | TODO!
}
CPUM.timestamp += MEMCYC_XSLOW;
uint8 ret = CPUM.mdr & 0xFC;
ret |= Ports[0]->Read(WRIO & (0x40 << 0));
//printf("Read 4016: %02x\n", ret);
return ret;
}
static DEFWRITE(Write_4016)
{
CPUM.timestamp += MEMCYC_XSLOW;
JoyLS = V & 1;
for(unsigned sport = 0; sport < 2; sport++)
Ports[sport]->SetLatch(JoyLS);
//printf("Write 4016: %02x\n", V);
}
static DEFREAD(Read_4017)
{
if(MDFN_UNLIKELY(DBG_InHLRead))
{
return (CPUM.mdr & 0xE0) | 0x1C; // | TODO!
}
CPUM.timestamp += MEMCYC_XSLOW;
uint8 ret = (CPUM.mdr & 0xE0) | 0x1C;
ret |= Ports[1]->Read(WRIO & (0x40 << 1));
//printf("Read 4017: %02x\n", ret);
return ret;
}
static DEFWRITE(Write_WRIO)
{
CPUM.timestamp += MEMCYC_FAST;
WRIO = V;
}
static DEFREAD(Read_4213)
{
if(MDFN_UNLIKELY(DBG_InHLRead))
{
return WRIO;
}
CPUM.timestamp += MEMCYC_FAST;
return WRIO;
}
void INPUT_AutoRead(void)
{
for(unsigned sport = 0; sport < 2; sport++)
{
Ports[sport]->SetLatch(true);
Ports[sport]->SetLatch(false);
unsigned ard[2] = { 0 };
for(unsigned b = 0; b < 16; b++)
{
uint8 rv = Ports[sport]->Read(WRIO & (0x40 << sport));
ard[0] = (ard[0] << 1) | ((rv >> 0) & 1);
ard[1] = (ard[1] << 1) | ((rv >> 1) & 1);
}
for(unsigned ai = 0; ai < 2; ai++)
MDFN_en16lsb(&JoyARData[sport * 2 + ai * 4], ard[ai]);
}
JoyLS = false;
}
static MDFN_COLD void MapDevices(void)
{
for(unsigned sport = 0, vport = 0; sport < 2; sport++)
{
if(MTapEnabled[sport])
{
Ports[sport] = &PossibleMTaps[sport];
for(unsigned mport = 0; mport < 4; mport++)
PossibleMTaps[sport].SetSubDevice(mport, Devices[vport++]);
}
else
Ports[sport] = Devices[vport++];
}
}
void INPUT_Init(void)
{
for(unsigned bank = 0x00; bank < 0x100; bank++)
{
if(bank <= 0x3F || (bank >= 0x80 && bank <= 0xBF))
{
Set_A_Handlers((bank << 16) | 0x4016, Read_4016, Write_4016);
Set_A_Handlers((bank << 16) | 0x4017, Read_4017, OBWrite_XSLOW);
Set_A_Handlers((bank << 16) | 0x4201, OBRead_FAST, Write_WRIO);
Set_A_Handlers((bank << 16) | 0x4213, Read_4213, OBWrite_FAST);
Set_A_Handlers((bank << 16) | 0x4218, (bank << 16) | 0x421F, Read_JoyARData, OBWrite_FAST);
}
}
for(unsigned vport = 0; vport < 8; vport++)
{
DeviceData[vport] = nullptr;
Devices[vport] = &NoneDevice;
}
for(unsigned sport = 0; sport < 2; sport++)
for(unsigned mport = 0; mport < 4; mport++)
PossibleMTaps[sport].SetSubDevice(mport, &NoneDevice);
MTapEnabled[0] = MTapEnabled[1] = false;
MapDevices();
}
void INPUT_SetMultitap(const bool (&enabled)[2])
{
for(unsigned sport = 0; sport < 2; sport++)
{
if(enabled[sport] != MTapEnabled[sport])
{
PossibleMTaps[sport].SetLatch(JoyLS);
PossibleMTaps[sport].Power();
MTapEnabled[sport] = enabled[sport];
}
}
MapDevices();
}
void INPUT_Kill(void)
{
}
void INPUT_Reset(bool powering_up)
{
JoyLS = false;
for(unsigned sport = 0; sport < 2; sport++)
Ports[sport]->SetLatch(JoyLS);
memset(JoyARData, 0x00, sizeof(JoyARData));
if(powering_up)
{
WRIO = 0xFF;
for(unsigned sport = 0; sport < 2; sport++)
Ports[sport]->Power();
}
}
void INPUT_Set(unsigned vport, const char* type, uint8* ptr)
{
InputDevice* nd = &NoneDevice;
DeviceData[vport] = ptr;
if(!strcmp(type, "gamepad"))
nd = &PossibleDevices[vport].gamepad;
else if(strcmp(type, "none"))
abort();
if(Devices[vport] != nd)
{
Devices[vport] = nd;
Devices[vport]->SetLatch(JoyLS);
Devices[vport]->Power();
}
MapDevices();
}
void INPUT_StateAction(StateMem* sm, const unsigned load, const bool data_only)
{
SFORMAT StateRegs[] =
{
SFVAR(JoyARData),
SFVAR(JoyLS),
SFVAR(WRIO),
SFEND
};
MDFNSS_StateAction(sm, load, data_only, StateRegs, "INPUT");
for(unsigned sport = 0; sport < 2; sport++)
{
char sprefix[32] = "PORTn";
sprefix[4] = '0' + sport;
Ports[sport]->StateAction(sm, load, data_only, sprefix);
}
}
void <API key>(void)
{
for(unsigned vport = 0; vport < 8; vport++)
Devices[vport]->UpdatePhysicalState(DeviceData[vport]);
}
static const IDIISG GamepadIDII =
{
IDIIS_ButtonCR("b", "B (center, lower)", 7, NULL),
IDIIS_ButtonCR("y", "Y (left)", 6, NULL),
IDIIS_Button("select", "SELECT", 4, NULL),
IDIIS_Button("start", "START", 5, NULL),
IDIIS_Button("up", "UP ↑", 0, "down"),
IDIIS_Button("down", "DOWN ↓", 1, "up"),
IDIIS_Button("left", "LEFT ←", 2, "right"),
IDIIS_Button("right", "RIGHT →", 3, "left"),
IDIIS_ButtonCR("a", "A (right)", 9, NULL),
IDIIS_ButtonCR("x", "X (center, upper)", 8, NULL),
IDIIS_Button("l", "Left Shoulder", 10, NULL),
IDIIS_Button("r", "Right Shoulder", 11, NULL),
};
static const std::vector<<API key>> InputDeviceInfo =
{
// None
{
"none",
"none",
NULL,
IDII_Empty
},
// Gamepad
{
"gamepad",
"Gamepad",
NULL,
GamepadIDII
},
};
const std::vector<InputPortInfoStruct> INPUT_PortInfo =
{
{ "port1", "Virtual Port 1", InputDeviceInfo, "gamepad" },
{ "port2", "Virtual Port 2", InputDeviceInfo, "gamepad" },
{ "port3", "Virtual Port 3", InputDeviceInfo, "gamepad" },
{ "port4", "Virtual Port 4", InputDeviceInfo, "gamepad" },
{ "port5", "Virtual Port 5", InputDeviceInfo, "gamepad" },
{ "port6", "Virtual Port 6", InputDeviceInfo, "gamepad" },
{ "port7", "Virtual Port 7", InputDeviceInfo, "gamepad" },
{ "port8", "Virtual Port 8", InputDeviceInfo, "gamepad" }
};
}
|
#pragma once
#include <memory>
#include <string>
#include <vector>
class CEvent;
namespace KODI
{
namespace MESSAGING
{
class <API key>;
class ThreadMessage
{
friend <API key>;
public:
ThreadMessage()
: ThreadMessage{ 0, -1, -1, nullptr }
{
}
explicit ThreadMessage(uint32_t messageId)
: ThreadMessage{ messageId, -1, -1, nullptr }
{
}
ThreadMessage(uint32_t messageId, int p1, int p2, void* payload)
: dwMessage{ messageId }
, param1{ p1 }
, param2{ p2 }
, lpVoid{ payload }
{
}
ThreadMessage(uint32_t messageId, int p1, int p2, void* payload, std::string param, std::vector<std::string> vecParams)
: dwMessage{ messageId }
, param1{ p1 }
, param2{ p2 }
, lpVoid{ payload }
, strParam( param )
, params( vecParams )
{
}
ThreadMessage(const ThreadMessage& other)
: dwMessage(other.dwMessage),
param1(other.param1),
param2(other.param2),
lpVoid(other.lpVoid),
strParam(other.strParam),
params(other.params),
waitEvent(other.waitEvent),
result(other.result)
{
}
ThreadMessage(ThreadMessage&& other)
: dwMessage(other.dwMessage),
param1(other.param1),
param2(other.param2),
lpVoid(other.lpVoid),
strParam(std::move(other.strParam)),
params(std::move(other.params)),
waitEvent(std::move(other.waitEvent)),
result(std::move(other.result))
{
}
ThreadMessage& operator=(const ThreadMessage& other)
{
if (this == &other)
return *this;
dwMessage = other.dwMessage;
param1 = other.param1;
param2 = other.param2;
lpVoid = other.lpVoid;
strParam = other.strParam;
params = other.params;
waitEvent = other.waitEvent;
result = other.result;
return *this;
}
ThreadMessage& operator=(ThreadMessage&& other)
{
if (this == &other)
return *this;
dwMessage = other.dwMessage;
param1 = other.param1;
param2 = other.param2;
lpVoid = other.lpVoid;
strParam = std::move(other.strParam);
params = std::move(other.params);
waitEvent = std::move(other.waitEvent);
result = std::move(other.result);
return *this;
}
uint32_t dwMessage;
int param1;
int param2;
void* lpVoid;
std::string strParam;
std::vector<std::string> params;
void SetResult(int res)
{
//On posted messages result will be zero, since they can't
//retrieve the response we silently ignore this to let message
//handlers not have to worry about it
if (result)
*result = res;
}
protected:
std::shared_ptr<CEvent> waitEvent;
std::shared_ptr<int> result;
};
}
}
|
<!DOCTYPE html PUBLIC "-
<html xmlns="http:
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>oRTP: /Users/huyheo/Documents/Linphone/linphone-iphone/submodules/linphone/oRTP/src Directory Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">oRTP
 <span id="projectnumber">0.22.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Data Structures</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="<API key>.html">linphone</a></li><li class="navelem"><a class="el" href="<API key>.html">oRTP</a></li><li class="navelem"><a class="el" href="<API key>.html">src</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title">src Directory Reference</div> </div>
</div><!--header
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="files"></a>
Files</h2></td></tr>
<tr class="memitem:avprofile_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>avprofile.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:b64_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><a class="el" href="b64_8c.html">b64.c</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:dll__entry_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>dll_entry.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:event_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>event.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:jitterctl_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>jitterctl.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:jitterctl_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>jitterctl.h</b> <a href="jitterctl_8h_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:logging_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>logging.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:netsim_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>netsim.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:<API key>"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>ortp-config-win32.h</b> <a href="<API key>.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ortp_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>ortp.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:ortp__srtp_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>ortp_srtp.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:payloadtype_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>payloadtype.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:port_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>port.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:posixtimer_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>posixtimer.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtcp_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtcp.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtcpparse_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtcpparse.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpparse_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpparse.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpprofile_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpprofile.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpsession_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpsession.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpsession__inet_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpsession_inet.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpsession__priv_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpsession_priv.h</b> <a href="<API key>.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtpsignaltable_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtpsignaltable.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtptimer_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtptimer.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:rtptimer_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>rtptimer.h</b> <a href="rtptimer_8h_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:scheduler_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>scheduler.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:scheduler_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>scheduler.h</b> <a href="scheduler_8h_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:sessionset_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>sessionset.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:str__utils_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>str_utils.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:stun_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>stun.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:stun__udp_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>stun_udp.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:telephonyevents_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>telephonyevents.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:utils_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>utils.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:utils_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>utils.h</b> <a href="utils_8h_source.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:winrttimer_8h"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>winrttimer.h</b> <a href="<API key>.html">[code]</a></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:zrtp_8c"><td class="memItemLeft" align="right" valign="top">file  </td><td class="memItemRight" valign="bottom"><b>zrtp.c</b></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2"> </td></tr>
</table>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Wed Jul 31 2013 14:43:09 for oRTP by &
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.3.1
</small></address>
</body>
</html>
|
<!DOCTYPE html PUBLIC "-
<html><head><title></title>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta name="generator" content="Doxygen 1.8.3.1">
<link rel="stylesheet" type="text/css" href="search.css"/>
<script type="text/javascript" src="enumvalues_6a.js"></script>
<script type="text/javascript" src="search.js"></script>
</head>
<body class="SRPage">
<div id="SRIndex">
<div class="SRStatus" id="Loading">Loading...</div>
<div id="SRResults"></div>
<script type="text/javascript"><!
createResults();
--></script>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
<script type="text/javascript"><!
document.getElementById("Loading").style.display="none";
document.getElementById("NoMatches").style.display="none";
var searchResults = new SearchResults("searchResults");
searchResults.Search();
--></script>
</div>
</body>
</html>
|
# This files goal is to take CMake options found in kokkos_options.cmake but
# possibly set from elsewhere
# (see: trilinos/cmake/<API key>.cmake)
# using CMake idioms and map them onto the KOKKOS_SETTINGS variables that gets
# passed to the kokkos makefile configuration:
# make -f ${CMAKE_SOURCE_DIR}/core/src/Makefile ${KOKKOS_SETTINGS} <API key>
# that generates KokkosCore_config.h and <API key>.cmake
# To understand how to form KOKKOS_SETTINGS, see
# <KOKKOS_PATH>/Makefile.kokkos
# Ensure that KOKKOS_ARCH is in the ARCH_LIST
if (KOKKOS_ARCH MATCHES ",")
message("-- Detected a comma in: KOKKOS_ARCH=${KOKKOS_ARCH}")
message("-- Although we prefer KOKKOS_ARCH to be semicolon-delimited, we do allow")
message("-- comma-delimited values for compatibility with scripts (see github.com/trilinos/Trilinos/issues/2330)")
string(REPLACE "," ";" KOKKOS_ARCH "${KOKKOS_ARCH}")
message("-- Commas were changed to semicolons, now KOKKOS_ARCH=${KOKKOS_ARCH}")
endif()
foreach(arch ${KOKKOS_ARCH})
list(FIND KOKKOS_ARCH_LIST ${arch} indx)
if (indx EQUAL -1)
message(FATAL_ERROR "${arch} is not an accepted value for KOKKOS_ARCH."
" Please pick from these choices: ${<API key>}")
endif ()
endforeach()
# KOKKOS_SETTINGS uses KOKKOS_ARCH
string(REPLACE ";" "," KOKKOS_GMAKE_ARCH "${KOKKOS_ARCH}")
# From Makefile.kokkos: Options: yes,no
if(${KOKKOS_ENABLE_DEBUG})
set(KOKKOS_GMAKE_DEBUG yes)
else()
set(KOKKOS_GMAKE_DEBUG no)
endif()
# Can have multiple devices
set(KOKKOS_DEVICESl)
foreach(devopt ${KOKKOS_DEVICES_LIST})
string(TOUPPER ${devopt} devoptuc)
if (${KOKKOS_ENABLE_${devoptuc}})
list(APPEND KOKKOS_DEVICESl ${devopt})
endif ()
endforeach()
# List needs to be comma-delmitted
string(REPLACE ";" "," <API key> "${KOKKOS_DEVICESl}")
# From Makefile.kokkos: Options: <API key>,disable_profiling,<API key>
#compiler_warnings, <API key>, disable_profiling, <API key>, <API key>
set(KOKKOS_OPTIONSl)
if(${<API key>})
list(APPEND KOKKOS_OPTIONSl compiler_warnings)
endif()
if(${<API key>})
list(APPEND KOKKOS_OPTIONSl <API key>)
endif()
if(NOT ${<API key>})
list(APPEND KOKKOS_OPTIONSl disable_profiling)
endif()
if(NOT ${<API key>})
list(APPEND KOKKOS_OPTIONSl <API key>)
endif()
if(NOT ${<API key>})
list(APPEND KOKKOS_OPTIONSl <API key>)
endif()
if(${<API key>})
list(APPEND KOKKOS_OPTIONSl <API key>)
endif()
# List needs to be comma-delimitted
string(REPLACE ";" "," <API key> "${KOKKOS_OPTIONSl}")
# Construct the Makefile options
set(KOKKOS_USE_TPLSl)
foreach(tplopt ${<API key>})
if (${KOKKOS_ENABLE_${tplopt}})
list(APPEND KOKKOS_USE_TPLSl ${KOKKOS_INTERNAL_${tplopt}})
endif ()
endforeach()
# List needs to be comma-delimitted
string(REPLACE ";" "," <API key> "${KOKKOS_USE_TPLSl}")
# Construct the Makefile options
set(<API key>)
foreach(cudaopt ${<API key>})
if (${KOKKOS_ENABLE_CUDA_${cudaopt}})
list(APPEND <API key> ${KOKKOS_INTERNAL_${cudaopt}})
endif ()
endforeach()
# List needs to be comma-delmitted
string(REPLACE ";" "," <API key> "${<API key>}")
# Want makefile to use same executables specified which means modifying
# the path so the $(shell ...) commands in the makefile see the right exec
# Also, the Makefile's use FOO_PATH naming scheme for -I/-L construction
#TODO: Makefile.kokkos allows this to be overwritten? ROCM_HCC_PATH
set(<API key>)
set(addpathl)
foreach(kvar IN LISTS <API key> ITEMS CUDA QTHREADS)
if(${KOKKOS_ENABLE_${kvar}})
if(DEFINED KOKKOS_${kvar}_DIR)
set(<API key> ${<API key>} "${kvar}_PATH=${KOKKOS_${kvar}_DIR}")
if(IS_DIRECTORY ${KOKKOS_${kvar}_DIR}/bin)
list(APPEND addpathl ${KOKKOS_${kvar}_DIR}/bin)
endif()
endif()
endif()
endforeach()
# Path env is : delimitted
string(REPLACE ";" ":" <API key> "${addpathl}")
# Set the KOKKOS_SETTINGS String -- this is the primary communication with the
# makefile configuration. See Makefile.kokkos
set(KOKKOS_SETTINGS KOKKOS_SRC_PATH=${KOKKOS_SRC_PATH})
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} KOKKOS_PATH=${KOKKOS_PATH})
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} KOKKOS_INSTALL_PATH=${<API key>})
# Form of KOKKOS_foo=$KOKKOS_foo
foreach(kvar ARCH;DEVICES;DEBUG;OPTIONS;CUDA_OPTIONS;USE_TPLS)
if(DEFINED KOKKOS_GMAKE_${kvar})
if (NOT "${KOKKOS_GMAKE_${kvar}}" STREQUAL "")
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} KOKKOS_${kvar}=${KOKKOS_GMAKE_${kvar}})
endif()
endif()
endforeach()
# Form of VAR=VAL
#TODO: Makefile supports MPICH_CXX, OMPI_CXX as well
foreach(ovar CXX;CXXFLAGS;LDFLAGS)
if(DEFINED ${ovar})
if (NOT "${${ovar}}" STREQUAL "")
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} ${ovar}=${${ovar}})
endif()
endif()
endforeach()
# Finally, do the paths
if (NOT "${<API key>}" STREQUAL "")
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} ${<API key>})
endif()
if (NOT "${<API key>}" STREQUAL "")
set(KOKKOS_SETTINGS ${KOKKOS_SETTINGS} "PATH=\"${<API key>}:$ENV{PATH}\"")
endif()
# Final form that gets passed to make
set(KOKKOS_SETTINGS env ${KOKKOS_SETTINGS})
if(<API key>)
message(STATUS "")
message(STATUS "****************** Kokkos Settings ******************")
message(STATUS "Execution Spaces")
if(KOKKOS_ENABLE_CUDA)
message(STATUS " Device Parallel: Cuda")
else()
message(STATUS " Device Parallel: None")
endif()
if(<API key>)
message(STATUS " Host Parallel: OpenMP")
elseif(<API key>)
message(STATUS " Host Parallel: Pthread")
elseif(<API key>)
message(STATUS " Host Parallel: Qthreads")
else()
message(STATUS " Host Parallel: None")
endif()
if(<API key>)
message(STATUS " Host Serial: Serial")
else()
message(STATUS " Host Serial: None")
endif()
message(STATUS "")
message(STATUS "Architectures:")
message(STATUS " ${KOKKOS_GMAKE_ARCH}")
message(STATUS "")
message(STATUS "Enabled options")
if(<API key>)
message(STATUS " <API key>")
endif()
foreach(opt IN LISTS <API key>)
string(TOUPPER ${opt} OPT)
if (KOKKOS_ENABLE_${OPT})
message(STATUS " KOKKOS_ENABLE_${OPT}")
endif()
endforeach()
if(KOKKOS_ENABLE_CUDA)
if(KOKKOS_CUDA_DIR)
message(STATUS " KOKKOS_CUDA_DIR: ${KOKKOS_CUDA_DIR}")
endif()
endif()
if(KOKKOS_QTHREADS_DIR)
message(STATUS " KOKKOS_QTHREADS_DIR: ${KOKKOS_QTHREADS_DIR}")
endif()
if(KOKKOS_HWLOC_DIR)
message(STATUS " KOKKOS_HWLOC_DIR: ${KOKKOS_HWLOC_DIR}")
endif()
if(KOKKOS_MEMKIND_DIR)
message(STATUS " KOKKOS_MEMKIND_DIR: ${KOKKOS_MEMKIND_DIR}")
endif()
message(STATUS "")
message(STATUS "Final kokkos settings variable:")
message(STATUS " ${KOKKOS_SETTINGS}")
message(STATUS "*****************************************************")
message(STATUS "")
endif()
|
<?php
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
use Symfony\Component\Form\FormError;
use Symfony\Component\Intl\Util\IntlTestHelper;
class DateTypeTest extends BaseTypeTest
{
const TESTED_TYPE = 'date';
private $defaultTimezone;
protected function setUp()
{
parent::setUp();
$this->defaultTimezone = <API key>();
}
protected function tearDown()
{
<API key>($this->defaultTimezone);
\Locale::setDefault('en');
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'fake_widget',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'input' => 'fake_input',
));
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
$form->submit('2010-06-02');
$this-><API key>(new \DateTime('2010-06-02 UTC'), $form->getData());
$this->assertEquals('2010-06-02', $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
'format' => 'yyyy',
));
$form->submit('2010');
$this-><API key>(new \DateTime('2010-01-01 UTC'), $form->getData());
$this->assertEquals('2010', $form->getViewData());
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'datetime',
));
$form->submit('2.6.2010');
$this-><API key>(new \DateTime('2010-06-02 UTC'), $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'string',
));
$form->submit('2.6.2010');
$this->assertEquals('2010-06-02', $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'timestamp',
));
$form->submit('2.6.2010');
$dateTime = new \DateTime('2010-06-02 UTC');
$this->assertEquals($dateTime->format('U'), $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'single_text',
'input' => 'array',
));
$form->submit('2.6.2010');
$output = array(
'day' => '2',
'month' => '6',
'year' => '2010',
);
$this->assertEquals($output, $form->getData());
$this->assertEquals('02.06.2010', $form->getViewData());
}
public function testSubmitFromText()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'text',
));
$text = array(
'day' => '2',
'month' => '6',
'year' => '2010',
);
$form->submit($text);
$dateTime = new \DateTime('2010-06-02 UTC');
$this-><API key>($dateTime, $form->getData());
$this->assertEquals($text, $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
'years' => array(2010),
));
$text = array(
'day' => '2',
'month' => '6',
'year' => '2010',
);
$form->submit($text);
$dateTime = new \DateTime('2010-06-02 UTC');
$this-><API key>($dateTime, $form->getData());
$this->assertEquals($text, $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
'required' => false,
));
$text = array(
'day' => '',
'month' => '',
'year' => '',
);
$form->submit($text);
$this->assertNull($form->getData());
$this->assertEquals($text, $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'datetime',
));
$form->submit('06*2010*02');
$this-><API key>(new \DateTime('2010-06-02 UTC'), $form->getData());
$this->assertEquals('06*2010*02', $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'string',
));
$form->submit('06*2010*02');
$this->assertEquals('2010-06-02', $form->getData());
$this->assertEquals('06*2010*02', $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'timestamp',
));
$form->submit('06*2010*02');
$dateTime = new \DateTime('2010-06-02 UTC');
$this->assertEquals($dateTime->format('U'), $form->getData());
$this->assertEquals('06*2010*02', $form->getViewData());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'format' => 'MM*yyyy*dd',
'widget' => 'single_text',
'input' => 'array',
));
$form->submit('06*2010*02');
$output = array(
'day' => '2',
'month' => '6',
'year' => '2010',
);
$this->assertEquals($output, $form->getData());
$this->assertEquals('06*2010*02', $form->getViewData());
}
/**
* @dataProvider provideDateFormats
*/
public function <API key>($format, $pattern)
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => $format,
))
->createView();
$this->assertEquals($pattern, $view->vars['date_pattern']);
}
public function provideDateFormats()
{
return array(
array('dMy', '{{ day }}{{ month }}{{ year }}'),
array('d-M-yyyy', '{{ day }}-{{ month }}-{{ year }}'),
array('M d y', '{{ month }} {{ day }} {{ year }}'),
);
}
/**
* This test is to check that the strings '0', '1', '2', '3' are not accepted
* as valid IntlDateFormatter constants for FULL, LONG, MEDIUM or SHORT respectively.
*
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'format' => '0',
'widget' => 'single_text',
'input' => 'string',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
* @<API key> The "format" option should contain the letters "y", "M" and "d". Its current value is "yy".
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'months' => array(6, 7),
'format' => 'yy',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
* @<API key> The "format" option should contain the letters "y", "M" or "d". Its current value is "wrong".
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
'format' => 'wrong',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'format' => 105,
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'format' => array(),
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'years' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'months' => 'bad value',
));
}
/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\<API key>
*/
public function <API key>()
{
$this->factory->create(static::TESTED_TYPE, null, array(
'days' => 'bad value',
));
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'America/New_York',
'input' => 'string',
'widget' => 'single_text',
));
$form->setData('2010-06-02');
// 2010-06-02 00:00:00 UTC
// 2010-06-01 20:00:00 UTC-4
$this->assertEquals('01.06.2010', $form->getViewData());
}
public function <API key>()
{
// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_DE');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::MEDIUM,
'model_timezone' => 'UTC',
'view_timezone' => 'America/New_York',
'input' => 'datetime',
'widget' => 'single_text',
));
$dateTime = new \DateTime('2010-06-02 UTC');
$form->setData($dateTime);
// 2010-06-02 00:00:00 UTC
// 2010-06-01 20:00:00 UTC-4
$this-><API key>($dateTime, $form->getData());
$this->assertEquals('01.06.2010', $form->getViewData());
}
public function testYearsOption()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'years' => array(2010, 2011),
));
$view = $form->createView();
$this->assertEquals(array(
new ChoiceView('2010', '2010', '2010'),
new ChoiceView('2011', '2011', '2011'),
), $view['year']->vars['choices']);
}
public function testMonthsOption()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'months' => array(6, 7),
'format' => \IntlDateFormatter::SHORT,
));
$view = $form->createView();
$this->assertEquals(array(
new ChoiceView(6, '6', '06'),
new ChoiceView(7, '7', '07'),
), $view['month']->vars['choices']);
}
public function <API key>()
{
// we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this, '57.1');
\Locale::setDefault('de_AT');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'months' => array(1, 4),
'format' => 'dd.MMM.yy',
));
$view = $form->createView();
$this->assertEquals(array(
new ChoiceView(1, '1', 'Jän.'),
new ChoiceView(4, '4', 'Apr.'),
), $view['month']->vars['choices']);
}
public function <API key>()
{
// we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT');
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'months' => array(1, 4),
'format' => 'dd.MMMM.yy',
))
->createView();
$this->assertEquals(array(
new ChoiceView(1, '1', 'Jänner'),
new ChoiceView(4, '4', 'April'),
), $view['month']->vars['choices']);
}
public function <API key>()
{
// we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT');
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'months' => array(1, 4),
'format' => 'dd.MMMM.yy',
))
->createView();
$this->assertEquals(array(
new ChoiceView(1, '1', 'Jänner'),
new ChoiceView(4, '4', 'April'),
), $view['month']->vars['choices']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'days' => array(6, 7),
))
->createView();
$this->assertEquals(array(
new ChoiceView(6, '6', '06'),
new ChoiceView(7, '7', '07'),
), $view['day']->vars['choices']);
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));
$form->submit(array(
'day' => '',
'month' => '',
'year' => '',
));
$this->assertTrue($form->isSynchronized());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, new \DateTime(), array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));
$form->submit(array(
'day' => '1',
'month' => '6',
'year' => '2010',
));
$this->assertTrue($form->isSynchronized());
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'model_timezone' => 'UTC',
'view_timezone' => 'UTC',
'widget' => 'choice',
));
$form->submit(array(
'day' => '',
'month' => '6',
'year' => '2010',
));
$this->assertFalse($form->isSynchronized());
}
public function <API key>()
{
// we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT');
$view = $this->factory->create(static::TESTED_TYPE)
->createView();
$this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
}
public function <API key>()
{
// we test against "de_AT", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('de_AT');
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => \IntlDateFormatter::LONG,
))
->createView();
$this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => 'MMyyyydd',
))
->createView();
$this->assertSame('{{ month }}{{ year }}{{ day }}', $view->vars['date_pattern']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'format' => 'MM*yyyy*dd',
))
->createView();
$this->assertSame('{{ month }}*{{ year }}*{{ day }}', $view->vars['date_pattern']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
))
->createView();
$this->assertFalse(isset($view->vars['date_pattern']));
}
public function <API key>()
{
// we test against "es_ES", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);
\Locale::setDefault('es_ES');
$view = $this->factory->create(static::TESTED_TYPE, null, array(
// EEEE, d 'de' MMMM 'de' y
'format' => \IntlDateFormatter::FULL,
))
->createView();
$this->assertEquals('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
))
->createView();
$this->assertSame('single_text', $view->vars['widget']);
}
public function <API key>()
{
// Throws an exception if "data_class" option is not explicitly set
// to null in the type
$this->assertInstanceOf('Symfony\Component\Form\FormInterface', $this->factory->create(static::TESTED_TYPE, new \DateTime()));
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
))
->createView();
$this->assertEquals('date', $view->vars['type']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'required' => false,
))
->createView();
$this->assertSame('', $view['year']->vars['placeholder']);
$this->assertSame('', $view['month']->vars['placeholder']);
$this->assertSame('', $view['day']->vars['placeholder']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'required' => true,
))
->createView();
$this->assertNull($view['year']->vars['placeholder']);
$this->assertNull($view['month']->vars['placeholder']);
$this->assertNull($view['day']->vars['placeholder']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'placeholder' => 'Empty',
))
->createView();
$this->assertSame('Empty', $view['year']->vars['placeholder']);
$this->assertSame('Empty', $view['month']->vars['placeholder']);
$this->assertSame('Empty', $view['day']->vars['placeholder']);
}
/**
* @group legacy
*/
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'empty_value' => 'Empty',
))
->createView();
$this->assertSame('Empty', $view['year']->vars['placeholder']);
$this->assertSame('Empty', $view['month']->vars['placeholder']);
$this->assertSame('Empty', $view['day']->vars['placeholder']);
$this->assertSame('Empty', $view['year']->vars['empty_value']);
$this->assertSame('Empty', $view['month']->vars['empty_value']);
$this->assertSame('Empty', $view['day']->vars['empty_value']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'placeholder' => array(
'year' => 'Empty year',
'month' => 'Empty month',
'day' => 'Empty day',
),
))
->createView();
$this->assertSame('Empty year', $view['year']->vars['placeholder']);
$this->assertSame('Empty month', $view['month']->vars['placeholder']);
$this->assertSame('Empty day', $view['day']->vars['placeholder']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'required' => false,
'placeholder' => array(
'year' => 'Empty year',
'day' => 'Empty day',
),
))
->createView();
$this->assertSame('Empty year', $view['year']->vars['placeholder']);
$this->assertSame('', $view['month']->vars['placeholder']);
$this->assertSame('Empty day', $view['day']->vars['placeholder']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'required' => true,
'placeholder' => array(
'year' => 'Empty year',
'day' => 'Empty day',
),
))
->createView();
$this->assertSame('Empty year', $view['year']->vars['placeholder']);
$this->assertNull($view['month']->vars['placeholder']);
$this->assertSame('Empty day', $view['day']->vars['placeholder']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
))
->createView();
$this->assertSame('date', $view->vars['type']);
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
'html5' => false,
))
->createView();
$this->assertFalse(isset($view->vars['type']));
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
'format' => \IntlDateFormatter::MEDIUM,
))
->createView();
$this->assertFalse(isset($view->vars['type']));
}
public function <API key>()
{
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'text',
))
->createView();
$this->assertFalse(isset($view->vars['type']));
}
public function <API key>()
{
return array(
array('text'),
array('choice'),
);
}
/**
* @dataProvider <API key>
*/
public function <API key>($widget)
{
$error = new FormError('Invalid!');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => $widget,
));
$form['year']->addError($error);
$this->assertSame(array(), iterator_to_array($form['year']->getErrors()));
$this->assertSame(array($error), iterator_to_array($form->getErrors()));
}
/**
* @dataProvider <API key>
*/
public function <API key>($widget)
{
$error = new FormError('Invalid!');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => $widget,
));
$form['month']->addError($error);
$this->assertSame(array(), iterator_to_array($form['month']->getErrors()));
$this->assertSame(array($error), iterator_to_array($form->getErrors()));
}
/**
* @dataProvider <API key>
*/
public function <API key>($widget)
{
$error = new FormError('Invalid!');
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => $widget,
));
$form['day']->addError($error);
$this->assertSame(array(), iterator_to_array($form['day']->getErrors()));
$this->assertSame(array($error), iterator_to_array($form->getErrors()));
}
public function <API key>()
{
if (4 !== PHP_INT_SIZE) {
$this->markTestSkipped('PHP 32 bit is required.');
}
$view = $this->factory->create(static::TESTED_TYPE, null, array(
'years' => range(1900, 2040),
))
->createView();
$listChoices = array();
foreach (range(1902, 2037) as $y) {
$listChoices[] = new ChoiceView($y, $y, $y);
}
$this->assertEquals($listChoices, $view['year']->vars['choices']);
}
public function testSubmitNull($expected = null, $norm = null, $view = null)
{
parent::testSubmitNull($expected, $norm, array('year' => '', 'month' => '', 'day' => ''));
}
public function <API key>()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'widget' => 'single_text',
));
$form->submit(null);
$this->assertNull($form->getData());
$this->assertNull($form->getNormData());
$this->assertSame('', $form->getViewData());
}
}
|
/**
* CCITT Fax Group 3 and 4 decompression
* @file
* @author Konstantin Shishkov
*/
#ifndef AVCODEC_FAXCOMPR_H
#define AVCODEC_FAXCOMPR_H
#include "avcodec.h"
#include "tiff.h"
/**
* initialize upacker code
*/
void <API key>(void);
/**
* unpack data compressed with CCITT Group 3 1/2-D or Group 4 method
*/
int ff_ccitt_unpack(AVCodecContext *avctx,
const uint8_t *src, int srcsize,
uint8_t *dst, int height, int stride,
enum TiffCompr compr, int opts);
#endif /* AVCODEC_FAXCOMPR_H */
|
module Katello
module UINotifications
module Subscriptions
class SCADisableSuccess < UINotifications::<API key>
private
def blueprint
@blueprint ||= <API key>.find_by(name: 'sca_disable_success')
end
end
end
end
end
|
<?php
namespace TYPO3\CMS\Workspaces\Controller;
use TYPO3\CMS\Backend\Utility\BackendUtility;
use TYPO3\CMS\Core\Imaging\Icon;
use TYPO3\CMS\Core\Utility\<API key>;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
use TYPO3\CMS\Workspaces\Service\WorkspaceService;
/**
* Review controller.
*/
class ReviewController extends AbstractController
{
/**
* Set up the doc header properly here
*
* @param ViewInterface $view
*/
protected function initializeView(ViewInterface $view)
{
parent::initializeView($view);
$this->registerButtons();
$this->view->getModuleTemplate()-><API key>($this->controllerContext-><API key>());
}
/**
* Registers the DocHeader buttons
*/
protected function registerButtons()
{
$buttonBar = $this->view->getModuleTemplate()-><API key>()->getButtonBar();
$currentRequest = $this->request;
$moduleName = $currentRequest->getPluginName();
$getVars = $this->request->getArguments();
$extensionName = $currentRequest-><API key>();
if (count($getVars) === 0) {
$modulePrefix = strtolower('tx_' . $extensionName . '_' . $moduleName);
$getVars = array('id', 'M', $modulePrefix);
}
$shortcutButton = $buttonBar->makeShortcutButton()
->setModuleName($moduleName)
->setGetVariables($getVars);
$buttonBar->addButton($shortcutButton);
}
/**
* Renders the review module user dependent with all workspaces.
* The module will show all records of one workspace.
*
* @return void
*/
public function indexAction()
{
/** @var WorkspaceService $wsService */
$wsService = GeneralUtility::makeInstance(WorkspaceService::class);
$this->view->assign('showGrid', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
$this->view->assign('showAllWorkspaceTab', true);
$this->view->assign('pageUid', GeneralUtility::_GP('id'));
if (GeneralUtility::_GP('id')) {
$pageRecord = BackendUtility::getRecord('pages', GeneralUtility::_GP('id'));
if ($pageRecord) {
$this->view->getModuleTemplate()-><API key>()->setMetaInformation($pageRecord);
$this->view->assign('pageTitle', BackendUtility::getRecordTitle('pages', $pageRecord));
}
}
$this->view->assign('showLegend', !($GLOBALS['BE_USER']->workspace === 0 && !$GLOBALS['BE_USER']->isAdmin()));
$wsList = $wsService-><API key>();
$activeWorkspace = $GLOBALS['BE_USER']->workspace;
$<API key> = false;
// Only admins see multiple tabs, we decided to use it this
// way for usability reasons. Regular users might be confused
// by switching workspaces with the tabs in a module.
if (!$GLOBALS['BE_USER']->isAdmin()) {
$wsCur = array($activeWorkspace => true);
$wsList = array_intersect_key($wsList, $wsCur);
} else {
if ((string)GeneralUtility::_GP('workspace') !== '') {
$switchWs = (int)GeneralUtility::_GP('workspace');
if (in_array($switchWs, array_keys($wsList)) && $activeWorkspace != $switchWs) {
$activeWorkspace = $switchWs;
$GLOBALS['BE_USER']->setWorkspace($activeWorkspace);
$<API key> = true;
BackendUtility::setUpdateSignal('updatePageTree');
} elseif ($switchWs == WorkspaceService::<API key>) {
$this->redirect('fullIndex');
}
}
}
$this->pageRenderer->addInlineSetting('Workspaces', 'isLiveWorkspace', (int)$GLOBALS['BE_USER']->workspace === 0);
$this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this-><API key>($wsList, $activeWorkspace));
$this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', $activeWorkspace);
$this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit'));
$this->view->assign('<API key>', $<API key>);
$this->view->assign('workspaceList', $wsList);
$this->view->assign('activeWorkspaceUid', $activeWorkspace);
$this->view->assign('<API key>', WorkspaceService::getWorkspaceTitle($activeWorkspace));
if ($wsService-><API key>(GeneralUtility::_GP('id'), $activeWorkspace)) {
$buttonBar = $this->view->getModuleTemplate()-><API key>()->getButtonBar();
$iconFactory = $this->view->getModuleTemplate()->getIconFactory();
$showButton = $buttonBar->makeLinkButton()
->setHref('
->setOnClick('TYPO3.Workspaces.Actions.<API key>();return false;')
->setTitle($this->getLanguageService()->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:tooltip.generatePagePreview'))
->setIcon($iconFactory->getIcon('<API key>', Icon::SIZE_SMALL));
$buttonBar->addButton($showButton);
}
$this->view->assign('showPreviewLink', $wsService-><API key>(GeneralUtility::_GP('id'), $activeWorkspace));
$GLOBALS['BE_USER']-><API key>('<API key>', $activeWorkspace);
}
/**
* Renders the review module user dependent.
* The module will show all records of all workspaces.
*
* @return void
*/
public function fullIndexAction()
{
$wsService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
$wsList = $wsService-><API key>();
if (!$GLOBALS['BE_USER']->isAdmin()) {
$activeWorkspace = $GLOBALS['BE_USER']->workspace;
$wsCur = array($activeWorkspace => true);
$wsList = array_intersect_key($wsList, $wsCur);
}
$this->pageRenderer->addInlineSetting('Workspaces', 'workspaceTabs', $this-><API key>($wsList, WorkspaceService::<API key>));
$this->pageRenderer->addInlineSetting('Workspaces', 'activeWorkspaceId', WorkspaceService::<API key>);
$this->view->assign('pageUid', GeneralUtility::_GP('id'));
$this->view->assign('showGrid', true);
$this->view->assign('showLegend', true);
$this->view->assign('showAllWorkspaceTab', true);
$this->view->assign('workspaceList', $wsList);
$this->view->assign('activeWorkspaceUid', WorkspaceService::<API key>);
$this->view->assign('showPreviewLink', false);
$GLOBALS['BE_USER']-><API key>('<API key>', WorkspaceService::<API key>);
// set flag for javascript
$this->pageRenderer->addInlineSetting('Workspaces', 'allView', '1');
}
/**
* Renders the review module for a single page. This is used within the
* workspace-preview frame.
*
* @return void
*/
public function singleIndexAction()
{
$wsService = GeneralUtility::makeInstance(\TYPO3\CMS\Workspaces\Service\WorkspaceService::class);
$wsList = $wsService-><API key>();
$activeWorkspace = $GLOBALS['BE_USER']->workspace;
$wsCur = array($activeWorkspace => true);
$wsList = array_intersect_key($wsList, $wsCur);
$backendDomain = GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY');
$this->view->assign('pageUid', GeneralUtility::_GP('id'));
$this->view->assign('showGrid', true);
$this->view->assign('showAllWorkspaceTab', false);
$this->view->assign('workspaceList', $wsList);
$this->view->assign('backendDomain', $backendDomain);
// Setting the document.domain early before JavScript
// libraries are loaded, try to access top frame reference
// and possibly run into some CORS issue
$this->pageRenderer->setMetaCharsetTag(
$this->pageRenderer->getMetaCharsetTag() . LF
. GeneralUtility::wrapJS('document.domain = ' . GeneralUtility::quoteJSvalue($backendDomain) . ';')
);
$this->pageRenderer->addInlineSetting('Workspaces', 'singleView', '1');
}
/**
* Initializes the controller before invoking an action method.
*
* @return void
*/
protected function initializeAction()
{
parent::initializeAction();
$backendRelPath = <API key>::extRelPath('backend');
$this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/ExtDirect.StateProvider.js');
if (WorkspaceService::<API key>()) {
$flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $GLOBALS['LANG']->sL('LLL:EXT:workspaces/Resources/Private/Language/locallang.xlf:warning.<API key>'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
/** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
/** @var $<API key> \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
$<API key> = $flashMessageService-><API key>();
$<API key>->enqueue($flashMessage);
}
$this->pageRenderer->loadExtJS();
$states = $GLOBALS['BE_USER']->uc['moduleData']['Workspaces']['States'];
$this->pageRenderer->addInlineSetting('Workspaces', 'States', $states);
// Load JavaScript:
$this->pageRenderer->addExtDirectCode(array(
'TYPO3.Workspaces'
));
$this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.grid.RowExpander.js');
$this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.app.SearchField.js');
$this->pageRenderer->addJsFile($backendRelPath . 'Resources/Public/JavaScript/extjs/ux/Ext.ux.FitToParent.js');
$resourcePath = <API key>::extRelPath('workspaces') . 'Resources/Public/JavaScript/';
// @todo Integrate additional stylesheet resources
$this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/GridFilters.css');
$this->pageRenderer->addCssFile($resourcePath . 'gridfilters/css/RangeMenu.css');
$filters = array(
$resourcePath . 'gridfilters/menu/RangeMenu.js',
$resourcePath . 'gridfilters/menu/ListMenu.js',
$resourcePath . 'gridfilters/GridFilters.js',
$resourcePath . 'gridfilters/filter/Filter.js',
$resourcePath . 'gridfilters/filter/StringFilter.js',
$resourcePath . 'gridfilters/filter/DateFilter.js',
$resourcePath . 'gridfilters/filter/ListFilter.js',
$resourcePath . 'gridfilters/filter/NumericFilter.js',
$resourcePath . 'gridfilters/filter/BooleanFilter.js',
$resourcePath . 'gridfilters/filter/BooleanFilter.js',
);
$custom = $this-><API key>()-><API key>();
$resources = array(
$resourcePath . 'Component/RowDetailTemplate.js',
$resourcePath . 'Component/RowExpander.js',
$resourcePath . 'Component/TabPanel.js',
$resourcePath . 'Store/mainstore.js',
$resourcePath . 'configuration.js',
$resourcePath . 'helpers.js',
$resourcePath . 'actions.js',
$resourcePath . 'component.js',
$resourcePath . 'toolbar.js',
$resourcePath . 'grid.js',
$resourcePath . 'workspaces.js'
);
$javaScriptFiles = array_merge($filters, $custom, $resources);
foreach ($javaScriptFiles as $javaScriptFile) {
$this->pageRenderer->addJsFile($javaScriptFile);
}
foreach ($this-><API key>()-><API key>() as $<API key>) {
$this->pageRenderer-><API key>($<API key>);
}
$this->pageRenderer->addInlineSetting('FormEngine', 'moduleUrl', BackendUtility::getModuleUrl('record_edit'));
$this->pageRenderer->addInlineSetting('RecordHistory', 'moduleUrl', BackendUtility::getModuleUrl('record_history'));
}
/**
* Prepares available workspace tabs.
*
* @param array $workspaceList
* @param int $activeWorkspace
* @return array
*/
protected function <API key>(array $workspaceList, $activeWorkspace)
{
$tabs = array();
if ($activeWorkspace !== WorkspaceService::<API key>) {
$tabs[] = array(
'title' => $workspaceList[$activeWorkspace],
'itemId' => 'workspace-' . $activeWorkspace,
'workspaceId' => $activeWorkspace,
'triggerUrl' => $this->getModuleUri($activeWorkspace),
);
}
$tabs[] = array(
'title' => 'All workspaces',
'itemId' => 'workspace-' . WorkspaceService::<API key>,
'workspaceId' => WorkspaceService::<API key>,
'triggerUrl' => $this->getModuleUri(WorkspaceService::<API key>),
);
foreach ($workspaceList as $workspaceId => $workspaceTitle) {
if ($workspaceId === $activeWorkspace) {
continue;
}
$tabs[] = array(
'title' => $workspaceTitle,
'itemId' => 'workspace-' . $workspaceId,
'workspaceId' => $workspaceId,
'triggerUrl' => $this->getModuleUri($workspaceId),
);
}
return $tabs;
}
/**
* Gets the module URI.
*
* @param int $workspaceId
* @return string
*/
protected function getModuleUri($workspaceId)
{
$parameters = array(
'id' => (int)$this->pageId,
'workspace' => (int)$workspaceId,
);
// The "all workspaces" tab is handled in fullIndexAction
// which is required as additional GET parameter in the URI then
if ($workspaceId === WorkspaceService::<API key>) {
$this->uriBuilder->reset()->uriFor('fullIndex');
$parameters = array_merge($parameters, $this->uriBuilder->getArguments());
}
return BackendUtility::getModuleUrl('<API key>', $parameters);
}
/**
* @return \TYPO3\CMS\Lang\LanguageService
*/
protected function getLanguageService()
{
return $GLOBALS['LANG'];
}
}
|
#ifndef MDSS_DSI_H
#define MDSS_DSI_H
#include <linux/list.h>
#include <linux/mdss_io_util.h>
#include <mach/scm-io.h>
#include <linux/irqreturn.h>
#include <linux/pinctrl/consumer.h>
#include "mdss_panel.h"
#include "mdss_dsi_cmd.h"
#define <API key> 0x04f01000 /* mmss (De)Serializer CFG */
#define MIPI_OUTP(addr, data) writel_relaxed((data), (addr))
#define MIPI_INP(addr) readl_relaxed(addr)
#define MIPI_OUTP_SECURE(addr, data) writel_relaxed((data), (addr))
#define MIPI_INP_SECURE(addr) readl_relaxed(addr)
#define MIPI_DSI_PRIM 1
#define MIPI_DSI_SECD 2
#define MIPI_DSI_PANEL_VGA 0
#define MIPI_DSI_PANEL_WVGA 1
#define <API key> 2
#define <API key> 3
#define <API key> 4
#define <API key> 5
#define MIPI_DSI_PANEL_WXGA 6
#define <API key> 7
#define <API key> 8
#define DSI_PANEL_MAX 8
enum { /* mipi dsi panel */
DSI_VIDEO_MODE,
DSI_CMD_MODE,
};
enum {
ST_DSI_CLK_OFF,
ST_DSI_SUSPEND,
ST_DSI_RESUME,
ST_DSI_PLAYING,
ST_DSI_NUM
};
enum {
EV_DSI_UPDATE,
EV_DSI_DONE,
EV_DSI_TOUT,
EV_DSI_NUM
};
enum {
LANDSCAPE = 1,
PORTRAIT = 2,
};
enum dsi_trigger_type {
DSI_CMD_MODE_DMA,
DSI_CMD_MODE_MDP,
};
enum dsi_panel_bl_ctrl {
UNKNOWN_CTRL,
BL_PWM,
BL_WLED,
BL_DCS_CMD,
BL_EXTERNAL,
};
enum dsi_ctrl_op_mode {
DSI_LP_MODE,
DSI_HS_MODE,
};
enum dsi_lane_map_type {
DSI_LANE_MAP_0123,
DSI_LANE_MAP_3012,
DSI_LANE_MAP_2301,
DSI_LANE_MAP_1230,
DSI_LANE_MAP_0321,
DSI_LANE_MAP_1032,
DSI_LANE_MAP_2103,
DSI_LANE_MAP_3210,
};
#define CTRL_STATE_UNKNOWN 0x00
#define <API key> BIT(0)
#define <API key> BIT(1)
#define <API key> 0
#define <API key> 1
#define DSI_BURST_MODE 2
#define DSI_RGB_SWAP_RGB 0
#define DSI_RGB_SWAP_RBG 1
#define DSI_RGB_SWAP_BGR 2
#define DSI_RGB_SWAP_BRG 3
#define DSI_RGB_SWAP_GRB 4
#define DSI_RGB_SWAP_GBR 5
#define <API key> 0
#define <API key> 1
#define <API key> 2
#define <API key> 3
#define <API key> 0
#define <API key> 3
#define <API key> 4
#define <API key> 6
#define <API key> 7
#define <API key> 8
#define DSI_INTR_ERROR_MASK BIT(25)
#define DSI_INTR_ERROR BIT(24)
#define <API key> BIT(21)
#define DSI_INTR_BTA_DONE BIT(20)
#define <API key> BIT(17)
#define DSI_INTR_VIDEO_DONE BIT(16)
#define <API key> BIT(9)
#define <API key> BIT(8)
#define <API key> BIT(1)
#define <API key> BIT(0)
#define <API key> 0x0 /* mdp trigger */
#define DSI_CMD_TRIGGER_TE 0x02
#define DSI_CMD_TRIGGER_SW 0x04
#define <API key> 0x05 /* cmd dma only */
#define <API key> 0x06
#define DSI_VIDEO_TERM BIT(16)
#define DSI_MDP_TERM BIT(8)
#define DSI_BTA_TERM BIT(1)
#define DSI_CMD_TERM BIT(0)
extern struct device dsi_dev;
extern u32 dsi_irq;
extern struct mdss_dsi_ctrl_pdata *ctrl_list[];
struct <API key> {
u32 clk_rate;
u32 fb_divider;
u32 ref_divider_ratio;
u32 bit_clk_divider; /* oCLK1 */
u32 byte_clk_divider; /* oCLK2 */
u32 analog_posDiv;
u32 digital_posDiv;
};
extern struct <API key> pll_divider_config;
struct dsi_clk_mnd_table {
u8 lanes;
u8 bpp;
u8 pll_digital_posDiv;
u8 pclk_m;
u8 pclk_n;
u8 pclk_d;
};
static const struct dsi_clk_mnd_table mnd_table[] = {
{ 1, 2, 8, 1, 1, 0},
{ 1, 3, 12, 1, 1, 0},
{ 2, 2, 4, 1, 1, 0},
{ 2, 3, 6, 1, 1, 0},
{ 3, 2, 1, 3, 8, 4},
{ 3, 3, 4, 1, 1, 0},
{ 4, 2, 2, 1, 1, 0},
{ 4, 3, 3, 1, 1, 0},
};
struct dsi_clk_desc {
u32 src;
u32 m;
u32 n;
u32 d;
u32 mnd_mode;
u32 pre_div_func;
};
struct dsi_panel_cmds {
char *buf;
int blen;
struct dsi_cmd_desc *cmds;
int cmd_cnt;
int link_state;
};
struct dsi_kickoff_action {
struct list_head act_entry;
void (*action) (void *);
void *data;
};
struct dsi_drv_cm_data {
struct regulator *vdd_vreg;
struct regulator *vdd_io_vreg;
struct regulator *vdda_vreg;
int broadcast_enable;
};
struct dsi_pinctrl_res {
struct pinctrl *pinctrl;
struct pinctrl_state *gpio_state_active;
struct pinctrl_state *gpio_state_suspend;
};
enum {
DSI_CTRL_0,
DSI_CTRL_1,
DSI_CTRL_MAX,
};
/* DSI controller #0 is always treated as a master in broadcast mode */
#define DSI_CTRL_MASTER DSI_CTRL_0
#define DSI_CTRL_SLAVE DSI_CTRL_1
#define DSI_BUS_CLKS BIT(0)
#define DSI_LINK_CLKS BIT(1)
#define DSI_ALL_CLKS ((DSI_BUS_CLKS) | (DSI_LINK_CLKS))
#define DSI_EV_PLL_UNLOCKED 0x0001
#define <API key> 0x0002
#define <API key> 0x80000000
struct mdss_dsi_ctrl_pdata {
int ndx; /* panel_num */
int (*on) (struct mdss_panel_data *pdata);
int (*off) (struct mdss_panel_data *pdata);
int (*partial_update_fnc) (struct mdss_panel_data *pdata);
int (*check_status) (struct mdss_dsi_ctrl_pdata *pdata);
int (*cmdlist_commit)(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp);
struct mdss_panel_data panel_data;
unsigned char *ctrl_base;
struct dss_io_data ctrl_io;
struct dss_io_data mmss_misc_io;
struct dss_io_data phy_io;
int reg_size;
u32 bus_clk_cnt;
u32 link_clk_cnt;
u32 flags;
struct clk *mdp_core_clk;
struct clk *ahb_clk;
struct clk *axi_clk;
struct clk *mmss_misc_ahb_clk;
struct clk *byte_clk;
struct clk *esc_clk;
struct clk *pixel_clk;
u8 ctrl_state;
int panel_mode;
int irq_cnt;
int rst_gpio;
int disp_en_gpio;
int disp_te_gpio;
int bklt_en_gpio;
int mode_gpio;
int <API key>;
int bklt_ctrl; /* backlight ctrl */
int pwm_period;
int pwm_pmic_gpio;
int pwm_lpg_chan;
int bklt_max;
int new_fps;
int pwm_enabled;
int idle;
bool blanked;
struct pwm_device *pwm_bl;
struct dsi_drv_cm_data shared_pdata;
u32 pclk_rate;
u32 byte_clk_rate;
struct dss_module_power power_data;
u32 dsi_irq_mask;
struct mdss_hw *dsi_hw;
struct mdss_panel_recovery *recovery;
struct dsi_panel_cmds on_cmds;
struct dsi_panel_cmds off_cmds;
struct dsi_panel_cmds idle_on_cmds;
struct dsi_panel_cmds idle_off_cmds;
struct dsi_panel_cmds <API key>;
struct dsi_panel_cmds <API key>;
struct dcs_cmd_list cmdlist;
struct completion dma_comp;
struct completion mdp_comp;
struct completion video_comp;
struct completion bta_comp;
spinlock_t irq_lock;
spinlock_t mdp_lock;
int mdp_busy;
struct mutex mutex;
struct mutex cmd_mutex;
struct mutex suspend_mutex;
bool ulps;
struct mutex ulps_lock;
unsigned int ulps_ref_count;
struct dsi_buf tx_buf;
struct dsi_buf rx_buf;
struct dsi_pinctrl_res pin_res;
};
int <API key>(struct device_node *pan_node,
struct mdss_dsi_ctrl_pdata *ctrl_pdata);
int mdss_dsi_cmds_tx(struct mdss_dsi_ctrl_pdata *ctrl,
struct dsi_cmd_desc *cmds, int cnt);
int mdss_dsi_cmds_rx(struct mdss_dsi_ctrl_pdata *ctrl,
struct dsi_cmd_desc *cmds, int rlen);
void mdss_dsi_host_init(struct mdss_panel_data *pdata);
void <API key>(int mode,
struct mdss_panel_data *pdata);
void <API key>(int enable);
void <API key>(void);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void <API key>(struct mdss_panel_data *pdata);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
int mdss_dsi_clk_ctrl(struct mdss_dsi_ctrl_pdata *ctrl,
u8 clk_type, int enable);
void mdss_dsi_clk_req(struct mdss_dsi_ctrl_pdata *ctrl,
int enable);
void <API key>(int enable,
struct mdss_panel_data *pdata);
void mdss_dsi_sw_reset(struct mdss_panel_data *pdata);
irqreturn_t mdss_dsi_isr(int irq, void *ptr);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl_pdata);
void <API key>(int mode, struct mdss_panel_data *pdata);
int <API key>(struct mdss_panel_info *panel_info,
int frame_rate);
int mdss_dsi_clk_init(struct platform_device *pdev,
struct mdss_dsi_ctrl_pdata *ctrl_pdata);
void mdss_dsi_clk_deinit(struct mdss_dsi_ctrl_pdata *ctrl_pdata);
int <API key>(struct mdss_dsi_ctrl_pdata *ctrl_pdata);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl_pdata);
int <API key>(struct mdss_panel_data *pdata, int enable);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void mdss_dsi_phy_init(struct mdss_panel_data *pdata);
void <API key>(unsigned char *ctrl_base);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void mdss_dsi_ctrl_init(struct mdss_dsi_ctrl_pdata *ctrl);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
int <API key>(struct mdss_dsi_ctrl_pdata *ctrl, int from_mdp);
void <API key>(int intf);
int <API key>(struct mdss_dsi_ctrl_pdata *ctrl);
bool <API key>(struct mdss_dsi_ctrl_pdata *ctrl, u8 clk_type);
int <API key>(struct mdss_dsi_ctrl_pdata *ctrl, int enable);
int mdss_dsi_panel_init(struct device_node *node,
struct mdss_dsi_ctrl_pdata *ctrl_pdata,
bool cmd_cfg_cont_splash);
void <API key>(struct mdss_dsi_ctrl_pdata *ctrl, int enable);
static inline bool <API key>(void)
{
return ctrl_list[DSI_CTRL_MASTER]->shared_pdata.broadcast_enable &&
ctrl_list[DSI_CTRL_SLAVE] &&
ctrl_list[DSI_CTRL_SLAVE]->shared_pdata.broadcast_enable;
}
static inline struct mdss_dsi_ctrl_pdata *<API key>(void)
{
if (<API key>())
return ctrl_list[DSI_CTRL_MASTER];
else
return NULL;
}
static inline struct mdss_dsi_ctrl_pdata *<API key>(void)
{
if (<API key>())
return ctrl_list[DSI_CTRL_SLAVE];
else
return NULL;
}
static inline bool <API key>(struct mdss_dsi_ctrl_pdata *ctrl)
{
return <API key>() &&
(ctrl->ndx == DSI_CTRL_MASTER);
}
static inline bool <API key>(struct mdss_dsi_ctrl_pdata *ctrl)
{
return <API key>() &&
(ctrl->ndx == DSI_CTRL_SLAVE);
}
static inline struct mdss_dsi_ctrl_pdata *<API key>(int ndx)
{
if (ndx >= DSI_CTRL_MAX)
return NULL;
return ctrl_list[ndx];
}
#endif /* MDSS_DSI_H */
|
using System;
using System.Collections.Generic;
using System.Data;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;
using System.ComponentModel;
namespace Lcc.Entrada.Articulos
{
public partial class DetalleComprobante : <API key>
{
protected bool <API key>, m_DiscriminarIva = false, m_AplicarIva = true;
protected Precios m_Precio = Precios.Pvp;
protected ControlesSock m_ControlStock = ControlesSock.Ambos;
protected Lbl.Articulos.<API key> m_DatosSeguimiento = new Lbl.Articulos.<API key>();
protected Lbl.Impuestos.Alicuota m_Alicuota = null;
protected decimal <API key> = 0m;
new public event System.Windows.Forms.KeyEventHandler KeyDown;
public event System.EventHandler ImportesChanged;
public event System.EventHandler <API key>;
public DetalleComprobante()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (Lfx.Workspace.Master != null) {
switch (m_Precio) {
case Precios.Costo:
EntradaUnitario.DecimalPlaces = Lfx.Workspace.Master.CurrentConfig.Moneda.DecimalesCosto;
EntradaImporte.DecimalPlaces = Lfx.Workspace.Master.CurrentConfig.Moneda.DecimalesCosto;
break;
case Precios.Pvp:
EntradaUnitario.DecimalPlaces = Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales;
EntradaImporte.DecimalPlaces = Lfx.Workspace.Master.CurrentConfig.Moneda.Decimales;
break;
}
}
}
public ControlesSock ControlStock
{
get
{
return m_ControlStock;
}
set
{
m_ControlStock = value;
PonerFiltros();
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
override public bool ShowChanged
{
set
{
base.ShowChanged = value;
EntradaArticulo.ShowChanged = value;
EntradaDescuento.ShowChanged = value;
EntradaCantidad.ShowChanged = value;
EntradaUnitario.ShowChanged = value;
}
}
[EditorBrowsable(<API key>.Never),
System.ComponentModel.Browsable(false),
<API key>(<API key>.Hidden)]
public bool AutoUpdate
{
get
{
return EntradaArticulo.AutoUpdate;
}
set
{
EntradaArticulo.AutoUpdate = value;
}
}
public bool PermiteCrear
{
get
{
return EntradaArticulo.CanCreate;
}
set
{
EntradaArticulo.CanCreate = value;
}
}
[EditorBrowsable(<API key>.Never),
System.ComponentModel.Browsable(false),
<API key>(<API key>.Hidden)]
public override bool IsEmpty
{
get
{
return EntradaArticulo.IsEmpty;
}
}
[EditorBrowsable(<API key>.Never),
Browsable(false),
<API key>(<API key>.Hidden)]
new public int ValueInt
{
get
{
return EntradaArticulo.ValueInt;
}
set
{
if (EntradaArticulo.ValueInt != value)
EntradaArticulo.ValueInt = value;
}
}
[EditorBrowsable(<API key>.Never),
Browsable(false),
<API key>(<API key>.Hidden)]
public Lbl.Articulos.<API key> DatosSeguimiento
{
get
{
return m_DatosSeguimiento;
}
set
{
if (m_DatosSeguimiento != value) {
this.Changed = true;
}
m_DatosSeguimiento = value;
if (m_DatosSeguimiento == null || m_DatosSeguimiento.Count == 0) {
LabelSerials.Visible = false;
} else {
LabelSerials.Text = "Seguimiento: " + m_DatosSeguimiento.ToString();
LabelSerials.Visible = true;
if (this.Cantidad != m_DatosSeguimiento.CantidadTotal)
this.Cantidad = m_DatosSeguimiento.CantidadTotal;
}
}
}
public bool MuestraPrecio
{
get
{
return EntradaUnitario.Visible;
}
set
{
EntradaUnitario.Visible = value;
EntradaIva.Visible = value;
EntradaCantidad.Visible = value;
EntradaDescuento.Visible = value;
EntradaImporte.Visible = value;
if (value)
EntradaArticulo.Width = EntradaUnitario.Left - 1;
else
EntradaArticulo.Width = this.Width;
}
}
// Oculta al changed de abajo
[EditorBrowsable(<API key>.Never),
Browsable(false),
<API key>(<API key>.Hidden)]
new public bool Changed
{
get
{
return EntradaArticulo.Changed || EntradaCantidad.Changed || EntradaUnitario.Changed || EntradaDescuento.Changed;
}
set
{
EntradaArticulo.Changed = value;
EntradaDescuento.Changed = value;
EntradaCantidad.Changed = value;
EntradaUnitario.Changed = value;
}
}
public Precios UsarPrecio
{
get
{
return m_Precio;
}
set
{
m_Precio = value;
this.CambiarArticulo(this.Articulo);
this.Changed = false;
}
}
public bool BloquearAtriculo
{
get
{
return EntradaArticulo.TemporaryReadOnly;
}
set
{
EntradaArticulo.TemporaryReadOnly = value;
}
}
public bool BloquearCantidad
{
get
{
return EntradaCantidad.TemporaryReadOnly;
}
set
{
EntradaCantidad.TemporaryReadOnly = value;
}
}
public bool BloquearPrecio
{
get
{
return EntradaUnitario.TemporaryReadOnly;
}
set
{
EntradaUnitario.ReadOnly = value;
EntradaDescuento.ReadOnly = value || this.BloquearDescuento;
}
}
public bool BloquearDescuento
{
get
{
return EntradaDescuento.TemporaryReadOnly;
}
set
{
EntradaDescuento.ReadOnly = value || this.BloquearPrecio;
}
}
public bool MostrarExistencias
{
get
{
return <API key>;
}
set
{
<API key> = value;
VerificarStock();
}
}
<summary>
Indica si los precios se muestran con IVA discriminado.
</summary>
public bool DiscriminarIva
{
get
{
return m_DiscriminarIva;
}
set
{
bool AntesDiscriminaba = m_DiscriminarIva;
m_DiscriminarIva = value;
EntradaIva.Enabled = this.DiscriminarIva && this.AplicarIva;
if (m_DiscriminarIva != AntesDiscriminaba && m_AplicarIva && m_Alicuota != null) {
if (value) {
this.<API key>(this.ImporteUnitario / (1 + m_Alicuota.Porcentaje / 100m));
} else {
// Antes discriminaba y ahora no
this.<API key>(this.ImporteUnitario);
}
this.<API key>();
if (null != ImportesChanged) {
ImportesChanged(this, null);
}
}
this.<API key>();
}
}
<summary>
Indica si debe aplicar IVA al cliente.
</summary>
public bool AplicarIva
{
get
{
return m_AplicarIva;
}
set
{
bool AntesAplicaba = m_AplicarIva;
m_AplicarIva = value;
EntradaIva.Enabled = this.DiscriminarIva && this.AplicarIva;
if (m_AplicarIva != AntesAplicaba && m_Alicuota != null) {
decimal <API key> = this.ImporteUnitario * (m_Alicuota.Porcentaje / 100m);
if (value) {
this.<API key>(this.ImporteUnitario);
} else {
// Antes aplicaba y ahora no
this.<API key>((this.ImporteUnitario + this.<API key>) / (1m + m_Alicuota.Porcentaje / 100m));
}
this.<API key>();
if (null != ImportesChanged) {
ImportesChanged(this, null);
}
}
}
}
public bool Required
{
get
{
return EntradaArticulo.Required;
}
set
{
EntradaArticulo.Required = value;
}
}
[System.ComponentModel.Category("Datos")]
public string FreeTextCode
{
get
{
return EntradaArticulo.FreeTextCode;
}
set
{
EntradaArticulo.FreeTextCode = value;
}
}
public int UnitarioLeft
{
get
{
return EntradaUnitario.Left;
}
}
public int DescuentoLeft
{
get
{
return EntradaDescuento.Left;
}
}
public int CantidadLeft
{
get
{
return EntradaCantidad.Left;
}
}
public int IvaLeft
{
get
{
return EntradaIva.Left;
}
}
public int ImporteLeft
{
get
{
return EntradaImporte.Left;
}
}
public override string Text
{
get
{
if (EntradaArticulo.Text == EntradaArticulo.FreeTextCode && EntradaArticulo.FreeTextCode.Length > 0)
return EntradaArticulo.Text;
else
return EntradaArticulo.ValueInt.ToString();
}
set
{
if (EntradaArticulo.Text != value) {
EntradaArticulo.Text = value;
}
this.Changed = false;
}
}
public string TextDetail
{
get
{
return EntradaArticulo.TextDetail;
}
set
{
EntradaArticulo.TextDetail = value;
this.Changed = false;
}
}
<summary>
El importe final, con IVA, por cantidad y con descuento.
</summary>
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal ImporteFinal
{
get
{
return EntradaImporte.ValueDecimal;
}
set
{
EntradaImporte.ValueDecimal = value;
this.Changed = false;
}
}
<summary>
El importe de IVA unitario (sin descuento).
</summary>
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal ImporteIvaUnitario
{
get
{
return this.<API key>;
}
set
{
this.<API key> = value;
if(this.DiscriminarIva) {
this.<API key>(this, null);
}
this.Changed = false;
}
}
<summary>
El importe de IVA discriminado unitario (sin descuento), o 0 si el IVA no está discriminado.
</summary>
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal <API key>
{
get
{
return EntradaIva.ValueDecimal;
}
set
{
EntradaIva.ValueDecimal = value;
this.Changed = false;
}
}
<summary>
El importe de IVA final, por cantidad y con descuento.
</summary>
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal <API key>
{
get
{
return this.ImporteIvaUnitario * this.Cantidad * (1m - this.Descuento / 100m);
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal ImporteUnitario
{
get
{
return EntradaUnitario.ValueDecimal;
}
set
{
EntradaUnitario.ValueDecimal = value;
this.Changed = false;
}
}
<summary>
El importe unitario final, por cantidad y con descuento.
</summary>
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal <API key>
{
get
{
return this.ImporteUnitario * this.Cantidad * (1m - this.Descuento / 100m);
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal Descuento
{
get
{
return EntradaDescuento.ValueDecimal;
}
set
{
EntradaDescuento.ValueDecimal = value;
this.Changed = false;
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public Lbl.Articulos.Articulo Articulo
{
get
{
return EntradaArticulo.Elemento as Lbl.Articulos.Articulo;
}
set
{
EntradaArticulo.Elemento = value;
this.Elemento = value;
if(value == null) {
this.m_Alicuota = null;
} else {
this.m_Alicuota = value.ObtenerAlicuota();
}
<API key>(this, null);
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public Lbl.Impuestos.Alicuota Alicuota
{
get
{
return m_Alicuota;
}
}
[EditorBrowsable(<API key>.Never), Browsable(false), <API key>(<API key>.Hidden)]
public decimal Cantidad
{
get
{
if (this.<API key>())
return EntradaCantidad.ValueDecimal;
else
return EntradaCantidad.ValueDecimal / Articulo.Rendimiento;
}
set
{
if (this.<API key>())
EntradaCantidad.ValueDecimal = value;
else
EntradaCantidad.ValueDecimal = value * this.Articulo.Rendimiento;
this.Changed = false;
}
}
private bool <API key>()
{
return (this.Articulo == null || Articulo.Unidad == null || EntradaCantidad.Sufijo == Articulo.Unidad || (EntradaCantidad.Sufijo.Length == 0 && Articulo.Unidad == "u") || Articulo.Rendimiento == 0);
}
private void <API key>(object sender, System.EventArgs e)
{
if (this.Connection == null)
return;
EntradaUnitario.TabStop = EntradaArticulo.IsFreeText;
if (this.Elemento != EntradaArticulo.Elemento || EntradaArticulo.IsFreeText) {
this.Elemento = EntradaArticulo.Elemento;
if (this.Articulo != null) {
this.m_Alicuota = this.Articulo.ObtenerAlicuota();
}
this.CambiarArticulo(this.Articulo);
}
this.DatosSeguimiento = null;
this.Changed = true;
this.OnTextChanged(EventArgs.Empty);
}
private void <API key>(object sender, System.EventArgs e)
{
if (this.Connection != null) {
decimal ValorAnterior = EntradaImporte.ValueDecimal;
this.<API key>();
this.VerificarStock();
if (EntradaImporte.ValueDecimal != ValorAnterior) {
this.Changed = true;
if (null != ImportesChanged) {
ImportesChanged(this, null);
}
}
}
}
private void VerificarStock()
{
if (<API key> && Articulo != null) {
if (this.TemporaryReadOnly == false && this.Articulo.TipoDeArticulo != Lbl.Articulos.TiposDeArticulo.Servicio && this.Articulo.Existencias < this.Cantidad) {
if (this.Articulo.Existencias + this.Articulo.Pedido >= this.Cantidad) {
//EntradaArticulo.Font = null;
EntradaArticulo.ForeColor = Color.OrangeRed;
} else {
//EntradaArticulo.Font = new Font(this.Font, FontStyle.Strikeout);
EntradaArticulo.ForeColor = Color.Red;
}
} else {
//EntradaArticulo.Font = null;
EntradaArticulo.ForeColor = this.DisplayStyle.TextColor;
}
} else {
//EntradaArticulo.Font = null;
EntradaArticulo.ForeColor = this.DisplayStyle.TextColor;
}
}
public override bool TemporaryReadOnly
{
get
{
return base.TemporaryReadOnly;
}
set
{
base.TemporaryReadOnly = value;
if (value) {
EntradaArticulo.TemporaryReadOnly = true;
EntradaUnitario.TemporaryReadOnly = true;
EntradaDescuento.TemporaryReadOnly = true;
EntradaCantidad.TemporaryReadOnly = true;
}
this.VerificarStock();
}
}
private void <API key>(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (e.Alt == false && e.Control == false && e.Shift == false) {
switch (e.KeyCode) {
case Keys.Right:
case Keys.Return:
e.Handled = true;
if (EntradaUnitario.Visible && this.ReadOnly == false && this.TemporaryReadOnly == false) {
if (this.BloquearPrecio)
EntradaCantidad.Focus();
else
EntradaUnitario.Focus();
} else {
System.Windows.Forms.SendKeys.Send("{tab}");
}
break;
default:
if (KeyDown != null)
KeyDown(sender, e);
this.AutoUpdate = true;
break;
}
}
if (e.Alt == false && e.Control == true && e.Shift == false) {
switch (e.KeyCode) {
case Keys.S:
this.<API key>();
break;
}
}
}
protected void <API key>()
{
if (this.Articulo != null && this.Articulo.ObtenerSeguimiento() != Lbl.Articulos.Seguimientos.Ninguno && this.<API key> != null)
this.<API key>(this, new EventArgs());
}
protected override void OnLeave(EventArgs e)
{
Lbl.Articulos.Articulo Art = this.Elemento as Lbl.Articulos.Articulo;
if (this.Cantidad != 0 && Art != null && Art.ObtenerSeguimiento() != Lbl.Articulos.Seguimientos.Ninguno && (this.DatosSeguimiento == null || this.DatosSeguimiento.Count != this.Cantidad)) {
this.<API key>();
}
base.OnLeave(e);
}
private void <API key>(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode) {
case Keys.E:
if (e.Control) {
EntradaUnitario.SelectionLength = 0;
EntradaUnitario.SelectionStart = EntradaUnitario.Text.Length;
e.Handled = true;
}
break;
case Keys.Left:
if (EntradaUnitario.SelectionStart == 0) {
e.Handled = true;
EntradaArticulo.Focus();
}
break;
case Keys.Right:
case Keys.Return:
if (EntradaUnitario.SelectionStart >= EntradaUnitario.TextRaw.Length || EntradaUnitario.SelectionLength > 0) {
e.Handled = true;
EntradaCantidad.Focus();
}
break;
case Keys.Up:
System.Windows.Forms.SendKeys.Send("+{tab}");
break;
case Keys.Down:
System.Windows.Forms.SendKeys.Send("{tab}");
break;
default:
if (null != KeyDown)
KeyDown(sender, e);
break;
}
}
private void <API key>(object sender, KeyEventArgs e)
{
switch (e.KeyCode) {
case Keys.Left:
if (EntradaDescuento.SelectionStart == 0) {
e.Handled = true;
EntradaCantidad.Focus();
}
break;
case Keys.Up:
System.Windows.Forms.SendKeys.Send("+{tab}");
break;
case Keys.Down:
System.Windows.Forms.SendKeys.Send("{tab}");
break;
default:
if (null != KeyDown)
KeyDown(sender, e);
break;
}
}
private void <API key>(object sender, System.Windows.Forms.KeyEventArgs e)
{
switch (e.KeyCode) {
case Keys.Left:
e.Handled = true;
if (this.BloquearPrecio)
EntradaArticulo.Focus();
else
EntradaUnitario.Focus();
break;
case Keys.Right:
case Keys.Return:
if (EntradaCantidad.SelectionStart >= EntradaCantidad.TextRaw.Length || EntradaCantidad.SelectionLength > 0) {
if (this.BloquearPrecio == false) {
e.Handled = true;
EntradaDescuento.Focus();
}
}
break;
case Keys.Up:
System.Windows.Forms.SendKeys.Send("+{tab}");
break;
case Keys.Down:
System.Windows.Forms.SendKeys.Send("{tab}");
break;
case Keys.D0:
case Keys.D1:
case Keys.D2:
case Keys.D3:
case Keys.D4:
case Keys.D5:
case Keys.D6:
case Keys.D7:
case Keys.D8:
case Keys.D9:
case Keys.Space:
e.Handled = true;
this.<API key>();
break;
default:
if (KeyDown != null)
KeyDown(sender, e);
break;
}
}
protected override void OnEnter(EventArgs e)
{
base.OnEnter(e);
if (EntradaArticulo.Focused == false)
EntradaArticulo.Focus();
}
private void PonerFiltros()
{
string Filtros = "";
switch (m_ControlStock) {
case ControlesSock.ConControlStock:
Filtros += "control_stock=1";
break;
case ControlesSock.SinControlStock:
Filtros += "control_stock=0";
break;
}
EntradaArticulo.Filter = Filtros;
}
private void RecalcularAltura(object sender, System.EventArgs e)
{
LabelSerialsCruz.Visible = LabelSerials.Visible;
if (LabelSerials.Visible)
this.Height = this.LabelSerials.Bottom + this.EntradaArticulo.Top;
else
this.Height = this.EntradaArticulo.Bottom + this.EntradaArticulo.Top;
}
private void <API key>(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == ' ') {
if (Articulo != null) {
if (this.<API key>()) {
//Cambio a unidad secundaria
EntradaCantidad.Sufijo = Articulo.UnidadRendimiento;
EntradaCantidad.Text = Lfx.Types.Formatting.FormatStock(Lfx.Types.Parsing.ParseStock(EntradaCantidad.Text) * this.Articulo.Rendimiento);
} else {
//Cambio a unidad primaria
EntradaCantidad.Sufijo = Articulo.Unidad == "u" ? "" : Articulo.Unidad;
EntradaCantidad.Text = Lfx.Types.Formatting.FormatStock(Lfx.Types.Parsing.ParseStock(EntradaCantidad.Text) / this.Articulo.Rendimiento, 4);
}
e.Handled = true;
}
}
}
private void <API key>(object sender, EventArgs e)
{
this.<API key>();
}
protected void CambiarArticulo(Lbl.Articulos.Articulo articulo)
{
if (this.Articulo != null) {
EntradaUnitario.Enabled = true;
EntradaUnitario.Enabled = true;
EntradaDescuento.Enabled = true;
EntradaCantidad.Enabled = true;
EntradaImporte.Enabled = true;
EntradaCantidad.TemporaryReadOnly = this.Articulo.ObtenerSeguimiento() != Lbl.Articulos.Seguimientos.Ninguno || this.TemporaryReadOnly;
EntradaUnitario.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
EntradaDescuento.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
if (this.AutoUpdate) {
if (this.Articulo == null) {
return;
}
if (this.Articulo.Unidad != "u") {
EntradaCantidad.Sufijo = Articulo.Unidad;
} else {
EntradaCantidad.Sufijo = "";
}
decimal UnitarioMostrar;
if (m_Precio == Precios.Costo) {
UnitarioMostrar = Articulo.Costo;
} else {
UnitarioMostrar = Articulo.Pvp;
}
if (this.Cantidad == 0) {
this.Cantidad = 1;
}
this.<API key>(UnitarioMostrar);
this.<API key>();
}
} else if (EntradaArticulo.IsFreeText) {
EntradaUnitario.Enabled = true;
EntradaDescuento.Enabled = true;
EntradaCantidad.Enabled = true;
EntradaCantidad.TemporaryReadOnly = this.TemporaryReadOnly;
EntradaUnitario.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
EntradaDescuento.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
EntradaImporte.Enabled = true;
if (this.AutoUpdate) {
if (this.Cantidad == 0) {
this.Cantidad = 1;
}
}
} else if (EntradaArticulo.Text.Length == 0 || (EntradaArticulo.Text.IsNumericInt() && EntradaArticulo.ValueInt == 0)) {
EntradaUnitario.Enabled = false;
EntradaDescuento.Enabled = false;
EntradaCantidad.Enabled = false;
EntradaCantidad.TemporaryReadOnly = this.TemporaryReadOnly;
EntradaUnitario.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
EntradaDescuento.TemporaryReadOnly = this.TemporaryReadOnly || this.BloquearPrecio;
EntradaImporte.Enabled = false;
if (this.AutoUpdate) {
EntradaCantidad.ValueDecimal = 0m;
EntradaImporte.ValueDecimal = 0m;
this.<API key>(0m);
EntradaDescuento.ValueDecimal = 0m;
}
}
}
<summary>
Cambia el importe unitario original (sin IVA), y además recalcula el IVA y lo muestra discriminado si corresponde.
</summary>
<param name="unitario">El precio unitario a mostrar y usar como base para el cálculo de IVA e importe final.</param>
protected void <API key>(decimal unitario)
{
if (this.AplicarIva && m_Alicuota != null) {
this.ImporteIvaUnitario = unitario * (m_Alicuota.Porcentaje / 100m);
if (this.DiscriminarIva) {
EntradaUnitario.ValueDecimal = unitario;
EntradaIva.ValueDecimal = this.ImporteIvaUnitario;
} else {
EntradaUnitario.ValueDecimal = unitario + this.ImporteIvaUnitario;
EntradaIva.ValueDecimal = 0m;
}
} else {
this.ImporteIvaUnitario = 0m;
EntradaUnitario.ValueDecimal = unitario;
EntradaIva.ValueDecimal = 0;
}
}
<summary>
Recalcula el importe final, según importe, IVA, cantidad y descuento.
</summary>
protected void <API key>()
{
if(m_DiscriminarIva) {
if(m_AplicarIva && this.m_Alicuota != null) {
decimal Iva = this.ImporteUnitario * (this.m_Alicuota.Porcentaje / 100m);
if(Math.Abs(this.ImporteIvaUnitario - Iva) > 0.01m) {
this.ImporteIvaUnitario = Iva;
}
} else {
if(this.ImporteIvaUnitario != 0m) {
this.ImporteIvaUnitario = 0m;
}
}
EntradaIva.ValueDecimal = this.ImporteIvaUnitario;
} else {
EntradaIva.ValueDecimal = 0m;
}
try {
decimal ImporteFinal = (this.ImporteUnitario + this.<API key>) * this.Cantidad * (1m - this.Descuento / 100m);
EntradaImporte.ValueDecimal = ImporteFinal;
} catch {
EntradaImporte.ValueDecimal = 0m;
}
if (<API key>) {
VerificarStock();
}
}
}
}
|
#myGallery, #myGallerySet, #flickrGallery
{
width: 520px;
height: 300px;
z-index:5;
margin-bottom: 20px;
}
.jdGallery a
{
outline:0;
}
#flickrGallery
{
width: 500px;
height: 334px;
}
#myGallery img.thumbnail, #myGallerySet img.thumbnail
{
display: none;
}
.jdGallery
{
overflow: hidden;
position: relative;
}
.jdGallery img
{
border: 0;
margin: 0;
}
.jdGallery .slideElement
{
width: 100%;
height: 100%;
background-color: #000;
background-repeat: no-repeat;
background-position: center center;
background-image: url('img/loading-bar-black.gif');
}
.jdGallery .loadingElement
{
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
background-color: #000;
background-repeat: no-repeat;
background-position: center center;
background-image: url('img/loading-bar-black.gif');
}
.jdGallery .slideInfoZone
{
position: absolute;
z-index: 10;
width: 100%;
margin: 0px;
left: 0;
bottom: 0;
height: 120px;
background: #181818;
color: #fff;
text-indent: 0;
overflow: hidden;
}
* html .jdGallery .slideInfoZone
{
bottom: -1px;
}
.jdGallery .slideInfoZone h2
{
padding: 0;
font-size: 14px;
margin: 0;
margin: 2px 5px;
font-weight: bold;
color: #fff !important;
}
.jdGallery .slideInfoZone p
{
padding: 0;
font-size: 12px;
margin: 2px 5px;
color: #eee;
}
.jdGallery div.carouselContainer
{
position: absolute;
height: 135px;
width: 100%;
z-index: 10;
margin: 0px;
left: 0;
top: 0;
}
.jdGallery a.carouselBtn
{
position: absolute;
bottom: 0;
right: 30px;
height: 20px;
/*width: 100px; background: url('img/carousel_btn.gif') no-repeat;*/
text-align: center;
padding: 0 10px;
font-size: 13px;
background: #333;
color: #fff;
cursor: pointer;
}
.jdGallery .carousel
{
position: absolute;
width: 100%;
margin: 0px;
left: 0;
top: 0;
height: 115px;
background: #333;
color: #fff;
text-indent: 0;
overflow: hidden;
}
.jdExtCarousel
{
overflow: hidden;
position: relative;
}
.jdGallery .carousel .carouselWrapper, .jdExtCarousel .carouselWrapper
{
position: absolute;
width: 100%;
height: 78px;
top: 10px;
left: 0;
overflow: hidden;
}
.jdGallery .carousel .carouselInner, .jdExtCarousel .carouselInner
{
position: relative;
}
.jdGallery .carousel .carouselInner .thumbnail, .jdExtCarousel .carouselInner .thumbnail
{
cursor: pointer;
background: #000;
background-position: center center;
float: left;
border: solid 1px #fff;
}
.jdGallery .wall .thumbnail, .jdExtCarousel .wall .thumbnail
{
margin-bottom: 10px;
}
.jdGallery .carousel .label, .jdExtCarousel .label
{
font-size: 13px;
position: absolute;
bottom: 5px;
left: 10px;
padding: 0;
margin: 0;
}
.jdGallery .carousel .wallButton, .jdExtCarousel .wallButton
{
font-size: 10px;
position: absolute;
bottom: 5px;
right: 10px;
padding: 1px 2px;
margin: 0;
background: #222;
border: 1px solid #888;
cursor: pointer;
}
.jdGallery .carousel .label .number, .jdExtCarousel .label .number
{
color: #b5b5b5;
}
.jdGallery a
{
font-size: 100%;
text-decoration: none;
color: #fff;
}
.jdGallery a.right, .jdGallery a.left
{
position: absolute;
height: 99%;
width: 25%;
cursor: pointer;
z-index:10;
filter:alpha(opacity=20);
-moz-opacity:0.2;
-khtml-opacity: 0.2;
opacity: 0.2;
}
* html .jdGallery a.right, * html .jdGallery a.left
{
filter:alpha(opacity=50);
}
.jdGallery a.right:hover, .jdGallery a.left:hover
{
filter:alpha(opacity=80);
-moz-opacity:0.8;
-khtml-opacity: 0.8;
opacity: 0.8;
}
.jdGallery a.left
{
left: 0;
top: 0;
background: url('img/fleche1.png') no-repeat center left;
}
* html .jdGallery a.left { background: url('img/fleche1.gif') no-repeat center left; }
.jdGallery a.right
{
right: 0;
top: 0;
background: url('img/fleche2.png') no-repeat center right;
}
* html .jdGallery a.right { background: url('img/fleche2.gif') no-repeat center right; }
.jdGallery a.open
{
left: 0;
top: 0;
width: 100%;
height: 100%;
}
.withArrows a.open
{
position: absolute;
top: 0;
left: 25%;
height: 99%;
width: 50%;
cursor: pointer;
z-index: 10;
background: none;
-moz-opacity:0.8;
-khtml-opacity: 0.8;
opacity: 0.8;
}
.withArrows a.open:hover { background: url('img/open.png') no-repeat center center; }
* html .withArrows a.open:hover { background: url('img/open.gif') no-repeat center center;
filter:alpha(opacity=80); }
/* Gallery Sets */
.jdGallery a.gallerySelectorBtn
{
z-index: 15;
position: absolute;
top: 0;
left: 30px;
height: 20px;
/*width: 100px; background: url('img/carousel_btn.gif') no-repeat;*/
text-align: center;
padding: 0 10px;
font-size: 13px;
background: #333;
color: #fff;
cursor: pointer;
opacity: .4;
-moz-opacity: .4;
-khtml-opacity: 0.4;
filter:alpha(opacity=40);
}
.jdGallery .gallerySelector
{
z-index: 20;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: #000;
}
.jdGallery .gallerySelector h2
{
margin: 0;
padding: 10px 20px 10px 20px;
font-size: 20px;
line-height: 30px;
color: #fff !important;
}
.jdGallery .gallerySelector .<API key>
{
overflow: hidden;
}
.jdGallery .gallerySelector .<API key> div.galleryButton
{
margin-left: 10px;
margin-top: 10px;
border: 1px solid #888;
padding: 5px;
height: 40px;
color: #fff;
cursor: pointer;
float: left;
}
.jdGallery .gallerySelector .<API key> div.hover
{
background: #333;
}
.jdGallery .gallerySelector .<API key> div.galleryButton div.preview
{
background: #000;
background-position: center center;
float: left;
border: none;
width: 40px;
height: 40px;
margin-right: 5px;
}
.jdGallery .gallerySelector .<API key> div.galleryButton h3
{
margin: 0;
padding: 0;
font-size: 12px;
font-weight: normal;
color: #fff;
}
.jdGallery .gallerySelector .<API key> div.galleryButton p.info
{
margin: 0;
padding: 0;
font-size: 12px;
font-weight: normal;
color: #fff !important;
}
|
#include <stdio.h>
#include <l4/sys/kdebug.h>
void fork_to_background(void);
void fork_to_background(void)
{
printf("unimplemented: %s\n", __func__);
enter_kdebug();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.